babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809
  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/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  410. /**
  411. * Interface used to define the mechanism to get data from the network
  412. */
  413. export interface IWebRequest {
  414. /**
  415. * Returns client's response url
  416. */
  417. responseURL: string;
  418. /**
  419. * Returns client's status
  420. */
  421. status: number;
  422. /**
  423. * Returns client's status as a text
  424. */
  425. statusText: string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/webRequest" {
  429. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  430. import { Nullable } from "babylonjs/types";
  431. /**
  432. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  433. */
  434. export class WebRequest implements IWebRequest {
  435. private _xhr;
  436. /**
  437. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  438. * i.e. when loading files, where the server/service expects an Authorization header
  439. */
  440. static CustomRequestHeaders: {
  441. [key: string]: string;
  442. };
  443. /**
  444. * Add callback functions in this array to update all the requests before they get sent to the network
  445. */
  446. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  447. private _injectCustomRequestHeaders;
  448. /**
  449. * Gets or sets a function to be called when loading progress changes
  450. */
  451. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  452. /**
  453. * Returns client's state
  454. */
  455. readonly readyState: number;
  456. /**
  457. * Returns client's status
  458. */
  459. readonly status: number;
  460. /**
  461. * Returns client's status as a text
  462. */
  463. readonly statusText: string;
  464. /**
  465. * Returns client's response
  466. */
  467. readonly response: any;
  468. /**
  469. * Returns client's response url
  470. */
  471. readonly responseURL: string;
  472. /**
  473. * Returns client's response as text
  474. */
  475. readonly responseText: string;
  476. /**
  477. * Gets or sets the expected response type
  478. */
  479. responseType: XMLHttpRequestResponseType;
  480. /** @hidden */
  481. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  482. /** @hidden */
  483. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  484. /**
  485. * Cancels any network activity
  486. */
  487. abort(): void;
  488. /**
  489. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  490. * @param body defines an optional request body
  491. */
  492. send(body?: Document | BodyInit | null): void;
  493. /**
  494. * Sets the request method, request URL
  495. * @param method defines the method to use (GET, POST, etc..)
  496. * @param url defines the url to connect with
  497. */
  498. open(method: string, url: string): void;
  499. /**
  500. * Sets the value of a request header.
  501. * @param name The name of the header whose value is to be set
  502. * @param value The value to set as the body of the header
  503. */
  504. setRequestHeader(name: string, value: string): void;
  505. /**
  506. * Get the string containing the text of a particular header's value.
  507. * @param name The name of the header
  508. * @returns The string containing the text of the given header name
  509. */
  510. getResponseHeader(name: string): Nullable<string>;
  511. }
  512. }
  513. declare module "babylonjs/Misc/fileRequest" {
  514. import { Observable } from "babylonjs/Misc/observable";
  515. /**
  516. * File request interface
  517. */
  518. export interface IFileRequest {
  519. /**
  520. * Raised when the request is complete (success or error).
  521. */
  522. onCompleteObservable: Observable<IFileRequest>;
  523. /**
  524. * Aborts the request for a file.
  525. */
  526. abort: () => void;
  527. }
  528. }
  529. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  530. /**
  531. * Define options used to create a render target texture
  532. */
  533. export class RenderTargetCreationOptions {
  534. /**
  535. * Specifies is mipmaps must be generated
  536. */
  537. generateMipMaps?: boolean;
  538. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  539. generateDepthBuffer?: boolean;
  540. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  541. generateStencilBuffer?: boolean;
  542. /** Defines texture type (int by default) */
  543. type?: number;
  544. /** Defines sampling mode (trilinear by default) */
  545. samplingMode?: number;
  546. /** Defines format (RGBA by default) */
  547. format?: number;
  548. }
  549. }
  550. declare module "babylonjs/Instrumentation/timeToken" {
  551. import { Nullable } from "babylonjs/types";
  552. /**
  553. * @hidden
  554. **/
  555. export class _TimeToken {
  556. _startTimeQuery: Nullable<WebGLQuery>;
  557. _endTimeQuery: Nullable<WebGLQuery>;
  558. _timeElapsedQuery: Nullable<WebGLQuery>;
  559. _timeElapsedQueryEnded: boolean;
  560. }
  561. }
  562. declare module "babylonjs/Engines/constants" {
  563. /** Defines the cross module used constants to avoid circular dependncies */
  564. export class Constants {
  565. /** Defines that alpha blending is disabled */
  566. static readonly ALPHA_DISABLE: number;
  567. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  568. static readonly ALPHA_ADD: number;
  569. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  570. static readonly ALPHA_COMBINE: number;
  571. /** Defines that alpha blending to DEST - SRC * DEST */
  572. static readonly ALPHA_SUBTRACT: number;
  573. /** Defines that alpha blending to SRC * DEST */
  574. static readonly ALPHA_MULTIPLY: number;
  575. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  576. static readonly ALPHA_MAXIMIZED: number;
  577. /** Defines that alpha blending to SRC + DEST */
  578. static readonly ALPHA_ONEONE: number;
  579. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  580. static readonly ALPHA_PREMULTIPLIED: number;
  581. /**
  582. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  583. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  584. */
  585. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  586. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  587. static readonly ALPHA_INTERPOLATE: number;
  588. /**
  589. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  590. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  591. */
  592. static readonly ALPHA_SCREENMODE: number;
  593. /**
  594. * Defines that alpha blending to SRC + DST
  595. * Alpha will be set to SRC ALPHA + DST ALPHA
  596. */
  597. static readonly ALPHA_ONEONE_ONEONE: number;
  598. /**
  599. * Defines that alpha blending to SRC * DST ALPHA + DST
  600. * Alpha will be set to 0
  601. */
  602. static readonly ALPHA_ALPHATOCOLOR: number;
  603. /**
  604. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  605. */
  606. static readonly ALPHA_REVERSEONEMINUS: number;
  607. /**
  608. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  609. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  610. */
  611. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  612. /**
  613. * Defines that alpha blending to SRC + DST
  614. * Alpha will be set to SRC ALPHA
  615. */
  616. static readonly ALPHA_ONEONE_ONEZERO: number;
  617. /** Defines that alpha blending equation a SUM */
  618. static readonly ALPHA_EQUATION_ADD: number;
  619. /** Defines that alpha blending equation a SUBSTRACTION */
  620. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  621. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  622. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  623. /** Defines that alpha blending equation a MAX operation */
  624. static readonly ALPHA_EQUATION_MAX: number;
  625. /** Defines that alpha blending equation a MIN operation */
  626. static readonly ALPHA_EQUATION_MIN: number;
  627. /**
  628. * Defines that alpha blending equation a DARKEN operation:
  629. * It takes the min of the src and sums the alpha channels.
  630. */
  631. static readonly ALPHA_EQUATION_DARKEN: number;
  632. /** Defines that the ressource is not delayed*/
  633. static readonly DELAYLOADSTATE_NONE: number;
  634. /** Defines that the ressource was successfully delay loaded */
  635. static readonly DELAYLOADSTATE_LOADED: number;
  636. /** Defines that the ressource is currently delay loading */
  637. static readonly DELAYLOADSTATE_LOADING: number;
  638. /** Defines that the ressource is delayed and has not started loading */
  639. static readonly DELAYLOADSTATE_NOTLOADED: number;
  640. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  641. static readonly NEVER: number;
  642. /** 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 */
  643. static readonly ALWAYS: number;
  644. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  645. static readonly LESS: number;
  646. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  647. static readonly EQUAL: number;
  648. /** 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 */
  649. static readonly LEQUAL: number;
  650. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  651. static readonly GREATER: number;
  652. /** 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 */
  653. static readonly GEQUAL: number;
  654. /** 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 */
  655. static readonly NOTEQUAL: number;
  656. /** Passed to stencilOperation to specify that stencil value must be kept */
  657. static readonly KEEP: number;
  658. /** Passed to stencilOperation to specify that stencil value must be replaced */
  659. static readonly REPLACE: number;
  660. /** Passed to stencilOperation to specify that stencil value must be incremented */
  661. static readonly INCR: number;
  662. /** Passed to stencilOperation to specify that stencil value must be decremented */
  663. static readonly DECR: number;
  664. /** Passed to stencilOperation to specify that stencil value must be inverted */
  665. static readonly INVERT: number;
  666. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  667. static readonly INCR_WRAP: number;
  668. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  669. static readonly DECR_WRAP: number;
  670. /** Texture is not repeating outside of 0..1 UVs */
  671. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  672. /** Texture is repeating outside of 0..1 UVs */
  673. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  674. /** Texture is repeating and mirrored */
  675. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  676. /** ALPHA */
  677. static readonly TEXTUREFORMAT_ALPHA: number;
  678. /** LUMINANCE */
  679. static readonly TEXTUREFORMAT_LUMINANCE: number;
  680. /** LUMINANCE_ALPHA */
  681. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  682. /** RGB */
  683. static readonly TEXTUREFORMAT_RGB: number;
  684. /** RGBA */
  685. static readonly TEXTUREFORMAT_RGBA: number;
  686. /** RED */
  687. static readonly TEXTUREFORMAT_RED: number;
  688. /** RED (2nd reference) */
  689. static readonly TEXTUREFORMAT_R: number;
  690. /** RG */
  691. static readonly TEXTUREFORMAT_RG: number;
  692. /** RED_INTEGER */
  693. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  694. /** RED_INTEGER (2nd reference) */
  695. static readonly TEXTUREFORMAT_R_INTEGER: number;
  696. /** RG_INTEGER */
  697. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  698. /** RGB_INTEGER */
  699. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  700. /** RGBA_INTEGER */
  701. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  702. /** UNSIGNED_BYTE */
  703. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  704. /** UNSIGNED_BYTE (2nd reference) */
  705. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  706. /** FLOAT */
  707. static readonly TEXTURETYPE_FLOAT: number;
  708. /** HALF_FLOAT */
  709. static readonly TEXTURETYPE_HALF_FLOAT: number;
  710. /** BYTE */
  711. static readonly TEXTURETYPE_BYTE: number;
  712. /** SHORT */
  713. static readonly TEXTURETYPE_SHORT: number;
  714. /** UNSIGNED_SHORT */
  715. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  716. /** INT */
  717. static readonly TEXTURETYPE_INT: number;
  718. /** UNSIGNED_INT */
  719. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  720. /** UNSIGNED_SHORT_4_4_4_4 */
  721. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  722. /** UNSIGNED_SHORT_5_5_5_1 */
  723. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  724. /** UNSIGNED_SHORT_5_6_5 */
  725. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  726. /** UNSIGNED_INT_2_10_10_10_REV */
  727. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  728. /** UNSIGNED_INT_24_8 */
  729. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  730. /** UNSIGNED_INT_10F_11F_11F_REV */
  731. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  732. /** UNSIGNED_INT_5_9_9_9_REV */
  733. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  734. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  735. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  736. /** nearest is mag = nearest and min = nearest and mip = linear */
  737. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  738. /** Bilinear is mag = linear and min = linear and mip = nearest */
  739. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  740. /** Trilinear is mag = linear and min = linear and mip = linear */
  741. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  742. /** nearest is mag = nearest and min = nearest and mip = linear */
  743. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  744. /** Bilinear is mag = linear and min = linear and mip = nearest */
  745. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  746. /** Trilinear is mag = linear and min = linear and mip = linear */
  747. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  748. /** mag = nearest and min = nearest and mip = nearest */
  749. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  750. /** mag = nearest and min = linear and mip = nearest */
  751. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  752. /** mag = nearest and min = linear and mip = linear */
  753. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  754. /** mag = nearest and min = linear and mip = none */
  755. static readonly TEXTURE_NEAREST_LINEAR: number;
  756. /** mag = nearest and min = nearest and mip = none */
  757. static readonly TEXTURE_NEAREST_NEAREST: number;
  758. /** mag = linear and min = nearest and mip = nearest */
  759. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  760. /** mag = linear and min = nearest and mip = linear */
  761. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  762. /** mag = linear and min = linear and mip = none */
  763. static readonly TEXTURE_LINEAR_LINEAR: number;
  764. /** mag = linear and min = nearest and mip = none */
  765. static readonly TEXTURE_LINEAR_NEAREST: number;
  766. /** Explicit coordinates mode */
  767. static readonly TEXTURE_EXPLICIT_MODE: number;
  768. /** Spherical coordinates mode */
  769. static readonly TEXTURE_SPHERICAL_MODE: number;
  770. /** Planar coordinates mode */
  771. static readonly TEXTURE_PLANAR_MODE: number;
  772. /** Cubic coordinates mode */
  773. static readonly TEXTURE_CUBIC_MODE: number;
  774. /** Projection coordinates mode */
  775. static readonly TEXTURE_PROJECTION_MODE: number;
  776. /** Skybox coordinates mode */
  777. static readonly TEXTURE_SKYBOX_MODE: number;
  778. /** Inverse Cubic coordinates mode */
  779. static readonly TEXTURE_INVCUBIC_MODE: number;
  780. /** Equirectangular coordinates mode */
  781. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  782. /** Equirectangular Fixed coordinates mode */
  783. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  784. /** Equirectangular Fixed Mirrored coordinates mode */
  785. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  786. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  787. static readonly SCALEMODE_FLOOR: number;
  788. /** Defines that texture rescaling will look for the nearest power of 2 size */
  789. static readonly SCALEMODE_NEAREST: number;
  790. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  791. static readonly SCALEMODE_CEILING: number;
  792. /**
  793. * The dirty texture flag value
  794. */
  795. static readonly MATERIAL_TextureDirtyFlag: number;
  796. /**
  797. * The dirty light flag value
  798. */
  799. static readonly MATERIAL_LightDirtyFlag: number;
  800. /**
  801. * The dirty fresnel flag value
  802. */
  803. static readonly MATERIAL_FresnelDirtyFlag: number;
  804. /**
  805. * The dirty attribute flag value
  806. */
  807. static readonly MATERIAL_AttributesDirtyFlag: number;
  808. /**
  809. * The dirty misc flag value
  810. */
  811. static readonly MATERIAL_MiscDirtyFlag: number;
  812. /**
  813. * The all dirty flag value
  814. */
  815. static readonly MATERIAL_AllDirtyFlag: number;
  816. /**
  817. * Returns the triangle fill mode
  818. */
  819. static readonly MATERIAL_TriangleFillMode: number;
  820. /**
  821. * Returns the wireframe mode
  822. */
  823. static readonly MATERIAL_WireFrameFillMode: number;
  824. /**
  825. * Returns the point fill mode
  826. */
  827. static readonly MATERIAL_PointFillMode: number;
  828. /**
  829. * Returns the point list draw mode
  830. */
  831. static readonly MATERIAL_PointListDrawMode: number;
  832. /**
  833. * Returns the line list draw mode
  834. */
  835. static readonly MATERIAL_LineListDrawMode: number;
  836. /**
  837. * Returns the line loop draw mode
  838. */
  839. static readonly MATERIAL_LineLoopDrawMode: number;
  840. /**
  841. * Returns the line strip draw mode
  842. */
  843. static readonly MATERIAL_LineStripDrawMode: number;
  844. /**
  845. * Returns the triangle strip draw mode
  846. */
  847. static readonly MATERIAL_TriangleStripDrawMode: number;
  848. /**
  849. * Returns the triangle fan draw mode
  850. */
  851. static readonly MATERIAL_TriangleFanDrawMode: number;
  852. /**
  853. * Stores the clock-wise side orientation
  854. */
  855. static readonly MATERIAL_ClockWiseSideOrientation: number;
  856. /**
  857. * Stores the counter clock-wise side orientation
  858. */
  859. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  860. /**
  861. * Nothing
  862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  863. */
  864. static readonly ACTION_NothingTrigger: number;
  865. /**
  866. * On pick
  867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  868. */
  869. static readonly ACTION_OnPickTrigger: number;
  870. /**
  871. * On left pick
  872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  873. */
  874. static readonly ACTION_OnLeftPickTrigger: number;
  875. /**
  876. * On right pick
  877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  878. */
  879. static readonly ACTION_OnRightPickTrigger: number;
  880. /**
  881. * On center pick
  882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  883. */
  884. static readonly ACTION_OnCenterPickTrigger: number;
  885. /**
  886. * On pick down
  887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  888. */
  889. static readonly ACTION_OnPickDownTrigger: number;
  890. /**
  891. * On double pick
  892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  893. */
  894. static readonly ACTION_OnDoublePickTrigger: number;
  895. /**
  896. * On pick up
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_OnPickUpTrigger: number;
  900. /**
  901. * On pick out.
  902. * This trigger will only be raised if you also declared a OnPickDown
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickOutTrigger: number;
  906. /**
  907. * On long press
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLongPressTrigger: number;
  911. /**
  912. * On pointer over
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnPointerOverTrigger: number;
  916. /**
  917. * On pointer out
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPointerOutTrigger: number;
  921. /**
  922. * On every frame
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnEveryFrameTrigger: number;
  926. /**
  927. * On intersection enter
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnIntersectionEnterTrigger: number;
  931. /**
  932. * On intersection exit
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnIntersectionExitTrigger: number;
  936. /**
  937. * On key down
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnKeyDownTrigger: number;
  941. /**
  942. * On key up
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnKeyUpTrigger: number;
  946. /**
  947. * Billboard mode will only apply to Y axis
  948. */
  949. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  950. /**
  951. * Billboard mode will apply to all axes
  952. */
  953. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  954. /**
  955. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  956. */
  957. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  958. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  959. * Test order :
  960. * Is the bounding sphere outside the frustum ?
  961. * If not, are the bounding box vertices outside the frustum ?
  962. * It not, then the cullable object is in the frustum.
  963. */
  964. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  965. /** Culling strategy : Bounding Sphere Only.
  966. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  967. * It's also less accurate than the standard because some not visible objects can still be selected.
  968. * Test : is the bounding sphere outside the frustum ?
  969. * If not, then the cullable object is in the frustum.
  970. */
  971. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  972. /** Culling strategy : Optimistic Inclusion.
  973. * This in an inclusion test first, then the standard exclusion test.
  974. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  975. * 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.
  976. * Anyway, it's as accurate as the standard strategy.
  977. * Test :
  978. * Is the cullable object bounding sphere center in the frustum ?
  979. * If not, apply the default culling strategy.
  980. */
  981. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  982. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  983. * This in an inclusion test first, then the bounding sphere only exclusion test.
  984. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  985. * 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.
  986. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  987. * Test :
  988. * Is the cullable object bounding sphere center in the frustum ?
  989. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  990. */
  991. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  992. /**
  993. * No logging while loading
  994. */
  995. static readonly SCENELOADER_NO_LOGGING: number;
  996. /**
  997. * Minimal logging while loading
  998. */
  999. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1000. /**
  1001. * Summary logging while loading
  1002. */
  1003. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1004. /**
  1005. * Detailled logging while loading
  1006. */
  1007. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1008. }
  1009. }
  1010. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1011. import { Nullable } from "babylonjs/types";
  1012. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1013. /**
  1014. * This represents the required contract to create a new type of texture loader.
  1015. */
  1016. export interface IInternalTextureLoader {
  1017. /**
  1018. * Defines wether the loader supports cascade loading the different faces.
  1019. */
  1020. supportCascades: boolean;
  1021. /**
  1022. * This returns if the loader support the current file information.
  1023. * @param extension defines the file extension of the file being loaded
  1024. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1025. * @param fallback defines the fallback internal texture if any
  1026. * @param isBase64 defines whether the texture is encoded as a base64
  1027. * @param isBuffer defines whether the texture data are stored as a buffer
  1028. * @returns true if the loader can load the specified file
  1029. */
  1030. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1031. /**
  1032. * Transform the url before loading if required.
  1033. * @param rootUrl the url of the texture
  1034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1035. * @returns the transformed texture
  1036. */
  1037. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1038. /**
  1039. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1040. * @param rootUrl the url of the texture
  1041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1042. * @returns the fallback texture
  1043. */
  1044. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1045. /**
  1046. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1047. * @param data contains the texture data
  1048. * @param texture defines the BabylonJS internal texture
  1049. * @param createPolynomials will be true if polynomials have been requested
  1050. * @param onLoad defines the callback to trigger once the texture is ready
  1051. * @param onError defines the callback to trigger in case of error
  1052. */
  1053. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1054. /**
  1055. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1056. * @param data contains the texture data
  1057. * @param texture defines the BabylonJS internal texture
  1058. * @param callback defines the method to call once ready to upload
  1059. */
  1060. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1061. }
  1062. }
  1063. declare module "babylonjs/Engines/IPipelineContext" {
  1064. /**
  1065. * Class used to store and describe the pipeline context associated with an effect
  1066. */
  1067. export interface IPipelineContext {
  1068. /**
  1069. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1070. */
  1071. isAsync: boolean;
  1072. /**
  1073. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1074. */
  1075. isReady: boolean;
  1076. /** @hidden */
  1077. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1078. }
  1079. }
  1080. declare module "babylonjs/Meshes/dataBuffer" {
  1081. /**
  1082. * Class used to store gfx data (like WebGLBuffer)
  1083. */
  1084. export class DataBuffer {
  1085. /**
  1086. * Gets or sets the number of objects referencing this buffer
  1087. */
  1088. references: number;
  1089. /** Gets or sets the size of the underlying buffer */
  1090. capacity: number;
  1091. /**
  1092. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1093. */
  1094. is32Bits: boolean;
  1095. /**
  1096. * Gets the underlying buffer
  1097. */
  1098. readonly underlyingResource: any;
  1099. }
  1100. }
  1101. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1102. /** @hidden */
  1103. export interface IShaderProcessor {
  1104. attributeProcessor?: (attribute: string) => string;
  1105. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1106. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1107. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1108. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1109. lineProcessor?: (line: string, isFragment: boolean) => string;
  1110. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1111. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1112. }
  1113. }
  1114. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1115. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1116. /** @hidden */
  1117. export interface ProcessingOptions {
  1118. defines: string[];
  1119. indexParameters: any;
  1120. isFragment: boolean;
  1121. shouldUseHighPrecisionShader: boolean;
  1122. supportsUniformBuffers: boolean;
  1123. shadersRepository: string;
  1124. includesShadersStore: {
  1125. [key: string]: string;
  1126. };
  1127. processor?: IShaderProcessor;
  1128. version: string;
  1129. platformName: string;
  1130. lookForClosingBracketForUniformBuffer?: boolean;
  1131. }
  1132. }
  1133. declare module "babylonjs/Misc/stringTools" {
  1134. /**
  1135. * Helper to manipulate strings
  1136. */
  1137. export class StringTools {
  1138. /**
  1139. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1140. * @param str Source string
  1141. * @param suffix Suffix to search for in the source string
  1142. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1143. */
  1144. static EndsWith(str: string, suffix: string): boolean;
  1145. /**
  1146. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1147. * @param str Source string
  1148. * @param suffix Suffix to search for in the source string
  1149. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1150. */
  1151. static StartsWith(str: string, suffix: string): boolean;
  1152. /**
  1153. * Decodes a buffer into a string
  1154. * @param buffer The buffer to decode
  1155. * @returns The decoded string
  1156. */
  1157. static Decode(buffer: Uint8Array | Uint16Array): string;
  1158. /**
  1159. * Encode a buffer to a base64 string
  1160. * @param buffer defines the buffer to encode
  1161. * @returns the encoded string
  1162. */
  1163. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  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. * Classed 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. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  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. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  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. * Creates a right-handed perspective projection matrix
  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 defines the far clip plane
  4496. * @returns a new matrix as a right-handed perspective projection matrix
  4497. */
  4498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4499. /**
  4500. * Stores a right-handed perspective projection into a given matrix
  4501. * @param fov defines the horizontal field of view
  4502. * @param aspect defines the aspect ratio
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @param result defines the target matrix
  4506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4507. */
  4508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4509. /**
  4510. * Stores a perspective projection for WebVR info a given matrix
  4511. * @param fov defines the field of view
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4516. */
  4517. static PerspectiveFovWebVRToRef(fov: {
  4518. upDegrees: number;
  4519. downDegrees: number;
  4520. leftDegrees: number;
  4521. rightDegrees: number;
  4522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4523. /**
  4524. * Computes a complete transformation matrix
  4525. * @param viewport defines the viewport to use
  4526. * @param world defines the world matrix
  4527. * @param view defines the view matrix
  4528. * @param projection defines the projection matrix
  4529. * @param zmin defines the near clip plane
  4530. * @param zmax defines the far clip plane
  4531. * @returns the transformation matrix
  4532. */
  4533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4534. /**
  4535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4536. * @param matrix defines the matrix to use
  4537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4538. */
  4539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4540. /**
  4541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4542. * @param matrix defines the matrix to use
  4543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4544. */
  4545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4546. /**
  4547. * Compute the transpose of a given matrix
  4548. * @param matrix defines the matrix to transpose
  4549. * @returns the new matrix
  4550. */
  4551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4552. /**
  4553. * Compute the transpose of a matrix and store it in a target matrix
  4554. * @param matrix defines the matrix to transpose
  4555. * @param result defines the target matrix
  4556. */
  4557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4558. /**
  4559. * Computes a reflection matrix from a plane
  4560. * @param plane defines the reflection plane
  4561. * @returns a new matrix
  4562. */
  4563. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4564. /**
  4565. * Computes a reflection matrix from a plane
  4566. * @param plane defines the reflection plane
  4567. * @param result defines the target matrix
  4568. */
  4569. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4570. /**
  4571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4572. * @param xaxis defines the value of the 1st axis
  4573. * @param yaxis defines the value of the 2nd axis
  4574. * @param zaxis defines the value of the 3rd axis
  4575. * @param result defines the target matrix
  4576. */
  4577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4578. /**
  4579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4580. * @param quat defines the quaternion to use
  4581. * @param result defines the target matrix
  4582. */
  4583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4584. }
  4585. /**
  4586. * @hidden
  4587. */
  4588. export class TmpVectors {
  4589. static Vector2: Vector2[];
  4590. static Vector3: Vector3[];
  4591. static Vector4: Vector4[];
  4592. static Quaternion: Quaternion[];
  4593. static Matrix: Matrix[];
  4594. }
  4595. }
  4596. declare module "babylonjs/Maths/math.path" {
  4597. import { DeepImmutable, Nullable } from "babylonjs/types";
  4598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4599. /**
  4600. * Defines potential orientation for back face culling
  4601. */
  4602. export enum Orientation {
  4603. /**
  4604. * Clockwise
  4605. */
  4606. CW = 0,
  4607. /** Counter clockwise */
  4608. CCW = 1
  4609. }
  4610. /** Class used to represent a Bezier curve */
  4611. export class BezierCurve {
  4612. /**
  4613. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4614. * @param t defines the time
  4615. * @param x1 defines the left coordinate on X axis
  4616. * @param y1 defines the left coordinate on Y axis
  4617. * @param x2 defines the right coordinate on X axis
  4618. * @param y2 defines the right coordinate on Y axis
  4619. * @returns the interpolated value
  4620. */
  4621. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4622. }
  4623. /**
  4624. * Defines angle representation
  4625. */
  4626. export class Angle {
  4627. private _radians;
  4628. /**
  4629. * Creates an Angle object of "radians" radians (float).
  4630. * @param radians the angle in radians
  4631. */
  4632. constructor(radians: number);
  4633. /**
  4634. * Get value in degrees
  4635. * @returns the Angle value in degrees (float)
  4636. */
  4637. degrees(): number;
  4638. /**
  4639. * Get value in radians
  4640. * @returns the Angle value in radians (float)
  4641. */
  4642. radians(): number;
  4643. /**
  4644. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4645. * @param a defines first vector
  4646. * @param b defines second vector
  4647. * @returns a new Angle
  4648. */
  4649. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4650. /**
  4651. * Gets a new Angle object from the given float in radians
  4652. * @param radians defines the angle value in radians
  4653. * @returns a new Angle
  4654. */
  4655. static FromRadians(radians: number): Angle;
  4656. /**
  4657. * Gets a new Angle object from the given float in degrees
  4658. * @param degrees defines the angle value in degrees
  4659. * @returns a new Angle
  4660. */
  4661. static FromDegrees(degrees: number): Angle;
  4662. }
  4663. /**
  4664. * This represents an arc in a 2d space.
  4665. */
  4666. export class Arc2 {
  4667. /** Defines the start point of the arc */
  4668. startPoint: Vector2;
  4669. /** Defines the mid point of the arc */
  4670. midPoint: Vector2;
  4671. /** Defines the end point of the arc */
  4672. endPoint: Vector2;
  4673. /**
  4674. * Defines the center point of the arc.
  4675. */
  4676. centerPoint: Vector2;
  4677. /**
  4678. * Defines the radius of the arc.
  4679. */
  4680. radius: number;
  4681. /**
  4682. * Defines the angle of the arc (from mid point to end point).
  4683. */
  4684. angle: Angle;
  4685. /**
  4686. * Defines the start angle of the arc (from start point to middle point).
  4687. */
  4688. startAngle: Angle;
  4689. /**
  4690. * Defines the orientation of the arc (clock wise/counter clock wise).
  4691. */
  4692. orientation: Orientation;
  4693. /**
  4694. * Creates an Arc object from the three given points : start, middle and end.
  4695. * @param startPoint Defines the start point of the arc
  4696. * @param midPoint Defines the midlle point of the arc
  4697. * @param endPoint Defines the end point of the arc
  4698. */
  4699. constructor(
  4700. /** Defines the start point of the arc */
  4701. startPoint: Vector2,
  4702. /** Defines the mid point of the arc */
  4703. midPoint: Vector2,
  4704. /** Defines the end point of the arc */
  4705. endPoint: Vector2);
  4706. }
  4707. /**
  4708. * Represents a 2D path made up of multiple 2D points
  4709. */
  4710. export class Path2 {
  4711. private _points;
  4712. private _length;
  4713. /**
  4714. * If the path start and end point are the same
  4715. */
  4716. closed: boolean;
  4717. /**
  4718. * Creates a Path2 object from the starting 2D coordinates x and y.
  4719. * @param x the starting points x value
  4720. * @param y the starting points y value
  4721. */
  4722. constructor(x: number, y: number);
  4723. /**
  4724. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4725. * @param x the added points x value
  4726. * @param y the added points y value
  4727. * @returns the updated Path2.
  4728. */
  4729. addLineTo(x: number, y: number): Path2;
  4730. /**
  4731. * 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.
  4732. * @param midX middle point x value
  4733. * @param midY middle point y value
  4734. * @param endX end point x value
  4735. * @param endY end point y value
  4736. * @param numberOfSegments (default: 36)
  4737. * @returns the updated Path2.
  4738. */
  4739. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4740. /**
  4741. * Closes the Path2.
  4742. * @returns the Path2.
  4743. */
  4744. close(): Path2;
  4745. /**
  4746. * Gets the sum of the distance between each sequential point in the path
  4747. * @returns the Path2 total length (float).
  4748. */
  4749. length(): number;
  4750. /**
  4751. * Gets the points which construct the path
  4752. * @returns the Path2 internal array of points.
  4753. */
  4754. getPoints(): Vector2[];
  4755. /**
  4756. * Retreives the point at the distance aways from the starting point
  4757. * @param normalizedLengthPosition the length along the path to retreive the point from
  4758. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4759. */
  4760. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4761. /**
  4762. * Creates a new path starting from an x and y position
  4763. * @param x starting x value
  4764. * @param y starting y value
  4765. * @returns a new Path2 starting at the coordinates (x, y).
  4766. */
  4767. static StartingAt(x: number, y: number): Path2;
  4768. }
  4769. /**
  4770. * Represents a 3D path made up of multiple 3D points
  4771. */
  4772. export class Path3D {
  4773. /**
  4774. * an array of Vector3, the curve axis of the Path3D
  4775. */
  4776. path: Vector3[];
  4777. private _curve;
  4778. private _distances;
  4779. private _tangents;
  4780. private _normals;
  4781. private _binormals;
  4782. private _raw;
  4783. /**
  4784. * new Path3D(path, normal, raw)
  4785. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4786. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4787. * @param path an array of Vector3, the curve axis of the Path3D
  4788. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4789. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4790. */
  4791. constructor(
  4792. /**
  4793. * an array of Vector3, the curve axis of the Path3D
  4794. */
  4795. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4796. /**
  4797. * Returns the Path3D array of successive Vector3 designing its curve.
  4798. * @returns the Path3D array of successive Vector3 designing its curve.
  4799. */
  4800. getCurve(): Vector3[];
  4801. /**
  4802. * Returns an array populated with tangent vectors on each Path3D curve point.
  4803. * @returns an array populated with tangent vectors on each Path3D curve point.
  4804. */
  4805. getTangents(): Vector3[];
  4806. /**
  4807. * Returns an array populated with normal vectors on each Path3D curve point.
  4808. * @returns an array populated with normal vectors on each Path3D curve point.
  4809. */
  4810. getNormals(): Vector3[];
  4811. /**
  4812. * Returns an array populated with binormal vectors on each Path3D curve point.
  4813. * @returns an array populated with binormal vectors on each Path3D curve point.
  4814. */
  4815. getBinormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4818. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4819. */
  4820. getDistances(): number[];
  4821. /**
  4822. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4823. * @param path path which all values are copied into the curves points
  4824. * @param firstNormal which should be projected onto the curve
  4825. * @returns the same object updated.
  4826. */
  4827. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4828. private _compute;
  4829. private _getFirstNonNullVector;
  4830. private _getLastNonNullVector;
  4831. private _normalVector;
  4832. }
  4833. /**
  4834. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4835. * A Curve3 is designed from a series of successive Vector3.
  4836. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4837. */
  4838. export class Curve3 {
  4839. private _points;
  4840. private _length;
  4841. /**
  4842. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4843. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4844. * @param v1 (Vector3) the control point
  4845. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4846. * @param nbPoints (integer) the wanted number of points in the curve
  4847. * @returns the created Curve3
  4848. */
  4849. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4850. /**
  4851. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4852. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4853. * @param v1 (Vector3) the first control point
  4854. * @param v2 (Vector3) the second control point
  4855. * @param v3 (Vector3) the end point of the Cubic Bezier
  4856. * @param nbPoints (integer) the wanted number of points in the curve
  4857. * @returns the created Curve3
  4858. */
  4859. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4860. /**
  4861. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4862. * @param p1 (Vector3) the origin point of the Hermite Spline
  4863. * @param t1 (Vector3) the tangent vector at the origin point
  4864. * @param p2 (Vector3) the end point of the Hermite Spline
  4865. * @param t2 (Vector3) the tangent vector at the end point
  4866. * @param nbPoints (integer) the wanted number of points in the curve
  4867. * @returns the created Curve3
  4868. */
  4869. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4870. /**
  4871. * Returns a Curve3 object along a CatmullRom Spline curve :
  4872. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4873. * @param nbPoints (integer) the wanted number of points between each curve control points
  4874. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4875. * @returns the created Curve3
  4876. */
  4877. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4878. /**
  4879. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4880. * A Curve3 is designed from a series of successive Vector3.
  4881. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4882. * @param points points which make up the curve
  4883. */
  4884. constructor(points: Vector3[]);
  4885. /**
  4886. * @returns the Curve3 stored array of successive Vector3
  4887. */
  4888. getPoints(): Vector3[];
  4889. /**
  4890. * @returns the computed length (float) of the curve.
  4891. */
  4892. length(): number;
  4893. /**
  4894. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4895. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4896. * curveA and curveB keep unchanged.
  4897. * @param curve the curve to continue from this curve
  4898. * @returns the newly constructed curve
  4899. */
  4900. continue(curve: DeepImmutable<Curve3>): Curve3;
  4901. private _computeLength;
  4902. }
  4903. }
  4904. declare module "babylonjs/Animations/easing" {
  4905. /**
  4906. * This represents the main contract an easing function should follow.
  4907. * Easing functions are used throughout the animation system.
  4908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4909. */
  4910. export interface IEasingFunction {
  4911. /**
  4912. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4913. * of the easing function.
  4914. * The link below provides some of the most common examples of easing functions.
  4915. * @see https://easings.net/
  4916. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4917. * @returns the corresponding value on the curve defined by the easing function
  4918. */
  4919. ease(gradient: number): number;
  4920. }
  4921. /**
  4922. * Base class used for every default easing function.
  4923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4924. */
  4925. export class EasingFunction implements IEasingFunction {
  4926. /**
  4927. * Interpolation follows the mathematical formula associated with the easing function.
  4928. */
  4929. static readonly EASINGMODE_EASEIN: number;
  4930. /**
  4931. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4932. */
  4933. static readonly EASINGMODE_EASEOUT: number;
  4934. /**
  4935. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4936. */
  4937. static readonly EASINGMODE_EASEINOUT: number;
  4938. private _easingMode;
  4939. /**
  4940. * Sets the easing mode of the current function.
  4941. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4942. */
  4943. setEasingMode(easingMode: number): void;
  4944. /**
  4945. * Gets the current easing mode.
  4946. * @returns the easing mode
  4947. */
  4948. getEasingMode(): number;
  4949. /**
  4950. * @hidden
  4951. */
  4952. easeInCore(gradient: number): number;
  4953. /**
  4954. * Given an input gradient between 0 and 1, this returns the corresponding value
  4955. * of the easing function.
  4956. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4957. * @returns the corresponding value on the curve defined by the easing function
  4958. */
  4959. ease(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a circle shape (see link below).
  4963. * @see https://easings.net/#easeInCirc
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. export class CircleEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a ease back shape (see link below).
  4972. * @see https://easings.net/#easeInBack
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. export class BackEase extends EasingFunction implements IEasingFunction {
  4976. /** Defines the amplitude of the function */
  4977. amplitude: number;
  4978. /**
  4979. * Instantiates a back ease easing
  4980. * @see https://easings.net/#easeInBack
  4981. * @param amplitude Defines the amplitude of the function
  4982. */
  4983. constructor(
  4984. /** Defines the amplitude of the function */
  4985. amplitude?: number);
  4986. /** @hidden */
  4987. easeInCore(gradient: number): number;
  4988. }
  4989. /**
  4990. * Easing function with a bouncing shape (see link below).
  4991. * @see https://easings.net/#easeInBounce
  4992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4993. */
  4994. export class BounceEase extends EasingFunction implements IEasingFunction {
  4995. /** Defines the number of bounces */
  4996. bounces: number;
  4997. /** Defines the amplitude of the bounce */
  4998. bounciness: number;
  4999. /**
  5000. * Instantiates a bounce easing
  5001. * @see https://easings.net/#easeInBounce
  5002. * @param bounces Defines the number of bounces
  5003. * @param bounciness Defines the amplitude of the bounce
  5004. */
  5005. constructor(
  5006. /** Defines the number of bounces */
  5007. bounces?: number,
  5008. /** Defines the amplitude of the bounce */
  5009. bounciness?: number);
  5010. /** @hidden */
  5011. easeInCore(gradient: number): number;
  5012. }
  5013. /**
  5014. * Easing function with a power of 3 shape (see link below).
  5015. * @see https://easings.net/#easeInCubic
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export class CubicEase extends EasingFunction implements IEasingFunction {
  5019. /** @hidden */
  5020. easeInCore(gradient: number): number;
  5021. }
  5022. /**
  5023. * Easing function with an elastic shape (see link below).
  5024. * @see https://easings.net/#easeInElastic
  5025. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5026. */
  5027. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5028. /** Defines the number of oscillations*/
  5029. oscillations: number;
  5030. /** Defines the amplitude of the oscillations*/
  5031. springiness: number;
  5032. /**
  5033. * Instantiates an elastic easing function
  5034. * @see https://easings.net/#easeInElastic
  5035. * @param oscillations Defines the number of oscillations
  5036. * @param springiness Defines the amplitude of the oscillations
  5037. */
  5038. constructor(
  5039. /** Defines the number of oscillations*/
  5040. oscillations?: number,
  5041. /** Defines the amplitude of the oscillations*/
  5042. springiness?: number);
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with an exponential shape (see link below).
  5048. * @see https://easings.net/#easeInExpo
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5052. /** Defines the exponent of the function */
  5053. exponent: number;
  5054. /**
  5055. * Instantiates an exponential easing function
  5056. * @see https://easings.net/#easeInExpo
  5057. * @param exponent Defines the exponent of the function
  5058. */
  5059. constructor(
  5060. /** Defines the exponent of the function */
  5061. exponent?: number);
  5062. /** @hidden */
  5063. easeInCore(gradient: number): number;
  5064. }
  5065. /**
  5066. * Easing function with a power shape (see link below).
  5067. * @see https://easings.net/#easeInQuad
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export class PowerEase extends EasingFunction implements IEasingFunction {
  5071. /** Defines the power of the function */
  5072. power: number;
  5073. /**
  5074. * Instantiates an power base easing function
  5075. * @see https://easings.net/#easeInQuad
  5076. * @param power Defines the power of the function
  5077. */
  5078. constructor(
  5079. /** Defines the power of the function */
  5080. power?: number);
  5081. /** @hidden */
  5082. easeInCore(gradient: number): number;
  5083. }
  5084. /**
  5085. * Easing function with a power of 2 shape (see link below).
  5086. * @see https://easings.net/#easeInQuad
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5090. /** @hidden */
  5091. easeInCore(gradient: number): number;
  5092. }
  5093. /**
  5094. * Easing function with a power of 4 shape (see link below).
  5095. * @see https://easings.net/#easeInQuart
  5096. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5097. */
  5098. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a power of 5 shape (see link below).
  5104. * @see https://easings.net/#easeInQuint
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5108. /** @hidden */
  5109. easeInCore(gradient: number): number;
  5110. }
  5111. /**
  5112. * Easing function with a sin shape (see link below).
  5113. * @see https://easings.net/#easeInSine
  5114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5115. */
  5116. export class SineEase extends EasingFunction implements IEasingFunction {
  5117. /** @hidden */
  5118. easeInCore(gradient: number): number;
  5119. }
  5120. /**
  5121. * Easing function with a bezier shape (see link below).
  5122. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5123. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5124. */
  5125. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5126. /** Defines the x component of the start tangent in the bezier curve */
  5127. x1: number;
  5128. /** Defines the y component of the start tangent in the bezier curve */
  5129. y1: number;
  5130. /** Defines the x component of the end tangent in the bezier curve */
  5131. x2: number;
  5132. /** Defines the y component of the end tangent in the bezier curve */
  5133. y2: number;
  5134. /**
  5135. * Instantiates a bezier function
  5136. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5137. * @param x1 Defines the x component of the start tangent in the bezier curve
  5138. * @param y1 Defines the y component of the start tangent in the bezier curve
  5139. * @param x2 Defines the x component of the end tangent in the bezier curve
  5140. * @param y2 Defines the y component of the end tangent in the bezier curve
  5141. */
  5142. constructor(
  5143. /** Defines the x component of the start tangent in the bezier curve */
  5144. x1?: number,
  5145. /** Defines the y component of the start tangent in the bezier curve */
  5146. y1?: number,
  5147. /** Defines the x component of the end tangent in the bezier curve */
  5148. x2?: number,
  5149. /** Defines the y component of the end tangent in the bezier curve */
  5150. y2?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. }
  5155. declare module "babylonjs/Maths/math.color" {
  5156. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5157. /**
  5158. * Class used to hold a RBG color
  5159. */
  5160. export class Color3 {
  5161. /**
  5162. * Defines the red component (between 0 and 1, default is 0)
  5163. */
  5164. r: number;
  5165. /**
  5166. * Defines the green component (between 0 and 1, default is 0)
  5167. */
  5168. g: number;
  5169. /**
  5170. * Defines the blue component (between 0 and 1, default is 0)
  5171. */
  5172. b: number;
  5173. /**
  5174. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5175. * @param r defines the red component (between 0 and 1, default is 0)
  5176. * @param g defines the green component (between 0 and 1, default is 0)
  5177. * @param b defines the blue component (between 0 and 1, default is 0)
  5178. */
  5179. constructor(
  5180. /**
  5181. * Defines the red component (between 0 and 1, default is 0)
  5182. */
  5183. r?: number,
  5184. /**
  5185. * Defines the green component (between 0 and 1, default is 0)
  5186. */
  5187. g?: number,
  5188. /**
  5189. * Defines the blue component (between 0 and 1, default is 0)
  5190. */
  5191. b?: number);
  5192. /**
  5193. * Creates a string with the Color3 current values
  5194. * @returns the string representation of the Color3 object
  5195. */
  5196. toString(): string;
  5197. /**
  5198. * Returns the string "Color3"
  5199. * @returns "Color3"
  5200. */
  5201. getClassName(): string;
  5202. /**
  5203. * Compute the Color3 hash code
  5204. * @returns an unique number that can be used to hash Color3 objects
  5205. */
  5206. getHashCode(): number;
  5207. /**
  5208. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5209. * @param array defines the array where to store the r,g,b components
  5210. * @param index defines an optional index in the target array to define where to start storing values
  5211. * @returns the current Color3 object
  5212. */
  5213. toArray(array: FloatArray, index?: number): Color3;
  5214. /**
  5215. * Returns a new Color4 object from the current Color3 and the given alpha
  5216. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5217. * @returns a new Color4 object
  5218. */
  5219. toColor4(alpha?: number): Color4;
  5220. /**
  5221. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5222. * @returns the new array
  5223. */
  5224. asArray(): number[];
  5225. /**
  5226. * Returns the luminance value
  5227. * @returns a float value
  5228. */
  5229. toLuminance(): number;
  5230. /**
  5231. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5232. * @param otherColor defines the second operand
  5233. * @returns the new Color3 object
  5234. */
  5235. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5236. /**
  5237. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5238. * @param otherColor defines the second operand
  5239. * @param result defines the Color3 object where to store the result
  5240. * @returns the current Color3
  5241. */
  5242. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5243. /**
  5244. * Determines equality between Color3 objects
  5245. * @param otherColor defines the second operand
  5246. * @returns true if the rgb values are equal to the given ones
  5247. */
  5248. equals(otherColor: DeepImmutable<Color3>): boolean;
  5249. /**
  5250. * Determines equality between the current Color3 object and a set of r,b,g values
  5251. * @param r defines the red component to check
  5252. * @param g defines the green component to check
  5253. * @param b defines the blue component to check
  5254. * @returns true if the rgb values are equal to the given ones
  5255. */
  5256. equalsFloats(r: number, g: number, b: number): boolean;
  5257. /**
  5258. * Multiplies in place each rgb value by scale
  5259. * @param scale defines the scaling factor
  5260. * @returns the updated Color3
  5261. */
  5262. scale(scale: number): Color3;
  5263. /**
  5264. * Multiplies the rgb values by scale and stores the result into "result"
  5265. * @param scale defines the scaling factor
  5266. * @param result defines the Color3 object where to store the result
  5267. * @returns the unmodified current Color3
  5268. */
  5269. scaleToRef(scale: number, result: Color3): Color3;
  5270. /**
  5271. * Scale the current Color3 values by a factor and add the result to a given Color3
  5272. * @param scale defines the scale factor
  5273. * @param result defines color to store the result into
  5274. * @returns the unmodified current Color3
  5275. */
  5276. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5277. /**
  5278. * Clamps the rgb values by the min and max values and stores the result into "result"
  5279. * @param min defines minimum clamping value (default is 0)
  5280. * @param max defines maximum clamping value (default is 1)
  5281. * @param result defines color to store the result into
  5282. * @returns the original Color3
  5283. */
  5284. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5285. /**
  5286. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5287. * @param otherColor defines the second operand
  5288. * @returns the new Color3
  5289. */
  5290. add(otherColor: DeepImmutable<Color3>): Color3;
  5291. /**
  5292. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5293. * @param otherColor defines the second operand
  5294. * @param result defines Color3 object to store the result into
  5295. * @returns the unmodified current Color3
  5296. */
  5297. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5298. /**
  5299. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5300. * @param otherColor defines the second operand
  5301. * @returns the new Color3
  5302. */
  5303. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5304. /**
  5305. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5306. * @param otherColor defines the second operand
  5307. * @param result defines Color3 object to store the result into
  5308. * @returns the unmodified current Color3
  5309. */
  5310. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5311. /**
  5312. * Copy the current object
  5313. * @returns a new Color3 copied the current one
  5314. */
  5315. clone(): Color3;
  5316. /**
  5317. * Copies the rgb values from the source in the current Color3
  5318. * @param source defines the source Color3 object
  5319. * @returns the updated Color3 object
  5320. */
  5321. copyFrom(source: DeepImmutable<Color3>): Color3;
  5322. /**
  5323. * Updates the Color3 rgb values from the given floats
  5324. * @param r defines the red component to read from
  5325. * @param g defines the green component to read from
  5326. * @param b defines the blue component to read from
  5327. * @returns the current Color3 object
  5328. */
  5329. copyFromFloats(r: number, g: number, b: number): Color3;
  5330. /**
  5331. * Updates the Color3 rgb values from the given floats
  5332. * @param r defines the red component to read from
  5333. * @param g defines the green component to read from
  5334. * @param b defines the blue component to read from
  5335. * @returns the current Color3 object
  5336. */
  5337. set(r: number, g: number, b: number): Color3;
  5338. /**
  5339. * Compute the Color3 hexadecimal code as a string
  5340. * @returns a string containing the hexadecimal representation of the Color3 object
  5341. */
  5342. toHexString(): string;
  5343. /**
  5344. * Computes a new Color3 converted from the current one to linear space
  5345. * @returns a new Color3 object
  5346. */
  5347. toLinearSpace(): Color3;
  5348. /**
  5349. * Converts current color in rgb space to HSV values
  5350. * @returns a new color3 representing the HSV values
  5351. */
  5352. toHSV(): Color3;
  5353. /**
  5354. * Converts current color in rgb space to HSV values
  5355. * @param result defines the Color3 where to store the HSV values
  5356. */
  5357. toHSVToRef(result: Color3): void;
  5358. /**
  5359. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5360. * @param convertedColor defines the Color3 object where to store the linear space version
  5361. * @returns the unmodified Color3
  5362. */
  5363. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5364. /**
  5365. * Computes a new Color3 converted from the current one to gamma space
  5366. * @returns a new Color3 object
  5367. */
  5368. toGammaSpace(): Color3;
  5369. /**
  5370. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5371. * @param convertedColor defines the Color3 object where to store the gamma space version
  5372. * @returns the unmodified Color3
  5373. */
  5374. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5375. private static _BlackReadOnly;
  5376. /**
  5377. * Convert Hue, saturation and value to a Color3 (RGB)
  5378. * @param hue defines the hue
  5379. * @param saturation defines the saturation
  5380. * @param value defines the value
  5381. * @param result defines the Color3 where to store the RGB values
  5382. */
  5383. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5384. /**
  5385. * Creates a new Color3 from the string containing valid hexadecimal values
  5386. * @param hex defines a string containing valid hexadecimal values
  5387. * @returns a new Color3 object
  5388. */
  5389. static FromHexString(hex: string): Color3;
  5390. /**
  5391. * Creates a new Color3 from the starting index of the given array
  5392. * @param array defines the source array
  5393. * @param offset defines an offset in the source array
  5394. * @returns a new Color3 object
  5395. */
  5396. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5397. /**
  5398. * Creates a new Color3 from integer values (< 256)
  5399. * @param r defines the red component to read from (value between 0 and 255)
  5400. * @param g defines the green component to read from (value between 0 and 255)
  5401. * @param b defines the blue component to read from (value between 0 and 255)
  5402. * @returns a new Color3 object
  5403. */
  5404. static FromInts(r: number, g: number, b: number): Color3;
  5405. /**
  5406. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5407. * @param start defines the start Color3 value
  5408. * @param end defines the end Color3 value
  5409. * @param amount defines the gradient value between start and end
  5410. * @returns a new Color3 object
  5411. */
  5412. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5413. /**
  5414. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5415. * @param left defines the start value
  5416. * @param right defines the end value
  5417. * @param amount defines the gradient factor
  5418. * @param result defines the Color3 object where to store the result
  5419. */
  5420. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5421. /**
  5422. * Returns a Color3 value containing a red color
  5423. * @returns a new Color3 object
  5424. */
  5425. static Red(): Color3;
  5426. /**
  5427. * Returns a Color3 value containing a green color
  5428. * @returns a new Color3 object
  5429. */
  5430. static Green(): Color3;
  5431. /**
  5432. * Returns a Color3 value containing a blue color
  5433. * @returns a new Color3 object
  5434. */
  5435. static Blue(): Color3;
  5436. /**
  5437. * Returns a Color3 value containing a black color
  5438. * @returns a new Color3 object
  5439. */
  5440. static Black(): Color3;
  5441. /**
  5442. * Gets a Color3 value containing a black color that must not be updated
  5443. */
  5444. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5445. /**
  5446. * Returns a Color3 value containing a white color
  5447. * @returns a new Color3 object
  5448. */
  5449. static White(): Color3;
  5450. /**
  5451. * Returns a Color3 value containing a purple color
  5452. * @returns a new Color3 object
  5453. */
  5454. static Purple(): Color3;
  5455. /**
  5456. * Returns a Color3 value containing a magenta color
  5457. * @returns a new Color3 object
  5458. */
  5459. static Magenta(): Color3;
  5460. /**
  5461. * Returns a Color3 value containing a yellow color
  5462. * @returns a new Color3 object
  5463. */
  5464. static Yellow(): Color3;
  5465. /**
  5466. * Returns a Color3 value containing a gray color
  5467. * @returns a new Color3 object
  5468. */
  5469. static Gray(): Color3;
  5470. /**
  5471. * Returns a Color3 value containing a teal color
  5472. * @returns a new Color3 object
  5473. */
  5474. static Teal(): Color3;
  5475. /**
  5476. * Returns a Color3 value containing a random color
  5477. * @returns a new Color3 object
  5478. */
  5479. static Random(): Color3;
  5480. }
  5481. /**
  5482. * Class used to hold a RBGA color
  5483. */
  5484. export class Color4 {
  5485. /**
  5486. * Defines the red component (between 0 and 1, default is 0)
  5487. */
  5488. r: number;
  5489. /**
  5490. * Defines the green component (between 0 and 1, default is 0)
  5491. */
  5492. g: number;
  5493. /**
  5494. * Defines the blue component (between 0 and 1, default is 0)
  5495. */
  5496. b: number;
  5497. /**
  5498. * Defines the alpha component (between 0 and 1, default is 1)
  5499. */
  5500. a: number;
  5501. /**
  5502. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5503. * @param r defines the red component (between 0 and 1, default is 0)
  5504. * @param g defines the green component (between 0 and 1, default is 0)
  5505. * @param b defines the blue component (between 0 and 1, default is 0)
  5506. * @param a defines the alpha component (between 0 and 1, default is 1)
  5507. */
  5508. constructor(
  5509. /**
  5510. * Defines the red component (between 0 and 1, default is 0)
  5511. */
  5512. r?: number,
  5513. /**
  5514. * Defines the green component (between 0 and 1, default is 0)
  5515. */
  5516. g?: number,
  5517. /**
  5518. * Defines the blue component (between 0 and 1, default is 0)
  5519. */
  5520. b?: number,
  5521. /**
  5522. * Defines the alpha component (between 0 and 1, default is 1)
  5523. */
  5524. a?: number);
  5525. /**
  5526. * Adds in place the given Color4 values to the current Color4 object
  5527. * @param right defines the second operand
  5528. * @returns the current updated Color4 object
  5529. */
  5530. addInPlace(right: DeepImmutable<Color4>): Color4;
  5531. /**
  5532. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5533. * @returns the new array
  5534. */
  5535. asArray(): number[];
  5536. /**
  5537. * Stores from the starting index in the given array the Color4 successive values
  5538. * @param array defines the array where to store the r,g,b components
  5539. * @param index defines an optional index in the target array to define where to start storing values
  5540. * @returns the current Color4 object
  5541. */
  5542. toArray(array: number[], index?: number): Color4;
  5543. /**
  5544. * Determines equality between Color4 objects
  5545. * @param otherColor defines the second operand
  5546. * @returns true if the rgba values are equal to the given ones
  5547. */
  5548. equals(otherColor: DeepImmutable<Color4>): boolean;
  5549. /**
  5550. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5551. * @param right defines the second operand
  5552. * @returns a new Color4 object
  5553. */
  5554. add(right: DeepImmutable<Color4>): Color4;
  5555. /**
  5556. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5557. * @param right defines the second operand
  5558. * @returns a new Color4 object
  5559. */
  5560. subtract(right: DeepImmutable<Color4>): Color4;
  5561. /**
  5562. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5563. * @param right defines the second operand
  5564. * @param result defines the Color4 object where to store the result
  5565. * @returns the current Color4 object
  5566. */
  5567. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5568. /**
  5569. * Creates a new Color4 with the current Color4 values multiplied by scale
  5570. * @param scale defines the scaling factor to apply
  5571. * @returns a new Color4 object
  5572. */
  5573. scale(scale: number): Color4;
  5574. /**
  5575. * Multiplies the current Color4 values by scale and stores the result in "result"
  5576. * @param scale defines the scaling factor to apply
  5577. * @param result defines the Color4 object where to store the result
  5578. * @returns the current unmodified Color4
  5579. */
  5580. scaleToRef(scale: number, result: Color4): Color4;
  5581. /**
  5582. * Scale the current Color4 values by a factor and add the result to a given Color4
  5583. * @param scale defines the scale factor
  5584. * @param result defines the Color4 object where to store the result
  5585. * @returns the unmodified current Color4
  5586. */
  5587. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5588. /**
  5589. * Clamps the rgb values by the min and max values and stores the result into "result"
  5590. * @param min defines minimum clamping value (default is 0)
  5591. * @param max defines maximum clamping value (default is 1)
  5592. * @param result defines color to store the result into.
  5593. * @returns the cuurent Color4
  5594. */
  5595. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5596. /**
  5597. * Multipy an Color4 value by another and return a new Color4 object
  5598. * @param color defines the Color4 value to multiply by
  5599. * @returns a new Color4 object
  5600. */
  5601. multiply(color: Color4): Color4;
  5602. /**
  5603. * Multipy a Color4 value by another and push the result in a reference value
  5604. * @param color defines the Color4 value to multiply by
  5605. * @param result defines the Color4 to fill the result in
  5606. * @returns the result Color4
  5607. */
  5608. multiplyToRef(color: Color4, result: Color4): Color4;
  5609. /**
  5610. * Creates a string with the Color4 current values
  5611. * @returns the string representation of the Color4 object
  5612. */
  5613. toString(): string;
  5614. /**
  5615. * Returns the string "Color4"
  5616. * @returns "Color4"
  5617. */
  5618. getClassName(): string;
  5619. /**
  5620. * Compute the Color4 hash code
  5621. * @returns an unique number that can be used to hash Color4 objects
  5622. */
  5623. getHashCode(): number;
  5624. /**
  5625. * Creates a new Color4 copied from the current one
  5626. * @returns a new Color4 object
  5627. */
  5628. clone(): Color4;
  5629. /**
  5630. * Copies the given Color4 values into the current one
  5631. * @param source defines the source Color4 object
  5632. * @returns the current updated Color4 object
  5633. */
  5634. copyFrom(source: Color4): Color4;
  5635. /**
  5636. * Copies the given float values into the current one
  5637. * @param r defines the red component to read from
  5638. * @param g defines the green component to read from
  5639. * @param b defines the blue component to read from
  5640. * @param a defines the alpha component to read from
  5641. * @returns the current updated Color4 object
  5642. */
  5643. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5644. /**
  5645. * Copies the given float values into the current one
  5646. * @param r defines the red component to read from
  5647. * @param g defines the green component to read from
  5648. * @param b defines the blue component to read from
  5649. * @param a defines the alpha component to read from
  5650. * @returns the current updated Color4 object
  5651. */
  5652. set(r: number, g: number, b: number, a: number): Color4;
  5653. /**
  5654. * Compute the Color4 hexadecimal code as a string
  5655. * @returns a string containing the hexadecimal representation of the Color4 object
  5656. */
  5657. toHexString(): string;
  5658. /**
  5659. * Computes a new Color4 converted from the current one to linear space
  5660. * @returns a new Color4 object
  5661. */
  5662. toLinearSpace(): Color4;
  5663. /**
  5664. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5665. * @param convertedColor defines the Color4 object where to store the linear space version
  5666. * @returns the unmodified Color4
  5667. */
  5668. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5669. /**
  5670. * Computes a new Color4 converted from the current one to gamma space
  5671. * @returns a new Color4 object
  5672. */
  5673. toGammaSpace(): Color4;
  5674. /**
  5675. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5676. * @param convertedColor defines the Color4 object where to store the gamma space version
  5677. * @returns the unmodified Color4
  5678. */
  5679. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5680. /**
  5681. * Creates a new Color4 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color4 object
  5684. */
  5685. static FromHexString(hex: string): Color4;
  5686. /**
  5687. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5688. * @param left defines the start value
  5689. * @param right defines the end value
  5690. * @param amount defines the gradient factor
  5691. * @returns a new Color4 object
  5692. */
  5693. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5694. /**
  5695. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5696. * @param left defines the start value
  5697. * @param right defines the end value
  5698. * @param amount defines the gradient factor
  5699. * @param result defines the Color4 object where to store data
  5700. */
  5701. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5702. /**
  5703. * Creates a new Color4 from a Color3 and an alpha value
  5704. * @param color3 defines the source Color3 to read from
  5705. * @param alpha defines the alpha component (1.0 by default)
  5706. * @returns a new Color4 object
  5707. */
  5708. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5709. /**
  5710. * Creates a new Color4 from the starting index element of the given array
  5711. * @param array defines the source array to read from
  5712. * @param offset defines the offset in the source array
  5713. * @returns a new Color4 object
  5714. */
  5715. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5716. /**
  5717. * Creates a new Color3 from integer values (< 256)
  5718. * @param r defines the red component to read from (value between 0 and 255)
  5719. * @param g defines the green component to read from (value between 0 and 255)
  5720. * @param b defines the blue component to read from (value between 0 and 255)
  5721. * @param a defines the alpha component to read from (value between 0 and 255)
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5725. /**
  5726. * Check the content of a given array and convert it to an array containing RGBA data
  5727. * If the original array was already containing count * 4 values then it is returned directly
  5728. * @param colors defines the array to check
  5729. * @param count defines the number of RGBA data to expect
  5730. * @returns an array containing count * 4 values (RGBA)
  5731. */
  5732. static CheckColors4(colors: number[], count: number): number[];
  5733. }
  5734. /**
  5735. * @hidden
  5736. */
  5737. export class TmpColors {
  5738. static Color3: Color3[];
  5739. static Color4: Color4[];
  5740. }
  5741. }
  5742. declare module "babylonjs/Animations/animationKey" {
  5743. /**
  5744. * Defines an interface which represents an animation key frame
  5745. */
  5746. export interface IAnimationKey {
  5747. /**
  5748. * Frame of the key frame
  5749. */
  5750. frame: number;
  5751. /**
  5752. * Value at the specifies key frame
  5753. */
  5754. value: any;
  5755. /**
  5756. * The input tangent for the cubic hermite spline
  5757. */
  5758. inTangent?: any;
  5759. /**
  5760. * The output tangent for the cubic hermite spline
  5761. */
  5762. outTangent?: any;
  5763. /**
  5764. * The animation interpolation type
  5765. */
  5766. interpolation?: AnimationKeyInterpolation;
  5767. }
  5768. /**
  5769. * Enum for the animation key frame interpolation type
  5770. */
  5771. export enum AnimationKeyInterpolation {
  5772. /**
  5773. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5774. */
  5775. STEP = 1
  5776. }
  5777. }
  5778. declare module "babylonjs/Animations/animationRange" {
  5779. /**
  5780. * Represents the range of an animation
  5781. */
  5782. export class AnimationRange {
  5783. /**The name of the animation range**/
  5784. name: string;
  5785. /**The starting frame of the animation */
  5786. from: number;
  5787. /**The ending frame of the animation*/
  5788. to: number;
  5789. /**
  5790. * Initializes the range of an animation
  5791. * @param name The name of the animation range
  5792. * @param from The starting frame of the animation
  5793. * @param to The ending frame of the animation
  5794. */
  5795. constructor(
  5796. /**The name of the animation range**/
  5797. name: string,
  5798. /**The starting frame of the animation */
  5799. from: number,
  5800. /**The ending frame of the animation*/
  5801. to: number);
  5802. /**
  5803. * Makes a copy of the animation range
  5804. * @returns A copy of the animation range
  5805. */
  5806. clone(): AnimationRange;
  5807. }
  5808. }
  5809. declare module "babylonjs/Animations/animationEvent" {
  5810. /**
  5811. * Composed of a frame, and an action function
  5812. */
  5813. export class AnimationEvent {
  5814. /** The frame for which the event is triggered **/
  5815. frame: number;
  5816. /** The event to perform when triggered **/
  5817. action: (currentFrame: number) => void;
  5818. /** Specifies if the event should be triggered only once**/
  5819. onlyOnce?: boolean | undefined;
  5820. /**
  5821. * Specifies if the animation event is done
  5822. */
  5823. isDone: boolean;
  5824. /**
  5825. * Initializes the animation event
  5826. * @param frame The frame for which the event is triggered
  5827. * @param action The event to perform when triggered
  5828. * @param onlyOnce Specifies if the event should be triggered only once
  5829. */
  5830. constructor(
  5831. /** The frame for which the event is triggered **/
  5832. frame: number,
  5833. /** The event to perform when triggered **/
  5834. action: (currentFrame: number) => void,
  5835. /** Specifies if the event should be triggered only once**/
  5836. onlyOnce?: boolean | undefined);
  5837. /** @hidden */
  5838. _clone(): AnimationEvent;
  5839. }
  5840. }
  5841. declare module "babylonjs/Behaviors/behavior" {
  5842. import { Nullable } from "babylonjs/types";
  5843. /**
  5844. * Interface used to define a behavior
  5845. */
  5846. export interface Behavior<T> {
  5847. /** gets or sets behavior's name */
  5848. name: string;
  5849. /**
  5850. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5851. */
  5852. init(): void;
  5853. /**
  5854. * Called when the behavior is attached to a target
  5855. * @param target defines the target where the behavior is attached to
  5856. */
  5857. attach(target: T): void;
  5858. /**
  5859. * Called when the behavior is detached from its target
  5860. */
  5861. detach(): void;
  5862. }
  5863. /**
  5864. * Interface implemented by classes supporting behaviors
  5865. */
  5866. export interface IBehaviorAware<T> {
  5867. /**
  5868. * Attach a behavior
  5869. * @param behavior defines the behavior to attach
  5870. * @returns the current host
  5871. */
  5872. addBehavior(behavior: Behavior<T>): T;
  5873. /**
  5874. * Remove a behavior from the current object
  5875. * @param behavior defines the behavior to detach
  5876. * @returns the current host
  5877. */
  5878. removeBehavior(behavior: Behavior<T>): T;
  5879. /**
  5880. * Gets a behavior using its name to search
  5881. * @param name defines the name to search
  5882. * @returns the behavior or null if not found
  5883. */
  5884. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5885. }
  5886. }
  5887. declare module "babylonjs/Misc/smartArray" {
  5888. /**
  5889. * Defines an array and its length.
  5890. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5891. */
  5892. export interface ISmartArrayLike<T> {
  5893. /**
  5894. * The data of the array.
  5895. */
  5896. data: Array<T>;
  5897. /**
  5898. * The active length of the array.
  5899. */
  5900. length: number;
  5901. }
  5902. /**
  5903. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5904. */
  5905. export class SmartArray<T> implements ISmartArrayLike<T> {
  5906. /**
  5907. * The full set of data from the array.
  5908. */
  5909. data: Array<T>;
  5910. /**
  5911. * The active length of the array.
  5912. */
  5913. length: number;
  5914. protected _id: number;
  5915. /**
  5916. * Instantiates a Smart Array.
  5917. * @param capacity defines the default capacity of the array.
  5918. */
  5919. constructor(capacity: number);
  5920. /**
  5921. * Pushes a value at the end of the active data.
  5922. * @param value defines the object to push in the array.
  5923. */
  5924. push(value: T): void;
  5925. /**
  5926. * Iterates over the active data and apply the lambda to them.
  5927. * @param func defines the action to apply on each value.
  5928. */
  5929. forEach(func: (content: T) => void): void;
  5930. /**
  5931. * Sorts the full sets of data.
  5932. * @param compareFn defines the comparison function to apply.
  5933. */
  5934. sort(compareFn: (a: T, b: T) => number): void;
  5935. /**
  5936. * Resets the active data to an empty array.
  5937. */
  5938. reset(): void;
  5939. /**
  5940. * Releases all the data from the array as well as the array.
  5941. */
  5942. dispose(): void;
  5943. /**
  5944. * Concats the active data with a given array.
  5945. * @param array defines the data to concatenate with.
  5946. */
  5947. concat(array: any): void;
  5948. /**
  5949. * Returns the position of a value in the active data.
  5950. * @param value defines the value to find the index for
  5951. * @returns the index if found in the active data otherwise -1
  5952. */
  5953. indexOf(value: T): number;
  5954. /**
  5955. * Returns whether an element is part of the active data.
  5956. * @param value defines the value to look for
  5957. * @returns true if found in the active data otherwise false
  5958. */
  5959. contains(value: T): boolean;
  5960. private static _GlobalId;
  5961. }
  5962. /**
  5963. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5964. * The data in this array can only be present once
  5965. */
  5966. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5967. private _duplicateId;
  5968. /**
  5969. * Pushes a value at the end of the active data.
  5970. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5971. * @param value defines the object to push in the array.
  5972. */
  5973. push(value: T): void;
  5974. /**
  5975. * Pushes a value at the end of the active data.
  5976. * If the data is already present, it won t be added again
  5977. * @param value defines the object to push in the array.
  5978. * @returns true if added false if it was already present
  5979. */
  5980. pushNoDuplicate(value: T): boolean;
  5981. /**
  5982. * Resets the active data to an empty array.
  5983. */
  5984. reset(): void;
  5985. /**
  5986. * Concats the active data with a given array.
  5987. * This ensures no dupplicate will be present in the result.
  5988. * @param array defines the data to concatenate with.
  5989. */
  5990. concatWithNoDuplicate(array: any): void;
  5991. }
  5992. }
  5993. declare module "babylonjs/Cameras/cameraInputsManager" {
  5994. import { Nullable } from "babylonjs/types";
  5995. import { Camera } from "babylonjs/Cameras/camera";
  5996. /**
  5997. * @ignore
  5998. * This is a list of all the different input types that are available in the application.
  5999. * Fo instance: ArcRotateCameraGamepadInput...
  6000. */
  6001. export var CameraInputTypes: {};
  6002. /**
  6003. * This is the contract to implement in order to create a new input class.
  6004. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6005. */
  6006. export interface ICameraInput<TCamera extends Camera> {
  6007. /**
  6008. * Defines the camera the input is attached to.
  6009. */
  6010. camera: Nullable<TCamera>;
  6011. /**
  6012. * Gets the class name of the current intput.
  6013. * @returns the class name
  6014. */
  6015. getClassName(): string;
  6016. /**
  6017. * Get the friendly name associated with the input class.
  6018. * @returns the input friendly name
  6019. */
  6020. getSimpleName(): string;
  6021. /**
  6022. * Attach the input controls to a specific dom element to get the input from.
  6023. * @param element Defines the element the controls should be listened from
  6024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6025. */
  6026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6027. /**
  6028. * Detach the current controls from the specified dom element.
  6029. * @param element Defines the element to stop listening the inputs from
  6030. */
  6031. detachControl(element: Nullable<HTMLElement>): void;
  6032. /**
  6033. * Update the current camera state depending on the inputs that have been used this frame.
  6034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6035. */
  6036. checkInputs?: () => void;
  6037. }
  6038. /**
  6039. * Represents a map of input types to input instance or input index to input instance.
  6040. */
  6041. export interface CameraInputsMap<TCamera extends Camera> {
  6042. /**
  6043. * Accessor to the input by input type.
  6044. */
  6045. [name: string]: ICameraInput<TCamera>;
  6046. /**
  6047. * Accessor to the input by input index.
  6048. */
  6049. [idx: number]: ICameraInput<TCamera>;
  6050. }
  6051. /**
  6052. * This represents the input manager used within a camera.
  6053. * It helps dealing with all the different kind of input attached to a camera.
  6054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6055. */
  6056. export class CameraInputsManager<TCamera extends Camera> {
  6057. /**
  6058. * Defines the list of inputs attahed to the camera.
  6059. */
  6060. attached: CameraInputsMap<TCamera>;
  6061. /**
  6062. * Defines the dom element the camera is collecting inputs from.
  6063. * This is null if the controls have not been attached.
  6064. */
  6065. attachedElement: Nullable<HTMLElement>;
  6066. /**
  6067. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6068. */
  6069. noPreventDefault: boolean;
  6070. /**
  6071. * Defined the camera the input manager belongs to.
  6072. */
  6073. camera: TCamera;
  6074. /**
  6075. * Update the current camera state depending on the inputs that have been used this frame.
  6076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6077. */
  6078. checkInputs: () => void;
  6079. /**
  6080. * Instantiate a new Camera Input Manager.
  6081. * @param camera Defines the camera the input manager blongs to
  6082. */
  6083. constructor(camera: TCamera);
  6084. /**
  6085. * Add an input method to a camera
  6086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6087. * @param input camera input method
  6088. */
  6089. add(input: ICameraInput<TCamera>): void;
  6090. /**
  6091. * Remove a specific input method from a camera
  6092. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6093. * @param inputToRemove camera input method
  6094. */
  6095. remove(inputToRemove: ICameraInput<TCamera>): void;
  6096. /**
  6097. * Remove a specific input type from a camera
  6098. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6099. * @param inputType the type of the input to remove
  6100. */
  6101. removeByType(inputType: string): void;
  6102. private _addCheckInputs;
  6103. /**
  6104. * Attach the input controls to the currently attached dom element to listen the events from.
  6105. * @param input Defines the input to attach
  6106. */
  6107. attachInput(input: ICameraInput<TCamera>): void;
  6108. /**
  6109. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6110. * @param element Defines the dom element to collect the events from
  6111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6112. */
  6113. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6114. /**
  6115. * Detach the current manager inputs controls from a specific dom element.
  6116. * @param element Defines the dom element to collect the events from
  6117. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6118. */
  6119. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6120. /**
  6121. * Rebuild the dynamic inputCheck function from the current list of
  6122. * defined inputs in the manager.
  6123. */
  6124. rebuildInputCheck(): void;
  6125. /**
  6126. * Remove all attached input methods from a camera
  6127. */
  6128. clear(): void;
  6129. /**
  6130. * Serialize the current input manager attached to a camera.
  6131. * This ensures than once parsed,
  6132. * the input associated to the camera will be identical to the current ones
  6133. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6134. */
  6135. serialize(serializedCamera: any): void;
  6136. /**
  6137. * Parses an input manager serialized JSON to restore the previous list of inputs
  6138. * and states associated to a camera.
  6139. * @param parsedCamera Defines the JSON to parse
  6140. */
  6141. parse(parsedCamera: any): void;
  6142. }
  6143. }
  6144. declare module "babylonjs/Meshes/buffer" {
  6145. import { Nullable, DataArray } from "babylonjs/types";
  6146. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6147. /**
  6148. * Class used to store data that will be store in GPU memory
  6149. */
  6150. export class Buffer {
  6151. private _engine;
  6152. private _buffer;
  6153. /** @hidden */
  6154. _data: Nullable<DataArray>;
  6155. private _updatable;
  6156. private _instanced;
  6157. private _divisor;
  6158. /**
  6159. * Gets the byte stride.
  6160. */
  6161. readonly byteStride: number;
  6162. /**
  6163. * Constructor
  6164. * @param engine the engine
  6165. * @param data the data to use for this buffer
  6166. * @param updatable whether the data is updatable
  6167. * @param stride the stride (optional)
  6168. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6169. * @param instanced whether the buffer is instanced (optional)
  6170. * @param useBytes set to true if the stride in in bytes (optional)
  6171. * @param divisor sets an optional divisor for instances (1 by default)
  6172. */
  6173. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6174. /**
  6175. * Create a new VertexBuffer based on the current buffer
  6176. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6177. * @param offset defines offset in the buffer (0 by default)
  6178. * @param size defines the size in floats of attributes (position is 3 for instance)
  6179. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6180. * @param instanced defines if the vertex buffer contains indexed data
  6181. * @param useBytes defines if the offset and stride are in bytes *
  6182. * @param divisor sets an optional divisor for instances (1 by default)
  6183. * @returns the new vertex buffer
  6184. */
  6185. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6186. /**
  6187. * Gets a boolean indicating if the Buffer is updatable?
  6188. * @returns true if the buffer is updatable
  6189. */
  6190. isUpdatable(): boolean;
  6191. /**
  6192. * Gets current buffer's data
  6193. * @returns a DataArray or null
  6194. */
  6195. getData(): Nullable<DataArray>;
  6196. /**
  6197. * Gets underlying native buffer
  6198. * @returns underlying native buffer
  6199. */
  6200. getBuffer(): Nullable<DataBuffer>;
  6201. /**
  6202. * Gets the stride in float32 units (i.e. byte stride / 4).
  6203. * May not be an integer if the byte stride is not divisible by 4.
  6204. * DEPRECATED. Use byteStride instead.
  6205. * @returns the stride in float32 units
  6206. */
  6207. getStrideSize(): number;
  6208. /**
  6209. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6210. * @param data defines the data to store
  6211. */
  6212. create(data?: Nullable<DataArray>): void;
  6213. /** @hidden */
  6214. _rebuild(): void;
  6215. /**
  6216. * Update current buffer data
  6217. * @param data defines the data to store
  6218. */
  6219. update(data: DataArray): void;
  6220. /**
  6221. * Updates the data directly.
  6222. * @param data the new data
  6223. * @param offset the new offset
  6224. * @param vertexCount the vertex count (optional)
  6225. * @param useBytes set to true if the offset is in bytes
  6226. */
  6227. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6228. /**
  6229. * Release all resources
  6230. */
  6231. dispose(): void;
  6232. }
  6233. /**
  6234. * Specialized buffer used to store vertex data
  6235. */
  6236. export class VertexBuffer {
  6237. /** @hidden */
  6238. _buffer: Buffer;
  6239. private _kind;
  6240. private _size;
  6241. private _ownsBuffer;
  6242. private _instanced;
  6243. private _instanceDivisor;
  6244. /**
  6245. * The byte type.
  6246. */
  6247. static readonly BYTE: number;
  6248. /**
  6249. * The unsigned byte type.
  6250. */
  6251. static readonly UNSIGNED_BYTE: number;
  6252. /**
  6253. * The short type.
  6254. */
  6255. static readonly SHORT: number;
  6256. /**
  6257. * The unsigned short type.
  6258. */
  6259. static readonly UNSIGNED_SHORT: number;
  6260. /**
  6261. * The integer type.
  6262. */
  6263. static readonly INT: number;
  6264. /**
  6265. * The unsigned integer type.
  6266. */
  6267. static readonly UNSIGNED_INT: number;
  6268. /**
  6269. * The float type.
  6270. */
  6271. static readonly FLOAT: number;
  6272. /**
  6273. * Gets or sets the instance divisor when in instanced mode
  6274. */
  6275. instanceDivisor: number;
  6276. /**
  6277. * Gets the byte stride.
  6278. */
  6279. readonly byteStride: number;
  6280. /**
  6281. * Gets the byte offset.
  6282. */
  6283. readonly byteOffset: number;
  6284. /**
  6285. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6286. */
  6287. readonly normalized: boolean;
  6288. /**
  6289. * Gets the data type of each component in the array.
  6290. */
  6291. readonly type: number;
  6292. /**
  6293. * Constructor
  6294. * @param engine the engine
  6295. * @param data the data to use for this vertex buffer
  6296. * @param kind the vertex buffer kind
  6297. * @param updatable whether the data is updatable
  6298. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6299. * @param stride the stride (optional)
  6300. * @param instanced whether the buffer is instanced (optional)
  6301. * @param offset the offset of the data (optional)
  6302. * @param size the number of components (optional)
  6303. * @param type the type of the component (optional)
  6304. * @param normalized whether the data contains normalized data (optional)
  6305. * @param useBytes set to true if stride and offset are in bytes (optional)
  6306. * @param divisor defines the instance divisor to use (1 by default)
  6307. */
  6308. 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);
  6309. /** @hidden */
  6310. _rebuild(): void;
  6311. /**
  6312. * Returns the kind of the VertexBuffer (string)
  6313. * @returns a string
  6314. */
  6315. getKind(): string;
  6316. /**
  6317. * Gets a boolean indicating if the VertexBuffer is updatable?
  6318. * @returns true if the buffer is updatable
  6319. */
  6320. isUpdatable(): boolean;
  6321. /**
  6322. * Gets current buffer's data
  6323. * @returns a DataArray or null
  6324. */
  6325. getData(): Nullable<DataArray>;
  6326. /**
  6327. * Gets underlying native buffer
  6328. * @returns underlying native buffer
  6329. */
  6330. getBuffer(): Nullable<DataBuffer>;
  6331. /**
  6332. * Gets the stride in float32 units (i.e. byte stride / 4).
  6333. * May not be an integer if the byte stride is not divisible by 4.
  6334. * DEPRECATED. Use byteStride instead.
  6335. * @returns the stride in float32 units
  6336. */
  6337. getStrideSize(): number;
  6338. /**
  6339. * Returns the offset as a multiple of the type byte length.
  6340. * DEPRECATED. Use byteOffset instead.
  6341. * @returns the offset in bytes
  6342. */
  6343. getOffset(): number;
  6344. /**
  6345. * Returns the number of components per vertex attribute (integer)
  6346. * @returns the size in float
  6347. */
  6348. getSize(): number;
  6349. /**
  6350. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6351. * @returns true if this buffer is instanced
  6352. */
  6353. getIsInstanced(): boolean;
  6354. /**
  6355. * Returns the instancing divisor, zero for non-instanced (integer).
  6356. * @returns a number
  6357. */
  6358. getInstanceDivisor(): number;
  6359. /**
  6360. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6361. * @param data defines the data to store
  6362. */
  6363. create(data?: DataArray): void;
  6364. /**
  6365. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6366. * This function will create a new buffer if the current one is not updatable
  6367. * @param data defines the data to store
  6368. */
  6369. update(data: DataArray): void;
  6370. /**
  6371. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6372. * Returns the directly updated WebGLBuffer.
  6373. * @param data the new data
  6374. * @param offset the new offset
  6375. * @param useBytes set to true if the offset is in bytes
  6376. */
  6377. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6378. /**
  6379. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6380. */
  6381. dispose(): void;
  6382. /**
  6383. * Enumerates each value of this vertex buffer as numbers.
  6384. * @param count the number of values to enumerate
  6385. * @param callback the callback function called for each value
  6386. */
  6387. forEach(count: number, callback: (value: number, index: number) => void): void;
  6388. /**
  6389. * Positions
  6390. */
  6391. static readonly PositionKind: string;
  6392. /**
  6393. * Normals
  6394. */
  6395. static readonly NormalKind: string;
  6396. /**
  6397. * Tangents
  6398. */
  6399. static readonly TangentKind: string;
  6400. /**
  6401. * Texture coordinates
  6402. */
  6403. static readonly UVKind: string;
  6404. /**
  6405. * Texture coordinates 2
  6406. */
  6407. static readonly UV2Kind: string;
  6408. /**
  6409. * Texture coordinates 3
  6410. */
  6411. static readonly UV3Kind: string;
  6412. /**
  6413. * Texture coordinates 4
  6414. */
  6415. static readonly UV4Kind: string;
  6416. /**
  6417. * Texture coordinates 5
  6418. */
  6419. static readonly UV5Kind: string;
  6420. /**
  6421. * Texture coordinates 6
  6422. */
  6423. static readonly UV6Kind: string;
  6424. /**
  6425. * Colors
  6426. */
  6427. static readonly ColorKind: string;
  6428. /**
  6429. * Matrix indices (for bones)
  6430. */
  6431. static readonly MatricesIndicesKind: string;
  6432. /**
  6433. * Matrix weights (for bones)
  6434. */
  6435. static readonly MatricesWeightsKind: string;
  6436. /**
  6437. * Additional matrix indices (for bones)
  6438. */
  6439. static readonly MatricesIndicesExtraKind: string;
  6440. /**
  6441. * Additional matrix weights (for bones)
  6442. */
  6443. static readonly MatricesWeightsExtraKind: string;
  6444. /**
  6445. * Deduces the stride given a kind.
  6446. * @param kind The kind string to deduce
  6447. * @returns The deduced stride
  6448. */
  6449. static DeduceStride(kind: string): number;
  6450. /**
  6451. * Gets the byte length of the given type.
  6452. * @param type the type
  6453. * @returns the number of bytes
  6454. */
  6455. static GetTypeByteLength(type: number): number;
  6456. /**
  6457. * Enumerates each value of the given parameters as numbers.
  6458. * @param data the data to enumerate
  6459. * @param byteOffset the byte offset of the data
  6460. * @param byteStride the byte stride of the data
  6461. * @param componentCount the number of components per element
  6462. * @param componentType the type of the component
  6463. * @param count the number of values to enumerate
  6464. * @param normalized whether the data is normalized
  6465. * @param callback the callback function called for each value
  6466. */
  6467. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6468. private static _GetFloatValue;
  6469. }
  6470. }
  6471. declare module "babylonjs/Collisions/intersectionInfo" {
  6472. import { Nullable } from "babylonjs/types";
  6473. /**
  6474. * @hidden
  6475. */
  6476. export class IntersectionInfo {
  6477. bu: Nullable<number>;
  6478. bv: Nullable<number>;
  6479. distance: number;
  6480. faceId: number;
  6481. subMeshId: number;
  6482. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6483. }
  6484. }
  6485. declare module "babylonjs/Maths/math.plane" {
  6486. import { DeepImmutable } from "babylonjs/types";
  6487. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6488. /**
  6489. * Represens a plane by the equation ax + by + cz + d = 0
  6490. */
  6491. export class Plane {
  6492. private static _TmpMatrix;
  6493. /**
  6494. * Normal of the plane (a,b,c)
  6495. */
  6496. normal: Vector3;
  6497. /**
  6498. * d component of the plane
  6499. */
  6500. d: number;
  6501. /**
  6502. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6503. * @param a a component of the plane
  6504. * @param b b component of the plane
  6505. * @param c c component of the plane
  6506. * @param d d component of the plane
  6507. */
  6508. constructor(a: number, b: number, c: number, d: number);
  6509. /**
  6510. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6511. */
  6512. asArray(): number[];
  6513. /**
  6514. * @returns a new plane copied from the current Plane.
  6515. */
  6516. clone(): Plane;
  6517. /**
  6518. * @returns the string "Plane".
  6519. */
  6520. getClassName(): string;
  6521. /**
  6522. * @returns the Plane hash code.
  6523. */
  6524. getHashCode(): number;
  6525. /**
  6526. * Normalize the current Plane in place.
  6527. * @returns the updated Plane.
  6528. */
  6529. normalize(): Plane;
  6530. /**
  6531. * Applies a transformation the plane and returns the result
  6532. * @param transformation the transformation matrix to be applied to the plane
  6533. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6534. */
  6535. transform(transformation: DeepImmutable<Matrix>): Plane;
  6536. /**
  6537. * Calcualtte the dot product between the point and the plane normal
  6538. * @param point point to calculate the dot product with
  6539. * @returns the dot product (float) of the point coordinates and the plane normal.
  6540. */
  6541. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6542. /**
  6543. * Updates the current Plane from the plane defined by the three given points.
  6544. * @param point1 one of the points used to contruct the plane
  6545. * @param point2 one of the points used to contruct the plane
  6546. * @param point3 one of the points used to contruct the plane
  6547. * @returns the updated Plane.
  6548. */
  6549. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6550. /**
  6551. * Checks if the plane is facing a given direction
  6552. * @param direction the direction to check if the plane is facing
  6553. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6554. * @returns True is the vector "direction" is the same side than the plane normal.
  6555. */
  6556. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6557. /**
  6558. * Calculates the distance to a point
  6559. * @param point point to calculate distance to
  6560. * @returns the signed distance (float) from the given point to the Plane.
  6561. */
  6562. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6563. /**
  6564. * Creates a plane from an array
  6565. * @param array the array to create a plane from
  6566. * @returns a new Plane from the given array.
  6567. */
  6568. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6569. /**
  6570. * Creates a plane from three points
  6571. * @param point1 point used to create the plane
  6572. * @param point2 point used to create the plane
  6573. * @param point3 point used to create the plane
  6574. * @returns a new Plane defined by the three given points.
  6575. */
  6576. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6577. /**
  6578. * Creates a plane from an origin point and a normal
  6579. * @param origin origin of the plane to be constructed
  6580. * @param normal normal of the plane to be constructed
  6581. * @returns a new Plane the normal vector to this plane at the given origin point.
  6582. * Note : the vector "normal" is updated because normalized.
  6583. */
  6584. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6585. /**
  6586. * Calculates the distance from a plane and a point
  6587. * @param origin origin of the plane to be constructed
  6588. * @param normal normal of the plane to be constructed
  6589. * @param point point to calculate distance to
  6590. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6591. */
  6592. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6593. }
  6594. }
  6595. declare module "babylonjs/Culling/boundingSphere" {
  6596. import { DeepImmutable } from "babylonjs/types";
  6597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6598. import { Plane } from "babylonjs/Maths/math.plane";
  6599. /**
  6600. * Class used to store bounding sphere information
  6601. */
  6602. export class BoundingSphere {
  6603. /**
  6604. * Gets the center of the bounding sphere in local space
  6605. */
  6606. readonly center: Vector3;
  6607. /**
  6608. * Radius of the bounding sphere in local space
  6609. */
  6610. radius: number;
  6611. /**
  6612. * Gets the center of the bounding sphere in world space
  6613. */
  6614. readonly centerWorld: Vector3;
  6615. /**
  6616. * Radius of the bounding sphere in world space
  6617. */
  6618. radiusWorld: number;
  6619. /**
  6620. * Gets the minimum vector in local space
  6621. */
  6622. readonly minimum: Vector3;
  6623. /**
  6624. * Gets the maximum vector in local space
  6625. */
  6626. readonly maximum: Vector3;
  6627. private _worldMatrix;
  6628. private static readonly TmpVector3;
  6629. /**
  6630. * Creates a new bounding sphere
  6631. * @param min defines the minimum vector (in local space)
  6632. * @param max defines the maximum vector (in local space)
  6633. * @param worldMatrix defines the new world matrix
  6634. */
  6635. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6636. /**
  6637. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6638. * @param min defines the new minimum vector (in local space)
  6639. * @param max defines the new maximum vector (in local space)
  6640. * @param worldMatrix defines the new world matrix
  6641. */
  6642. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6643. /**
  6644. * Scale the current bounding sphere by applying a scale factor
  6645. * @param factor defines the scale factor to apply
  6646. * @returns the current bounding box
  6647. */
  6648. scale(factor: number): BoundingSphere;
  6649. /**
  6650. * Gets the world matrix of the bounding box
  6651. * @returns a matrix
  6652. */
  6653. getWorldMatrix(): DeepImmutable<Matrix>;
  6654. /** @hidden */
  6655. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6656. /**
  6657. * Tests if the bounding sphere is intersecting the frustum planes
  6658. * @param frustumPlanes defines the frustum planes to test
  6659. * @returns true if there is an intersection
  6660. */
  6661. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6662. /**
  6663. * Tests if the bounding sphere center is in between the frustum planes.
  6664. * Used for optimistic fast inclusion.
  6665. * @param frustumPlanes defines the frustum planes to test
  6666. * @returns true if the sphere center is in between the frustum planes
  6667. */
  6668. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6669. /**
  6670. * Tests if a point is inside the bounding sphere
  6671. * @param point defines the point to test
  6672. * @returns true if the point is inside the bounding sphere
  6673. */
  6674. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6675. /**
  6676. * Checks if two sphere intersct
  6677. * @param sphere0 sphere 0
  6678. * @param sphere1 sphere 1
  6679. * @returns true if the speres intersect
  6680. */
  6681. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6682. }
  6683. }
  6684. declare module "babylonjs/Culling/boundingBox" {
  6685. import { DeepImmutable } from "babylonjs/types";
  6686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6687. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6688. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding box information
  6692. */
  6693. export class BoundingBox implements ICullable {
  6694. /**
  6695. * Gets the 8 vectors representing the bounding box in local space
  6696. */
  6697. readonly vectors: Vector3[];
  6698. /**
  6699. * Gets the center of the bounding box in local space
  6700. */
  6701. readonly center: Vector3;
  6702. /**
  6703. * Gets the center of the bounding box in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Gets the extend size in local space
  6708. */
  6709. readonly extendSize: Vector3;
  6710. /**
  6711. * Gets the extend size in world space
  6712. */
  6713. readonly extendSizeWorld: Vector3;
  6714. /**
  6715. * Gets the OBB (object bounding box) directions
  6716. */
  6717. readonly directions: Vector3[];
  6718. /**
  6719. * Gets the 8 vectors representing the bounding box in world space
  6720. */
  6721. readonly vectorsWorld: Vector3[];
  6722. /**
  6723. * Gets the minimum vector in world space
  6724. */
  6725. readonly minimumWorld: Vector3;
  6726. /**
  6727. * Gets the maximum vector in world space
  6728. */
  6729. readonly maximumWorld: Vector3;
  6730. /**
  6731. * Gets the minimum vector in local space
  6732. */
  6733. readonly minimum: Vector3;
  6734. /**
  6735. * Gets the maximum vector in local space
  6736. */
  6737. readonly maximum: Vector3;
  6738. private _worldMatrix;
  6739. private static readonly TmpVector3;
  6740. /**
  6741. * @hidden
  6742. */
  6743. _tag: number;
  6744. /**
  6745. * Creates a new bounding box
  6746. * @param min defines the minimum vector (in local space)
  6747. * @param max defines the maximum vector (in local space)
  6748. * @param worldMatrix defines the new world matrix
  6749. */
  6750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6751. /**
  6752. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6753. * @param min defines the new minimum vector (in local space)
  6754. * @param max defines the new maximum vector (in local space)
  6755. * @param worldMatrix defines the new world matrix
  6756. */
  6757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6758. /**
  6759. * Scale the current bounding box by applying a scale factor
  6760. * @param factor defines the scale factor to apply
  6761. * @returns the current bounding box
  6762. */
  6763. scale(factor: number): BoundingBox;
  6764. /**
  6765. * Gets the world matrix of the bounding box
  6766. * @returns a matrix
  6767. */
  6768. getWorldMatrix(): DeepImmutable<Matrix>;
  6769. /** @hidden */
  6770. _update(world: DeepImmutable<Matrix>): void;
  6771. /**
  6772. * Tests if the bounding box is intersecting the frustum planes
  6773. * @param frustumPlanes defines the frustum planes to test
  6774. * @returns true if there is an intersection
  6775. */
  6776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6777. /**
  6778. * Tests if the bounding box is entirely inside the frustum planes
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if there is an inclusion
  6781. */
  6782. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding box
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding box
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Tests if the bounding box intersects with a bounding sphere
  6791. * @param sphere defines the sphere to test
  6792. * @returns true if there is an intersection
  6793. */
  6794. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6795. /**
  6796. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6797. * @param min defines the min vector to use
  6798. * @param max defines the max vector to use
  6799. * @returns true if there is an intersection
  6800. */
  6801. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6802. /**
  6803. * Tests if two bounding boxes are intersections
  6804. * @param box0 defines the first box to test
  6805. * @param box1 defines the second box to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6809. /**
  6810. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6811. * @param minPoint defines the minimum vector of the bounding box
  6812. * @param maxPoint defines the maximum vector of the bounding box
  6813. * @param sphereCenter defines the sphere center
  6814. * @param sphereRadius defines the sphere radius
  6815. * @returns true if there is an intersection
  6816. */
  6817. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6818. /**
  6819. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6820. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6821. * @param frustumPlanes defines the frustum planes to test
  6822. * @return true if there is an inclusion
  6823. */
  6824. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6825. /**
  6826. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6827. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6828. * @param frustumPlanes defines the frustum planes to test
  6829. * @return true if there is an intersection
  6830. */
  6831. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6832. }
  6833. }
  6834. declare module "babylonjs/Collisions/collider" {
  6835. import { Nullable, IndicesArray } from "babylonjs/types";
  6836. import { Vector3 } from "babylonjs/Maths/math.vector";
  6837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6838. import { Plane } from "babylonjs/Maths/math.plane";
  6839. /** @hidden */
  6840. export class Collider {
  6841. /** Define if a collision was found */
  6842. collisionFound: boolean;
  6843. /**
  6844. * Define last intersection point in local space
  6845. */
  6846. intersectionPoint: Vector3;
  6847. /**
  6848. * Define last collided mesh
  6849. */
  6850. collidedMesh: Nullable<AbstractMesh>;
  6851. private _collisionPoint;
  6852. private _planeIntersectionPoint;
  6853. private _tempVector;
  6854. private _tempVector2;
  6855. private _tempVector3;
  6856. private _tempVector4;
  6857. private _edge;
  6858. private _baseToVertex;
  6859. private _destinationPoint;
  6860. private _slidePlaneNormal;
  6861. private _displacementVector;
  6862. /** @hidden */
  6863. _radius: Vector3;
  6864. /** @hidden */
  6865. _retry: number;
  6866. private _velocity;
  6867. private _basePoint;
  6868. private _epsilon;
  6869. /** @hidden */
  6870. _velocityWorldLength: number;
  6871. /** @hidden */
  6872. _basePointWorld: Vector3;
  6873. private _velocityWorld;
  6874. private _normalizedVelocity;
  6875. /** @hidden */
  6876. _initialVelocity: Vector3;
  6877. /** @hidden */
  6878. _initialPosition: Vector3;
  6879. private _nearestDistance;
  6880. private _collisionMask;
  6881. collisionMask: number;
  6882. /**
  6883. * Gets the plane normal used to compute the sliding response (in local space)
  6884. */
  6885. readonly slidePlaneNormal: Vector3;
  6886. /** @hidden */
  6887. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6888. /** @hidden */
  6889. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6890. /** @hidden */
  6891. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6892. /** @hidden */
  6893. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6894. /** @hidden */
  6895. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6896. /** @hidden */
  6897. _getResponse(pos: Vector3, vel: Vector3): void;
  6898. }
  6899. }
  6900. declare module "babylonjs/Culling/boundingInfo" {
  6901. import { DeepImmutable } from "babylonjs/types";
  6902. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6903. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6904. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6905. import { Plane } from "babylonjs/Maths/math.plane";
  6906. import { Collider } from "babylonjs/Collisions/collider";
  6907. /**
  6908. * Interface for cullable objects
  6909. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6910. */
  6911. export interface ICullable {
  6912. /**
  6913. * Checks if the object or part of the object is in the frustum
  6914. * @param frustumPlanes Camera near/planes
  6915. * @returns true if the object is in frustum otherwise false
  6916. */
  6917. isInFrustum(frustumPlanes: Plane[]): boolean;
  6918. /**
  6919. * Checks if a cullable object (mesh...) is in the camera frustum
  6920. * Unlike isInFrustum this cheks the full bounding box
  6921. * @param frustumPlanes Camera near/planes
  6922. * @returns true if the object is in frustum otherwise false
  6923. */
  6924. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6925. }
  6926. /**
  6927. * Info for a bounding data of a mesh
  6928. */
  6929. export class BoundingInfo implements ICullable {
  6930. /**
  6931. * Bounding box for the mesh
  6932. */
  6933. readonly boundingBox: BoundingBox;
  6934. /**
  6935. * Bounding sphere for the mesh
  6936. */
  6937. readonly boundingSphere: BoundingSphere;
  6938. private _isLocked;
  6939. private static readonly TmpVector3;
  6940. /**
  6941. * Constructs bounding info
  6942. * @param minimum min vector of the bounding box/sphere
  6943. * @param maximum max vector of the bounding box/sphere
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * min vector of the bounding box/sphere
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * max vector of the bounding box/sphere
  6960. */
  6961. readonly maximum: Vector3;
  6962. /**
  6963. * If the info is locked and won't be updated to avoid perf overhead
  6964. */
  6965. isLocked: boolean;
  6966. /**
  6967. * Updates the bounding sphere and box
  6968. * @param world world matrix to be used to update
  6969. */
  6970. update(world: DeepImmutable<Matrix>): void;
  6971. /**
  6972. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6973. * @param center New center of the bounding info
  6974. * @param extend New extend of the bounding info
  6975. * @returns the current bounding info
  6976. */
  6977. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6978. /**
  6979. * Scale the current bounding info by applying a scale factor
  6980. * @param factor defines the scale factor to apply
  6981. * @returns the current bounding info
  6982. */
  6983. scale(factor: number): BoundingInfo;
  6984. /**
  6985. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6986. * @param frustumPlanes defines the frustum to test
  6987. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6988. * @returns true if the bounding info is in the frustum planes
  6989. */
  6990. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6991. /**
  6992. * Gets the world distance between the min and max points of the bounding box
  6993. */
  6994. readonly diagonalLength: number;
  6995. /**
  6996. * Checks if a cullable object (mesh...) is in the camera frustum
  6997. * Unlike isInFrustum this cheks the full bounding box
  6998. * @param frustumPlanes Camera near/planes
  6999. * @returns true if the object is in frustum otherwise false
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /** @hidden */
  7003. _checkCollision(collider: Collider): boolean;
  7004. /**
  7005. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7006. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7007. * @param point the point to check intersection with
  7008. * @returns if the point intersects
  7009. */
  7010. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7011. /**
  7012. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7013. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7014. * @param boundingInfo the bounding info to check intersection with
  7015. * @param precise if the intersection should be done using OBB
  7016. * @returns if the bounding info intersects
  7017. */
  7018. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7019. }
  7020. }
  7021. declare module "babylonjs/Maths/math.functions" {
  7022. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7023. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7024. /**
  7025. * Extracts minimum and maximum values from a list of indexed positions
  7026. * @param positions defines the positions to use
  7027. * @param indices defines the indices to the positions
  7028. * @param indexStart defines the start index
  7029. * @param indexCount defines the end index
  7030. * @param bias defines bias value to add to the result
  7031. * @return minimum and maximum values
  7032. */
  7033. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7034. minimum: Vector3;
  7035. maximum: Vector3;
  7036. };
  7037. /**
  7038. * Extracts minimum and maximum values from a list of positions
  7039. * @param positions defines the positions to use
  7040. * @param start defines the start index in the positions array
  7041. * @param count defines the number of positions to handle
  7042. * @param bias defines bias value to add to the result
  7043. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7044. * @return minimum and maximum values
  7045. */
  7046. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7047. minimum: Vector3;
  7048. maximum: Vector3;
  7049. };
  7050. }
  7051. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7052. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7053. /** @hidden */
  7054. export class WebGLDataBuffer extends DataBuffer {
  7055. private _buffer;
  7056. constructor(resource: WebGLBuffer);
  7057. readonly underlyingResource: any;
  7058. }
  7059. }
  7060. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7061. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7062. import { Nullable } from "babylonjs/types";
  7063. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7064. /** @hidden */
  7065. export class WebGLPipelineContext implements IPipelineContext {
  7066. engine: ThinEngine;
  7067. program: Nullable<WebGLProgram>;
  7068. context?: WebGLRenderingContext;
  7069. vertexShader?: WebGLShader;
  7070. fragmentShader?: WebGLShader;
  7071. isParallelCompiled: boolean;
  7072. onCompiled?: () => void;
  7073. transformFeedback?: WebGLTransformFeedback | null;
  7074. readonly isAsync: boolean;
  7075. readonly isReady: boolean;
  7076. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7077. }
  7078. }
  7079. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7080. import { FloatArray, Nullable } from "babylonjs/types";
  7081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7082. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7083. module "babylonjs/Engines/thinEngine" {
  7084. interface ThinEngine {
  7085. /**
  7086. * Create an uniform buffer
  7087. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7088. * @param elements defines the content of the uniform buffer
  7089. * @returns the webGL uniform buffer
  7090. */
  7091. createUniformBuffer(elements: FloatArray): DataBuffer;
  7092. /**
  7093. * Create a dynamic uniform buffer
  7094. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7095. * @param elements defines the content of the uniform buffer
  7096. * @returns the webGL uniform buffer
  7097. */
  7098. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7099. /**
  7100. * Update an existing uniform buffer
  7101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7102. * @param uniformBuffer defines the target uniform buffer
  7103. * @param elements defines the content to update
  7104. * @param offset defines the offset in the uniform buffer where update should start
  7105. * @param count defines the size of the data to update
  7106. */
  7107. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7108. /**
  7109. * Bind an uniform buffer to the current webGL context
  7110. * @param buffer defines the buffer to bind
  7111. */
  7112. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7113. /**
  7114. * Bind a buffer to the current webGL context at a given location
  7115. * @param buffer defines the buffer to bind
  7116. * @param location defines the index where to bind the buffer
  7117. */
  7118. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7119. /**
  7120. * Bind a specific block at a given index in a specific shader program
  7121. * @param pipelineContext defines the pipeline context to use
  7122. * @param blockName defines the block name
  7123. * @param index defines the index where to bind the block
  7124. */
  7125. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7126. }
  7127. }
  7128. }
  7129. declare module "babylonjs/Materials/uniformBuffer" {
  7130. import { Nullable, FloatArray } from "babylonjs/types";
  7131. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7132. import { Engine } from "babylonjs/Engines/engine";
  7133. import { Effect } from "babylonjs/Materials/effect";
  7134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7135. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7136. import { Color3 } from "babylonjs/Maths/math.color";
  7137. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7138. /**
  7139. * Uniform buffer objects.
  7140. *
  7141. * Handles blocks of uniform on the GPU.
  7142. *
  7143. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7144. *
  7145. * For more information, please refer to :
  7146. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7147. */
  7148. export class UniformBuffer {
  7149. private _engine;
  7150. private _buffer;
  7151. private _data;
  7152. private _bufferData;
  7153. private _dynamic?;
  7154. private _uniformLocations;
  7155. private _uniformSizes;
  7156. private _uniformLocationPointer;
  7157. private _needSync;
  7158. private _noUBO;
  7159. private _currentEffect;
  7160. /** @hidden */
  7161. _alreadyBound: boolean;
  7162. private static _MAX_UNIFORM_SIZE;
  7163. private static _tempBuffer;
  7164. /**
  7165. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7166. * This is dynamic to allow compat with webgl 1 and 2.
  7167. * You will need to pass the name of the uniform as well as the value.
  7168. */
  7169. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7170. /**
  7171. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7172. * This is dynamic to allow compat with webgl 1 and 2.
  7173. * You will need to pass the name of the uniform as well as the value.
  7174. */
  7175. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7176. /**
  7177. * Lambda to Update a single float in a uniform buffer.
  7178. * This is dynamic to allow compat with webgl 1 and 2.
  7179. * You will need to pass the name of the uniform as well as the value.
  7180. */
  7181. updateFloat: (name: string, x: number) => void;
  7182. /**
  7183. * Lambda to Update a vec2 of float in a uniform buffer.
  7184. * This is dynamic to allow compat with webgl 1 and 2.
  7185. * You will need to pass the name of the uniform as well as the value.
  7186. */
  7187. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7188. /**
  7189. * Lambda to Update a vec3 of float in a uniform buffer.
  7190. * This is dynamic to allow compat with webgl 1 and 2.
  7191. * You will need to pass the name of the uniform as well as the value.
  7192. */
  7193. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7194. /**
  7195. * Lambda to Update a vec4 of float in a uniform buffer.
  7196. * This is dynamic to allow compat with webgl 1 and 2.
  7197. * You will need to pass the name of the uniform as well as the value.
  7198. */
  7199. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7200. /**
  7201. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateMatrix: (name: string, mat: Matrix) => void;
  7206. /**
  7207. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateVector3: (name: string, vector: Vector3) => void;
  7212. /**
  7213. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateVector4: (name: string, vector: Vector4) => void;
  7218. /**
  7219. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7220. * This is dynamic to allow compat with webgl 1 and 2.
  7221. * You will need to pass the name of the uniform as well as the value.
  7222. */
  7223. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7224. /**
  7225. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7226. * This is dynamic to allow compat with webgl 1 and 2.
  7227. * You will need to pass the name of the uniform as well as the value.
  7228. */
  7229. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7230. /**
  7231. * Instantiates a new Uniform buffer objects.
  7232. *
  7233. * Handles blocks of uniform on the GPU.
  7234. *
  7235. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7236. *
  7237. * For more information, please refer to :
  7238. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7239. * @param engine Define the engine the buffer is associated with
  7240. * @param data Define the data contained in the buffer
  7241. * @param dynamic Define if the buffer is updatable
  7242. */
  7243. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7244. /**
  7245. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7246. * or just falling back on setUniformXXX calls.
  7247. */
  7248. readonly useUbo: boolean;
  7249. /**
  7250. * Indicates if the WebGL underlying uniform buffer is in sync
  7251. * with the javascript cache data.
  7252. */
  7253. readonly isSync: boolean;
  7254. /**
  7255. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7256. * Also, a dynamic UniformBuffer will disable cache verification and always
  7257. * update the underlying WebGL uniform buffer to the GPU.
  7258. * @returns if Dynamic, otherwise false
  7259. */
  7260. isDynamic(): boolean;
  7261. /**
  7262. * The data cache on JS side.
  7263. * @returns the underlying data as a float array
  7264. */
  7265. getData(): Float32Array;
  7266. /**
  7267. * The underlying WebGL Uniform buffer.
  7268. * @returns the webgl buffer
  7269. */
  7270. getBuffer(): Nullable<DataBuffer>;
  7271. /**
  7272. * std140 layout specifies how to align data within an UBO structure.
  7273. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7274. * for specs.
  7275. */
  7276. private _fillAlignment;
  7277. /**
  7278. * Adds an uniform in the buffer.
  7279. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7280. * for the layout to be correct !
  7281. * @param name Name of the uniform, as used in the uniform block in the shader.
  7282. * @param size Data size, or data directly.
  7283. */
  7284. addUniform(name: string, size: number | number[]): void;
  7285. /**
  7286. * Adds a Matrix 4x4 to the uniform buffer.
  7287. * @param name Name of the uniform, as used in the uniform block in the shader.
  7288. * @param mat A 4x4 matrix.
  7289. */
  7290. addMatrix(name: string, mat: Matrix): void;
  7291. /**
  7292. * Adds a vec2 to the uniform buffer.
  7293. * @param name Name of the uniform, as used in the uniform block in the shader.
  7294. * @param x Define the x component value of the vec2
  7295. * @param y Define the y component value of the vec2
  7296. */
  7297. addFloat2(name: string, x: number, y: number): void;
  7298. /**
  7299. * Adds a vec3 to the uniform buffer.
  7300. * @param name Name of the uniform, as used in the uniform block in the shader.
  7301. * @param x Define the x component value of the vec3
  7302. * @param y Define the y component value of the vec3
  7303. * @param z Define the z component value of the vec3
  7304. */
  7305. addFloat3(name: string, x: number, y: number, z: number): void;
  7306. /**
  7307. * Adds a vec3 to the uniform buffer.
  7308. * @param name Name of the uniform, as used in the uniform block in the shader.
  7309. * @param color Define the vec3 from a Color
  7310. */
  7311. addColor3(name: string, color: Color3): void;
  7312. /**
  7313. * Adds a vec4 to the uniform buffer.
  7314. * @param name Name of the uniform, as used in the uniform block in the shader.
  7315. * @param color Define the rgb components from a Color
  7316. * @param alpha Define the a component of the vec4
  7317. */
  7318. addColor4(name: string, color: Color3, alpha: number): void;
  7319. /**
  7320. * Adds a vec3 to the uniform buffer.
  7321. * @param name Name of the uniform, as used in the uniform block in the shader.
  7322. * @param vector Define the vec3 components from a Vector
  7323. */
  7324. addVector3(name: string, vector: Vector3): void;
  7325. /**
  7326. * Adds a Matrix 3x3 to the uniform buffer.
  7327. * @param name Name of the uniform, as used in the uniform block in the shader.
  7328. */
  7329. addMatrix3x3(name: string): void;
  7330. /**
  7331. * Adds a Matrix 2x2 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. */
  7334. addMatrix2x2(name: string): void;
  7335. /**
  7336. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7337. */
  7338. create(): void;
  7339. /** @hidden */
  7340. _rebuild(): void;
  7341. /**
  7342. * Updates the WebGL Uniform Buffer on the GPU.
  7343. * If the `dynamic` flag is set to true, no cache comparison is done.
  7344. * Otherwise, the buffer will be updated only if the cache differs.
  7345. */
  7346. update(): void;
  7347. /**
  7348. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7349. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7350. * @param data Define the flattened data
  7351. * @param size Define the size of the data.
  7352. */
  7353. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7354. private _valueCache;
  7355. private _cacheMatrix;
  7356. private _updateMatrix3x3ForUniform;
  7357. private _updateMatrix3x3ForEffect;
  7358. private _updateMatrix2x2ForEffect;
  7359. private _updateMatrix2x2ForUniform;
  7360. private _updateFloatForEffect;
  7361. private _updateFloatForUniform;
  7362. private _updateFloat2ForEffect;
  7363. private _updateFloat2ForUniform;
  7364. private _updateFloat3ForEffect;
  7365. private _updateFloat3ForUniform;
  7366. private _updateFloat4ForEffect;
  7367. private _updateFloat4ForUniform;
  7368. private _updateMatrixForEffect;
  7369. private _updateMatrixForUniform;
  7370. private _updateVector3ForEffect;
  7371. private _updateVector3ForUniform;
  7372. private _updateVector4ForEffect;
  7373. private _updateVector4ForUniform;
  7374. private _updateColor3ForEffect;
  7375. private _updateColor3ForUniform;
  7376. private _updateColor4ForEffect;
  7377. private _updateColor4ForUniform;
  7378. /**
  7379. * Sets a sampler uniform on the effect.
  7380. * @param name Define the name of the sampler.
  7381. * @param texture Define the texture to set in the sampler
  7382. */
  7383. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7384. /**
  7385. * Directly updates the value of the uniform in the cache AND on the GPU.
  7386. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7387. * @param data Define the flattened data
  7388. */
  7389. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7390. /**
  7391. * Binds this uniform buffer to an effect.
  7392. * @param effect Define the effect to bind the buffer to
  7393. * @param name Name of the uniform block in the shader.
  7394. */
  7395. bindToEffect(effect: Effect, name: string): void;
  7396. /**
  7397. * Disposes the uniform buffer.
  7398. */
  7399. dispose(): void;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/iInspectable" {
  7403. /**
  7404. * Enum that determines the text-wrapping mode to use.
  7405. */
  7406. export enum InspectableType {
  7407. /**
  7408. * Checkbox for booleans
  7409. */
  7410. Checkbox = 0,
  7411. /**
  7412. * Sliders for numbers
  7413. */
  7414. Slider = 1,
  7415. /**
  7416. * Vector3
  7417. */
  7418. Vector3 = 2,
  7419. /**
  7420. * Quaternions
  7421. */
  7422. Quaternion = 3,
  7423. /**
  7424. * Color3
  7425. */
  7426. Color3 = 4,
  7427. /**
  7428. * String
  7429. */
  7430. String = 5
  7431. }
  7432. /**
  7433. * Interface used to define custom inspectable properties.
  7434. * This interface is used by the inspector to display custom property grids
  7435. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7436. */
  7437. export interface IInspectable {
  7438. /**
  7439. * Gets the label to display
  7440. */
  7441. label: string;
  7442. /**
  7443. * Gets the name of the property to edit
  7444. */
  7445. propertyName: string;
  7446. /**
  7447. * Gets the type of the editor to use
  7448. */
  7449. type: InspectableType;
  7450. /**
  7451. * Gets the minimum value of the property when using in "slider" mode
  7452. */
  7453. min?: number;
  7454. /**
  7455. * Gets the maximum value of the property when using in "slider" mode
  7456. */
  7457. max?: number;
  7458. /**
  7459. * Gets the setp to use when using in "slider" mode
  7460. */
  7461. step?: number;
  7462. }
  7463. }
  7464. declare module "babylonjs/Misc/timingTools" {
  7465. /**
  7466. * Class used to provide helper for timing
  7467. */
  7468. export class TimingTools {
  7469. /**
  7470. * Polyfill for setImmediate
  7471. * @param action defines the action to execute after the current execution block
  7472. */
  7473. static SetImmediate(action: () => void): void;
  7474. }
  7475. }
  7476. declare module "babylonjs/Misc/instantiationTools" {
  7477. /**
  7478. * Class used to enable instatition of objects by class name
  7479. */
  7480. export class InstantiationTools {
  7481. /**
  7482. * Use this object to register external classes like custom textures or material
  7483. * to allow the laoders to instantiate them
  7484. */
  7485. static RegisteredExternalClasses: {
  7486. [key: string]: Object;
  7487. };
  7488. /**
  7489. * Tries to instantiate a new object from a given class name
  7490. * @param className defines the class name to instantiate
  7491. * @returns the new object or null if the system was not able to do the instantiation
  7492. */
  7493. static Instantiate(className: string): any;
  7494. }
  7495. }
  7496. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7497. /**
  7498. * Define options used to create a depth texture
  7499. */
  7500. export class DepthTextureCreationOptions {
  7501. /** Specifies whether or not a stencil should be allocated in the texture */
  7502. generateStencil?: boolean;
  7503. /** Specifies whether or not bilinear filtering is enable on the texture */
  7504. bilinearFiltering?: boolean;
  7505. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7506. comparisonFunction?: number;
  7507. /** Specifies if the created texture is a cube texture */
  7508. isCube?: boolean;
  7509. }
  7510. }
  7511. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7513. import { Nullable } from "babylonjs/types";
  7514. import { Scene } from "babylonjs/scene";
  7515. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7516. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7517. module "babylonjs/Engines/thinEngine" {
  7518. interface ThinEngine {
  7519. /**
  7520. * Creates a depth stencil cube texture.
  7521. * This is only available in WebGL 2.
  7522. * @param size The size of face edge in the cube texture.
  7523. * @param options The options defining the cube texture.
  7524. * @returns The cube texture
  7525. */
  7526. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7527. /**
  7528. * Creates a cube texture
  7529. * @param rootUrl defines the url where the files to load is located
  7530. * @param scene defines the current scene
  7531. * @param files defines the list of files to load (1 per face)
  7532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7533. * @param onLoad defines an optional callback raised when the texture is loaded
  7534. * @param onError defines an optional callback raised if there is an issue to load the texture
  7535. * @param format defines the format of the data
  7536. * @param forcedExtension defines the extension to use to pick the right loader
  7537. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7538. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7539. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7540. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7541. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7542. * @returns the cube texture as an InternalTexture
  7543. */
  7544. 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;
  7545. /**
  7546. * Creates a cube texture
  7547. * @param rootUrl defines the url where the files to load is located
  7548. * @param scene defines the current scene
  7549. * @param files defines the list of files to load (1 per face)
  7550. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7551. * @param onLoad defines an optional callback raised when the texture is loaded
  7552. * @param onError defines an optional callback raised if there is an issue to load the texture
  7553. * @param format defines the format of the data
  7554. * @param forcedExtension defines the extension to use to pick the right loader
  7555. * @returns the cube texture as an InternalTexture
  7556. */
  7557. 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;
  7558. /**
  7559. * Creates a cube texture
  7560. * @param rootUrl defines the url where the files to load is located
  7561. * @param scene defines the current scene
  7562. * @param files defines the list of files to load (1 per face)
  7563. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7564. * @param onLoad defines an optional callback raised when the texture is loaded
  7565. * @param onError defines an optional callback raised if there is an issue to load the texture
  7566. * @param format defines the format of the data
  7567. * @param forcedExtension defines the extension to use to pick the right loader
  7568. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7571. * @returns the cube texture as an InternalTexture
  7572. */
  7573. 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;
  7574. /** @hidden */
  7575. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7576. /** @hidden */
  7577. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7578. /** @hidden */
  7579. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7580. /** @hidden */
  7581. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7582. /**
  7583. * @hidden
  7584. */
  7585. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7586. }
  7587. }
  7588. }
  7589. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7590. import { Nullable } from "babylonjs/types";
  7591. import { Scene } from "babylonjs/scene";
  7592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7594. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7595. /**
  7596. * Class for creating a cube texture
  7597. */
  7598. export class CubeTexture extends BaseTexture {
  7599. private _delayedOnLoad;
  7600. /**
  7601. * The url of the texture
  7602. */
  7603. url: string;
  7604. /**
  7605. * Gets or sets the center of the bounding box associated with the cube texture.
  7606. * It must define where the camera used to render the texture was set
  7607. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7608. */
  7609. boundingBoxPosition: Vector3;
  7610. private _boundingBoxSize;
  7611. /**
  7612. * Gets or sets the size of the bounding box associated with the cube texture
  7613. * When defined, the cubemap will switch to local mode
  7614. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7615. * @example https://www.babylonjs-playground.com/#RNASML
  7616. */
  7617. /**
  7618. * Returns the bounding box size
  7619. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7620. */
  7621. boundingBoxSize: Vector3;
  7622. protected _rotationY: number;
  7623. /**
  7624. * Sets texture matrix rotation angle around Y axis in radians.
  7625. */
  7626. /**
  7627. * Gets texture matrix rotation angle around Y axis radians.
  7628. */
  7629. rotationY: number;
  7630. /**
  7631. * Are mip maps generated for this texture or not.
  7632. */
  7633. readonly noMipmap: boolean;
  7634. private _noMipmap;
  7635. private _files;
  7636. protected _forcedExtension: Nullable<string>;
  7637. private _extensions;
  7638. private _textureMatrix;
  7639. private _format;
  7640. private _createPolynomials;
  7641. /** @hidden */
  7642. _prefiltered: boolean;
  7643. /**
  7644. * Creates a cube texture from an array of image urls
  7645. * @param files defines an array of image urls
  7646. * @param scene defines the hosting scene
  7647. * @param noMipmap specifies if mip maps are not used
  7648. * @returns a cube texture
  7649. */
  7650. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7651. /**
  7652. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7653. * @param url defines the url of the prefiltered texture
  7654. * @param scene defines the scene the texture is attached to
  7655. * @param forcedExtension defines the extension of the file if different from the url
  7656. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7657. * @return the prefiltered texture
  7658. */
  7659. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7660. /**
  7661. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7662. * as prefiltered data.
  7663. * @param rootUrl defines the url of the texture or the root name of the six images
  7664. * @param scene defines the scene the texture is attached to
  7665. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7666. * @param noMipmap defines if mipmaps should be created or not
  7667. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7668. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7669. * @param onError defines a callback triggered in case of error during load
  7670. * @param format defines the internal format to use for the texture once loaded
  7671. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7672. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7673. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7674. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7675. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7676. * @return the cube texture
  7677. */
  7678. 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);
  7679. /**
  7680. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7681. */
  7682. readonly isPrefiltered: boolean;
  7683. /**
  7684. * Get the current class name of the texture useful for serialization or dynamic coding.
  7685. * @returns "CubeTexture"
  7686. */
  7687. getClassName(): string;
  7688. /**
  7689. * Update the url (and optional buffer) of this texture if url was null during construction.
  7690. * @param url the url of the texture
  7691. * @param forcedExtension defines the extension to use
  7692. * @param onLoad callback called when the texture is loaded (defaults to null)
  7693. */
  7694. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7695. /**
  7696. * Delays loading of the cube texture
  7697. * @param forcedExtension defines the extension to use
  7698. */
  7699. delayLoad(forcedExtension?: string): void;
  7700. /**
  7701. * Returns the reflection texture matrix
  7702. * @returns the reflection texture matrix
  7703. */
  7704. getReflectionTextureMatrix(): Matrix;
  7705. /**
  7706. * Sets the reflection texture matrix
  7707. * @param value Reflection texture matrix
  7708. */
  7709. setReflectionTextureMatrix(value: Matrix): void;
  7710. /**
  7711. * Parses text to create a cube texture
  7712. * @param parsedTexture define the serialized text to read from
  7713. * @param scene defines the hosting scene
  7714. * @param rootUrl defines the root url of the cube texture
  7715. * @returns a cube texture
  7716. */
  7717. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7718. /**
  7719. * Makes a clone, or deep copy, of the cube texture
  7720. * @returns a new cube texture
  7721. */
  7722. clone(): CubeTexture;
  7723. }
  7724. }
  7725. declare module "babylonjs/Materials/materialDefines" {
  7726. /**
  7727. * Manages the defines for the Material
  7728. */
  7729. export class MaterialDefines {
  7730. /** @hidden */
  7731. protected _keys: string[];
  7732. private _isDirty;
  7733. /** @hidden */
  7734. _renderId: number;
  7735. /** @hidden */
  7736. _areLightsDirty: boolean;
  7737. /** @hidden */
  7738. _areLightsDisposed: boolean;
  7739. /** @hidden */
  7740. _areAttributesDirty: boolean;
  7741. /** @hidden */
  7742. _areTexturesDirty: boolean;
  7743. /** @hidden */
  7744. _areFresnelDirty: boolean;
  7745. /** @hidden */
  7746. _areMiscDirty: boolean;
  7747. /** @hidden */
  7748. _areImageProcessingDirty: boolean;
  7749. /** @hidden */
  7750. _normals: boolean;
  7751. /** @hidden */
  7752. _uvs: boolean;
  7753. /** @hidden */
  7754. _needNormals: boolean;
  7755. /** @hidden */
  7756. _needUVs: boolean;
  7757. [id: string]: any;
  7758. /**
  7759. * Specifies if the material needs to be re-calculated
  7760. */
  7761. readonly isDirty: boolean;
  7762. /**
  7763. * Marks the material to indicate that it has been re-calculated
  7764. */
  7765. markAsProcessed(): void;
  7766. /**
  7767. * Marks the material to indicate that it needs to be re-calculated
  7768. */
  7769. markAsUnprocessed(): void;
  7770. /**
  7771. * Marks the material to indicate all of its defines need to be re-calculated
  7772. */
  7773. markAllAsDirty(): void;
  7774. /**
  7775. * Marks the material to indicate that image processing needs to be re-calculated
  7776. */
  7777. markAsImageProcessingDirty(): void;
  7778. /**
  7779. * Marks the material to indicate the lights need to be re-calculated
  7780. * @param disposed Defines whether the light is dirty due to dispose or not
  7781. */
  7782. markAsLightDirty(disposed?: boolean): void;
  7783. /**
  7784. * Marks the attribute state as changed
  7785. */
  7786. markAsAttributesDirty(): void;
  7787. /**
  7788. * Marks the texture state as changed
  7789. */
  7790. markAsTexturesDirty(): void;
  7791. /**
  7792. * Marks the fresnel state as changed
  7793. */
  7794. markAsFresnelDirty(): void;
  7795. /**
  7796. * Marks the misc state as changed
  7797. */
  7798. markAsMiscDirty(): void;
  7799. /**
  7800. * Rebuilds the material defines
  7801. */
  7802. rebuild(): void;
  7803. /**
  7804. * Specifies if two material defines are equal
  7805. * @param other - A material define instance to compare to
  7806. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7807. */
  7808. isEqual(other: MaterialDefines): boolean;
  7809. /**
  7810. * Clones this instance's defines to another instance
  7811. * @param other - material defines to clone values to
  7812. */
  7813. cloneTo(other: MaterialDefines): void;
  7814. /**
  7815. * Resets the material define values
  7816. */
  7817. reset(): void;
  7818. /**
  7819. * Converts the material define values to a string
  7820. * @returns - String of material define information
  7821. */
  7822. toString(): string;
  7823. }
  7824. }
  7825. declare module "babylonjs/Materials/colorCurves" {
  7826. import { Effect } from "babylonjs/Materials/effect";
  7827. /**
  7828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7830. * 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;
  7831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7832. */
  7833. export class ColorCurves {
  7834. private _dirty;
  7835. private _tempColor;
  7836. private _globalCurve;
  7837. private _highlightsCurve;
  7838. private _midtonesCurve;
  7839. private _shadowsCurve;
  7840. private _positiveCurve;
  7841. private _negativeCurve;
  7842. private _globalHue;
  7843. private _globalDensity;
  7844. private _globalSaturation;
  7845. private _globalExposure;
  7846. /**
  7847. * Gets the global Hue value.
  7848. * 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).
  7849. */
  7850. /**
  7851. * Sets the global Hue value.
  7852. * 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).
  7853. */
  7854. globalHue: number;
  7855. /**
  7856. * Gets the global Density value.
  7857. * 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.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the global Density value.
  7862. * 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.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. globalDensity: number;
  7866. /**
  7867. * Gets the global Saturation value.
  7868. * 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.
  7869. */
  7870. /**
  7871. * Sets the global Saturation value.
  7872. * 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.
  7873. */
  7874. globalSaturation: number;
  7875. /**
  7876. * Gets the global Exposure value.
  7877. * 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.
  7878. */
  7879. /**
  7880. * Sets the global Exposure value.
  7881. * 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.
  7882. */
  7883. globalExposure: number;
  7884. private _highlightsHue;
  7885. private _highlightsDensity;
  7886. private _highlightsSaturation;
  7887. private _highlightsExposure;
  7888. /**
  7889. * Gets the highlights Hue value.
  7890. * 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).
  7891. */
  7892. /**
  7893. * Sets the highlights Hue value.
  7894. * 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).
  7895. */
  7896. highlightsHue: number;
  7897. /**
  7898. * Gets the highlights Density value.
  7899. * 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.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. /**
  7903. * Sets the highlights Density value.
  7904. * 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.
  7905. * Values less than zero provide a filter of opposite hue.
  7906. */
  7907. highlightsDensity: number;
  7908. /**
  7909. * Gets the highlights Saturation value.
  7910. * 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.
  7911. */
  7912. /**
  7913. * Sets the highlights Saturation value.
  7914. * 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.
  7915. */
  7916. highlightsSaturation: number;
  7917. /**
  7918. * Gets the highlights Exposure value.
  7919. * 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.
  7920. */
  7921. /**
  7922. * Sets the highlights Exposure value.
  7923. * 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.
  7924. */
  7925. highlightsExposure: number;
  7926. private _midtonesHue;
  7927. private _midtonesDensity;
  7928. private _midtonesSaturation;
  7929. private _midtonesExposure;
  7930. /**
  7931. * Gets the midtones Hue value.
  7932. * 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).
  7933. */
  7934. /**
  7935. * Sets the midtones Hue value.
  7936. * 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).
  7937. */
  7938. midtonesHue: number;
  7939. /**
  7940. * Gets the midtones Density value.
  7941. * 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.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. /**
  7945. * Sets the midtones Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. midtonesDensity: number;
  7950. /**
  7951. * Gets the midtones Saturation value.
  7952. * 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.
  7953. */
  7954. /**
  7955. * Sets the midtones Saturation value.
  7956. * 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.
  7957. */
  7958. midtonesSaturation: number;
  7959. /**
  7960. * Gets the midtones Exposure value.
  7961. * 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.
  7962. */
  7963. /**
  7964. * Sets the midtones Exposure value.
  7965. * 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.
  7966. */
  7967. midtonesExposure: number;
  7968. private _shadowsHue;
  7969. private _shadowsDensity;
  7970. private _shadowsSaturation;
  7971. private _shadowsExposure;
  7972. /**
  7973. * Gets the shadows Hue value.
  7974. * 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).
  7975. */
  7976. /**
  7977. * Sets the shadows Hue value.
  7978. * 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).
  7979. */
  7980. shadowsHue: number;
  7981. /**
  7982. * Gets the shadows Density value.
  7983. * 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.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. /**
  7987. * Sets the shadows Density value.
  7988. * 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.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. shadowsDensity: number;
  7992. /**
  7993. * Gets the shadows Saturation value.
  7994. * 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.
  7995. */
  7996. /**
  7997. * Sets the shadows Saturation value.
  7998. * 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.
  7999. */
  8000. shadowsSaturation: number;
  8001. /**
  8002. * Gets the shadows Exposure value.
  8003. * 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.
  8004. */
  8005. /**
  8006. * Sets the shadows Exposure value.
  8007. * 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.
  8008. */
  8009. shadowsExposure: number;
  8010. /**
  8011. * Returns the class name
  8012. * @returns The class name
  8013. */
  8014. getClassName(): string;
  8015. /**
  8016. * Binds the color curves to the shader.
  8017. * @param colorCurves The color curve to bind
  8018. * @param effect The effect to bind to
  8019. * @param positiveUniform The positive uniform shader parameter
  8020. * @param neutralUniform The neutral uniform shader parameter
  8021. * @param negativeUniform The negative uniform shader parameter
  8022. */
  8023. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8024. /**
  8025. * Prepare the list of uniforms associated with the ColorCurves effects.
  8026. * @param uniformsList The list of uniforms used in the effect
  8027. */
  8028. static PrepareUniforms(uniformsList: string[]): void;
  8029. /**
  8030. * Returns color grading data based on a hue, density, saturation and exposure value.
  8031. * @param filterHue The hue of the color filter.
  8032. * @param filterDensity The density of the color filter.
  8033. * @param saturation The saturation.
  8034. * @param exposure The exposure.
  8035. * @param result The result data container.
  8036. */
  8037. private getColorGradingDataToRef;
  8038. /**
  8039. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8040. * @param value The input slider value in range [-100,100].
  8041. * @returns Adjusted value.
  8042. */
  8043. private static applyColorGradingSliderNonlinear;
  8044. /**
  8045. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8046. * @param hue The hue (H) input.
  8047. * @param saturation The saturation (S) input.
  8048. * @param brightness The brightness (B) input.
  8049. * @result An RGBA color represented as Vector4.
  8050. */
  8051. private static fromHSBToRef;
  8052. /**
  8053. * Returns a value clamped between min and max
  8054. * @param value The value to clamp
  8055. * @param min The minimum of value
  8056. * @param max The maximum of value
  8057. * @returns The clamped value.
  8058. */
  8059. private static clamp;
  8060. /**
  8061. * Clones the current color curve instance.
  8062. * @return The cloned curves
  8063. */
  8064. clone(): ColorCurves;
  8065. /**
  8066. * Serializes the current color curve instance to a json representation.
  8067. * @return a JSON representation
  8068. */
  8069. serialize(): any;
  8070. /**
  8071. * Parses the color curve from a json representation.
  8072. * @param source the JSON source to parse
  8073. * @return The parsed curves
  8074. */
  8075. static Parse(source: any): ColorCurves;
  8076. }
  8077. }
  8078. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8079. import { Observable } from "babylonjs/Misc/observable";
  8080. import { Nullable } from "babylonjs/types";
  8081. import { Color4 } from "babylonjs/Maths/math.color";
  8082. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8083. import { Effect } from "babylonjs/Materials/effect";
  8084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8085. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8086. /**
  8087. * Interface to follow in your material defines to integrate easily the
  8088. * Image proccessing functions.
  8089. * @hidden
  8090. */
  8091. export interface IImageProcessingConfigurationDefines {
  8092. IMAGEPROCESSING: boolean;
  8093. VIGNETTE: boolean;
  8094. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8095. VIGNETTEBLENDMODEOPAQUE: boolean;
  8096. TONEMAPPING: boolean;
  8097. TONEMAPPING_ACES: boolean;
  8098. CONTRAST: boolean;
  8099. EXPOSURE: boolean;
  8100. COLORCURVES: boolean;
  8101. COLORGRADING: boolean;
  8102. COLORGRADING3D: boolean;
  8103. SAMPLER3DGREENDEPTH: boolean;
  8104. SAMPLER3DBGRMAP: boolean;
  8105. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8106. }
  8107. /**
  8108. * @hidden
  8109. */
  8110. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8111. IMAGEPROCESSING: boolean;
  8112. VIGNETTE: boolean;
  8113. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8114. VIGNETTEBLENDMODEOPAQUE: boolean;
  8115. TONEMAPPING: boolean;
  8116. TONEMAPPING_ACES: boolean;
  8117. CONTRAST: boolean;
  8118. COLORCURVES: boolean;
  8119. COLORGRADING: boolean;
  8120. COLORGRADING3D: boolean;
  8121. SAMPLER3DGREENDEPTH: boolean;
  8122. SAMPLER3DBGRMAP: boolean;
  8123. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8124. EXPOSURE: boolean;
  8125. constructor();
  8126. }
  8127. /**
  8128. * This groups together the common properties used for image processing either in direct forward pass
  8129. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8130. * or not.
  8131. */
  8132. export class ImageProcessingConfiguration {
  8133. /**
  8134. * Default tone mapping applied in BabylonJS.
  8135. */
  8136. static readonly TONEMAPPING_STANDARD: number;
  8137. /**
  8138. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8139. * to other engines rendering to increase portability.
  8140. */
  8141. static readonly TONEMAPPING_ACES: number;
  8142. /**
  8143. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8144. */
  8145. colorCurves: Nullable<ColorCurves>;
  8146. private _colorCurvesEnabled;
  8147. /**
  8148. * Gets wether the color curves effect is enabled.
  8149. */
  8150. /**
  8151. * Sets wether the color curves effect is enabled.
  8152. */
  8153. colorCurvesEnabled: boolean;
  8154. private _colorGradingTexture;
  8155. /**
  8156. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8157. */
  8158. /**
  8159. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8160. */
  8161. colorGradingTexture: Nullable<BaseTexture>;
  8162. private _colorGradingEnabled;
  8163. /**
  8164. * Gets wether the color grading effect is enabled.
  8165. */
  8166. /**
  8167. * Sets wether the color grading effect is enabled.
  8168. */
  8169. colorGradingEnabled: boolean;
  8170. private _colorGradingWithGreenDepth;
  8171. /**
  8172. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8173. */
  8174. /**
  8175. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8176. */
  8177. colorGradingWithGreenDepth: boolean;
  8178. private _colorGradingBGR;
  8179. /**
  8180. * Gets wether the color grading texture contains BGR values.
  8181. */
  8182. /**
  8183. * Sets wether the color grading texture contains BGR values.
  8184. */
  8185. colorGradingBGR: boolean;
  8186. /** @hidden */
  8187. _exposure: number;
  8188. /**
  8189. * Gets the Exposure used in the effect.
  8190. */
  8191. /**
  8192. * Sets the Exposure used in the effect.
  8193. */
  8194. exposure: number;
  8195. private _toneMappingEnabled;
  8196. /**
  8197. * Gets wether the tone mapping effect is enabled.
  8198. */
  8199. /**
  8200. * Sets wether the tone mapping effect is enabled.
  8201. */
  8202. toneMappingEnabled: boolean;
  8203. private _toneMappingType;
  8204. /**
  8205. * Gets the type of tone mapping effect.
  8206. */
  8207. /**
  8208. * Sets the type of tone mapping effect used in BabylonJS.
  8209. */
  8210. toneMappingType: number;
  8211. protected _contrast: number;
  8212. /**
  8213. * Gets the contrast used in the effect.
  8214. */
  8215. /**
  8216. * Sets the contrast used in the effect.
  8217. */
  8218. contrast: number;
  8219. /**
  8220. * Vignette stretch size.
  8221. */
  8222. vignetteStretch: number;
  8223. /**
  8224. * Vignette centre X Offset.
  8225. */
  8226. vignetteCentreX: number;
  8227. /**
  8228. * Vignette centre Y Offset.
  8229. */
  8230. vignetteCentreY: number;
  8231. /**
  8232. * Vignette weight or intensity of the vignette effect.
  8233. */
  8234. vignetteWeight: number;
  8235. /**
  8236. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8237. * if vignetteEnabled is set to true.
  8238. */
  8239. vignetteColor: Color4;
  8240. /**
  8241. * Camera field of view used by the Vignette effect.
  8242. */
  8243. vignetteCameraFov: number;
  8244. private _vignetteBlendMode;
  8245. /**
  8246. * Gets the vignette blend mode allowing different kind of effect.
  8247. */
  8248. /**
  8249. * Sets the vignette blend mode allowing different kind of effect.
  8250. */
  8251. vignetteBlendMode: number;
  8252. private _vignetteEnabled;
  8253. /**
  8254. * Gets wether the vignette effect is enabled.
  8255. */
  8256. /**
  8257. * Sets wether the vignette effect is enabled.
  8258. */
  8259. vignetteEnabled: boolean;
  8260. private _applyByPostProcess;
  8261. /**
  8262. * Gets wether the image processing is applied through a post process or not.
  8263. */
  8264. /**
  8265. * Sets wether the image processing is applied through a post process or not.
  8266. */
  8267. applyByPostProcess: boolean;
  8268. private _isEnabled;
  8269. /**
  8270. * Gets wether the image processing is enabled or not.
  8271. */
  8272. /**
  8273. * Sets wether the image processing is enabled or not.
  8274. */
  8275. isEnabled: boolean;
  8276. /**
  8277. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8278. */
  8279. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8280. /**
  8281. * Method called each time the image processing information changes requires to recompile the effect.
  8282. */
  8283. protected _updateParameters(): void;
  8284. /**
  8285. * Gets the current class name.
  8286. * @return "ImageProcessingConfiguration"
  8287. */
  8288. getClassName(): string;
  8289. /**
  8290. * Prepare the list of uniforms associated with the Image Processing effects.
  8291. * @param uniforms The list of uniforms used in the effect
  8292. * @param defines the list of defines currently in use
  8293. */
  8294. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8295. /**
  8296. * Prepare the list of samplers associated with the Image Processing effects.
  8297. * @param samplersList The list of uniforms used in the effect
  8298. * @param defines the list of defines currently in use
  8299. */
  8300. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8301. /**
  8302. * Prepare the list of defines associated to the shader.
  8303. * @param defines the list of defines to complete
  8304. * @param forPostProcess Define if we are currently in post process mode or not
  8305. */
  8306. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8307. /**
  8308. * Returns true if all the image processing information are ready.
  8309. * @returns True if ready, otherwise, false
  8310. */
  8311. isReady(): boolean;
  8312. /**
  8313. * Binds the image processing to the shader.
  8314. * @param effect The effect to bind to
  8315. * @param aspectRatio Define the current aspect ratio of the effect
  8316. */
  8317. bind(effect: Effect, aspectRatio?: number): void;
  8318. /**
  8319. * Clones the current image processing instance.
  8320. * @return The cloned image processing
  8321. */
  8322. clone(): ImageProcessingConfiguration;
  8323. /**
  8324. * Serializes the current image processing instance to a json representation.
  8325. * @return a JSON representation
  8326. */
  8327. serialize(): any;
  8328. /**
  8329. * Parses the image processing from a json representation.
  8330. * @param source the JSON source to parse
  8331. * @return The parsed image processing
  8332. */
  8333. static Parse(source: any): ImageProcessingConfiguration;
  8334. private static _VIGNETTEMODE_MULTIPLY;
  8335. private static _VIGNETTEMODE_OPAQUE;
  8336. /**
  8337. * Used to apply the vignette as a mix with the pixel color.
  8338. */
  8339. static readonly VIGNETTEMODE_MULTIPLY: number;
  8340. /**
  8341. * Used to apply the vignette as a replacement of the pixel color.
  8342. */
  8343. static readonly VIGNETTEMODE_OPAQUE: number;
  8344. }
  8345. }
  8346. declare module "babylonjs/Shaders/postprocess.vertex" {
  8347. /** @hidden */
  8348. export var postprocessVertexShader: {
  8349. name: string;
  8350. shader: string;
  8351. };
  8352. }
  8353. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8354. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8355. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8356. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8357. module "babylonjs/Engines/thinEngine" {
  8358. interface ThinEngine {
  8359. /**
  8360. * Creates a new render target texture
  8361. * @param size defines the size of the texture
  8362. * @param options defines the options used to create the texture
  8363. * @returns a new render target texture stored in an InternalTexture
  8364. */
  8365. createRenderTargetTexture(size: number | {
  8366. width: number;
  8367. height: number;
  8368. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8369. /**
  8370. * Creates a depth stencil texture.
  8371. * This is only available in WebGL 2 or with the depth texture extension available.
  8372. * @param size The size of face edge in the texture.
  8373. * @param options The options defining the texture.
  8374. * @returns The texture
  8375. */
  8376. createDepthStencilTexture(size: number | {
  8377. width: number;
  8378. height: number;
  8379. }, options: DepthTextureCreationOptions): InternalTexture;
  8380. /** @hidden */
  8381. _createDepthStencilTexture(size: number | {
  8382. width: number;
  8383. height: number;
  8384. }, options: DepthTextureCreationOptions): InternalTexture;
  8385. }
  8386. }
  8387. }
  8388. declare module "babylonjs/Maths/math.axis" {
  8389. import { Vector3 } from "babylonjs/Maths/math.vector";
  8390. /** Defines supported spaces */
  8391. export enum Space {
  8392. /** Local (object) space */
  8393. LOCAL = 0,
  8394. /** World space */
  8395. WORLD = 1,
  8396. /** Bone space */
  8397. BONE = 2
  8398. }
  8399. /** Defines the 3 main axes */
  8400. export class Axis {
  8401. /** X axis */
  8402. static X: Vector3;
  8403. /** Y axis */
  8404. static Y: Vector3;
  8405. /** Z axis */
  8406. static Z: Vector3;
  8407. }
  8408. }
  8409. declare module "babylonjs/Cameras/targetCamera" {
  8410. import { Nullable } from "babylonjs/types";
  8411. import { Camera } from "babylonjs/Cameras/camera";
  8412. import { Scene } from "babylonjs/scene";
  8413. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8414. /**
  8415. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8416. * This is the base of the follow, arc rotate cameras and Free camera
  8417. * @see http://doc.babylonjs.com/features/cameras
  8418. */
  8419. export class TargetCamera extends Camera {
  8420. private static _RigCamTransformMatrix;
  8421. private static _TargetTransformMatrix;
  8422. private static _TargetFocalPoint;
  8423. /**
  8424. * Define the current direction the camera is moving to
  8425. */
  8426. cameraDirection: Vector3;
  8427. /**
  8428. * Define the current rotation the camera is rotating to
  8429. */
  8430. cameraRotation: Vector2;
  8431. /**
  8432. * When set, the up vector of the camera will be updated by the rotation of the camera
  8433. */
  8434. updateUpVectorFromRotation: boolean;
  8435. private _tmpQuaternion;
  8436. /**
  8437. * Define the current rotation of the camera
  8438. */
  8439. rotation: Vector3;
  8440. /**
  8441. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8442. */
  8443. rotationQuaternion: Quaternion;
  8444. /**
  8445. * Define the current speed of the camera
  8446. */
  8447. speed: number;
  8448. /**
  8449. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8450. * around all axis.
  8451. */
  8452. noRotationConstraint: boolean;
  8453. /**
  8454. * Define the current target of the camera as an object or a position.
  8455. */
  8456. lockedTarget: any;
  8457. /** @hidden */
  8458. _currentTarget: Vector3;
  8459. /** @hidden */
  8460. _initialFocalDistance: number;
  8461. /** @hidden */
  8462. _viewMatrix: Matrix;
  8463. /** @hidden */
  8464. _camMatrix: Matrix;
  8465. /** @hidden */
  8466. _cameraTransformMatrix: Matrix;
  8467. /** @hidden */
  8468. _cameraRotationMatrix: Matrix;
  8469. /** @hidden */
  8470. _referencePoint: Vector3;
  8471. /** @hidden */
  8472. _transformedReferencePoint: Vector3;
  8473. protected _globalCurrentTarget: Vector3;
  8474. protected _globalCurrentUpVector: Vector3;
  8475. /** @hidden */
  8476. _reset: () => void;
  8477. private _defaultUp;
  8478. /**
  8479. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8480. * This is the base of the follow, arc rotate cameras and Free camera
  8481. * @see http://doc.babylonjs.com/features/cameras
  8482. * @param name Defines the name of the camera in the scene
  8483. * @param position Defines the start position of the camera in the scene
  8484. * @param scene Defines the scene the camera belongs to
  8485. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8486. */
  8487. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8488. /**
  8489. * Gets the position in front of the camera at a given distance.
  8490. * @param distance The distance from the camera we want the position to be
  8491. * @returns the position
  8492. */
  8493. getFrontPosition(distance: number): Vector3;
  8494. /** @hidden */
  8495. _getLockedTargetPosition(): Nullable<Vector3>;
  8496. private _storedPosition;
  8497. private _storedRotation;
  8498. private _storedRotationQuaternion;
  8499. /**
  8500. * Store current camera state of the camera (fov, position, rotation, etc..)
  8501. * @returns the camera
  8502. */
  8503. storeState(): Camera;
  8504. /**
  8505. * Restored camera state. You must call storeState() first
  8506. * @returns whether it was successful or not
  8507. * @hidden
  8508. */
  8509. _restoreStateValues(): boolean;
  8510. /** @hidden */
  8511. _initCache(): void;
  8512. /** @hidden */
  8513. _updateCache(ignoreParentClass?: boolean): void;
  8514. /** @hidden */
  8515. _isSynchronizedViewMatrix(): boolean;
  8516. /** @hidden */
  8517. _computeLocalCameraSpeed(): number;
  8518. /**
  8519. * Defines the target the camera should look at.
  8520. * @param target Defines the new target as a Vector or a mesh
  8521. */
  8522. setTarget(target: Vector3): void;
  8523. /**
  8524. * Return the current target position of the camera. This value is expressed in local space.
  8525. * @returns the target position
  8526. */
  8527. getTarget(): Vector3;
  8528. /** @hidden */
  8529. _decideIfNeedsToMove(): boolean;
  8530. /** @hidden */
  8531. _updatePosition(): void;
  8532. /** @hidden */
  8533. _checkInputs(): void;
  8534. protected _updateCameraRotationMatrix(): void;
  8535. /**
  8536. * 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)
  8537. * @returns the current camera
  8538. */
  8539. private _rotateUpVectorWithCameraRotationMatrix;
  8540. private _cachedRotationZ;
  8541. private _cachedQuaternionRotationZ;
  8542. /** @hidden */
  8543. _getViewMatrix(): Matrix;
  8544. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8545. /**
  8546. * @hidden
  8547. */
  8548. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8549. /**
  8550. * @hidden
  8551. */
  8552. _updateRigCameras(): void;
  8553. private _getRigCamPositionAndTarget;
  8554. /**
  8555. * Gets the current object class name.
  8556. * @return the class name
  8557. */
  8558. getClassName(): string;
  8559. }
  8560. }
  8561. declare module "babylonjs/Events/keyboardEvents" {
  8562. /**
  8563. * Gather the list of keyboard event types as constants.
  8564. */
  8565. export class KeyboardEventTypes {
  8566. /**
  8567. * The keydown event is fired when a key becomes active (pressed).
  8568. */
  8569. static readonly KEYDOWN: number;
  8570. /**
  8571. * The keyup event is fired when a key has been released.
  8572. */
  8573. static readonly KEYUP: number;
  8574. }
  8575. /**
  8576. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8577. */
  8578. export class KeyboardInfo {
  8579. /**
  8580. * Defines the type of event (KeyboardEventTypes)
  8581. */
  8582. type: number;
  8583. /**
  8584. * Defines the related dom event
  8585. */
  8586. event: KeyboardEvent;
  8587. /**
  8588. * Instantiates a new keyboard info.
  8589. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8590. * @param type Defines the type of event (KeyboardEventTypes)
  8591. * @param event Defines the related dom event
  8592. */
  8593. constructor(
  8594. /**
  8595. * Defines the type of event (KeyboardEventTypes)
  8596. */
  8597. type: number,
  8598. /**
  8599. * Defines the related dom event
  8600. */
  8601. event: KeyboardEvent);
  8602. }
  8603. /**
  8604. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8605. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8606. */
  8607. export class KeyboardInfoPre extends KeyboardInfo {
  8608. /**
  8609. * Defines the type of event (KeyboardEventTypes)
  8610. */
  8611. type: number;
  8612. /**
  8613. * Defines the related dom event
  8614. */
  8615. event: KeyboardEvent;
  8616. /**
  8617. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8618. */
  8619. skipOnPointerObservable: boolean;
  8620. /**
  8621. * Instantiates a new keyboard pre info.
  8622. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8623. * @param type Defines the type of event (KeyboardEventTypes)
  8624. * @param event Defines the related dom event
  8625. */
  8626. constructor(
  8627. /**
  8628. * Defines the type of event (KeyboardEventTypes)
  8629. */
  8630. type: number,
  8631. /**
  8632. * Defines the related dom event
  8633. */
  8634. event: KeyboardEvent);
  8635. }
  8636. }
  8637. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8638. import { Nullable } from "babylonjs/types";
  8639. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8640. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8641. /**
  8642. * Manage the keyboard inputs to control the movement of a free camera.
  8643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8644. */
  8645. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8646. /**
  8647. * Defines the camera the input is attached to.
  8648. */
  8649. camera: FreeCamera;
  8650. /**
  8651. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8652. */
  8653. keysUp: number[];
  8654. /**
  8655. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8656. */
  8657. keysDown: number[];
  8658. /**
  8659. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8660. */
  8661. keysLeft: number[];
  8662. /**
  8663. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8664. */
  8665. keysRight: number[];
  8666. private _keys;
  8667. private _onCanvasBlurObserver;
  8668. private _onKeyboardObserver;
  8669. private _engine;
  8670. private _scene;
  8671. /**
  8672. * Attach the input controls to a specific dom element to get the input from.
  8673. * @param element Defines the element the controls should be listened from
  8674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8675. */
  8676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8677. /**
  8678. * Detach the current controls from the specified dom element.
  8679. * @param element Defines the element to stop listening the inputs from
  8680. */
  8681. detachControl(element: Nullable<HTMLElement>): void;
  8682. /**
  8683. * Update the current camera state depending on the inputs that have been used this frame.
  8684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8685. */
  8686. checkInputs(): void;
  8687. /**
  8688. * Gets the class name of the current intput.
  8689. * @returns the class name
  8690. */
  8691. getClassName(): string;
  8692. /** @hidden */
  8693. _onLostFocus(): void;
  8694. /**
  8695. * Get the friendly name associated with the input class.
  8696. * @returns the input friendly name
  8697. */
  8698. getSimpleName(): string;
  8699. }
  8700. }
  8701. declare module "babylonjs/Lights/shadowLight" {
  8702. import { Camera } from "babylonjs/Cameras/camera";
  8703. import { Scene } from "babylonjs/scene";
  8704. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8706. import { Light } from "babylonjs/Lights/light";
  8707. /**
  8708. * Interface describing all the common properties and methods a shadow light needs to implement.
  8709. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8710. * as well as binding the different shadow properties to the effects.
  8711. */
  8712. export interface IShadowLight extends Light {
  8713. /**
  8714. * The light id in the scene (used in scene.findLighById for instance)
  8715. */
  8716. id: string;
  8717. /**
  8718. * The position the shdow will be casted from.
  8719. */
  8720. position: Vector3;
  8721. /**
  8722. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8723. */
  8724. direction: Vector3;
  8725. /**
  8726. * The transformed position. Position of the light in world space taking parenting in account.
  8727. */
  8728. transformedPosition: Vector3;
  8729. /**
  8730. * The transformed direction. Direction of the light in world space taking parenting in account.
  8731. */
  8732. transformedDirection: Vector3;
  8733. /**
  8734. * The friendly name of the light in the scene.
  8735. */
  8736. name: string;
  8737. /**
  8738. * Defines the shadow projection clipping minimum z value.
  8739. */
  8740. shadowMinZ: number;
  8741. /**
  8742. * Defines the shadow projection clipping maximum z value.
  8743. */
  8744. shadowMaxZ: number;
  8745. /**
  8746. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8747. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8748. */
  8749. computeTransformedInformation(): boolean;
  8750. /**
  8751. * Gets the scene the light belongs to.
  8752. * @returns The scene
  8753. */
  8754. getScene(): Scene;
  8755. /**
  8756. * Callback defining a custom Projection Matrix Builder.
  8757. * This can be used to override the default projection matrix computation.
  8758. */
  8759. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8760. /**
  8761. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8762. * @param matrix The materix to updated with the projection information
  8763. * @param viewMatrix The transform matrix of the light
  8764. * @param renderList The list of mesh to render in the map
  8765. * @returns The current light
  8766. */
  8767. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8768. /**
  8769. * Gets the current depth scale used in ESM.
  8770. * @returns The scale
  8771. */
  8772. getDepthScale(): number;
  8773. /**
  8774. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8775. * @returns true if a cube texture needs to be use
  8776. */
  8777. needCube(): boolean;
  8778. /**
  8779. * Detects if the projection matrix requires to be recomputed this frame.
  8780. * @returns true if it requires to be recomputed otherwise, false.
  8781. */
  8782. needProjectionMatrixCompute(): boolean;
  8783. /**
  8784. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8785. */
  8786. forceProjectionMatrixCompute(): void;
  8787. /**
  8788. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8789. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8790. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8791. */
  8792. getShadowDirection(faceIndex?: number): Vector3;
  8793. /**
  8794. * Gets the minZ used for shadow according to both the scene and the light.
  8795. * @param activeCamera The camera we are returning the min for
  8796. * @returns the depth min z
  8797. */
  8798. getDepthMinZ(activeCamera: Camera): number;
  8799. /**
  8800. * Gets the maxZ used for shadow according to both the scene and the light.
  8801. * @param activeCamera The camera we are returning the max for
  8802. * @returns the depth max z
  8803. */
  8804. getDepthMaxZ(activeCamera: Camera): number;
  8805. }
  8806. /**
  8807. * Base implementation IShadowLight
  8808. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8809. */
  8810. export abstract class ShadowLight extends Light implements IShadowLight {
  8811. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8812. protected _position: Vector3;
  8813. protected _setPosition(value: Vector3): void;
  8814. /**
  8815. * Sets the position the shadow will be casted from. Also use as the light position for both
  8816. * point and spot lights.
  8817. */
  8818. /**
  8819. * Sets the position the shadow will be casted from. Also use as the light position for both
  8820. * point and spot lights.
  8821. */
  8822. position: Vector3;
  8823. protected _direction: Vector3;
  8824. protected _setDirection(value: Vector3): void;
  8825. /**
  8826. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8827. * Also use as the light direction on spot and directional lights.
  8828. */
  8829. /**
  8830. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8831. * Also use as the light direction on spot and directional lights.
  8832. */
  8833. direction: Vector3;
  8834. private _shadowMinZ;
  8835. /**
  8836. * Gets the shadow projection clipping minimum z value.
  8837. */
  8838. /**
  8839. * Sets the shadow projection clipping minimum z value.
  8840. */
  8841. shadowMinZ: number;
  8842. private _shadowMaxZ;
  8843. /**
  8844. * Sets the shadow projection clipping maximum z value.
  8845. */
  8846. /**
  8847. * Gets the shadow projection clipping maximum z value.
  8848. */
  8849. shadowMaxZ: number;
  8850. /**
  8851. * Callback defining a custom Projection Matrix Builder.
  8852. * This can be used to override the default projection matrix computation.
  8853. */
  8854. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8855. /**
  8856. * The transformed position. Position of the light in world space taking parenting in account.
  8857. */
  8858. transformedPosition: Vector3;
  8859. /**
  8860. * The transformed direction. Direction of the light in world space taking parenting in account.
  8861. */
  8862. transformedDirection: Vector3;
  8863. private _needProjectionMatrixCompute;
  8864. /**
  8865. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8866. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8867. */
  8868. computeTransformedInformation(): boolean;
  8869. /**
  8870. * Return the depth scale used for the shadow map.
  8871. * @returns the depth scale.
  8872. */
  8873. getDepthScale(): number;
  8874. /**
  8875. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8876. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8877. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8878. */
  8879. getShadowDirection(faceIndex?: number): Vector3;
  8880. /**
  8881. * Returns the ShadowLight absolute position in the World.
  8882. * @returns the position vector in world space
  8883. */
  8884. getAbsolutePosition(): Vector3;
  8885. /**
  8886. * Sets the ShadowLight direction toward the passed target.
  8887. * @param target The point to target in local space
  8888. * @returns the updated ShadowLight direction
  8889. */
  8890. setDirectionToTarget(target: Vector3): Vector3;
  8891. /**
  8892. * Returns the light rotation in euler definition.
  8893. * @returns the x y z rotation in local space.
  8894. */
  8895. getRotation(): Vector3;
  8896. /**
  8897. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8898. * @returns true if a cube texture needs to be use
  8899. */
  8900. needCube(): boolean;
  8901. /**
  8902. * Detects if the projection matrix requires to be recomputed this frame.
  8903. * @returns true if it requires to be recomputed otherwise, false.
  8904. */
  8905. needProjectionMatrixCompute(): boolean;
  8906. /**
  8907. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8908. */
  8909. forceProjectionMatrixCompute(): void;
  8910. /** @hidden */
  8911. _initCache(): void;
  8912. /** @hidden */
  8913. _isSynchronized(): boolean;
  8914. /**
  8915. * Computes the world matrix of the node
  8916. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8917. * @returns the world matrix
  8918. */
  8919. computeWorldMatrix(force?: boolean): Matrix;
  8920. /**
  8921. * Gets the minZ used for shadow according to both the scene and the light.
  8922. * @param activeCamera The camera we are returning the min for
  8923. * @returns the depth min z
  8924. */
  8925. getDepthMinZ(activeCamera: Camera): number;
  8926. /**
  8927. * Gets the maxZ used for shadow according to both the scene and the light.
  8928. * @param activeCamera The camera we are returning the max for
  8929. * @returns the depth max z
  8930. */
  8931. getDepthMaxZ(activeCamera: Camera): number;
  8932. /**
  8933. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8934. * @param matrix The materix to updated with the projection information
  8935. * @param viewMatrix The transform matrix of the light
  8936. * @param renderList The list of mesh to render in the map
  8937. * @returns The current light
  8938. */
  8939. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8940. }
  8941. }
  8942. declare module "babylonjs/Materials/effectFallbacks" {
  8943. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8944. import { Effect } from "babylonjs/Materials/effect";
  8945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8946. /**
  8947. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8948. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8949. */
  8950. export class EffectFallbacks implements IEffectFallbacks {
  8951. private _defines;
  8952. private _currentRank;
  8953. private _maxRank;
  8954. private _mesh;
  8955. /**
  8956. * Removes the fallback from the bound mesh.
  8957. */
  8958. unBindMesh(): void;
  8959. /**
  8960. * Adds a fallback on the specified property.
  8961. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8962. * @param define The name of the define in the shader
  8963. */
  8964. addFallback(rank: number, define: string): void;
  8965. /**
  8966. * Sets the mesh to use CPU skinning when needing to fallback.
  8967. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8968. * @param mesh The mesh to use the fallbacks.
  8969. */
  8970. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8971. /**
  8972. * Checks to see if more fallbacks are still availible.
  8973. */
  8974. readonly hasMoreFallbacks: boolean;
  8975. /**
  8976. * Removes the defines that should be removed when falling back.
  8977. * @param currentDefines defines the current define statements for the shader.
  8978. * @param effect defines the current effect we try to compile
  8979. * @returns The resulting defines with defines of the current rank removed.
  8980. */
  8981. reduce(currentDefines: string, effect: Effect): string;
  8982. }
  8983. }
  8984. declare module "babylonjs/Materials/materialHelper" {
  8985. import { Nullable } from "babylonjs/types";
  8986. import { Scene } from "babylonjs/scene";
  8987. import { Engine } from "babylonjs/Engines/engine";
  8988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8989. import { Light } from "babylonjs/Lights/light";
  8990. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8991. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8993. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8995. /**
  8996. * "Static Class" containing the most commonly used helper while dealing with material for
  8997. * rendering purpose.
  8998. *
  8999. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9000. *
  9001. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9002. */
  9003. export class MaterialHelper {
  9004. /**
  9005. * Bind the current view position to an effect.
  9006. * @param effect The effect to be bound
  9007. * @param scene The scene the eyes position is used from
  9008. */
  9009. static BindEyePosition(effect: Effect, scene: Scene): void;
  9010. /**
  9011. * Helps preparing the defines values about the UVs in used in the effect.
  9012. * UVs are shared as much as we can accross channels in the shaders.
  9013. * @param texture The texture we are preparing the UVs for
  9014. * @param defines The defines to update
  9015. * @param key The channel key "diffuse", "specular"... used in the shader
  9016. */
  9017. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9018. /**
  9019. * Binds a texture matrix value to its corrsponding uniform
  9020. * @param texture The texture to bind the matrix for
  9021. * @param uniformBuffer The uniform buffer receivin the data
  9022. * @param key The channel key "diffuse", "specular"... used in the shader
  9023. */
  9024. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9025. /**
  9026. * Gets the current status of the fog (should it be enabled?)
  9027. * @param mesh defines the mesh to evaluate for fog support
  9028. * @param scene defines the hosting scene
  9029. * @returns true if fog must be enabled
  9030. */
  9031. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9032. /**
  9033. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9034. * @param mesh defines the current mesh
  9035. * @param scene defines the current scene
  9036. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9037. * @param pointsCloud defines if point cloud rendering has to be turned on
  9038. * @param fogEnabled defines if fog has to be turned on
  9039. * @param alphaTest defines if alpha testing has to be turned on
  9040. * @param defines defines the current list of defines
  9041. */
  9042. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9043. /**
  9044. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9045. * @param scene defines the current scene
  9046. * @param engine defines the current engine
  9047. * @param defines specifies the list of active defines
  9048. * @param useInstances defines if instances have to be turned on
  9049. * @param useClipPlane defines if clip plane have to be turned on
  9050. */
  9051. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9052. /**
  9053. * Prepares the defines for bones
  9054. * @param mesh The mesh containing the geometry data we will draw
  9055. * @param defines The defines to update
  9056. */
  9057. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9058. /**
  9059. * Prepares the defines for morph targets
  9060. * @param mesh The mesh containing the geometry data we will draw
  9061. * @param defines The defines to update
  9062. */
  9063. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9064. /**
  9065. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9066. * @param mesh The mesh containing the geometry data we will draw
  9067. * @param defines The defines to update
  9068. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9069. * @param useBones Precise whether bones should be used or not (override mesh info)
  9070. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9071. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9072. * @returns false if defines are considered not dirty and have not been checked
  9073. */
  9074. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9075. /**
  9076. * Prepares the defines related to multiview
  9077. * @param scene The scene we are intending to draw
  9078. * @param defines The defines to update
  9079. */
  9080. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9081. /**
  9082. * Prepares the defines related to the light information passed in parameter
  9083. * @param scene The scene we are intending to draw
  9084. * @param mesh The mesh the effect is compiling for
  9085. * @param light The light the effect is compiling for
  9086. * @param lightIndex The index of the light
  9087. * @param defines The defines to update
  9088. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9089. * @param state Defines the current state regarding what is needed (normals, etc...)
  9090. */
  9091. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9092. needNormals: boolean;
  9093. needRebuild: boolean;
  9094. shadowEnabled: boolean;
  9095. specularEnabled: boolean;
  9096. lightmapMode: boolean;
  9097. }): void;
  9098. /**
  9099. * Prepares the defines related to the light information passed in parameter
  9100. * @param scene The scene we are intending to draw
  9101. * @param mesh The mesh the effect is compiling for
  9102. * @param defines The defines to update
  9103. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9104. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9105. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9106. * @returns true if normals will be required for the rest of the effect
  9107. */
  9108. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9109. /**
  9110. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9111. * @param lightIndex defines the light index
  9112. * @param uniformsList The uniform list
  9113. * @param samplersList The sampler list
  9114. * @param projectedLightTexture defines if projected texture must be used
  9115. * @param uniformBuffersList defines an optional list of uniform buffers
  9116. */
  9117. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9118. /**
  9119. * Prepares the uniforms and samplers list to be used in the effect
  9120. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9121. * @param samplersList The sampler list
  9122. * @param defines The defines helping in the list generation
  9123. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9124. */
  9125. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9126. /**
  9127. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9128. * @param defines The defines to update while falling back
  9129. * @param fallbacks The authorized effect fallbacks
  9130. * @param maxSimultaneousLights The maximum number of lights allowed
  9131. * @param rank the current rank of the Effect
  9132. * @returns The newly affected rank
  9133. */
  9134. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9135. private static _TmpMorphInfluencers;
  9136. /**
  9137. * Prepares the list of attributes required for morph targets according to the effect defines.
  9138. * @param attribs The current list of supported attribs
  9139. * @param mesh The mesh to prepare the morph targets attributes for
  9140. * @param influencers The number of influencers
  9141. */
  9142. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9143. /**
  9144. * Prepares the list of attributes required for morph targets according to the effect defines.
  9145. * @param attribs The current list of supported attribs
  9146. * @param mesh The mesh to prepare the morph targets attributes for
  9147. * @param defines The current Defines of the effect
  9148. */
  9149. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9150. /**
  9151. * Prepares the list of attributes required for bones according to the effect defines.
  9152. * @param attribs The current list of supported attribs
  9153. * @param mesh The mesh to prepare the bones attributes for
  9154. * @param defines The current Defines of the effect
  9155. * @param fallbacks The current efffect fallback strategy
  9156. */
  9157. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9158. /**
  9159. * Check and prepare the list of attributes required for instances according to the effect defines.
  9160. * @param attribs The current list of supported attribs
  9161. * @param defines The current MaterialDefines of the effect
  9162. */
  9163. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9164. /**
  9165. * Add the list of attributes required for instances to the attribs array.
  9166. * @param attribs The current list of supported attribs
  9167. */
  9168. static PushAttributesForInstances(attribs: string[]): void;
  9169. /**
  9170. * Binds the light information to the effect.
  9171. * @param light The light containing the generator
  9172. * @param effect The effect we are binding the data to
  9173. * @param lightIndex The light index in the effect used to render
  9174. */
  9175. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9176. /**
  9177. * Binds the lights information from the scene to the effect for the given mesh.
  9178. * @param light Light to bind
  9179. * @param lightIndex Light index
  9180. * @param scene The scene where the light belongs to
  9181. * @param effect The effect we are binding the data to
  9182. * @param useSpecular Defines if specular is supported
  9183. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9184. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9185. */
  9186. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9187. /**
  9188. * Binds the lights information from the scene to the effect for the given mesh.
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param effect The effect we are binding the data to
  9192. * @param defines The generated defines for the effect
  9193. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9194. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9195. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9196. */
  9197. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9198. private static _tempFogColor;
  9199. /**
  9200. * Binds the fog information from the scene to the effect for the given mesh.
  9201. * @param scene The scene the lights belongs to
  9202. * @param mesh The mesh we are binding the information to render
  9203. * @param effect The effect we are binding the data to
  9204. * @param linearSpace Defines if the fog effect is applied in linear space
  9205. */
  9206. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9207. /**
  9208. * Binds the bones information from the mesh to the effect.
  9209. * @param mesh The mesh we are binding the information to render
  9210. * @param effect The effect we are binding the data to
  9211. */
  9212. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9213. /**
  9214. * Binds the morph targets information from the mesh to the effect.
  9215. * @param abstractMesh The mesh we are binding the information to render
  9216. * @param effect The effect we are binding the data to
  9217. */
  9218. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9219. /**
  9220. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9221. * @param defines The generated defines used in the effect
  9222. * @param effect The effect we are binding the data to
  9223. * @param scene The scene we are willing to render with logarithmic scale for
  9224. */
  9225. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9226. /**
  9227. * Binds the clip plane information from the scene to the effect.
  9228. * @param scene The scene the clip plane information are extracted from
  9229. * @param effect The effect we are binding the data to
  9230. */
  9231. static BindClipPlane(effect: Effect, scene: Scene): void;
  9232. }
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9235. /** @hidden */
  9236. export var packingFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. /** @hidden */
  9244. export var shadowMapPixelShader: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9250. /** @hidden */
  9251. export var bonesDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9257. /** @hidden */
  9258. export var morphTargetsVertexGlobalDeclaration: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9264. /** @hidden */
  9265. export var morphTargetsVertexDeclaration: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9271. /** @hidden */
  9272. export var instancesDeclaration: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9278. /** @hidden */
  9279. export var helperFunctions: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9285. /** @hidden */
  9286. export var morphTargetsVertex: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9292. /** @hidden */
  9293. export var instancesVertex: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9299. /** @hidden */
  9300. export var bonesVertex: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9306. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9307. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9308. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9309. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9311. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9312. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9313. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9314. /** @hidden */
  9315. export var shadowMapVertexShader: {
  9316. name: string;
  9317. shader: string;
  9318. };
  9319. }
  9320. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9321. /** @hidden */
  9322. export var depthBoxBlurPixelShader: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9328. import { Nullable } from "babylonjs/types";
  9329. import { Scene } from "babylonjs/scene";
  9330. import { Matrix } from "babylonjs/Maths/math.vector";
  9331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9333. import { Mesh } from "babylonjs/Meshes/mesh";
  9334. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9335. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9336. import { Effect } from "babylonjs/Materials/effect";
  9337. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9338. import "babylonjs/Shaders/shadowMap.fragment";
  9339. import "babylonjs/Shaders/shadowMap.vertex";
  9340. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9341. import { Observable } from "babylonjs/Misc/observable";
  9342. /**
  9343. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9344. */
  9345. export interface ICustomShaderOptions {
  9346. /**
  9347. * Gets or sets the custom shader name to use
  9348. */
  9349. shaderName: string;
  9350. /**
  9351. * The list of attribute names used in the shader
  9352. */
  9353. attributes?: string[];
  9354. /**
  9355. * The list of unifrom names used in the shader
  9356. */
  9357. uniforms?: string[];
  9358. /**
  9359. * The list of sampler names used in the shader
  9360. */
  9361. samplers?: string[];
  9362. /**
  9363. * The list of defines used in the shader
  9364. */
  9365. defines?: string[];
  9366. }
  9367. /**
  9368. * Interface to implement to create a shadow generator compatible with BJS.
  9369. */
  9370. export interface IShadowGenerator {
  9371. /**
  9372. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9373. * @returns The render target texture if present otherwise, null
  9374. */
  9375. getShadowMap(): Nullable<RenderTargetTexture>;
  9376. /**
  9377. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9378. * @returns The render target texture if the shadow map is present otherwise, null
  9379. */
  9380. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9381. /**
  9382. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9383. * @param subMesh The submesh we want to render in the shadow map
  9384. * @param useInstances Defines wether will draw in the map using instances
  9385. * @returns true if ready otherwise, false
  9386. */
  9387. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9388. /**
  9389. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9390. * @param defines Defines of the material we want to update
  9391. * @param lightIndex Index of the light in the enabled light list of the material
  9392. */
  9393. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9394. /**
  9395. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9396. * defined in the generator but impacting the effect).
  9397. * It implies the unifroms available on the materials are the standard BJS ones.
  9398. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9399. * @param effect The effect we are binfing the information for
  9400. */
  9401. bindShadowLight(lightIndex: string, effect: Effect): void;
  9402. /**
  9403. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9404. * (eq to shadow prjection matrix * light transform matrix)
  9405. * @returns The transform matrix used to create the shadow map
  9406. */
  9407. getTransformMatrix(): Matrix;
  9408. /**
  9409. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9410. * Cube and 2D textures for instance.
  9411. */
  9412. recreateShadowMap(): void;
  9413. /**
  9414. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9415. * @param onCompiled Callback triggered at the and of the effects compilation
  9416. * @param options Sets of optional options forcing the compilation with different modes
  9417. */
  9418. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9419. useInstances: boolean;
  9420. }>): void;
  9421. /**
  9422. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9423. * @param options Sets of optional options forcing the compilation with different modes
  9424. * @returns A promise that resolves when the compilation completes
  9425. */
  9426. forceCompilationAsync(options?: Partial<{
  9427. useInstances: boolean;
  9428. }>): Promise<void>;
  9429. /**
  9430. * Serializes the shadow generator setup to a json object.
  9431. * @returns The serialized JSON object
  9432. */
  9433. serialize(): any;
  9434. /**
  9435. * Disposes the Shadow map and related Textures and effects.
  9436. */
  9437. dispose(): void;
  9438. }
  9439. /**
  9440. * Default implementation IShadowGenerator.
  9441. * This is the main object responsible of generating shadows in the framework.
  9442. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9443. */
  9444. export class ShadowGenerator implements IShadowGenerator {
  9445. /**
  9446. * Shadow generator mode None: no filtering applied.
  9447. */
  9448. static readonly FILTER_NONE: number;
  9449. /**
  9450. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9451. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9452. */
  9453. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9454. /**
  9455. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9456. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9457. */
  9458. static readonly FILTER_POISSONSAMPLING: number;
  9459. /**
  9460. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9461. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9462. */
  9463. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9464. /**
  9465. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9466. * edge artifacts on steep falloff.
  9467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9468. */
  9469. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9470. /**
  9471. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9472. * edge artifacts on steep falloff.
  9473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9474. */
  9475. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9476. /**
  9477. * Shadow generator mode PCF: Percentage Closer Filtering
  9478. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9479. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9480. */
  9481. static readonly FILTER_PCF: number;
  9482. /**
  9483. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9485. * Contact Hardening
  9486. */
  9487. static readonly FILTER_PCSS: number;
  9488. /**
  9489. * Reserved for PCF and PCSS
  9490. * Highest Quality.
  9491. *
  9492. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9493. *
  9494. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9495. */
  9496. static readonly QUALITY_HIGH: number;
  9497. /**
  9498. * Reserved for PCF and PCSS
  9499. * Good tradeoff for quality/perf cross devices
  9500. *
  9501. * Execute PCF on a 3*3 kernel.
  9502. *
  9503. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9504. */
  9505. static readonly QUALITY_MEDIUM: number;
  9506. /**
  9507. * Reserved for PCF and PCSS
  9508. * The lowest quality but the fastest.
  9509. *
  9510. * Execute PCF on a 1*1 kernel.
  9511. *
  9512. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9513. */
  9514. static readonly QUALITY_LOW: number;
  9515. /** Gets or sets the custom shader name to use */
  9516. customShaderOptions: ICustomShaderOptions;
  9517. /**
  9518. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9519. */
  9520. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9521. /**
  9522. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9523. */
  9524. onAfterShadowMapRenderObservable: Observable<Effect>;
  9525. /**
  9526. * Observable triggered before a mesh is rendered in the shadow map.
  9527. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9528. */
  9529. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9530. /**
  9531. * Observable triggered after a mesh is rendered in the shadow map.
  9532. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9533. */
  9534. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9535. private _bias;
  9536. /**
  9537. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9538. */
  9539. /**
  9540. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9541. */
  9542. bias: number;
  9543. private _normalBias;
  9544. /**
  9545. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9546. */
  9547. /**
  9548. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9549. */
  9550. normalBias: number;
  9551. private _blurBoxOffset;
  9552. /**
  9553. * Gets the blur box offset: offset applied during the blur pass.
  9554. * Only useful if useKernelBlur = false
  9555. */
  9556. /**
  9557. * Sets the blur box offset: offset applied during the blur pass.
  9558. * Only useful if useKernelBlur = false
  9559. */
  9560. blurBoxOffset: number;
  9561. private _blurScale;
  9562. /**
  9563. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9564. * 2 means half of the size.
  9565. */
  9566. /**
  9567. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9568. * 2 means half of the size.
  9569. */
  9570. blurScale: number;
  9571. private _blurKernel;
  9572. /**
  9573. * Gets the blur kernel: kernel size of the blur pass.
  9574. * Only useful if useKernelBlur = true
  9575. */
  9576. /**
  9577. * Sets the blur kernel: kernel size of the blur pass.
  9578. * Only useful if useKernelBlur = true
  9579. */
  9580. blurKernel: number;
  9581. private _useKernelBlur;
  9582. /**
  9583. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9584. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9585. */
  9586. /**
  9587. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9588. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9589. */
  9590. useKernelBlur: boolean;
  9591. private _depthScale;
  9592. /**
  9593. * Gets the depth scale used in ESM mode.
  9594. */
  9595. /**
  9596. * Sets the depth scale used in ESM mode.
  9597. * This can override the scale stored on the light.
  9598. */
  9599. depthScale: number;
  9600. private _filter;
  9601. /**
  9602. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9603. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9604. */
  9605. /**
  9606. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9607. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9608. */
  9609. filter: number;
  9610. /**
  9611. * Gets if the current filter is set to Poisson Sampling.
  9612. */
  9613. /**
  9614. * Sets the current filter to Poisson Sampling.
  9615. */
  9616. usePoissonSampling: boolean;
  9617. /**
  9618. * Gets if the current filter is set to ESM.
  9619. */
  9620. /**
  9621. * Sets the current filter is to ESM.
  9622. */
  9623. useExponentialShadowMap: boolean;
  9624. /**
  9625. * Gets if the current filter is set to filtered ESM.
  9626. */
  9627. /**
  9628. * Gets if the current filter is set to filtered ESM.
  9629. */
  9630. useBlurExponentialShadowMap: boolean;
  9631. /**
  9632. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9633. * exponential to prevent steep falloff artifacts).
  9634. */
  9635. /**
  9636. * Sets the current filter to "close ESM" (using the inverse of the
  9637. * exponential to prevent steep falloff artifacts).
  9638. */
  9639. useCloseExponentialShadowMap: boolean;
  9640. /**
  9641. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9642. * exponential to prevent steep falloff artifacts).
  9643. */
  9644. /**
  9645. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9646. * exponential to prevent steep falloff artifacts).
  9647. */
  9648. useBlurCloseExponentialShadowMap: boolean;
  9649. /**
  9650. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9651. */
  9652. /**
  9653. * Sets the current filter to "PCF" (percentage closer filtering).
  9654. */
  9655. usePercentageCloserFiltering: boolean;
  9656. private _filteringQuality;
  9657. /**
  9658. * Gets the PCF or PCSS Quality.
  9659. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9660. */
  9661. /**
  9662. * Sets the PCF or PCSS Quality.
  9663. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9664. */
  9665. filteringQuality: number;
  9666. /**
  9667. * Gets if the current filter is set to "PCSS" (contact hardening).
  9668. */
  9669. /**
  9670. * Sets the current filter to "PCSS" (contact hardening).
  9671. */
  9672. useContactHardeningShadow: boolean;
  9673. private _contactHardeningLightSizeUVRatio;
  9674. /**
  9675. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9676. * Using a ratio helps keeping shape stability independently of the map size.
  9677. *
  9678. * It does not account for the light projection as it was having too much
  9679. * instability during the light setup or during light position changes.
  9680. *
  9681. * Only valid if useContactHardeningShadow is true.
  9682. */
  9683. /**
  9684. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9685. * Using a ratio helps keeping shape stability independently of the map size.
  9686. *
  9687. * It does not account for the light projection as it was having too much
  9688. * instability during the light setup or during light position changes.
  9689. *
  9690. * Only valid if useContactHardeningShadow is true.
  9691. */
  9692. contactHardeningLightSizeUVRatio: number;
  9693. private _darkness;
  9694. /** Gets or sets the actual darkness of a shadow */
  9695. darkness: number;
  9696. /**
  9697. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9698. * 0 means strongest and 1 would means no shadow.
  9699. * @returns the darkness.
  9700. */
  9701. getDarkness(): number;
  9702. /**
  9703. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9704. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9705. * @returns the shadow generator allowing fluent coding.
  9706. */
  9707. setDarkness(darkness: number): ShadowGenerator;
  9708. private _transparencyShadow;
  9709. /** Gets or sets the ability to have transparent shadow */
  9710. transparencyShadow: boolean;
  9711. /**
  9712. * Sets the ability to have transparent shadow (boolean).
  9713. * @param transparent True if transparent else False
  9714. * @returns the shadow generator allowing fluent coding
  9715. */
  9716. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9717. private _shadowMap;
  9718. private _shadowMap2;
  9719. /**
  9720. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9721. * @returns The render target texture if present otherwise, null
  9722. */
  9723. getShadowMap(): Nullable<RenderTargetTexture>;
  9724. /**
  9725. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9726. * @returns The render target texture if the shadow map is present otherwise, null
  9727. */
  9728. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9729. /**
  9730. * Gets the class name of that object
  9731. * @returns "ShadowGenerator"
  9732. */
  9733. getClassName(): string;
  9734. /**
  9735. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9736. * @param mesh Mesh to add
  9737. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9738. * @returns the Shadow Generator itself
  9739. */
  9740. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9741. /**
  9742. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9743. * @param mesh Mesh to remove
  9744. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9745. * @returns the Shadow Generator itself
  9746. */
  9747. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9748. /**
  9749. * Controls the extent to which the shadows fade out at the edge of the frustum
  9750. * Used only by directionals and spots
  9751. */
  9752. frustumEdgeFalloff: number;
  9753. private _light;
  9754. /**
  9755. * Returns the associated light object.
  9756. * @returns the light generating the shadow
  9757. */
  9758. getLight(): IShadowLight;
  9759. /**
  9760. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9761. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9762. * It might on the other hand introduce peter panning.
  9763. */
  9764. forceBackFacesOnly: boolean;
  9765. private _scene;
  9766. private _lightDirection;
  9767. private _effect;
  9768. private _viewMatrix;
  9769. private _projectionMatrix;
  9770. private _transformMatrix;
  9771. private _cachedPosition;
  9772. private _cachedDirection;
  9773. private _cachedDefines;
  9774. private _currentRenderID;
  9775. private _boxBlurPostprocess;
  9776. private _kernelBlurXPostprocess;
  9777. private _kernelBlurYPostprocess;
  9778. private _blurPostProcesses;
  9779. private _mapSize;
  9780. private _currentFaceIndex;
  9781. private _currentFaceIndexCache;
  9782. private _textureType;
  9783. private _defaultTextureMatrix;
  9784. private _storedUniqueId;
  9785. /** @hidden */
  9786. static _SceneComponentInitialization: (scene: Scene) => void;
  9787. /**
  9788. * Creates a ShadowGenerator object.
  9789. * A ShadowGenerator is the required tool to use the shadows.
  9790. * Each light casting shadows needs to use its own ShadowGenerator.
  9791. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9792. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9793. * @param light The light object generating the shadows.
  9794. * @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.
  9795. */
  9796. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9797. private _initializeGenerator;
  9798. private _initializeShadowMap;
  9799. private _initializeBlurRTTAndPostProcesses;
  9800. private _renderForShadowMap;
  9801. private _renderSubMeshForShadowMap;
  9802. private _applyFilterValues;
  9803. /**
  9804. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9805. * @param onCompiled Callback triggered at the and of the effects compilation
  9806. * @param options Sets of optional options forcing the compilation with different modes
  9807. */
  9808. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9809. useInstances: boolean;
  9810. }>): void;
  9811. /**
  9812. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9813. * @param options Sets of optional options forcing the compilation with different modes
  9814. * @returns A promise that resolves when the compilation completes
  9815. */
  9816. forceCompilationAsync(options?: Partial<{
  9817. useInstances: boolean;
  9818. }>): Promise<void>;
  9819. /**
  9820. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9821. * @param subMesh The submesh we want to render in the shadow map
  9822. * @param useInstances Defines wether will draw in the map using instances
  9823. * @returns true if ready otherwise, false
  9824. */
  9825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9826. /**
  9827. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9828. * @param defines Defines of the material we want to update
  9829. * @param lightIndex Index of the light in the enabled light list of the material
  9830. */
  9831. prepareDefines(defines: any, lightIndex: number): void;
  9832. /**
  9833. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9834. * defined in the generator but impacting the effect).
  9835. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9836. * @param effect The effect we are binfing the information for
  9837. */
  9838. bindShadowLight(lightIndex: string, effect: Effect): void;
  9839. /**
  9840. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9841. * (eq to shadow prjection matrix * light transform matrix)
  9842. * @returns The transform matrix used to create the shadow map
  9843. */
  9844. getTransformMatrix(): Matrix;
  9845. /**
  9846. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9847. * Cube and 2D textures for instance.
  9848. */
  9849. recreateShadowMap(): void;
  9850. private _disposeBlurPostProcesses;
  9851. private _disposeRTTandPostProcesses;
  9852. /**
  9853. * Disposes the ShadowGenerator.
  9854. * Returns nothing.
  9855. */
  9856. dispose(): void;
  9857. /**
  9858. * Serializes the shadow generator setup to a json object.
  9859. * @returns The serialized JSON object
  9860. */
  9861. serialize(): any;
  9862. /**
  9863. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9864. * @param parsedShadowGenerator The JSON object to parse
  9865. * @param scene The scene to create the shadow map for
  9866. * @returns The parsed shadow generator
  9867. */
  9868. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9869. }
  9870. }
  9871. declare module "babylonjs/Lights/light" {
  9872. import { Nullable } from "babylonjs/types";
  9873. import { Scene } from "babylonjs/scene";
  9874. import { Vector3 } from "babylonjs/Maths/math.vector";
  9875. import { Color3 } from "babylonjs/Maths/math.color";
  9876. import { Node } from "babylonjs/node";
  9877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9878. import { Effect } from "babylonjs/Materials/effect";
  9879. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9880. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9881. /**
  9882. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9883. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9884. * 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.
  9885. */
  9886. export abstract class Light extends Node {
  9887. /**
  9888. * Falloff Default: light is falling off following the material specification:
  9889. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9890. */
  9891. static readonly FALLOFF_DEFAULT: number;
  9892. /**
  9893. * Falloff Physical: light is falling off following the inverse squared distance law.
  9894. */
  9895. static readonly FALLOFF_PHYSICAL: number;
  9896. /**
  9897. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9898. * to enhance interoperability with other engines.
  9899. */
  9900. static readonly FALLOFF_GLTF: number;
  9901. /**
  9902. * Falloff Standard: light is falling off like in the standard material
  9903. * to enhance interoperability with other materials.
  9904. */
  9905. static readonly FALLOFF_STANDARD: number;
  9906. /**
  9907. * If every light affecting the material is in this lightmapMode,
  9908. * material.lightmapTexture adds or multiplies
  9909. * (depends on material.useLightmapAsShadowmap)
  9910. * after every other light calculations.
  9911. */
  9912. static readonly LIGHTMAP_DEFAULT: number;
  9913. /**
  9914. * material.lightmapTexture as only diffuse lighting from this light
  9915. * adds only specular lighting from this light
  9916. * adds dynamic shadows
  9917. */
  9918. static readonly LIGHTMAP_SPECULAR: number;
  9919. /**
  9920. * material.lightmapTexture as only lighting
  9921. * no light calculation from this light
  9922. * only adds dynamic shadows from this light
  9923. */
  9924. static readonly LIGHTMAP_SHADOWSONLY: number;
  9925. /**
  9926. * Each light type uses the default quantity according to its type:
  9927. * point/spot lights use luminous intensity
  9928. * directional lights use illuminance
  9929. */
  9930. static readonly INTENSITYMODE_AUTOMATIC: number;
  9931. /**
  9932. * lumen (lm)
  9933. */
  9934. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9935. /**
  9936. * candela (lm/sr)
  9937. */
  9938. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9939. /**
  9940. * lux (lm/m^2)
  9941. */
  9942. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9943. /**
  9944. * nit (cd/m^2)
  9945. */
  9946. static readonly INTENSITYMODE_LUMINANCE: number;
  9947. /**
  9948. * Light type const id of the point light.
  9949. */
  9950. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9951. /**
  9952. * Light type const id of the directional light.
  9953. */
  9954. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9955. /**
  9956. * Light type const id of the spot light.
  9957. */
  9958. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9959. /**
  9960. * Light type const id of the hemispheric light.
  9961. */
  9962. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9963. /**
  9964. * Diffuse gives the basic color to an object.
  9965. */
  9966. diffuse: Color3;
  9967. /**
  9968. * Specular produces a highlight color on an object.
  9969. * Note: This is note affecting PBR materials.
  9970. */
  9971. specular: Color3;
  9972. /**
  9973. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9974. * falling off base on range or angle.
  9975. * This can be set to any values in Light.FALLOFF_x.
  9976. *
  9977. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9978. * other types of materials.
  9979. */
  9980. falloffType: number;
  9981. /**
  9982. * Strength of the light.
  9983. * Note: By default it is define in the framework own unit.
  9984. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9985. */
  9986. intensity: number;
  9987. private _range;
  9988. protected _inverseSquaredRange: number;
  9989. /**
  9990. * Defines how far from the source the light is impacting in scene units.
  9991. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9992. */
  9993. /**
  9994. * Defines how far from the source the light is impacting in scene units.
  9995. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9996. */
  9997. range: number;
  9998. /**
  9999. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10000. * of light.
  10001. */
  10002. private _photometricScale;
  10003. private _intensityMode;
  10004. /**
  10005. * Gets the photometric scale used to interpret the intensity.
  10006. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10007. */
  10008. /**
  10009. * Sets the photometric scale used to interpret the intensity.
  10010. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10011. */
  10012. intensityMode: number;
  10013. private _radius;
  10014. /**
  10015. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10016. */
  10017. /**
  10018. * sets the light radius used by PBR Materials to simulate soft area lights.
  10019. */
  10020. radius: number;
  10021. private _renderPriority;
  10022. /**
  10023. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10024. * exceeding the number allowed of the materials.
  10025. */
  10026. renderPriority: number;
  10027. private _shadowEnabled;
  10028. /**
  10029. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10030. * the current shadow generator.
  10031. */
  10032. /**
  10033. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10034. * the current shadow generator.
  10035. */
  10036. shadowEnabled: boolean;
  10037. private _includedOnlyMeshes;
  10038. /**
  10039. * Gets the only meshes impacted by this light.
  10040. */
  10041. /**
  10042. * Sets the only meshes impacted by this light.
  10043. */
  10044. includedOnlyMeshes: AbstractMesh[];
  10045. private _excludedMeshes;
  10046. /**
  10047. * Gets the meshes not impacted by this light.
  10048. */
  10049. /**
  10050. * Sets the meshes not impacted by this light.
  10051. */
  10052. excludedMeshes: AbstractMesh[];
  10053. private _excludeWithLayerMask;
  10054. /**
  10055. * Gets the layer id use to find what meshes are not impacted by the light.
  10056. * Inactive if 0
  10057. */
  10058. /**
  10059. * Sets the layer id use to find what meshes are not impacted by the light.
  10060. * Inactive if 0
  10061. */
  10062. excludeWithLayerMask: number;
  10063. private _includeOnlyWithLayerMask;
  10064. /**
  10065. * Gets the layer id use to find what meshes are impacted by the light.
  10066. * Inactive if 0
  10067. */
  10068. /**
  10069. * Sets the layer id use to find what meshes are impacted by the light.
  10070. * Inactive if 0
  10071. */
  10072. includeOnlyWithLayerMask: number;
  10073. private _lightmapMode;
  10074. /**
  10075. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10076. */
  10077. /**
  10078. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10079. */
  10080. lightmapMode: number;
  10081. /**
  10082. * Shadow generator associted to the light.
  10083. * @hidden Internal use only.
  10084. */
  10085. _shadowGenerator: Nullable<IShadowGenerator>;
  10086. /**
  10087. * @hidden Internal use only.
  10088. */
  10089. _excludedMeshesIds: string[];
  10090. /**
  10091. * @hidden Internal use only.
  10092. */
  10093. _includedOnlyMeshesIds: string[];
  10094. /**
  10095. * The current light unifom buffer.
  10096. * @hidden Internal use only.
  10097. */
  10098. _uniformBuffer: UniformBuffer;
  10099. /** @hidden */
  10100. _renderId: number;
  10101. /**
  10102. * Creates a Light object in the scene.
  10103. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10104. * @param name The firendly name of the light
  10105. * @param scene The scene the light belongs too
  10106. */
  10107. constructor(name: string, scene: Scene);
  10108. protected abstract _buildUniformLayout(): void;
  10109. /**
  10110. * Sets the passed Effect "effect" with the Light information.
  10111. * @param effect The effect to update
  10112. * @param lightIndex The index of the light in the effect to update
  10113. * @returns The light
  10114. */
  10115. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10116. /**
  10117. * Sets the passed Effect "effect" with the Light information.
  10118. * @param effect The effect to update
  10119. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10120. * @returns The light
  10121. */
  10122. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10123. /**
  10124. * Returns the string "Light".
  10125. * @returns the class name
  10126. */
  10127. getClassName(): string;
  10128. /** @hidden */
  10129. readonly _isLight: boolean;
  10130. /**
  10131. * Converts the light information to a readable string for debug purpose.
  10132. * @param fullDetails Supports for multiple levels of logging within scene loading
  10133. * @returns the human readable light info
  10134. */
  10135. toString(fullDetails?: boolean): string;
  10136. /** @hidden */
  10137. protected _syncParentEnabledState(): void;
  10138. /**
  10139. * Set the enabled state of this node.
  10140. * @param value - the new enabled state
  10141. */
  10142. setEnabled(value: boolean): void;
  10143. /**
  10144. * Returns the Light associated shadow generator if any.
  10145. * @return the associated shadow generator.
  10146. */
  10147. getShadowGenerator(): Nullable<IShadowGenerator>;
  10148. /**
  10149. * Returns a Vector3, the absolute light position in the World.
  10150. * @returns the world space position of the light
  10151. */
  10152. getAbsolutePosition(): Vector3;
  10153. /**
  10154. * Specifies if the light will affect the passed mesh.
  10155. * @param mesh The mesh to test against the light
  10156. * @return true the mesh is affected otherwise, false.
  10157. */
  10158. canAffectMesh(mesh: AbstractMesh): boolean;
  10159. /**
  10160. * Sort function to order lights for rendering.
  10161. * @param a First Light object to compare to second.
  10162. * @param b Second Light object to compare first.
  10163. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10164. */
  10165. static CompareLightsPriority(a: Light, b: Light): number;
  10166. /**
  10167. * Releases resources associated with this node.
  10168. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10169. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10170. */
  10171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10172. /**
  10173. * Returns the light type ID (integer).
  10174. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10175. */
  10176. getTypeID(): number;
  10177. /**
  10178. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10179. * @returns the scaled intensity in intensity mode unit
  10180. */
  10181. getScaledIntensity(): number;
  10182. /**
  10183. * Returns a new Light object, named "name", from the current one.
  10184. * @param name The name of the cloned light
  10185. * @returns the new created light
  10186. */
  10187. clone(name: string): Nullable<Light>;
  10188. /**
  10189. * Serializes the current light into a Serialization object.
  10190. * @returns the serialized object.
  10191. */
  10192. serialize(): any;
  10193. /**
  10194. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10195. * This new light is named "name" and added to the passed scene.
  10196. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10197. * @param name The friendly name of the light
  10198. * @param scene The scene the new light will belong to
  10199. * @returns the constructor function
  10200. */
  10201. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10202. /**
  10203. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10204. * @param parsedLight The JSON representation of the light
  10205. * @param scene The scene to create the parsed light in
  10206. * @returns the created light after parsing
  10207. */
  10208. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10209. private _hookArrayForExcluded;
  10210. private _hookArrayForIncludedOnly;
  10211. private _resyncMeshes;
  10212. /**
  10213. * Forces the meshes to update their light related information in their rendering used effects
  10214. * @hidden Internal Use Only
  10215. */
  10216. _markMeshesAsLightDirty(): void;
  10217. /**
  10218. * Recomputes the cached photometric scale if needed.
  10219. */
  10220. private _computePhotometricScale;
  10221. /**
  10222. * Returns the Photometric Scale according to the light type and intensity mode.
  10223. */
  10224. private _getPhotometricScale;
  10225. /**
  10226. * Reorder the light in the scene according to their defined priority.
  10227. * @hidden Internal Use Only
  10228. */
  10229. _reorderLightsInScene(): void;
  10230. /**
  10231. * Prepares the list of defines specific to the light type.
  10232. * @param defines the list of defines
  10233. * @param lightIndex defines the index of the light for the effect
  10234. */
  10235. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10236. }
  10237. }
  10238. declare module "babylonjs/Actions/action" {
  10239. import { Observable } from "babylonjs/Misc/observable";
  10240. import { Condition } from "babylonjs/Actions/condition";
  10241. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10242. import { ActionManager } from "babylonjs/Actions/actionManager";
  10243. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10244. /**
  10245. * Interface used to define Action
  10246. */
  10247. export interface IAction {
  10248. /**
  10249. * Trigger for the action
  10250. */
  10251. trigger: number;
  10252. /** Options of the trigger */
  10253. triggerOptions: any;
  10254. /**
  10255. * Gets the trigger parameters
  10256. * @returns the trigger parameters
  10257. */
  10258. getTriggerParameter(): any;
  10259. /**
  10260. * Internal only - executes current action event
  10261. * @hidden
  10262. */
  10263. _executeCurrent(evt?: ActionEvent): void;
  10264. /**
  10265. * Serialize placeholder for child classes
  10266. * @param parent of child
  10267. * @returns the serialized object
  10268. */
  10269. serialize(parent: any): any;
  10270. /**
  10271. * Internal only
  10272. * @hidden
  10273. */
  10274. _prepare(): void;
  10275. /**
  10276. * Internal only - manager for action
  10277. * @hidden
  10278. */
  10279. _actionManager: AbstractActionManager;
  10280. /**
  10281. * Adds action to chain of actions, may be a DoNothingAction
  10282. * @param action defines the next action to execute
  10283. * @returns The action passed in
  10284. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10285. */
  10286. then(action: IAction): IAction;
  10287. }
  10288. /**
  10289. * The action to be carried out following a trigger
  10290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10291. */
  10292. export class Action implements IAction {
  10293. /** the trigger, with or without parameters, for the action */
  10294. triggerOptions: any;
  10295. /**
  10296. * Trigger for the action
  10297. */
  10298. trigger: number;
  10299. /**
  10300. * Internal only - manager for action
  10301. * @hidden
  10302. */
  10303. _actionManager: ActionManager;
  10304. private _nextActiveAction;
  10305. private _child;
  10306. private _condition?;
  10307. private _triggerParameter;
  10308. /**
  10309. * An event triggered prior to action being executed.
  10310. */
  10311. onBeforeExecuteObservable: Observable<Action>;
  10312. /**
  10313. * Creates a new Action
  10314. * @param triggerOptions the trigger, with or without parameters, for the action
  10315. * @param condition an optional determinant of action
  10316. */
  10317. constructor(
  10318. /** the trigger, with or without parameters, for the action */
  10319. triggerOptions: any, condition?: Condition);
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. _prepare(): void;
  10325. /**
  10326. * Gets the trigger parameters
  10327. * @returns the trigger parameters
  10328. */
  10329. getTriggerParameter(): any;
  10330. /**
  10331. * Internal only - executes current action event
  10332. * @hidden
  10333. */
  10334. _executeCurrent(evt?: ActionEvent): void;
  10335. /**
  10336. * Execute placeholder for child classes
  10337. * @param evt optional action event
  10338. */
  10339. execute(evt?: ActionEvent): void;
  10340. /**
  10341. * Skips to next active action
  10342. */
  10343. skipToNextActiveAction(): void;
  10344. /**
  10345. * Adds action to chain of actions, may be a DoNothingAction
  10346. * @param action defines the next action to execute
  10347. * @returns The action passed in
  10348. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10349. */
  10350. then(action: Action): Action;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. _getProperty(propertyPath: string): string;
  10356. /**
  10357. * Internal only
  10358. * @hidden
  10359. */
  10360. _getEffectiveTarget(target: any, propertyPath: string): any;
  10361. /**
  10362. * Serialize placeholder for child classes
  10363. * @param parent of child
  10364. * @returns the serialized object
  10365. */
  10366. serialize(parent: any): any;
  10367. /**
  10368. * Internal only called by serialize
  10369. * @hidden
  10370. */
  10371. protected _serialize(serializedAction: any, parent?: any): any;
  10372. /**
  10373. * Internal only
  10374. * @hidden
  10375. */
  10376. static _SerializeValueAsString: (value: any) => string;
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10382. name: string;
  10383. targetType: string;
  10384. value: string;
  10385. };
  10386. }
  10387. }
  10388. declare module "babylonjs/Actions/condition" {
  10389. import { ActionManager } from "babylonjs/Actions/actionManager";
  10390. /**
  10391. * A Condition applied to an Action
  10392. */
  10393. export class Condition {
  10394. /**
  10395. * Internal only - manager for action
  10396. * @hidden
  10397. */
  10398. _actionManager: ActionManager;
  10399. /**
  10400. * Internal only
  10401. * @hidden
  10402. */
  10403. _evaluationId: number;
  10404. /**
  10405. * Internal only
  10406. * @hidden
  10407. */
  10408. _currentResult: boolean;
  10409. /**
  10410. * Creates a new Condition
  10411. * @param actionManager the manager of the action the condition is applied to
  10412. */
  10413. constructor(actionManager: ActionManager);
  10414. /**
  10415. * Check if the current condition is valid
  10416. * @returns a boolean
  10417. */
  10418. isValid(): boolean;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. _getProperty(propertyPath: string): string;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /**
  10430. * Serialize placeholder for child classes
  10431. * @returns the serialized object
  10432. */
  10433. serialize(): any;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. protected _serialize(serializedCondition: any): any;
  10439. }
  10440. /**
  10441. * Defines specific conditional operators as extensions of Condition
  10442. */
  10443. export class ValueCondition extends Condition {
  10444. /** path to specify the property of the target the conditional operator uses */
  10445. propertyPath: string;
  10446. /** the value compared by the conditional operator against the current value of the property */
  10447. value: any;
  10448. /** the conditional operator, default ValueCondition.IsEqual */
  10449. operator: number;
  10450. /**
  10451. * Internal only
  10452. * @hidden
  10453. */
  10454. private static _IsEqual;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private static _IsDifferent;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private static _IsGreater;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. private static _IsLesser;
  10470. /**
  10471. * returns the number for IsEqual
  10472. */
  10473. static readonly IsEqual: number;
  10474. /**
  10475. * Returns the number for IsDifferent
  10476. */
  10477. static readonly IsDifferent: number;
  10478. /**
  10479. * Returns the number for IsGreater
  10480. */
  10481. static readonly IsGreater: number;
  10482. /**
  10483. * Returns the number for IsLesser
  10484. */
  10485. static readonly IsLesser: number;
  10486. /**
  10487. * Internal only The action manager for the condition
  10488. * @hidden
  10489. */
  10490. _actionManager: ActionManager;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. private _target;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. private _effectiveTarget;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. private _property;
  10506. /**
  10507. * Creates a new ValueCondition
  10508. * @param actionManager manager for the action the condition applies to
  10509. * @param target for the action
  10510. * @param propertyPath path to specify the property of the target the conditional operator uses
  10511. * @param value the value compared by the conditional operator against the current value of the property
  10512. * @param operator the conditional operator, default ValueCondition.IsEqual
  10513. */
  10514. constructor(actionManager: ActionManager, target: any,
  10515. /** path to specify the property of the target the conditional operator uses */
  10516. propertyPath: string,
  10517. /** the value compared by the conditional operator against the current value of the property */
  10518. value: any,
  10519. /** the conditional operator, default ValueCondition.IsEqual */
  10520. operator?: number);
  10521. /**
  10522. * Compares the given value with the property value for the specified conditional operator
  10523. * @returns the result of the comparison
  10524. */
  10525. isValid(): boolean;
  10526. /**
  10527. * Serialize the ValueCondition into a JSON compatible object
  10528. * @returns serialization object
  10529. */
  10530. serialize(): any;
  10531. /**
  10532. * Gets the name of the conditional operator for the ValueCondition
  10533. * @param operator the conditional operator
  10534. * @returns the name
  10535. */
  10536. static GetOperatorName(operator: number): string;
  10537. }
  10538. /**
  10539. * Defines a predicate condition as an extension of Condition
  10540. */
  10541. export class PredicateCondition extends Condition {
  10542. /** defines the predicate function used to validate the condition */
  10543. predicate: () => boolean;
  10544. /**
  10545. * Internal only - manager for action
  10546. * @hidden
  10547. */
  10548. _actionManager: ActionManager;
  10549. /**
  10550. * Creates a new PredicateCondition
  10551. * @param actionManager manager for the action the condition applies to
  10552. * @param predicate defines the predicate function used to validate the condition
  10553. */
  10554. constructor(actionManager: ActionManager,
  10555. /** defines the predicate function used to validate the condition */
  10556. predicate: () => boolean);
  10557. /**
  10558. * @returns the validity of the predicate condition
  10559. */
  10560. isValid(): boolean;
  10561. }
  10562. /**
  10563. * Defines a state condition as an extension of Condition
  10564. */
  10565. export class StateCondition extends Condition {
  10566. /** Value to compare with target state */
  10567. value: string;
  10568. /**
  10569. * Internal only - manager for action
  10570. * @hidden
  10571. */
  10572. _actionManager: ActionManager;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. private _target;
  10578. /**
  10579. * Creates a new StateCondition
  10580. * @param actionManager manager for the action the condition applies to
  10581. * @param target of the condition
  10582. * @param value to compare with target state
  10583. */
  10584. constructor(actionManager: ActionManager, target: any,
  10585. /** Value to compare with target state */
  10586. value: string);
  10587. /**
  10588. * Gets a boolean indicating if the current condition is met
  10589. * @returns the validity of the state
  10590. */
  10591. isValid(): boolean;
  10592. /**
  10593. * Serialize the StateCondition into a JSON compatible object
  10594. * @returns serialization object
  10595. */
  10596. serialize(): any;
  10597. }
  10598. }
  10599. declare module "babylonjs/Actions/directActions" {
  10600. import { Action } from "babylonjs/Actions/action";
  10601. import { Condition } from "babylonjs/Actions/condition";
  10602. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10603. /**
  10604. * This defines an action responsible to toggle a boolean once triggered.
  10605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10606. */
  10607. export class SwitchBooleanAction extends Action {
  10608. /**
  10609. * The path to the boolean property in the target object
  10610. */
  10611. propertyPath: string;
  10612. private _target;
  10613. private _effectiveTarget;
  10614. private _property;
  10615. /**
  10616. * Instantiate the action
  10617. * @param triggerOptions defines the trigger options
  10618. * @param target defines the object containing the boolean
  10619. * @param propertyPath defines the path to the boolean property in the target object
  10620. * @param condition defines the trigger related conditions
  10621. */
  10622. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10623. /** @hidden */
  10624. _prepare(): void;
  10625. /**
  10626. * Execute the action toggle the boolean value.
  10627. */
  10628. execute(): void;
  10629. /**
  10630. * Serializes the actions and its related information.
  10631. * @param parent defines the object to serialize in
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. }
  10636. /**
  10637. * This defines an action responsible to set a the state field of the target
  10638. * to a desired value once triggered.
  10639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10640. */
  10641. export class SetStateAction extends Action {
  10642. /**
  10643. * The value to store in the state field.
  10644. */
  10645. value: string;
  10646. private _target;
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param target defines the object containing the state property
  10651. * @param value defines the value to store in the state field
  10652. * @param condition defines the trigger related conditions
  10653. */
  10654. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10655. /**
  10656. * Execute the action and store the value on the target state property.
  10657. */
  10658. execute(): void;
  10659. /**
  10660. * Serializes the actions and its related information.
  10661. * @param parent defines the object to serialize in
  10662. * @returns the serialized object
  10663. */
  10664. serialize(parent: any): any;
  10665. }
  10666. /**
  10667. * This defines an action responsible to set a property of the target
  10668. * to a desired value once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class SetValueAction extends Action {
  10672. /**
  10673. * The path of the property to set in the target.
  10674. */
  10675. propertyPath: string;
  10676. /**
  10677. * The value to set in the property
  10678. */
  10679. value: any;
  10680. private _target;
  10681. private _effectiveTarget;
  10682. private _property;
  10683. /**
  10684. * Instantiate the action
  10685. * @param triggerOptions defines the trigger options
  10686. * @param target defines the object containing the property
  10687. * @param propertyPath defines the path of the property to set in the target
  10688. * @param value defines the value to set in the property
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and set the targetted property to the desired value.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible to increment the target value
  10707. * to a desired value once triggered.
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10709. */
  10710. export class IncrementValueAction extends Action {
  10711. /**
  10712. * The path of the property to increment in the target.
  10713. */
  10714. propertyPath: string;
  10715. /**
  10716. * The value we should increment the property by.
  10717. */
  10718. value: any;
  10719. private _target;
  10720. private _effectiveTarget;
  10721. private _property;
  10722. /**
  10723. * Instantiate the action
  10724. * @param triggerOptions defines the trigger options
  10725. * @param target defines the object containing the property
  10726. * @param propertyPath defines the path of the property to increment in the target
  10727. * @param value defines the value value we should increment the property by
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and increment the target of the value amount.
  10735. */
  10736. execute(): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible to start an animation once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class PlayAnimationAction extends Action {
  10749. /**
  10750. * Where the animation should start (animation frame)
  10751. */
  10752. from: number;
  10753. /**
  10754. * Where the animation should stop (animation frame)
  10755. */
  10756. to: number;
  10757. /**
  10758. * Define if the animation should loop or stop after the first play.
  10759. */
  10760. loop?: boolean;
  10761. private _target;
  10762. /**
  10763. * Instantiate the action
  10764. * @param triggerOptions defines the trigger options
  10765. * @param target defines the target animation or animation name
  10766. * @param from defines from where the animation should start (animation frame)
  10767. * @param end defines where the animation should stop (animation frame)
  10768. * @param loop defines if the animation should loop or stop after the first play
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10772. /** @hidden */
  10773. _prepare(): void;
  10774. /**
  10775. * Execute the action and play the animation.
  10776. */
  10777. execute(): void;
  10778. /**
  10779. * Serializes the actions and its related information.
  10780. * @param parent defines the object to serialize in
  10781. * @returns the serialized object
  10782. */
  10783. serialize(parent: any): any;
  10784. }
  10785. /**
  10786. * This defines an action responsible to stop an animation once triggered.
  10787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10788. */
  10789. export class StopAnimationAction extends Action {
  10790. private _target;
  10791. /**
  10792. * Instantiate the action
  10793. * @param triggerOptions defines the trigger options
  10794. * @param target defines the target animation or animation name
  10795. * @param condition defines the trigger related conditions
  10796. */
  10797. constructor(triggerOptions: any, target: any, condition?: Condition);
  10798. /** @hidden */
  10799. _prepare(): void;
  10800. /**
  10801. * Execute the action and stop the animation.
  10802. */
  10803. execute(): void;
  10804. /**
  10805. * Serializes the actions and its related information.
  10806. * @param parent defines the object to serialize in
  10807. * @returns the serialized object
  10808. */
  10809. serialize(parent: any): any;
  10810. }
  10811. /**
  10812. * This defines an action responsible that does nothing once triggered.
  10813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10814. */
  10815. export class DoNothingAction extends Action {
  10816. /**
  10817. * Instantiate the action
  10818. * @param triggerOptions defines the trigger options
  10819. * @param condition defines the trigger related conditions
  10820. */
  10821. constructor(triggerOptions?: any, condition?: Condition);
  10822. /**
  10823. * Execute the action and do nothing.
  10824. */
  10825. execute(): void;
  10826. /**
  10827. * Serializes the actions and its related information.
  10828. * @param parent defines the object to serialize in
  10829. * @returns the serialized object
  10830. */
  10831. serialize(parent: any): any;
  10832. }
  10833. /**
  10834. * This defines an action responsible to trigger several actions once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class CombineAction extends Action {
  10838. /**
  10839. * The list of aggregated animations to run.
  10840. */
  10841. children: Action[];
  10842. /**
  10843. * Instantiate the action
  10844. * @param triggerOptions defines the trigger options
  10845. * @param children defines the list of aggregated animations to run
  10846. * @param condition defines the trigger related conditions
  10847. */
  10848. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10849. /** @hidden */
  10850. _prepare(): void;
  10851. /**
  10852. * Execute the action and executes all the aggregated actions.
  10853. */
  10854. execute(evt: ActionEvent): void;
  10855. /**
  10856. * Serializes the actions and its related information.
  10857. * @param parent defines the object to serialize in
  10858. * @returns the serialized object
  10859. */
  10860. serialize(parent: any): any;
  10861. }
  10862. /**
  10863. * This defines an action responsible to run code (external event) once triggered.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export class ExecuteCodeAction extends Action {
  10867. /**
  10868. * The callback function to run.
  10869. */
  10870. func: (evt: ActionEvent) => void;
  10871. /**
  10872. * Instantiate the action
  10873. * @param triggerOptions defines the trigger options
  10874. * @param func defines the callback function to run
  10875. * @param condition defines the trigger related conditions
  10876. */
  10877. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10878. /**
  10879. * Execute the action and run the attached code.
  10880. */
  10881. execute(evt: ActionEvent): void;
  10882. }
  10883. /**
  10884. * This defines an action responsible to set the parent property of the target once triggered.
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10886. */
  10887. export class SetParentAction extends Action {
  10888. private _parent;
  10889. private _target;
  10890. /**
  10891. * Instantiate the action
  10892. * @param triggerOptions defines the trigger options
  10893. * @param target defines the target containing the parent property
  10894. * @param parent defines from where the animation should start (animation frame)
  10895. * @param condition defines the trigger related conditions
  10896. */
  10897. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10898. /** @hidden */
  10899. _prepare(): void;
  10900. /**
  10901. * Execute the action and set the parent property.
  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. declare module "babylonjs/Actions/actionManager" {
  10913. import { Nullable } from "babylonjs/types";
  10914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10915. import { Scene } from "babylonjs/scene";
  10916. import { IAction } from "babylonjs/Actions/action";
  10917. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10918. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10919. /**
  10920. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10921. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class ActionManager extends AbstractActionManager {
  10925. /**
  10926. * Nothing
  10927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10928. */
  10929. static readonly NothingTrigger: number;
  10930. /**
  10931. * On pick
  10932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10933. */
  10934. static readonly OnPickTrigger: number;
  10935. /**
  10936. * On left pick
  10937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10938. */
  10939. static readonly OnLeftPickTrigger: number;
  10940. /**
  10941. * On right pick
  10942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10943. */
  10944. static readonly OnRightPickTrigger: number;
  10945. /**
  10946. * On center pick
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10948. */
  10949. static readonly OnCenterPickTrigger: number;
  10950. /**
  10951. * On pick down
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10953. */
  10954. static readonly OnPickDownTrigger: number;
  10955. /**
  10956. * On double pick
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10958. */
  10959. static readonly OnDoublePickTrigger: number;
  10960. /**
  10961. * On pick up
  10962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10963. */
  10964. static readonly OnPickUpTrigger: number;
  10965. /**
  10966. * On pick out.
  10967. * This trigger will only be raised if you also declared a OnPickDown
  10968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10969. */
  10970. static readonly OnPickOutTrigger: number;
  10971. /**
  10972. * On long press
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10974. */
  10975. static readonly OnLongPressTrigger: number;
  10976. /**
  10977. * On pointer over
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10979. */
  10980. static readonly OnPointerOverTrigger: number;
  10981. /**
  10982. * On pointer out
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10984. */
  10985. static readonly OnPointerOutTrigger: number;
  10986. /**
  10987. * On every frame
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10989. */
  10990. static readonly OnEveryFrameTrigger: number;
  10991. /**
  10992. * On intersection enter
  10993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10994. */
  10995. static readonly OnIntersectionEnterTrigger: number;
  10996. /**
  10997. * On intersection exit
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10999. */
  11000. static readonly OnIntersectionExitTrigger: number;
  11001. /**
  11002. * On key down
  11003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11004. */
  11005. static readonly OnKeyDownTrigger: number;
  11006. /**
  11007. * On key up
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11009. */
  11010. static readonly OnKeyUpTrigger: number;
  11011. private _scene;
  11012. /**
  11013. * Creates a new action manager
  11014. * @param scene defines the hosting scene
  11015. */
  11016. constructor(scene: Scene);
  11017. /**
  11018. * Releases all associated resources
  11019. */
  11020. dispose(): void;
  11021. /**
  11022. * Gets hosting scene
  11023. * @returns the hosting scene
  11024. */
  11025. getScene(): Scene;
  11026. /**
  11027. * Does this action manager handles actions of any of the given triggers
  11028. * @param triggers defines the triggers to be tested
  11029. * @return a boolean indicating whether one (or more) of the triggers is handled
  11030. */
  11031. hasSpecificTriggers(triggers: number[]): boolean;
  11032. /**
  11033. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11034. * speed.
  11035. * @param triggerA defines the trigger to be tested
  11036. * @param triggerB defines the trigger to be tested
  11037. * @return a boolean indicating whether one (or more) of the triggers is handled
  11038. */
  11039. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11040. /**
  11041. * Does this action manager handles actions of a given trigger
  11042. * @param trigger defines the trigger to be tested
  11043. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11044. * @return whether the trigger is handled
  11045. */
  11046. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11047. /**
  11048. * Does this action manager has pointer triggers
  11049. */
  11050. readonly hasPointerTriggers: boolean;
  11051. /**
  11052. * Does this action manager has pick triggers
  11053. */
  11054. readonly hasPickTriggers: boolean;
  11055. /**
  11056. * Registers an action to this action manager
  11057. * @param action defines the action to be registered
  11058. * @return the action amended (prepared) after registration
  11059. */
  11060. registerAction(action: IAction): Nullable<IAction>;
  11061. /**
  11062. * Unregisters an action to this action manager
  11063. * @param action defines the action to be unregistered
  11064. * @return a boolean indicating whether the action has been unregistered
  11065. */
  11066. unregisterAction(action: IAction): Boolean;
  11067. /**
  11068. * Process a specific trigger
  11069. * @param trigger defines the trigger to process
  11070. * @param evt defines the event details to be processed
  11071. */
  11072. processTrigger(trigger: number, evt?: IActionEvent): void;
  11073. /** @hidden */
  11074. _getEffectiveTarget(target: any, propertyPath: string): any;
  11075. /** @hidden */
  11076. _getProperty(propertyPath: string): string;
  11077. /**
  11078. * Serialize this manager to a JSON object
  11079. * @param name defines the property name to store this manager
  11080. * @returns a JSON representation of this manager
  11081. */
  11082. serialize(name: string): any;
  11083. /**
  11084. * Creates a new ActionManager from a JSON data
  11085. * @param parsedActions defines the JSON data to read from
  11086. * @param object defines the hosting mesh
  11087. * @param scene defines the hosting scene
  11088. */
  11089. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11090. /**
  11091. * Get a trigger name by index
  11092. * @param trigger defines the trigger index
  11093. * @returns a trigger name
  11094. */
  11095. static GetTriggerName(trigger: number): string;
  11096. }
  11097. }
  11098. declare module "babylonjs/Culling/ray" {
  11099. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11100. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11102. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11103. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11104. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11105. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11106. import { Plane } from "babylonjs/Maths/math.plane";
  11107. /**
  11108. * Class representing a ray with position and direction
  11109. */
  11110. export class Ray {
  11111. /** origin point */
  11112. origin: Vector3;
  11113. /** direction */
  11114. direction: Vector3;
  11115. /** length of the ray */
  11116. length: number;
  11117. private static readonly TmpVector3;
  11118. private _tmpRay;
  11119. /**
  11120. * Creates a new ray
  11121. * @param origin origin point
  11122. * @param direction direction
  11123. * @param length length of the ray
  11124. */
  11125. constructor(
  11126. /** origin point */
  11127. origin: Vector3,
  11128. /** direction */
  11129. direction: Vector3,
  11130. /** length of the ray */
  11131. length?: number);
  11132. /**
  11133. * Checks if the ray intersects a box
  11134. * @param minimum bound of the box
  11135. * @param maximum bound of the box
  11136. * @param intersectionTreshold extra extend to be added to the box in all direction
  11137. * @returns if the box was hit
  11138. */
  11139. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11140. /**
  11141. * Checks if the ray intersects a box
  11142. * @param box the bounding box to check
  11143. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11144. * @returns if the box was hit
  11145. */
  11146. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11147. /**
  11148. * If the ray hits a sphere
  11149. * @param sphere the bounding sphere to check
  11150. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11151. * @returns true if it hits the sphere
  11152. */
  11153. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11154. /**
  11155. * If the ray hits a triange
  11156. * @param vertex0 triangle vertex
  11157. * @param vertex1 triangle vertex
  11158. * @param vertex2 triangle vertex
  11159. * @returns intersection information if hit
  11160. */
  11161. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11162. /**
  11163. * Checks if ray intersects a plane
  11164. * @param plane the plane to check
  11165. * @returns the distance away it was hit
  11166. */
  11167. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11168. /**
  11169. * Calculate the intercept of a ray on a given axis
  11170. * @param axis to check 'x' | 'y' | 'z'
  11171. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11172. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11173. */
  11174. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11175. /**
  11176. * Checks if ray intersects a mesh
  11177. * @param mesh the mesh to check
  11178. * @param fastCheck if only the bounding box should checked
  11179. * @returns picking info of the intersecton
  11180. */
  11181. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11182. /**
  11183. * Checks if ray intersects a mesh
  11184. * @param meshes the meshes to check
  11185. * @param fastCheck if only the bounding box should checked
  11186. * @param results array to store result in
  11187. * @returns Array of picking infos
  11188. */
  11189. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11190. private _comparePickingInfo;
  11191. private static smallnum;
  11192. private static rayl;
  11193. /**
  11194. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11195. * @param sega the first point of the segment to test the intersection against
  11196. * @param segb the second point of the segment to test the intersection against
  11197. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11198. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11199. */
  11200. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11201. /**
  11202. * Update the ray from viewport position
  11203. * @param x position
  11204. * @param y y position
  11205. * @param viewportWidth viewport width
  11206. * @param viewportHeight viewport height
  11207. * @param world world matrix
  11208. * @param view view matrix
  11209. * @param projection projection matrix
  11210. * @returns this ray updated
  11211. */
  11212. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11213. /**
  11214. * Creates a ray with origin and direction of 0,0,0
  11215. * @returns the new ray
  11216. */
  11217. static Zero(): Ray;
  11218. /**
  11219. * Creates a new ray from screen space and viewport
  11220. * @param x position
  11221. * @param y y position
  11222. * @param viewportWidth viewport width
  11223. * @param viewportHeight viewport height
  11224. * @param world world matrix
  11225. * @param view view matrix
  11226. * @param projection projection matrix
  11227. * @returns new ray
  11228. */
  11229. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11230. /**
  11231. * 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
  11232. * transformed to the given world matrix.
  11233. * @param origin The origin point
  11234. * @param end The end point
  11235. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11236. * @returns the new ray
  11237. */
  11238. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11239. /**
  11240. * Transforms a ray by a matrix
  11241. * @param ray ray to transform
  11242. * @param matrix matrix to apply
  11243. * @returns the resulting new ray
  11244. */
  11245. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11246. /**
  11247. * Transforms a ray by a matrix
  11248. * @param ray ray to transform
  11249. * @param matrix matrix to apply
  11250. * @param result ray to store result in
  11251. */
  11252. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11253. /**
  11254. * Unproject a ray from screen space to object space
  11255. * @param sourceX defines the screen space x coordinate to use
  11256. * @param sourceY defines the screen space y coordinate to use
  11257. * @param viewportWidth defines the current width of the viewport
  11258. * @param viewportHeight defines the current height of the viewport
  11259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11260. * @param view defines the view matrix to use
  11261. * @param projection defines the projection matrix to use
  11262. */
  11263. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11264. }
  11265. /**
  11266. * Type used to define predicate used to select faces when a mesh intersection is detected
  11267. */
  11268. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11269. module "babylonjs/scene" {
  11270. interface Scene {
  11271. /** @hidden */
  11272. _tempPickingRay: Nullable<Ray>;
  11273. /** @hidden */
  11274. _cachedRayForTransform: Ray;
  11275. /** @hidden */
  11276. _pickWithRayInverseMatrix: Matrix;
  11277. /** @hidden */
  11278. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11279. /** @hidden */
  11280. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11281. }
  11282. }
  11283. }
  11284. declare module "babylonjs/sceneComponent" {
  11285. import { Scene } from "babylonjs/scene";
  11286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11288. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11289. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11290. import { Nullable } from "babylonjs/types";
  11291. import { Camera } from "babylonjs/Cameras/camera";
  11292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11293. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11294. import { AbstractScene } from "babylonjs/abstractScene";
  11295. import { Mesh } from "babylonjs/Meshes/mesh";
  11296. /**
  11297. * Groups all the scene component constants in one place to ease maintenance.
  11298. * @hidden
  11299. */
  11300. export class SceneComponentConstants {
  11301. static readonly NAME_EFFECTLAYER: string;
  11302. static readonly NAME_LAYER: string;
  11303. static readonly NAME_LENSFLARESYSTEM: string;
  11304. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11305. static readonly NAME_PARTICLESYSTEM: string;
  11306. static readonly NAME_GAMEPAD: string;
  11307. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11308. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11309. static readonly NAME_DEPTHRENDERER: string;
  11310. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11311. static readonly NAME_SPRITE: string;
  11312. static readonly NAME_OUTLINERENDERER: string;
  11313. static readonly NAME_PROCEDURALTEXTURE: string;
  11314. static readonly NAME_SHADOWGENERATOR: string;
  11315. static readonly NAME_OCTREE: string;
  11316. static readonly NAME_PHYSICSENGINE: string;
  11317. static readonly NAME_AUDIO: string;
  11318. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11319. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11320. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11321. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11322. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11323. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11324. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11325. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11326. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11327. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11328. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11329. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11330. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11331. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11332. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11333. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11334. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11335. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11336. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11337. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11338. static readonly STEP_AFTERRENDER_AUDIO: number;
  11339. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11340. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11341. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11342. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11343. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11344. static readonly STEP_POINTERMOVE_SPRITE: number;
  11345. static readonly STEP_POINTERDOWN_SPRITE: number;
  11346. static readonly STEP_POINTERUP_SPRITE: number;
  11347. }
  11348. /**
  11349. * This represents a scene component.
  11350. *
  11351. * This is used to decouple the dependency the scene is having on the different workloads like
  11352. * layers, post processes...
  11353. */
  11354. export interface ISceneComponent {
  11355. /**
  11356. * The name of the component. Each component must have a unique name.
  11357. */
  11358. name: string;
  11359. /**
  11360. * The scene the component belongs to.
  11361. */
  11362. scene: Scene;
  11363. /**
  11364. * Register the component to one instance of a scene.
  11365. */
  11366. register(): void;
  11367. /**
  11368. * Rebuilds the elements related to this component in case of
  11369. * context lost for instance.
  11370. */
  11371. rebuild(): void;
  11372. /**
  11373. * Disposes the component and the associated ressources.
  11374. */
  11375. dispose(): void;
  11376. }
  11377. /**
  11378. * This represents a SERIALIZABLE scene component.
  11379. *
  11380. * This extends Scene Component to add Serialization methods on top.
  11381. */
  11382. export interface ISceneSerializableComponent extends ISceneComponent {
  11383. /**
  11384. * Adds all the elements from the container to the scene
  11385. * @param container the container holding the elements
  11386. */
  11387. addFromContainer(container: AbstractScene): void;
  11388. /**
  11389. * Removes all the elements in the container from the scene
  11390. * @param container contains the elements to remove
  11391. * @param dispose if the removed element should be disposed (default: false)
  11392. */
  11393. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11394. /**
  11395. * Serializes the component data to the specified json object
  11396. * @param serializationObject The object to serialize to
  11397. */
  11398. serialize(serializationObject: any): void;
  11399. }
  11400. /**
  11401. * Strong typing of a Mesh related stage step action
  11402. */
  11403. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11404. /**
  11405. * Strong typing of a Evaluate Sub Mesh related stage step action
  11406. */
  11407. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11408. /**
  11409. * Strong typing of a Active Mesh related stage step action
  11410. */
  11411. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11412. /**
  11413. * Strong typing of a Camera related stage step action
  11414. */
  11415. export type CameraStageAction = (camera: Camera) => void;
  11416. /**
  11417. * Strong typing of a Camera Frame buffer related stage step action
  11418. */
  11419. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11420. /**
  11421. * Strong typing of a Render Target related stage step action
  11422. */
  11423. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11424. /**
  11425. * Strong typing of a RenderingGroup related stage step action
  11426. */
  11427. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11428. /**
  11429. * Strong typing of a Mesh Render related stage step action
  11430. */
  11431. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11432. /**
  11433. * Strong typing of a simple stage step action
  11434. */
  11435. export type SimpleStageAction = () => void;
  11436. /**
  11437. * Strong typing of a render target action.
  11438. */
  11439. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11440. /**
  11441. * Strong typing of a pointer move action.
  11442. */
  11443. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11444. /**
  11445. * Strong typing of a pointer up/down action.
  11446. */
  11447. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11448. /**
  11449. * Representation of a stage in the scene (Basically a list of ordered steps)
  11450. * @hidden
  11451. */
  11452. export class Stage<T extends Function> extends Array<{
  11453. index: number;
  11454. component: ISceneComponent;
  11455. action: T;
  11456. }> {
  11457. /**
  11458. * Hide ctor from the rest of the world.
  11459. * @param items The items to add.
  11460. */
  11461. private constructor();
  11462. /**
  11463. * Creates a new Stage.
  11464. * @returns A new instance of a Stage
  11465. */
  11466. static Create<T extends Function>(): Stage<T>;
  11467. /**
  11468. * Registers a step in an ordered way in the targeted stage.
  11469. * @param index Defines the position to register the step in
  11470. * @param component Defines the component attached to the step
  11471. * @param action Defines the action to launch during the step
  11472. */
  11473. registerStep(index: number, component: ISceneComponent, action: T): void;
  11474. /**
  11475. * Clears all the steps from the stage.
  11476. */
  11477. clear(): void;
  11478. }
  11479. }
  11480. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11481. import { Nullable } from "babylonjs/types";
  11482. import { Observable } from "babylonjs/Misc/observable";
  11483. import { Scene } from "babylonjs/scene";
  11484. import { Sprite } from "babylonjs/Sprites/sprite";
  11485. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11486. import { Ray } from "babylonjs/Culling/ray";
  11487. import { Camera } from "babylonjs/Cameras/camera";
  11488. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11489. import { ISceneComponent } from "babylonjs/sceneComponent";
  11490. module "babylonjs/scene" {
  11491. interface Scene {
  11492. /** @hidden */
  11493. _pointerOverSprite: Nullable<Sprite>;
  11494. /** @hidden */
  11495. _pickedDownSprite: Nullable<Sprite>;
  11496. /** @hidden */
  11497. _tempSpritePickingRay: Nullable<Ray>;
  11498. /**
  11499. * All of the sprite managers added to this scene
  11500. * @see http://doc.babylonjs.com/babylon101/sprites
  11501. */
  11502. spriteManagers: Array<ISpriteManager>;
  11503. /**
  11504. * An event triggered when sprites rendering is about to start
  11505. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11506. */
  11507. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11508. /**
  11509. * An event triggered when sprites rendering is done
  11510. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11511. */
  11512. onAfterSpritesRenderingObservable: Observable<Scene>;
  11513. /** @hidden */
  11514. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11515. /** Launch a ray to try to pick a sprite in the scene
  11516. * @param x position on screen
  11517. * @param y position on screen
  11518. * @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
  11519. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11520. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11521. * @returns a PickingInfo
  11522. */
  11523. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11524. /** Use the given ray to pick a sprite in the scene
  11525. * @param ray The ray (in world space) to use to pick meshes
  11526. * @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
  11527. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11528. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11529. * @returns a PickingInfo
  11530. */
  11531. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11532. /** @hidden */
  11533. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11534. /** Launch a ray to try to pick sprites in the scene
  11535. * @param x position on screen
  11536. * @param y position on screen
  11537. * @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
  11538. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11539. * @returns a PickingInfo array
  11540. */
  11541. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11542. /** Use the given ray to pick sprites in the scene
  11543. * @param ray The ray (in world space) to use to pick meshes
  11544. * @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
  11545. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11546. * @returns a PickingInfo array
  11547. */
  11548. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11549. /**
  11550. * Force the sprite under the pointer
  11551. * @param sprite defines the sprite to use
  11552. */
  11553. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11554. /**
  11555. * Gets the sprite under the pointer
  11556. * @returns a Sprite or null if no sprite is under the pointer
  11557. */
  11558. getPointerOverSprite(): Nullable<Sprite>;
  11559. }
  11560. }
  11561. /**
  11562. * Defines the sprite scene component responsible to manage sprites
  11563. * in a given scene.
  11564. */
  11565. export class SpriteSceneComponent implements ISceneComponent {
  11566. /**
  11567. * The component name helpfull to identify the component in the list of scene components.
  11568. */
  11569. readonly name: string;
  11570. /**
  11571. * The scene the component belongs to.
  11572. */
  11573. scene: Scene;
  11574. /** @hidden */
  11575. private _spritePredicate;
  11576. /**
  11577. * Creates a new instance of the component for the given scene
  11578. * @param scene Defines the scene to register the component in
  11579. */
  11580. constructor(scene: Scene);
  11581. /**
  11582. * Registers the component in a given scene
  11583. */
  11584. register(): void;
  11585. /**
  11586. * Rebuilds the elements related to this component in case of
  11587. * context lost for instance.
  11588. */
  11589. rebuild(): void;
  11590. /**
  11591. * Disposes the component and the associated ressources.
  11592. */
  11593. dispose(): void;
  11594. private _pickSpriteButKeepRay;
  11595. private _pointerMove;
  11596. private _pointerDown;
  11597. private _pointerUp;
  11598. }
  11599. }
  11600. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11601. /** @hidden */
  11602. export var fogFragmentDeclaration: {
  11603. name: string;
  11604. shader: string;
  11605. };
  11606. }
  11607. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11608. /** @hidden */
  11609. export var fogFragment: {
  11610. name: string;
  11611. shader: string;
  11612. };
  11613. }
  11614. declare module "babylonjs/Shaders/sprites.fragment" {
  11615. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11616. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11617. /** @hidden */
  11618. export var spritesPixelShader: {
  11619. name: string;
  11620. shader: string;
  11621. };
  11622. }
  11623. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11624. /** @hidden */
  11625. export var fogVertexDeclaration: {
  11626. name: string;
  11627. shader: string;
  11628. };
  11629. }
  11630. declare module "babylonjs/Shaders/sprites.vertex" {
  11631. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11632. /** @hidden */
  11633. export var spritesVertexShader: {
  11634. name: string;
  11635. shader: string;
  11636. };
  11637. }
  11638. declare module "babylonjs/Sprites/spriteManager" {
  11639. import { IDisposable, Scene } from "babylonjs/scene";
  11640. import { Nullable } from "babylonjs/types";
  11641. import { Observable } from "babylonjs/Misc/observable";
  11642. import { Sprite } from "babylonjs/Sprites/sprite";
  11643. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11644. import { Camera } from "babylonjs/Cameras/camera";
  11645. import { Texture } from "babylonjs/Materials/Textures/texture";
  11646. import "babylonjs/Shaders/sprites.fragment";
  11647. import "babylonjs/Shaders/sprites.vertex";
  11648. import { Ray } from "babylonjs/Culling/ray";
  11649. /**
  11650. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11651. */
  11652. export interface ISpriteManager extends IDisposable {
  11653. /**
  11654. * Restricts the camera to viewing objects with the same layerMask.
  11655. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11656. */
  11657. layerMask: number;
  11658. /**
  11659. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11660. */
  11661. isPickable: boolean;
  11662. /**
  11663. * Specifies the rendering group id for this mesh (0 by default)
  11664. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11665. */
  11666. renderingGroupId: number;
  11667. /**
  11668. * Defines the list of sprites managed by the manager.
  11669. */
  11670. sprites: Array<Sprite>;
  11671. /**
  11672. * Tests the intersection of a sprite with a specific ray.
  11673. * @param ray The ray we are sending to test the collision
  11674. * @param camera The camera space we are sending rays in
  11675. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11676. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11677. * @returns picking info or null.
  11678. */
  11679. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11680. /**
  11681. * Intersects the sprites with a ray
  11682. * @param ray defines the ray to intersect with
  11683. * @param camera defines the current active camera
  11684. * @param predicate defines a predicate used to select candidate sprites
  11685. * @returns null if no hit or a PickingInfo array
  11686. */
  11687. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11688. /**
  11689. * Renders the list of sprites on screen.
  11690. */
  11691. render(): void;
  11692. }
  11693. /**
  11694. * Class used to manage multiple sprites on the same spritesheet
  11695. * @see http://doc.babylonjs.com/babylon101/sprites
  11696. */
  11697. export class SpriteManager implements ISpriteManager {
  11698. /** defines the manager's name */
  11699. name: string;
  11700. /** Gets the list of sprites */
  11701. sprites: Sprite[];
  11702. /** Gets or sets the rendering group id (0 by default) */
  11703. renderingGroupId: number;
  11704. /** Gets or sets camera layer mask */
  11705. layerMask: number;
  11706. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11707. fogEnabled: boolean;
  11708. /** Gets or sets a boolean indicating if the sprites are pickable */
  11709. isPickable: boolean;
  11710. /** Defines the default width of a cell in the spritesheet */
  11711. cellWidth: number;
  11712. /** Defines the default height of a cell in the spritesheet */
  11713. cellHeight: number;
  11714. /** Associative array from JSON sprite data file */
  11715. private _cellData;
  11716. /** Array of sprite names from JSON sprite data file */
  11717. private _spriteMap;
  11718. /** True when packed cell data from JSON file is ready*/
  11719. private _packedAndReady;
  11720. /**
  11721. * An event triggered when the manager is disposed.
  11722. */
  11723. onDisposeObservable: Observable<SpriteManager>;
  11724. private _onDisposeObserver;
  11725. /**
  11726. * Callback called when the manager is disposed
  11727. */
  11728. onDispose: () => void;
  11729. private _capacity;
  11730. private _fromPacked;
  11731. private _spriteTexture;
  11732. private _epsilon;
  11733. private _scene;
  11734. private _vertexData;
  11735. private _buffer;
  11736. private _vertexBuffers;
  11737. private _indexBuffer;
  11738. private _effectBase;
  11739. private _effectFog;
  11740. /**
  11741. * Gets or sets the spritesheet texture
  11742. */
  11743. texture: Texture;
  11744. /**
  11745. * Creates a new sprite manager
  11746. * @param name defines the manager's name
  11747. * @param imgUrl defines the sprite sheet url
  11748. * @param capacity defines the maximum allowed number of sprites
  11749. * @param cellSize defines the size of a sprite cell
  11750. * @param scene defines the hosting scene
  11751. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11752. * @param samplingMode defines the smapling mode to use with spritesheet
  11753. * @param fromPacked set to false; do not alter
  11754. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11755. */
  11756. constructor(
  11757. /** defines the manager's name */
  11758. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11759. private _makePacked;
  11760. private _appendSpriteVertex;
  11761. /**
  11762. * Intersects the sprites with a ray
  11763. * @param ray defines the ray to intersect with
  11764. * @param camera defines the current active camera
  11765. * @param predicate defines a predicate used to select candidate sprites
  11766. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11767. * @returns null if no hit or a PickingInfo
  11768. */
  11769. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11770. /**
  11771. * Intersects the sprites with a ray
  11772. * @param ray defines the ray to intersect with
  11773. * @param camera defines the current active camera
  11774. * @param predicate defines a predicate used to select candidate sprites
  11775. * @returns null if no hit or a PickingInfo array
  11776. */
  11777. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11778. /**
  11779. * Render all child sprites
  11780. */
  11781. render(): void;
  11782. /**
  11783. * Release associated resources
  11784. */
  11785. dispose(): void;
  11786. }
  11787. }
  11788. declare module "babylonjs/Sprites/sprite" {
  11789. import { Vector3 } from "babylonjs/Maths/math.vector";
  11790. import { Nullable } from "babylonjs/types";
  11791. import { ActionManager } from "babylonjs/Actions/actionManager";
  11792. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11793. import { Color4 } from "babylonjs/Maths/math.color";
  11794. /**
  11795. * Class used to represent a sprite
  11796. * @see http://doc.babylonjs.com/babylon101/sprites
  11797. */
  11798. export class Sprite {
  11799. /** defines the name */
  11800. name: string;
  11801. /** Gets or sets the current world position */
  11802. position: Vector3;
  11803. /** Gets or sets the main color */
  11804. color: Color4;
  11805. /** Gets or sets the width */
  11806. width: number;
  11807. /** Gets or sets the height */
  11808. height: number;
  11809. /** Gets or sets rotation angle */
  11810. angle: number;
  11811. /** Gets or sets the cell index in the sprite sheet */
  11812. cellIndex: number;
  11813. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11814. cellRef: string;
  11815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11816. invertU: number;
  11817. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11818. invertV: number;
  11819. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11820. disposeWhenFinishedAnimating: boolean;
  11821. /** Gets the list of attached animations */
  11822. animations: Animation[];
  11823. /** Gets or sets a boolean indicating if the sprite can be picked */
  11824. isPickable: boolean;
  11825. /**
  11826. * Gets or sets the associated action manager
  11827. */
  11828. actionManager: Nullable<ActionManager>;
  11829. private _animationStarted;
  11830. private _loopAnimation;
  11831. private _fromIndex;
  11832. private _toIndex;
  11833. private _delay;
  11834. private _direction;
  11835. private _manager;
  11836. private _time;
  11837. private _onAnimationEnd;
  11838. /**
  11839. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11840. */
  11841. isVisible: boolean;
  11842. /**
  11843. * Gets or sets the sprite size
  11844. */
  11845. size: number;
  11846. /**
  11847. * Creates a new Sprite
  11848. * @param name defines the name
  11849. * @param manager defines the manager
  11850. */
  11851. constructor(
  11852. /** defines the name */
  11853. name: string, manager: ISpriteManager);
  11854. /**
  11855. * Starts an animation
  11856. * @param from defines the initial key
  11857. * @param to defines the end key
  11858. * @param loop defines if the animation must loop
  11859. * @param delay defines the start delay (in ms)
  11860. * @param onAnimationEnd defines a callback to call when animation ends
  11861. */
  11862. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11863. /** Stops current animation (if any) */
  11864. stopAnimation(): void;
  11865. /** @hidden */
  11866. _animate(deltaTime: number): void;
  11867. /** Release associated resources */
  11868. dispose(): void;
  11869. }
  11870. }
  11871. declare module "babylonjs/Collisions/pickingInfo" {
  11872. import { Nullable } from "babylonjs/types";
  11873. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11875. import { Sprite } from "babylonjs/Sprites/sprite";
  11876. import { Ray } from "babylonjs/Culling/ray";
  11877. /**
  11878. * Information about the result of picking within a scene
  11879. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11880. */
  11881. export class PickingInfo {
  11882. /** @hidden */
  11883. _pickingUnavailable: boolean;
  11884. /**
  11885. * If the pick collided with an object
  11886. */
  11887. hit: boolean;
  11888. /**
  11889. * Distance away where the pick collided
  11890. */
  11891. distance: number;
  11892. /**
  11893. * The location of pick collision
  11894. */
  11895. pickedPoint: Nullable<Vector3>;
  11896. /**
  11897. * The mesh corresponding the the pick collision
  11898. */
  11899. pickedMesh: Nullable<AbstractMesh>;
  11900. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11901. bu: number;
  11902. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11903. bv: number;
  11904. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11905. faceId: number;
  11906. /** Id of the the submesh that was picked */
  11907. subMeshId: number;
  11908. /** If a sprite was picked, this will be the sprite the pick collided with */
  11909. pickedSprite: Nullable<Sprite>;
  11910. /**
  11911. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11912. */
  11913. originMesh: Nullable<AbstractMesh>;
  11914. /**
  11915. * The ray that was used to perform the picking.
  11916. */
  11917. ray: Nullable<Ray>;
  11918. /**
  11919. * Gets the normal correspodning to the face the pick collided with
  11920. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11921. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11922. * @returns The normal correspodning to the face the pick collided with
  11923. */
  11924. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11925. /**
  11926. * Gets the texture coordinates of where the pick occured
  11927. * @returns the vector containing the coordnates of the texture
  11928. */
  11929. getTextureCoordinates(): Nullable<Vector2>;
  11930. }
  11931. }
  11932. declare module "babylonjs/Events/pointerEvents" {
  11933. import { Nullable } from "babylonjs/types";
  11934. import { Vector2 } from "babylonjs/Maths/math.vector";
  11935. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11936. import { Ray } from "babylonjs/Culling/ray";
  11937. /**
  11938. * Gather the list of pointer event types as constants.
  11939. */
  11940. export class PointerEventTypes {
  11941. /**
  11942. * 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.
  11943. */
  11944. static readonly POINTERDOWN: number;
  11945. /**
  11946. * The pointerup event is fired when a pointer is no longer active.
  11947. */
  11948. static readonly POINTERUP: number;
  11949. /**
  11950. * The pointermove event is fired when a pointer changes coordinates.
  11951. */
  11952. static readonly POINTERMOVE: number;
  11953. /**
  11954. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11955. */
  11956. static readonly POINTERWHEEL: number;
  11957. /**
  11958. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11959. */
  11960. static readonly POINTERPICK: number;
  11961. /**
  11962. * The pointertap event is fired when a the object has been touched and released without drag.
  11963. */
  11964. static readonly POINTERTAP: number;
  11965. /**
  11966. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11967. */
  11968. static readonly POINTERDOUBLETAP: number;
  11969. }
  11970. /**
  11971. * Base class of pointer info types.
  11972. */
  11973. export class PointerInfoBase {
  11974. /**
  11975. * Defines the type of event (PointerEventTypes)
  11976. */
  11977. type: number;
  11978. /**
  11979. * Defines the related dom event
  11980. */
  11981. event: PointerEvent | MouseWheelEvent;
  11982. /**
  11983. * Instantiates the base class of pointers info.
  11984. * @param type Defines the type of event (PointerEventTypes)
  11985. * @param event Defines the related dom event
  11986. */
  11987. constructor(
  11988. /**
  11989. * Defines the type of event (PointerEventTypes)
  11990. */
  11991. type: number,
  11992. /**
  11993. * Defines the related dom event
  11994. */
  11995. event: PointerEvent | MouseWheelEvent);
  11996. }
  11997. /**
  11998. * This class is used to store pointer related info for the onPrePointerObservable event.
  11999. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12000. */
  12001. export class PointerInfoPre extends PointerInfoBase {
  12002. /**
  12003. * Ray from a pointer if availible (eg. 6dof controller)
  12004. */
  12005. ray: Nullable<Ray>;
  12006. /**
  12007. * Defines the local position of the pointer on the canvas.
  12008. */
  12009. localPosition: Vector2;
  12010. /**
  12011. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12012. */
  12013. skipOnPointerObservable: boolean;
  12014. /**
  12015. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12016. * @param type Defines the type of event (PointerEventTypes)
  12017. * @param event Defines the related dom event
  12018. * @param localX Defines the local x coordinates of the pointer when the event occured
  12019. * @param localY Defines the local y coordinates of the pointer when the event occured
  12020. */
  12021. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12022. }
  12023. /**
  12024. * This type contains all the data related to a pointer event in Babylon.js.
  12025. * 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.
  12026. */
  12027. export class PointerInfo extends PointerInfoBase {
  12028. /**
  12029. * Defines the picking info associated to the info (if any)\
  12030. */
  12031. pickInfo: Nullable<PickingInfo>;
  12032. /**
  12033. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12034. * @param type Defines the type of event (PointerEventTypes)
  12035. * @param event Defines the related dom event
  12036. * @param pickInfo Defines the picking info associated to the info (if any)\
  12037. */
  12038. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12039. /**
  12040. * Defines the picking info associated to the info (if any)\
  12041. */
  12042. pickInfo: Nullable<PickingInfo>);
  12043. }
  12044. /**
  12045. * Data relating to a touch event on the screen.
  12046. */
  12047. export interface PointerTouch {
  12048. /**
  12049. * X coordinate of touch.
  12050. */
  12051. x: number;
  12052. /**
  12053. * Y coordinate of touch.
  12054. */
  12055. y: number;
  12056. /**
  12057. * Id of touch. Unique for each finger.
  12058. */
  12059. pointerId: number;
  12060. /**
  12061. * Event type passed from DOM.
  12062. */
  12063. type: any;
  12064. }
  12065. }
  12066. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12067. import { Observable } from "babylonjs/Misc/observable";
  12068. import { Nullable } from "babylonjs/types";
  12069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12070. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12071. /**
  12072. * Manage the mouse inputs to control the movement of a free camera.
  12073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12074. */
  12075. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12076. /**
  12077. * Define if touch is enabled in the mouse input
  12078. */
  12079. touchEnabled: boolean;
  12080. /**
  12081. * Defines the camera the input is attached to.
  12082. */
  12083. camera: FreeCamera;
  12084. /**
  12085. * Defines the buttons associated with the input to handle camera move.
  12086. */
  12087. buttons: number[];
  12088. /**
  12089. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12090. */
  12091. angularSensibility: number;
  12092. private _pointerInput;
  12093. private _onMouseMove;
  12094. private _observer;
  12095. private previousPosition;
  12096. /**
  12097. * Observable for when a pointer move event occurs containing the move offset
  12098. */
  12099. onPointerMovedObservable: Observable<{
  12100. offsetX: number;
  12101. offsetY: number;
  12102. }>;
  12103. /**
  12104. * @hidden
  12105. * If the camera should be rotated automatically based on pointer movement
  12106. */
  12107. _allowCameraRotation: boolean;
  12108. /**
  12109. * Manage the mouse inputs to control the movement of a free camera.
  12110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12111. * @param touchEnabled Defines if touch is enabled or not
  12112. */
  12113. constructor(
  12114. /**
  12115. * Define if touch is enabled in the mouse input
  12116. */
  12117. touchEnabled?: boolean);
  12118. /**
  12119. * Attach the input controls to a specific dom element to get the input from.
  12120. * @param element Defines the element the controls should be listened from
  12121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12122. */
  12123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12124. /**
  12125. * Called on JS contextmenu event.
  12126. * Override this method to provide functionality.
  12127. */
  12128. protected onContextMenu(evt: PointerEvent): void;
  12129. /**
  12130. * Detach the current controls from the specified dom element.
  12131. * @param element Defines the element to stop listening the inputs from
  12132. */
  12133. detachControl(element: Nullable<HTMLElement>): void;
  12134. /**
  12135. * Gets the class name of the current intput.
  12136. * @returns the class name
  12137. */
  12138. getClassName(): string;
  12139. /**
  12140. * Get the friendly name associated with the input class.
  12141. * @returns the input friendly name
  12142. */
  12143. getSimpleName(): string;
  12144. }
  12145. }
  12146. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12147. import { Nullable } from "babylonjs/types";
  12148. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12149. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12150. /**
  12151. * Manage the touch inputs to control the movement of a free camera.
  12152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12153. */
  12154. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12155. /**
  12156. * Defines the camera the input is attached to.
  12157. */
  12158. camera: FreeCamera;
  12159. /**
  12160. * Defines the touch sensibility for rotation.
  12161. * The higher the faster.
  12162. */
  12163. touchAngularSensibility: number;
  12164. /**
  12165. * Defines the touch sensibility for move.
  12166. * The higher the faster.
  12167. */
  12168. touchMoveSensibility: number;
  12169. private _offsetX;
  12170. private _offsetY;
  12171. private _pointerPressed;
  12172. private _pointerInput;
  12173. private _observer;
  12174. private _onLostFocus;
  12175. /**
  12176. * Attach the input controls to a specific dom element to get the input from.
  12177. * @param element Defines the element the controls should be listened from
  12178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12179. */
  12180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12181. /**
  12182. * Detach the current controls from the specified dom element.
  12183. * @param element Defines the element to stop listening the inputs from
  12184. */
  12185. detachControl(element: Nullable<HTMLElement>): void;
  12186. /**
  12187. * Update the current camera state depending on the inputs that have been used this frame.
  12188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12189. */
  12190. checkInputs(): void;
  12191. /**
  12192. * Gets the class name of the current intput.
  12193. * @returns the class name
  12194. */
  12195. getClassName(): string;
  12196. /**
  12197. * Get the friendly name associated with the input class.
  12198. * @returns the input friendly name
  12199. */
  12200. getSimpleName(): string;
  12201. }
  12202. }
  12203. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12205. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12206. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12207. import { Nullable } from "babylonjs/types";
  12208. /**
  12209. * Default Inputs manager for the FreeCamera.
  12210. * It groups all the default supported inputs for ease of use.
  12211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12212. */
  12213. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12214. /**
  12215. * @hidden
  12216. */
  12217. _mouseInput: Nullable<FreeCameraMouseInput>;
  12218. /**
  12219. * Instantiates a new FreeCameraInputsManager.
  12220. * @param camera Defines the camera the inputs belong to
  12221. */
  12222. constructor(camera: FreeCamera);
  12223. /**
  12224. * Add keyboard input support to the input manager.
  12225. * @returns the current input manager
  12226. */
  12227. addKeyboard(): FreeCameraInputsManager;
  12228. /**
  12229. * Add mouse input support to the input manager.
  12230. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12231. * @returns the current input manager
  12232. */
  12233. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12234. /**
  12235. * Removes the mouse input support from the manager
  12236. * @returns the current input manager
  12237. */
  12238. removeMouse(): FreeCameraInputsManager;
  12239. /**
  12240. * Add touch input support to the input manager.
  12241. * @returns the current input manager
  12242. */
  12243. addTouch(): FreeCameraInputsManager;
  12244. /**
  12245. * Remove all attached input methods from a camera
  12246. */
  12247. clear(): void;
  12248. }
  12249. }
  12250. declare module "babylonjs/Cameras/freeCamera" {
  12251. import { Vector3 } from "babylonjs/Maths/math.vector";
  12252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12253. import { Scene } from "babylonjs/scene";
  12254. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12255. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12256. /**
  12257. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12258. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12260. */
  12261. export class FreeCamera extends TargetCamera {
  12262. /**
  12263. * Define the collision ellipsoid of the camera.
  12264. * This is helpful to simulate a camera body like the player body around the camera
  12265. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12266. */
  12267. ellipsoid: Vector3;
  12268. /**
  12269. * Define an offset for the position of the ellipsoid around the camera.
  12270. * This can be helpful to determine the center of the body near the gravity center of the body
  12271. * instead of its head.
  12272. */
  12273. ellipsoidOffset: Vector3;
  12274. /**
  12275. * Enable or disable collisions of the camera with the rest of the scene objects.
  12276. */
  12277. checkCollisions: boolean;
  12278. /**
  12279. * Enable or disable gravity on the camera.
  12280. */
  12281. applyGravity: boolean;
  12282. /**
  12283. * Define the input manager associated to the camera.
  12284. */
  12285. inputs: FreeCameraInputsManager;
  12286. /**
  12287. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12288. * Higher values reduce sensitivity.
  12289. */
  12290. /**
  12291. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12292. * Higher values reduce sensitivity.
  12293. */
  12294. angularSensibility: number;
  12295. /**
  12296. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12297. */
  12298. keysUp: number[];
  12299. /**
  12300. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12301. */
  12302. keysDown: number[];
  12303. /**
  12304. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12305. */
  12306. keysLeft: number[];
  12307. /**
  12308. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12309. */
  12310. keysRight: number[];
  12311. /**
  12312. * Event raised when the camera collide with a mesh in the scene.
  12313. */
  12314. onCollide: (collidedMesh: AbstractMesh) => void;
  12315. private _collider;
  12316. private _needMoveForGravity;
  12317. private _oldPosition;
  12318. private _diffPosition;
  12319. private _newPosition;
  12320. /** @hidden */
  12321. _localDirection: Vector3;
  12322. /** @hidden */
  12323. _transformedDirection: Vector3;
  12324. /**
  12325. * Instantiates a Free Camera.
  12326. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12327. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12329. * @param name Define the name of the camera in the scene
  12330. * @param position Define the start position of the camera in the scene
  12331. * @param scene Define the scene the camera belongs to
  12332. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12333. */
  12334. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12335. /**
  12336. * Attached controls to the current camera.
  12337. * @param element Defines the element the controls should be listened from
  12338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12339. */
  12340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12341. /**
  12342. * Detach the current controls from the camera.
  12343. * The camera will stop reacting to inputs.
  12344. * @param element Defines the element to stop listening the inputs from
  12345. */
  12346. detachControl(element: HTMLElement): void;
  12347. private _collisionMask;
  12348. /**
  12349. * Define a collision mask to limit the list of object the camera can collide with
  12350. */
  12351. collisionMask: number;
  12352. /** @hidden */
  12353. _collideWithWorld(displacement: Vector3): void;
  12354. private _onCollisionPositionChange;
  12355. /** @hidden */
  12356. _checkInputs(): void;
  12357. /** @hidden */
  12358. _decideIfNeedsToMove(): boolean;
  12359. /** @hidden */
  12360. _updatePosition(): void;
  12361. /**
  12362. * Destroy the camera and release the current resources hold by it.
  12363. */
  12364. dispose(): void;
  12365. /**
  12366. * Gets the current object class name.
  12367. * @return the class name
  12368. */
  12369. getClassName(): string;
  12370. }
  12371. }
  12372. declare module "babylonjs/Gamepads/gamepad" {
  12373. import { Observable } from "babylonjs/Misc/observable";
  12374. /**
  12375. * Represents a gamepad control stick position
  12376. */
  12377. export class StickValues {
  12378. /**
  12379. * The x component of the control stick
  12380. */
  12381. x: number;
  12382. /**
  12383. * The y component of the control stick
  12384. */
  12385. y: number;
  12386. /**
  12387. * Initializes the gamepad x and y control stick values
  12388. * @param x The x component of the gamepad control stick value
  12389. * @param y The y component of the gamepad control stick value
  12390. */
  12391. constructor(
  12392. /**
  12393. * The x component of the control stick
  12394. */
  12395. x: number,
  12396. /**
  12397. * The y component of the control stick
  12398. */
  12399. y: number);
  12400. }
  12401. /**
  12402. * An interface which manages callbacks for gamepad button changes
  12403. */
  12404. export interface GamepadButtonChanges {
  12405. /**
  12406. * Called when a gamepad has been changed
  12407. */
  12408. changed: boolean;
  12409. /**
  12410. * Called when a gamepad press event has been triggered
  12411. */
  12412. pressChanged: boolean;
  12413. /**
  12414. * Called when a touch event has been triggered
  12415. */
  12416. touchChanged: boolean;
  12417. /**
  12418. * Called when a value has changed
  12419. */
  12420. valueChanged: boolean;
  12421. }
  12422. /**
  12423. * Represents a gamepad
  12424. */
  12425. export class Gamepad {
  12426. /**
  12427. * The id of the gamepad
  12428. */
  12429. id: string;
  12430. /**
  12431. * The index of the gamepad
  12432. */
  12433. index: number;
  12434. /**
  12435. * The browser gamepad
  12436. */
  12437. browserGamepad: any;
  12438. /**
  12439. * Specifies what type of gamepad this represents
  12440. */
  12441. type: number;
  12442. private _leftStick;
  12443. private _rightStick;
  12444. /** @hidden */
  12445. _isConnected: boolean;
  12446. private _leftStickAxisX;
  12447. private _leftStickAxisY;
  12448. private _rightStickAxisX;
  12449. private _rightStickAxisY;
  12450. /**
  12451. * Triggered when the left control stick has been changed
  12452. */
  12453. private _onleftstickchanged;
  12454. /**
  12455. * Triggered when the right control stick has been changed
  12456. */
  12457. private _onrightstickchanged;
  12458. /**
  12459. * Represents a gamepad controller
  12460. */
  12461. static GAMEPAD: number;
  12462. /**
  12463. * Represents a generic controller
  12464. */
  12465. static GENERIC: number;
  12466. /**
  12467. * Represents an XBox controller
  12468. */
  12469. static XBOX: number;
  12470. /**
  12471. * Represents a pose-enabled controller
  12472. */
  12473. static POSE_ENABLED: number;
  12474. /**
  12475. * Represents an Dual Shock controller
  12476. */
  12477. static DUALSHOCK: number;
  12478. /**
  12479. * Specifies whether the left control stick should be Y-inverted
  12480. */
  12481. protected _invertLeftStickY: boolean;
  12482. /**
  12483. * Specifies if the gamepad has been connected
  12484. */
  12485. readonly isConnected: boolean;
  12486. /**
  12487. * Initializes the gamepad
  12488. * @param id The id of the gamepad
  12489. * @param index The index of the gamepad
  12490. * @param browserGamepad The browser gamepad
  12491. * @param leftStickX The x component of the left joystick
  12492. * @param leftStickY The y component of the left joystick
  12493. * @param rightStickX The x component of the right joystick
  12494. * @param rightStickY The y component of the right joystick
  12495. */
  12496. constructor(
  12497. /**
  12498. * The id of the gamepad
  12499. */
  12500. id: string,
  12501. /**
  12502. * The index of the gamepad
  12503. */
  12504. index: number,
  12505. /**
  12506. * The browser gamepad
  12507. */
  12508. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12509. /**
  12510. * Callback triggered when the left joystick has changed
  12511. * @param callback
  12512. */
  12513. onleftstickchanged(callback: (values: StickValues) => void): void;
  12514. /**
  12515. * Callback triggered when the right joystick has changed
  12516. * @param callback
  12517. */
  12518. onrightstickchanged(callback: (values: StickValues) => void): void;
  12519. /**
  12520. * Gets the left joystick
  12521. */
  12522. /**
  12523. * Sets the left joystick values
  12524. */
  12525. leftStick: StickValues;
  12526. /**
  12527. * Gets the right joystick
  12528. */
  12529. /**
  12530. * Sets the right joystick value
  12531. */
  12532. rightStick: StickValues;
  12533. /**
  12534. * Updates the gamepad joystick positions
  12535. */
  12536. update(): void;
  12537. /**
  12538. * Disposes the gamepad
  12539. */
  12540. dispose(): void;
  12541. }
  12542. /**
  12543. * Represents a generic gamepad
  12544. */
  12545. export class GenericPad extends Gamepad {
  12546. private _buttons;
  12547. private _onbuttondown;
  12548. private _onbuttonup;
  12549. /**
  12550. * Observable triggered when a button has been pressed
  12551. */
  12552. onButtonDownObservable: Observable<number>;
  12553. /**
  12554. * Observable triggered when a button has been released
  12555. */
  12556. onButtonUpObservable: Observable<number>;
  12557. /**
  12558. * Callback triggered when a button has been pressed
  12559. * @param callback Called when a button has been pressed
  12560. */
  12561. onbuttondown(callback: (buttonPressed: number) => void): void;
  12562. /**
  12563. * Callback triggered when a button has been released
  12564. * @param callback Called when a button has been released
  12565. */
  12566. onbuttonup(callback: (buttonReleased: number) => void): void;
  12567. /**
  12568. * Initializes the generic gamepad
  12569. * @param id The id of the generic gamepad
  12570. * @param index The index of the generic gamepad
  12571. * @param browserGamepad The browser gamepad
  12572. */
  12573. constructor(id: string, index: number, browserGamepad: any);
  12574. private _setButtonValue;
  12575. /**
  12576. * Updates the generic gamepad
  12577. */
  12578. update(): void;
  12579. /**
  12580. * Disposes the generic gamepad
  12581. */
  12582. dispose(): void;
  12583. }
  12584. }
  12585. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12586. import { Nullable } from "babylonjs/types";
  12587. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12588. import { Scene } from "babylonjs/scene";
  12589. module "babylonjs/Engines/engine" {
  12590. interface Engine {
  12591. /**
  12592. * Creates a raw texture
  12593. * @param data defines the data to store in the texture
  12594. * @param width defines the width of the texture
  12595. * @param height defines the height of the texture
  12596. * @param format defines the format of the data
  12597. * @param generateMipMaps defines if the engine should generate the mip levels
  12598. * @param invertY defines if data must be stored with Y axis inverted
  12599. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12600. * @param compression defines the compression used (null by default)
  12601. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12602. * @returns the raw texture inside an InternalTexture
  12603. */
  12604. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12605. /**
  12606. * Update a raw texture
  12607. * @param texture defines the texture to update
  12608. * @param data defines the data to store in the texture
  12609. * @param format defines the format of the data
  12610. * @param invertY defines if data must be stored with Y axis inverted
  12611. */
  12612. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12613. /**
  12614. * Update a raw texture
  12615. * @param texture defines the texture to update
  12616. * @param data defines the data to store in the texture
  12617. * @param format defines the format of the data
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @param compression defines the compression used (null by default)
  12620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12621. */
  12622. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12623. /**
  12624. * Creates a new raw cube texture
  12625. * @param data defines the array of data to use to create each face
  12626. * @param size defines the size of the textures
  12627. * @param format defines the format of the data
  12628. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12629. * @param generateMipMaps defines if the engine should generate the mip levels
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12632. * @param compression defines the compression used (null by default)
  12633. * @returns the cube texture as an InternalTexture
  12634. */
  12635. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12636. /**
  12637. * Update a raw cube texture
  12638. * @param texture defines the texture to udpdate
  12639. * @param data defines the data to store
  12640. * @param format defines the data format
  12641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12642. * @param invertY defines if data must be stored with Y axis inverted
  12643. */
  12644. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12645. /**
  12646. * Update a raw cube texture
  12647. * @param texture defines the texture to udpdate
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12651. * @param invertY defines if data must be stored with Y axis inverted
  12652. * @param compression defines the compression used (null by default)
  12653. */
  12654. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12655. /**
  12656. * Update a raw cube texture
  12657. * @param texture defines the texture to udpdate
  12658. * @param data defines the data to store
  12659. * @param format defines the data format
  12660. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12661. * @param invertY defines if data must be stored with Y axis inverted
  12662. * @param compression defines the compression used (null by default)
  12663. * @param level defines which level of the texture to update
  12664. */
  12665. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12666. /**
  12667. * Creates a new raw cube texture from a specified url
  12668. * @param url defines the url where the data is located
  12669. * @param scene defines the current scene
  12670. * @param size defines the size of the textures
  12671. * @param format defines the format of the data
  12672. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12673. * @param noMipmap defines if the engine should avoid generating the mip levels
  12674. * @param callback defines a callback used to extract texture data from loaded data
  12675. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12676. * @param onLoad defines a callback called when texture is loaded
  12677. * @param onError defines a callback called if there is an error
  12678. * @returns the cube texture as an InternalTexture
  12679. */
  12680. 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;
  12681. /**
  12682. * Creates a new raw cube texture from a specified url
  12683. * @param url defines the url where the data is located
  12684. * @param scene defines the current scene
  12685. * @param size defines the size of the textures
  12686. * @param format defines the format of the data
  12687. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12688. * @param noMipmap defines if the engine should avoid generating the mip levels
  12689. * @param callback defines a callback used to extract texture data from loaded data
  12690. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12691. * @param onLoad defines a callback called when texture is loaded
  12692. * @param onError defines a callback called if there is an error
  12693. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12694. * @param invertY defines if data must be stored with Y axis inverted
  12695. * @returns the cube texture as an InternalTexture
  12696. */
  12697. 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;
  12698. /**
  12699. * Creates a new raw 3D texture
  12700. * @param data defines the data used to create the texture
  12701. * @param width defines the width of the texture
  12702. * @param height defines the height of the texture
  12703. * @param depth defines the depth of the texture
  12704. * @param format defines the format of the texture
  12705. * @param generateMipMaps defines if the engine must generate mip levels
  12706. * @param invertY defines if data must be stored with Y axis inverted
  12707. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12708. * @param compression defines the compressed used (can be null)
  12709. * @param textureType defines the compressed used (can be null)
  12710. * @returns a new raw 3D texture (stored in an InternalTexture)
  12711. */
  12712. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12713. /**
  12714. * Update a raw 3D texture
  12715. * @param texture defines the texture to update
  12716. * @param data defines the data to store
  12717. * @param format defines the data format
  12718. * @param invertY defines if data must be stored with Y axis inverted
  12719. */
  12720. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12721. /**
  12722. * Update a raw 3D texture
  12723. * @param texture defines the texture to update
  12724. * @param data defines the data to store
  12725. * @param format defines the data format
  12726. * @param invertY defines if data must be stored with Y axis inverted
  12727. * @param compression defines the used compression (can be null)
  12728. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12729. */
  12730. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12731. }
  12732. }
  12733. }
  12734. declare module "babylonjs/Materials/Textures/rawTexture" {
  12735. import { Scene } from "babylonjs/scene";
  12736. import { Texture } from "babylonjs/Materials/Textures/texture";
  12737. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12738. /**
  12739. * Raw texture can help creating a texture directly from an array of data.
  12740. * This can be super useful if you either get the data from an uncompressed source or
  12741. * if you wish to create your texture pixel by pixel.
  12742. */
  12743. export class RawTexture extends Texture {
  12744. /**
  12745. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12746. */
  12747. format: number;
  12748. private _engine;
  12749. /**
  12750. * Instantiates a new RawTexture.
  12751. * Raw texture can help creating a texture directly from an array of data.
  12752. * This can be super useful if you either get the data from an uncompressed source or
  12753. * if you wish to create your texture pixel by pixel.
  12754. * @param data define the array of data to use to create the texture
  12755. * @param width define the width of the texture
  12756. * @param height define the height of the texture
  12757. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12758. * @param scene define the scene the texture belongs to
  12759. * @param generateMipMaps define whether mip maps should be generated or not
  12760. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12761. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12762. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12763. */
  12764. constructor(data: ArrayBufferView, width: number, height: number,
  12765. /**
  12766. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12767. */
  12768. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12769. /**
  12770. * Updates the texture underlying data.
  12771. * @param data Define the new data of the texture
  12772. */
  12773. update(data: ArrayBufferView): void;
  12774. /**
  12775. * Creates a luminance texture from some data.
  12776. * @param data Define the texture data
  12777. * @param width Define the width of the texture
  12778. * @param height Define the height of the texture
  12779. * @param scene Define the scene the texture belongs to
  12780. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12781. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12782. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12783. * @returns the luminance texture
  12784. */
  12785. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12786. /**
  12787. * Creates a luminance alpha texture from some data.
  12788. * @param data Define the texture data
  12789. * @param width Define the width of the texture
  12790. * @param height Define the height of the texture
  12791. * @param scene Define the scene the texture belongs to
  12792. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12793. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12794. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12795. * @returns the luminance alpha texture
  12796. */
  12797. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12798. /**
  12799. * Creates an alpha texture from some data.
  12800. * @param data Define the texture data
  12801. * @param width Define the width of the texture
  12802. * @param height Define the height of the texture
  12803. * @param scene Define the scene the texture belongs to
  12804. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12805. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12806. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12807. * @returns the alpha texture
  12808. */
  12809. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12810. /**
  12811. * Creates a RGB texture from some data.
  12812. * @param data Define the texture data
  12813. * @param width Define the width of the texture
  12814. * @param height Define the height of the texture
  12815. * @param scene Define the scene the texture belongs to
  12816. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12817. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12818. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12819. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12820. * @returns the RGB alpha texture
  12821. */
  12822. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12823. /**
  12824. * Creates a RGBA texture from some data.
  12825. * @param data Define the texture data
  12826. * @param width Define the width of the texture
  12827. * @param height Define the height of the texture
  12828. * @param scene Define the scene the texture belongs to
  12829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12832. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12833. * @returns the RGBA texture
  12834. */
  12835. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12836. /**
  12837. * Creates a R texture from some data.
  12838. * @param data Define the texture data
  12839. * @param width Define the width of the texture
  12840. * @param height Define the height of the texture
  12841. * @param scene Define the scene the texture belongs to
  12842. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12843. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12844. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12845. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12846. * @returns the R texture
  12847. */
  12848. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12849. }
  12850. }
  12851. declare module "babylonjs/Maths/math.size" {
  12852. /**
  12853. * Interface for the size containing width and height
  12854. */
  12855. export interface ISize {
  12856. /**
  12857. * Width
  12858. */
  12859. width: number;
  12860. /**
  12861. * Heighht
  12862. */
  12863. height: number;
  12864. }
  12865. /**
  12866. * Size containing widht and height
  12867. */
  12868. export class Size implements ISize {
  12869. /**
  12870. * Width
  12871. */
  12872. width: number;
  12873. /**
  12874. * Height
  12875. */
  12876. height: number;
  12877. /**
  12878. * Creates a Size object from the given width and height (floats).
  12879. * @param width width of the new size
  12880. * @param height height of the new size
  12881. */
  12882. constructor(width: number, height: number);
  12883. /**
  12884. * Returns a string with the Size width and height
  12885. * @returns a string with the Size width and height
  12886. */
  12887. toString(): string;
  12888. /**
  12889. * "Size"
  12890. * @returns the string "Size"
  12891. */
  12892. getClassName(): string;
  12893. /**
  12894. * Returns the Size hash code.
  12895. * @returns a hash code for a unique width and height
  12896. */
  12897. getHashCode(): number;
  12898. /**
  12899. * Updates the current size from the given one.
  12900. * @param src the given size
  12901. */
  12902. copyFrom(src: Size): void;
  12903. /**
  12904. * Updates in place the current Size from the given floats.
  12905. * @param width width of the new size
  12906. * @param height height of the new size
  12907. * @returns the updated Size.
  12908. */
  12909. copyFromFloats(width: number, height: number): Size;
  12910. /**
  12911. * Updates in place the current Size from the given floats.
  12912. * @param width width to set
  12913. * @param height height to set
  12914. * @returns the updated Size.
  12915. */
  12916. set(width: number, height: number): Size;
  12917. /**
  12918. * Multiplies the width and height by numbers
  12919. * @param w factor to multiple the width by
  12920. * @param h factor to multiple the height by
  12921. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12922. */
  12923. multiplyByFloats(w: number, h: number): Size;
  12924. /**
  12925. * Clones the size
  12926. * @returns a new Size copied from the given one.
  12927. */
  12928. clone(): Size;
  12929. /**
  12930. * True if the current Size and the given one width and height are strictly equal.
  12931. * @param other the other size to compare against
  12932. * @returns True if the current Size and the given one width and height are strictly equal.
  12933. */
  12934. equals(other: Size): boolean;
  12935. /**
  12936. * The surface of the Size : width * height (float).
  12937. */
  12938. readonly surface: number;
  12939. /**
  12940. * Create a new size of zero
  12941. * @returns a new Size set to (0.0, 0.0)
  12942. */
  12943. static Zero(): Size;
  12944. /**
  12945. * Sums the width and height of two sizes
  12946. * @param otherSize size to add to this size
  12947. * @returns a new Size set as the addition result of the current Size and the given one.
  12948. */
  12949. add(otherSize: Size): Size;
  12950. /**
  12951. * Subtracts the width and height of two
  12952. * @param otherSize size to subtract to this size
  12953. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12954. */
  12955. subtract(otherSize: Size): Size;
  12956. /**
  12957. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12958. * @param start starting size to lerp between
  12959. * @param end end size to lerp between
  12960. * @param amount amount to lerp between the start and end values
  12961. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12962. */
  12963. static Lerp(start: Size, end: Size, amount: number): Size;
  12964. }
  12965. }
  12966. declare module "babylonjs/Animations/runtimeAnimation" {
  12967. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12968. import { Animatable } from "babylonjs/Animations/animatable";
  12969. import { Scene } from "babylonjs/scene";
  12970. /**
  12971. * Defines a runtime animation
  12972. */
  12973. export class RuntimeAnimation {
  12974. private _events;
  12975. /**
  12976. * The current frame of the runtime animation
  12977. */
  12978. private _currentFrame;
  12979. /**
  12980. * The animation used by the runtime animation
  12981. */
  12982. private _animation;
  12983. /**
  12984. * The target of the runtime animation
  12985. */
  12986. private _target;
  12987. /**
  12988. * The initiating animatable
  12989. */
  12990. private _host;
  12991. /**
  12992. * The original value of the runtime animation
  12993. */
  12994. private _originalValue;
  12995. /**
  12996. * The original blend value of the runtime animation
  12997. */
  12998. private _originalBlendValue;
  12999. /**
  13000. * The offsets cache of the runtime animation
  13001. */
  13002. private _offsetsCache;
  13003. /**
  13004. * The high limits cache of the runtime animation
  13005. */
  13006. private _highLimitsCache;
  13007. /**
  13008. * Specifies if the runtime animation has been stopped
  13009. */
  13010. private _stopped;
  13011. /**
  13012. * The blending factor of the runtime animation
  13013. */
  13014. private _blendingFactor;
  13015. /**
  13016. * The BabylonJS scene
  13017. */
  13018. private _scene;
  13019. /**
  13020. * The current value of the runtime animation
  13021. */
  13022. private _currentValue;
  13023. /** @hidden */
  13024. _animationState: _IAnimationState;
  13025. /**
  13026. * The active target of the runtime animation
  13027. */
  13028. private _activeTargets;
  13029. private _currentActiveTarget;
  13030. private _directTarget;
  13031. /**
  13032. * The target path of the runtime animation
  13033. */
  13034. private _targetPath;
  13035. /**
  13036. * The weight of the runtime animation
  13037. */
  13038. private _weight;
  13039. /**
  13040. * The ratio offset of the runtime animation
  13041. */
  13042. private _ratioOffset;
  13043. /**
  13044. * The previous delay of the runtime animation
  13045. */
  13046. private _previousDelay;
  13047. /**
  13048. * The previous ratio of the runtime animation
  13049. */
  13050. private _previousRatio;
  13051. private _enableBlending;
  13052. private _keys;
  13053. private _minFrame;
  13054. private _maxFrame;
  13055. private _minValue;
  13056. private _maxValue;
  13057. private _targetIsArray;
  13058. /**
  13059. * Gets the current frame of the runtime animation
  13060. */
  13061. readonly currentFrame: number;
  13062. /**
  13063. * Gets the weight of the runtime animation
  13064. */
  13065. readonly weight: number;
  13066. /**
  13067. * Gets the current value of the runtime animation
  13068. */
  13069. readonly currentValue: any;
  13070. /**
  13071. * Gets the target path of the runtime animation
  13072. */
  13073. readonly targetPath: string;
  13074. /**
  13075. * Gets the actual target of the runtime animation
  13076. */
  13077. readonly target: any;
  13078. /** @hidden */
  13079. _onLoop: () => void;
  13080. /**
  13081. * Create a new RuntimeAnimation object
  13082. * @param target defines the target of the animation
  13083. * @param animation defines the source animation object
  13084. * @param scene defines the hosting scene
  13085. * @param host defines the initiating Animatable
  13086. */
  13087. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13088. private _preparePath;
  13089. /**
  13090. * Gets the animation from the runtime animation
  13091. */
  13092. readonly animation: Animation;
  13093. /**
  13094. * Resets the runtime animation to the beginning
  13095. * @param restoreOriginal defines whether to restore the target property to the original value
  13096. */
  13097. reset(restoreOriginal?: boolean): void;
  13098. /**
  13099. * Specifies if the runtime animation is stopped
  13100. * @returns Boolean specifying if the runtime animation is stopped
  13101. */
  13102. isStopped(): boolean;
  13103. /**
  13104. * Disposes of the runtime animation
  13105. */
  13106. dispose(): void;
  13107. /**
  13108. * Apply the interpolated value to the target
  13109. * @param currentValue defines the value computed by the animation
  13110. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13111. */
  13112. setValue(currentValue: any, weight: number): void;
  13113. private _getOriginalValues;
  13114. private _setValue;
  13115. /**
  13116. * Gets the loop pmode of the runtime animation
  13117. * @returns Loop Mode
  13118. */
  13119. private _getCorrectLoopMode;
  13120. /**
  13121. * Move the current animation to a given frame
  13122. * @param frame defines the frame to move to
  13123. */
  13124. goToFrame(frame: number): void;
  13125. /**
  13126. * @hidden Internal use only
  13127. */
  13128. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13129. /**
  13130. * Execute the current animation
  13131. * @param delay defines the delay to add to the current frame
  13132. * @param from defines the lower bound of the animation range
  13133. * @param to defines the upper bound of the animation range
  13134. * @param loop defines if the current animation must loop
  13135. * @param speedRatio defines the current speed ratio
  13136. * @param weight defines the weight of the animation (default is -1 so no weight)
  13137. * @param onLoop optional callback called when animation loops
  13138. * @returns a boolean indicating if the animation is running
  13139. */
  13140. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13141. }
  13142. }
  13143. declare module "babylonjs/Animations/animatable" {
  13144. import { Animation } from "babylonjs/Animations/animation";
  13145. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13146. import { Nullable } from "babylonjs/types";
  13147. import { Observable } from "babylonjs/Misc/observable";
  13148. import { Scene } from "babylonjs/scene";
  13149. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13150. import { Node } from "babylonjs/node";
  13151. /**
  13152. * Class used to store an actual running animation
  13153. */
  13154. export class Animatable {
  13155. /** defines the target object */
  13156. target: any;
  13157. /** defines the starting frame number (default is 0) */
  13158. fromFrame: number;
  13159. /** defines the ending frame number (default is 100) */
  13160. toFrame: number;
  13161. /** defines if the animation must loop (default is false) */
  13162. loopAnimation: boolean;
  13163. /** defines a callback to call when animation ends if it is not looping */
  13164. onAnimationEnd?: (() => void) | null | undefined;
  13165. /** defines a callback to call when animation loops */
  13166. onAnimationLoop?: (() => void) | null | undefined;
  13167. private _localDelayOffset;
  13168. private _pausedDelay;
  13169. private _runtimeAnimations;
  13170. private _paused;
  13171. private _scene;
  13172. private _speedRatio;
  13173. private _weight;
  13174. private _syncRoot;
  13175. /**
  13176. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13177. * This will only apply for non looping animation (default is true)
  13178. */
  13179. disposeOnEnd: boolean;
  13180. /**
  13181. * Gets a boolean indicating if the animation has started
  13182. */
  13183. animationStarted: boolean;
  13184. /**
  13185. * Observer raised when the animation ends
  13186. */
  13187. onAnimationEndObservable: Observable<Animatable>;
  13188. /**
  13189. * Observer raised when the animation loops
  13190. */
  13191. onAnimationLoopObservable: Observable<Animatable>;
  13192. /**
  13193. * Gets the root Animatable used to synchronize and normalize animations
  13194. */
  13195. readonly syncRoot: Nullable<Animatable>;
  13196. /**
  13197. * Gets the current frame of the first RuntimeAnimation
  13198. * Used to synchronize Animatables
  13199. */
  13200. readonly masterFrame: number;
  13201. /**
  13202. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13203. */
  13204. weight: number;
  13205. /**
  13206. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13207. */
  13208. speedRatio: number;
  13209. /**
  13210. * Creates a new Animatable
  13211. * @param scene defines the hosting scene
  13212. * @param target defines the target object
  13213. * @param fromFrame defines the starting frame number (default is 0)
  13214. * @param toFrame defines the ending frame number (default is 100)
  13215. * @param loopAnimation defines if the animation must loop (default is false)
  13216. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13217. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13218. * @param animations defines a group of animation to add to the new Animatable
  13219. * @param onAnimationLoop defines a callback to call when animation loops
  13220. */
  13221. constructor(scene: Scene,
  13222. /** defines the target object */
  13223. target: any,
  13224. /** defines the starting frame number (default is 0) */
  13225. fromFrame?: number,
  13226. /** defines the ending frame number (default is 100) */
  13227. toFrame?: number,
  13228. /** defines if the animation must loop (default is false) */
  13229. loopAnimation?: boolean, speedRatio?: number,
  13230. /** defines a callback to call when animation ends if it is not looping */
  13231. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13232. /** defines a callback to call when animation loops */
  13233. onAnimationLoop?: (() => void) | null | undefined);
  13234. /**
  13235. * Synchronize and normalize current Animatable with a source Animatable
  13236. * This is useful when using animation weights and when animations are not of the same length
  13237. * @param root defines the root Animatable to synchronize with
  13238. * @returns the current Animatable
  13239. */
  13240. syncWith(root: Animatable): Animatable;
  13241. /**
  13242. * Gets the list of runtime animations
  13243. * @returns an array of RuntimeAnimation
  13244. */
  13245. getAnimations(): RuntimeAnimation[];
  13246. /**
  13247. * Adds more animations to the current animatable
  13248. * @param target defines the target of the animations
  13249. * @param animations defines the new animations to add
  13250. */
  13251. appendAnimations(target: any, animations: Animation[]): void;
  13252. /**
  13253. * Gets the source animation for a specific property
  13254. * @param property defines the propertyu to look for
  13255. * @returns null or the source animation for the given property
  13256. */
  13257. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13258. /**
  13259. * Gets the runtime animation for a specific property
  13260. * @param property defines the propertyu to look for
  13261. * @returns null or the runtime animation for the given property
  13262. */
  13263. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13264. /**
  13265. * Resets the animatable to its original state
  13266. */
  13267. reset(): void;
  13268. /**
  13269. * Allows the animatable to blend with current running animations
  13270. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13271. * @param blendingSpeed defines the blending speed to use
  13272. */
  13273. enableBlending(blendingSpeed: number): void;
  13274. /**
  13275. * Disable animation blending
  13276. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13277. */
  13278. disableBlending(): void;
  13279. /**
  13280. * Jump directly to a given frame
  13281. * @param frame defines the frame to jump to
  13282. */
  13283. goToFrame(frame: number): void;
  13284. /**
  13285. * Pause the animation
  13286. */
  13287. pause(): void;
  13288. /**
  13289. * Restart the animation
  13290. */
  13291. restart(): void;
  13292. private _raiseOnAnimationEnd;
  13293. /**
  13294. * Stop and delete the current animation
  13295. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13296. * @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)
  13297. */
  13298. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13299. /**
  13300. * Wait asynchronously for the animation to end
  13301. * @returns a promise which will be fullfilled when the animation ends
  13302. */
  13303. waitAsync(): Promise<Animatable>;
  13304. /** @hidden */
  13305. _animate(delay: number): boolean;
  13306. }
  13307. module "babylonjs/scene" {
  13308. interface Scene {
  13309. /** @hidden */
  13310. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13311. /** @hidden */
  13312. _processLateAnimationBindingsForMatrices(holder: {
  13313. totalWeight: number;
  13314. animations: RuntimeAnimation[];
  13315. originalValue: Matrix;
  13316. }): any;
  13317. /** @hidden */
  13318. _processLateAnimationBindingsForQuaternions(holder: {
  13319. totalWeight: number;
  13320. animations: RuntimeAnimation[];
  13321. originalValue: Quaternion;
  13322. }, refQuaternion: Quaternion): Quaternion;
  13323. /** @hidden */
  13324. _processLateAnimationBindings(): void;
  13325. /**
  13326. * Will start the animation sequence of a given target
  13327. * @param target defines the target
  13328. * @param from defines from which frame should animation start
  13329. * @param to defines until which frame should animation run.
  13330. * @param weight defines the weight to apply to the animation (1.0 by default)
  13331. * @param loop defines if the animation loops
  13332. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13333. * @param onAnimationEnd defines the function to be executed when the animation ends
  13334. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13335. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13336. * @param onAnimationLoop defines the callback to call when an animation loops
  13337. * @returns the animatable object created for this animation
  13338. */
  13339. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13340. /**
  13341. * Will start the animation sequence of a given target
  13342. * @param target defines the target
  13343. * @param from defines from which frame should animation start
  13344. * @param to defines until which frame should animation run.
  13345. * @param loop defines if the animation loops
  13346. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13347. * @param onAnimationEnd defines the function to be executed when the animation ends
  13348. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13349. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13350. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13351. * @param onAnimationLoop defines the callback to call when an animation loops
  13352. * @returns the animatable object created for this animation
  13353. */
  13354. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13355. /**
  13356. * Will start the animation sequence of a given target and its hierarchy
  13357. * @param target defines the target
  13358. * @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.
  13359. * @param from defines from which frame should animation start
  13360. * @param to defines until which frame should animation run.
  13361. * @param loop defines if the animation loops
  13362. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13363. * @param onAnimationEnd defines the function to be executed when the animation ends
  13364. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13365. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13366. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13367. * @param onAnimationLoop defines the callback to call when an animation loops
  13368. * @returns the list of created animatables
  13369. */
  13370. 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[];
  13371. /**
  13372. * Begin a new animation on a given node
  13373. * @param target defines the target where the animation will take place
  13374. * @param animations defines the list of animations to start
  13375. * @param from defines the initial value
  13376. * @param to defines the final value
  13377. * @param loop defines if you want animation to loop (off by default)
  13378. * @param speedRatio defines the speed ratio to apply to all animations
  13379. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13380. * @param onAnimationLoop defines the callback to call when an animation loops
  13381. * @returns the list of created animatables
  13382. */
  13383. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13384. /**
  13385. * Begin a new animation on a given node and its hierarchy
  13386. * @param target defines the root node where the animation will take place
  13387. * @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.
  13388. * @param animations defines the list of animations to start
  13389. * @param from defines the initial value
  13390. * @param to defines the final value
  13391. * @param loop defines if you want animation to loop (off by default)
  13392. * @param speedRatio defines the speed ratio to apply to all animations
  13393. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13394. * @param onAnimationLoop defines the callback to call when an animation loops
  13395. * @returns the list of animatables created for all nodes
  13396. */
  13397. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13398. /**
  13399. * Gets the animatable associated with a specific target
  13400. * @param target defines the target of the animatable
  13401. * @returns the required animatable if found
  13402. */
  13403. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13404. /**
  13405. * Gets all animatables associated with a given target
  13406. * @param target defines the target to look animatables for
  13407. * @returns an array of Animatables
  13408. */
  13409. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13410. /**
  13411. * Stops and removes all animations that have been applied to the scene
  13412. */
  13413. stopAllAnimations(): void;
  13414. /**
  13415. * Gets the current delta time used by animation engine
  13416. */
  13417. deltaTime: number;
  13418. }
  13419. }
  13420. module "babylonjs/Bones/bone" {
  13421. interface Bone {
  13422. /**
  13423. * Copy an animation range from another bone
  13424. * @param source defines the source bone
  13425. * @param rangeName defines the range name to copy
  13426. * @param frameOffset defines the frame offset
  13427. * @param rescaleAsRequired defines if rescaling must be applied if required
  13428. * @param skelDimensionsRatio defines the scaling ratio
  13429. * @returns true if operation was successful
  13430. */
  13431. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13432. }
  13433. }
  13434. }
  13435. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13436. /**
  13437. * Class used to override all child animations of a given target
  13438. */
  13439. export class AnimationPropertiesOverride {
  13440. /**
  13441. * Gets or sets a value indicating if animation blending must be used
  13442. */
  13443. enableBlending: boolean;
  13444. /**
  13445. * Gets or sets the blending speed to use when enableBlending is true
  13446. */
  13447. blendingSpeed: number;
  13448. /**
  13449. * Gets or sets the default loop mode to use
  13450. */
  13451. loopMode: number;
  13452. }
  13453. }
  13454. declare module "babylonjs/Bones/skeleton" {
  13455. import { Bone } from "babylonjs/Bones/bone";
  13456. import { Observable } from "babylonjs/Misc/observable";
  13457. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13458. import { Scene } from "babylonjs/scene";
  13459. import { Nullable } from "babylonjs/types";
  13460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13461. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13462. import { Animatable } from "babylonjs/Animations/animatable";
  13463. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13464. import { Animation } from "babylonjs/Animations/animation";
  13465. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13466. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13467. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13468. /**
  13469. * Class used to handle skinning animations
  13470. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13471. */
  13472. export class Skeleton implements IAnimatable {
  13473. /** defines the skeleton name */
  13474. name: string;
  13475. /** defines the skeleton Id */
  13476. id: string;
  13477. /**
  13478. * Defines the list of child bones
  13479. */
  13480. bones: Bone[];
  13481. /**
  13482. * Defines an estimate of the dimension of the skeleton at rest
  13483. */
  13484. dimensionsAtRest: Vector3;
  13485. /**
  13486. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13487. */
  13488. needInitialSkinMatrix: boolean;
  13489. /**
  13490. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13491. */
  13492. overrideMesh: Nullable<AbstractMesh>;
  13493. /**
  13494. * Gets the list of animations attached to this skeleton
  13495. */
  13496. animations: Array<Animation>;
  13497. private _scene;
  13498. private _isDirty;
  13499. private _transformMatrices;
  13500. private _transformMatrixTexture;
  13501. private _meshesWithPoseMatrix;
  13502. private _animatables;
  13503. private _identity;
  13504. private _synchronizedWithMesh;
  13505. private _ranges;
  13506. private _lastAbsoluteTransformsUpdateId;
  13507. private _canUseTextureForBones;
  13508. private _uniqueId;
  13509. /** @hidden */
  13510. _numBonesWithLinkedTransformNode: number;
  13511. /** @hidden */
  13512. _hasWaitingData: Nullable<boolean>;
  13513. /**
  13514. * Specifies if the skeleton should be serialized
  13515. */
  13516. doNotSerialize: boolean;
  13517. private _useTextureToStoreBoneMatrices;
  13518. /**
  13519. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13520. * Please note that this option is not available if the hardware does not support it
  13521. */
  13522. useTextureToStoreBoneMatrices: boolean;
  13523. private _animationPropertiesOverride;
  13524. /**
  13525. * Gets or sets the animation properties override
  13526. */
  13527. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13528. /**
  13529. * List of inspectable custom properties (used by the Inspector)
  13530. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13531. */
  13532. inspectableCustomProperties: IInspectable[];
  13533. /**
  13534. * An observable triggered before computing the skeleton's matrices
  13535. */
  13536. onBeforeComputeObservable: Observable<Skeleton>;
  13537. /**
  13538. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13539. */
  13540. readonly isUsingTextureForMatrices: boolean;
  13541. /**
  13542. * Gets the unique ID of this skeleton
  13543. */
  13544. readonly uniqueId: number;
  13545. /**
  13546. * Creates a new skeleton
  13547. * @param name defines the skeleton name
  13548. * @param id defines the skeleton Id
  13549. * @param scene defines the hosting scene
  13550. */
  13551. constructor(
  13552. /** defines the skeleton name */
  13553. name: string,
  13554. /** defines the skeleton Id */
  13555. id: string, scene: Scene);
  13556. /**
  13557. * Gets the current object class name.
  13558. * @return the class name
  13559. */
  13560. getClassName(): string;
  13561. /**
  13562. * Returns an array containing the root bones
  13563. * @returns an array containing the root bones
  13564. */
  13565. getChildren(): Array<Bone>;
  13566. /**
  13567. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13568. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13569. * @returns a Float32Array containing matrices data
  13570. */
  13571. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13572. /**
  13573. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13574. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13575. * @returns a raw texture containing the data
  13576. */
  13577. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13578. /**
  13579. * Gets the current hosting scene
  13580. * @returns a scene object
  13581. */
  13582. getScene(): Scene;
  13583. /**
  13584. * Gets a string representing the current skeleton data
  13585. * @param fullDetails defines a boolean indicating if we want a verbose version
  13586. * @returns a string representing the current skeleton data
  13587. */
  13588. toString(fullDetails?: boolean): string;
  13589. /**
  13590. * Get bone's index searching by name
  13591. * @param name defines bone's name to search for
  13592. * @return the indice of the bone. Returns -1 if not found
  13593. */
  13594. getBoneIndexByName(name: string): number;
  13595. /**
  13596. * Creater a new animation range
  13597. * @param name defines the name of the range
  13598. * @param from defines the start key
  13599. * @param to defines the end key
  13600. */
  13601. createAnimationRange(name: string, from: number, to: number): void;
  13602. /**
  13603. * Delete a specific animation range
  13604. * @param name defines the name of the range
  13605. * @param deleteFrames defines if frames must be removed as well
  13606. */
  13607. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13608. /**
  13609. * Gets a specific animation range
  13610. * @param name defines the name of the range to look for
  13611. * @returns the requested animation range or null if not found
  13612. */
  13613. getAnimationRange(name: string): Nullable<AnimationRange>;
  13614. /**
  13615. * Gets the list of all animation ranges defined on this skeleton
  13616. * @returns an array
  13617. */
  13618. getAnimationRanges(): Nullable<AnimationRange>[];
  13619. /**
  13620. * Copy animation range from a source skeleton.
  13621. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13622. * @param source defines the source skeleton
  13623. * @param name defines the name of the range to copy
  13624. * @param rescaleAsRequired defines if rescaling must be applied if required
  13625. * @returns true if operation was successful
  13626. */
  13627. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13628. /**
  13629. * Forces the skeleton to go to rest pose
  13630. */
  13631. returnToRest(): void;
  13632. private _getHighestAnimationFrame;
  13633. /**
  13634. * Begin a specific animation range
  13635. * @param name defines the name of the range to start
  13636. * @param loop defines if looping must be turned on (false by default)
  13637. * @param speedRatio defines the speed ratio to apply (1 by default)
  13638. * @param onAnimationEnd defines a callback which will be called when animation will end
  13639. * @returns a new animatable
  13640. */
  13641. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13642. /** @hidden */
  13643. _markAsDirty(): void;
  13644. /** @hidden */
  13645. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13646. /** @hidden */
  13647. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13648. private _computeTransformMatrices;
  13649. /**
  13650. * Build all resources required to render a skeleton
  13651. */
  13652. prepare(): void;
  13653. /**
  13654. * Gets the list of animatables currently running for this skeleton
  13655. * @returns an array of animatables
  13656. */
  13657. getAnimatables(): IAnimatable[];
  13658. /**
  13659. * Clone the current skeleton
  13660. * @param name defines the name of the new skeleton
  13661. * @param id defines the id of the new skeleton
  13662. * @returns the new skeleton
  13663. */
  13664. clone(name: string, id: string): Skeleton;
  13665. /**
  13666. * Enable animation blending for this skeleton
  13667. * @param blendingSpeed defines the blending speed to apply
  13668. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13669. */
  13670. enableBlending(blendingSpeed?: number): void;
  13671. /**
  13672. * Releases all resources associated with the current skeleton
  13673. */
  13674. dispose(): void;
  13675. /**
  13676. * Serialize the skeleton in a JSON object
  13677. * @returns a JSON object
  13678. */
  13679. serialize(): any;
  13680. /**
  13681. * Creates a new skeleton from serialized data
  13682. * @param parsedSkeleton defines the serialized data
  13683. * @param scene defines the hosting scene
  13684. * @returns a new skeleton
  13685. */
  13686. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13687. /**
  13688. * Compute all node absolute transforms
  13689. * @param forceUpdate defines if computation must be done even if cache is up to date
  13690. */
  13691. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13692. /**
  13693. * Gets the root pose matrix
  13694. * @returns a matrix
  13695. */
  13696. getPoseMatrix(): Nullable<Matrix>;
  13697. /**
  13698. * Sorts bones per internal index
  13699. */
  13700. sortBones(): void;
  13701. private _sortBones;
  13702. }
  13703. }
  13704. declare module "babylonjs/Bones/bone" {
  13705. import { Skeleton } from "babylonjs/Bones/skeleton";
  13706. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13707. import { Nullable } from "babylonjs/types";
  13708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13709. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13710. import { Node } from "babylonjs/node";
  13711. import { Space } from "babylonjs/Maths/math.axis";
  13712. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13713. /**
  13714. * Class used to store bone information
  13715. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13716. */
  13717. export class Bone extends Node {
  13718. /**
  13719. * defines the bone name
  13720. */
  13721. name: string;
  13722. private static _tmpVecs;
  13723. private static _tmpQuat;
  13724. private static _tmpMats;
  13725. /**
  13726. * Gets the list of child bones
  13727. */
  13728. children: Bone[];
  13729. /** Gets the animations associated with this bone */
  13730. animations: import("babylonjs/Animations/animation").Animation[];
  13731. /**
  13732. * Gets or sets bone length
  13733. */
  13734. length: number;
  13735. /**
  13736. * @hidden Internal only
  13737. * Set this value to map this bone to a different index in the transform matrices
  13738. * Set this value to -1 to exclude the bone from the transform matrices
  13739. */
  13740. _index: Nullable<number>;
  13741. private _skeleton;
  13742. private _localMatrix;
  13743. private _restPose;
  13744. private _baseMatrix;
  13745. private _absoluteTransform;
  13746. private _invertedAbsoluteTransform;
  13747. private _parent;
  13748. private _scalingDeterminant;
  13749. private _worldTransform;
  13750. private _localScaling;
  13751. private _localRotation;
  13752. private _localPosition;
  13753. private _needToDecompose;
  13754. private _needToCompose;
  13755. /** @hidden */
  13756. _linkedTransformNode: Nullable<TransformNode>;
  13757. /** @hidden */
  13758. _waitingTransformNodeId: Nullable<string>;
  13759. /** @hidden */
  13760. /** @hidden */
  13761. _matrix: Matrix;
  13762. /**
  13763. * Create a new bone
  13764. * @param name defines the bone name
  13765. * @param skeleton defines the parent skeleton
  13766. * @param parentBone defines the parent (can be null if the bone is the root)
  13767. * @param localMatrix defines the local matrix
  13768. * @param restPose defines the rest pose matrix
  13769. * @param baseMatrix defines the base matrix
  13770. * @param index defines index of the bone in the hiearchy
  13771. */
  13772. constructor(
  13773. /**
  13774. * defines the bone name
  13775. */
  13776. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13777. /**
  13778. * Gets the current object class name.
  13779. * @return the class name
  13780. */
  13781. getClassName(): string;
  13782. /**
  13783. * Gets the parent skeleton
  13784. * @returns a skeleton
  13785. */
  13786. getSkeleton(): Skeleton;
  13787. /**
  13788. * Gets parent bone
  13789. * @returns a bone or null if the bone is the root of the bone hierarchy
  13790. */
  13791. getParent(): Nullable<Bone>;
  13792. /**
  13793. * Returns an array containing the root bones
  13794. * @returns an array containing the root bones
  13795. */
  13796. getChildren(): Array<Bone>;
  13797. /**
  13798. * Sets the parent bone
  13799. * @param parent defines the parent (can be null if the bone is the root)
  13800. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13801. */
  13802. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13803. /**
  13804. * Gets the local matrix
  13805. * @returns a matrix
  13806. */
  13807. getLocalMatrix(): Matrix;
  13808. /**
  13809. * Gets the base matrix (initial matrix which remains unchanged)
  13810. * @returns a matrix
  13811. */
  13812. getBaseMatrix(): Matrix;
  13813. /**
  13814. * Gets the rest pose matrix
  13815. * @returns a matrix
  13816. */
  13817. getRestPose(): Matrix;
  13818. /**
  13819. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13820. */
  13821. getWorldMatrix(): Matrix;
  13822. /**
  13823. * Sets the local matrix to rest pose matrix
  13824. */
  13825. returnToRest(): void;
  13826. /**
  13827. * Gets the inverse of the absolute transform matrix.
  13828. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13829. * @returns a matrix
  13830. */
  13831. getInvertedAbsoluteTransform(): Matrix;
  13832. /**
  13833. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13834. * @returns a matrix
  13835. */
  13836. getAbsoluteTransform(): Matrix;
  13837. /**
  13838. * Links with the given transform node.
  13839. * The local matrix of this bone is copied from the transform node every frame.
  13840. * @param transformNode defines the transform node to link to
  13841. */
  13842. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13843. /**
  13844. * Gets the node used to drive the bone's transformation
  13845. * @returns a transform node or null
  13846. */
  13847. getTransformNode(): Nullable<TransformNode>;
  13848. /** Gets or sets current position (in local space) */
  13849. position: Vector3;
  13850. /** Gets or sets current rotation (in local space) */
  13851. rotation: Vector3;
  13852. /** Gets or sets current rotation quaternion (in local space) */
  13853. rotationQuaternion: Quaternion;
  13854. /** Gets or sets current scaling (in local space) */
  13855. scaling: Vector3;
  13856. /**
  13857. * Gets the animation properties override
  13858. */
  13859. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13860. private _decompose;
  13861. private _compose;
  13862. /**
  13863. * Update the base and local matrices
  13864. * @param matrix defines the new base or local matrix
  13865. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13866. * @param updateLocalMatrix defines if the local matrix should be updated
  13867. */
  13868. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13869. /** @hidden */
  13870. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13871. /**
  13872. * Flag the bone as dirty (Forcing it to update everything)
  13873. */
  13874. markAsDirty(): void;
  13875. /** @hidden */
  13876. _markAsDirtyAndCompose(): void;
  13877. private _markAsDirtyAndDecompose;
  13878. /**
  13879. * Translate the bone in local or world space
  13880. * @param vec The amount to translate the bone
  13881. * @param space The space that the translation is in
  13882. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13883. */
  13884. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13885. /**
  13886. * Set the postion of the bone in local or world space
  13887. * @param position The position to set the bone
  13888. * @param space The space that the position is in
  13889. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13890. */
  13891. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13892. /**
  13893. * Set the absolute position of the bone (world space)
  13894. * @param position The position to set the bone
  13895. * @param mesh The mesh that this bone is attached to
  13896. */
  13897. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13898. /**
  13899. * Scale the bone on the x, y and z axes (in local space)
  13900. * @param x The amount to scale the bone on the x axis
  13901. * @param y The amount to scale the bone on the y axis
  13902. * @param z The amount to scale the bone on the z axis
  13903. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13904. */
  13905. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13906. /**
  13907. * Set the bone scaling in local space
  13908. * @param scale defines the scaling vector
  13909. */
  13910. setScale(scale: Vector3): void;
  13911. /**
  13912. * Gets the current scaling in local space
  13913. * @returns the current scaling vector
  13914. */
  13915. getScale(): Vector3;
  13916. /**
  13917. * Gets the current scaling in local space and stores it in a target vector
  13918. * @param result defines the target vector
  13919. */
  13920. getScaleToRef(result: Vector3): void;
  13921. /**
  13922. * Set the yaw, pitch, and roll of the bone in local or world space
  13923. * @param yaw The rotation of the bone on the y axis
  13924. * @param pitch The rotation of the bone on the x axis
  13925. * @param roll The rotation of the bone on the z axis
  13926. * @param space The space that the axes of rotation are in
  13927. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13928. */
  13929. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13930. /**
  13931. * Add a rotation to the bone on an axis in local or world space
  13932. * @param axis The axis to rotate the bone on
  13933. * @param amount The amount to rotate the bone
  13934. * @param space The space that the axis is in
  13935. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13936. */
  13937. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13938. /**
  13939. * Set the rotation of the bone to a particular axis angle in local or world space
  13940. * @param axis The axis to rotate the bone on
  13941. * @param angle The angle that the bone should be rotated to
  13942. * @param space The space that the axis is in
  13943. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13944. */
  13945. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13946. /**
  13947. * Set the euler rotation of the bone in local of world space
  13948. * @param rotation The euler rotation that the bone should be set to
  13949. * @param space The space that the rotation is in
  13950. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13951. */
  13952. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13953. /**
  13954. * Set the quaternion rotation of the bone in local of world space
  13955. * @param quat The quaternion rotation that the bone should be set to
  13956. * @param space The space that the rotation is in
  13957. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13958. */
  13959. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13960. /**
  13961. * Set the rotation matrix of the bone in local of world space
  13962. * @param rotMat The rotation matrix that the bone should be set to
  13963. * @param space The space that the rotation is in
  13964. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13965. */
  13966. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13967. private _rotateWithMatrix;
  13968. private _getNegativeRotationToRef;
  13969. /**
  13970. * Get the position of the bone in local or world space
  13971. * @param space The space that the returned position is in
  13972. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13973. * @returns The position of the bone
  13974. */
  13975. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13976. /**
  13977. * Copy the position of the bone to a vector3 in local or world space
  13978. * @param space The space that the returned position is in
  13979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13980. * @param result The vector3 to copy the position to
  13981. */
  13982. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13983. /**
  13984. * Get the absolute position of the bone (world space)
  13985. * @param mesh The mesh that this bone is attached to
  13986. * @returns The absolute position of the bone
  13987. */
  13988. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13989. /**
  13990. * Copy the absolute position of the bone (world space) to the result param
  13991. * @param mesh The mesh that this bone is attached to
  13992. * @param result The vector3 to copy the absolute position to
  13993. */
  13994. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13995. /**
  13996. * Compute the absolute transforms of this bone and its children
  13997. */
  13998. computeAbsoluteTransforms(): void;
  13999. /**
  14000. * Get the world direction from an axis that is in the local space of the bone
  14001. * @param localAxis The local direction that is used to compute the world direction
  14002. * @param mesh The mesh that this bone is attached to
  14003. * @returns The world direction
  14004. */
  14005. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14006. /**
  14007. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14008. * @param localAxis The local direction that is used to compute the world direction
  14009. * @param mesh The mesh that this bone is attached to
  14010. * @param result The vector3 that the world direction will be copied to
  14011. */
  14012. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14013. /**
  14014. * Get the euler rotation of the bone in local or world space
  14015. * @param space The space that the rotation should be in
  14016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14017. * @returns The euler rotation
  14018. */
  14019. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14020. /**
  14021. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14022. * @param space The space that the rotation should be in
  14023. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14024. * @param result The vector3 that the rotation should be copied to
  14025. */
  14026. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14027. /**
  14028. * Get the quaternion rotation of the bone in either local or world space
  14029. * @param space The space that the rotation should be in
  14030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14031. * @returns The quaternion rotation
  14032. */
  14033. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14034. /**
  14035. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14036. * @param space The space that the rotation should be in
  14037. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14038. * @param result The quaternion that the rotation should be copied to
  14039. */
  14040. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14041. /**
  14042. * Get the rotation matrix of the bone in local or world space
  14043. * @param space The space that the rotation should be in
  14044. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14045. * @returns The rotation matrix
  14046. */
  14047. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14048. /**
  14049. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14050. * @param space The space that the rotation should be in
  14051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14052. * @param result The quaternion that the rotation should be copied to
  14053. */
  14054. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14055. /**
  14056. * Get the world position of a point that is in the local space of the bone
  14057. * @param position The local position
  14058. * @param mesh The mesh that this bone is attached to
  14059. * @returns The world position
  14060. */
  14061. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14062. /**
  14063. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14064. * @param position The local position
  14065. * @param mesh The mesh that this bone is attached to
  14066. * @param result The vector3 that the world position should be copied to
  14067. */
  14068. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14069. /**
  14070. * Get the local position of a point that is in world space
  14071. * @param position The world position
  14072. * @param mesh The mesh that this bone is attached to
  14073. * @returns The local position
  14074. */
  14075. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14076. /**
  14077. * Get the local position of a point that is in world space and copy it to the result param
  14078. * @param position The world position
  14079. * @param mesh The mesh that this bone is attached to
  14080. * @param result The vector3 that the local position should be copied to
  14081. */
  14082. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14083. }
  14084. }
  14085. declare module "babylonjs/Meshes/transformNode" {
  14086. import { DeepImmutable } from "babylonjs/types";
  14087. import { Observable } from "babylonjs/Misc/observable";
  14088. import { Nullable } from "babylonjs/types";
  14089. import { Camera } from "babylonjs/Cameras/camera";
  14090. import { Scene } from "babylonjs/scene";
  14091. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14092. import { Node } from "babylonjs/node";
  14093. import { Bone } from "babylonjs/Bones/bone";
  14094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14095. import { Space } from "babylonjs/Maths/math.axis";
  14096. /**
  14097. * 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.
  14098. * @see https://doc.babylonjs.com/how_to/transformnode
  14099. */
  14100. export class TransformNode extends Node {
  14101. /**
  14102. * Object will not rotate to face the camera
  14103. */
  14104. static BILLBOARDMODE_NONE: number;
  14105. /**
  14106. * Object will rotate to face the camera but only on the x axis
  14107. */
  14108. static BILLBOARDMODE_X: number;
  14109. /**
  14110. * Object will rotate to face the camera but only on the y axis
  14111. */
  14112. static BILLBOARDMODE_Y: number;
  14113. /**
  14114. * Object will rotate to face the camera but only on the z axis
  14115. */
  14116. static BILLBOARDMODE_Z: number;
  14117. /**
  14118. * Object will rotate to face the camera
  14119. */
  14120. static BILLBOARDMODE_ALL: number;
  14121. /**
  14122. * Object will rotate to face the camera's position instead of orientation
  14123. */
  14124. static BILLBOARDMODE_USE_POSITION: number;
  14125. private _forward;
  14126. private _forwardInverted;
  14127. private _up;
  14128. private _right;
  14129. private _rightInverted;
  14130. private _position;
  14131. private _rotation;
  14132. private _rotationQuaternion;
  14133. protected _scaling: Vector3;
  14134. protected _isDirty: boolean;
  14135. private _transformToBoneReferal;
  14136. private _isAbsoluteSynced;
  14137. private _billboardMode;
  14138. /**
  14139. * Gets or sets the billboard mode. Default is 0.
  14140. *
  14141. * | Value | Type | Description |
  14142. * | --- | --- | --- |
  14143. * | 0 | BILLBOARDMODE_NONE | |
  14144. * | 1 | BILLBOARDMODE_X | |
  14145. * | 2 | BILLBOARDMODE_Y | |
  14146. * | 4 | BILLBOARDMODE_Z | |
  14147. * | 7 | BILLBOARDMODE_ALL | |
  14148. *
  14149. */
  14150. billboardMode: number;
  14151. private _preserveParentRotationForBillboard;
  14152. /**
  14153. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14154. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14155. */
  14156. preserveParentRotationForBillboard: boolean;
  14157. /**
  14158. * 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
  14159. */
  14160. scalingDeterminant: number;
  14161. private _infiniteDistance;
  14162. /**
  14163. * Gets or sets the distance of the object to max, often used by skybox
  14164. */
  14165. infiniteDistance: boolean;
  14166. /**
  14167. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14168. * By default the system will update normals to compensate
  14169. */
  14170. ignoreNonUniformScaling: boolean;
  14171. /**
  14172. * 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
  14173. */
  14174. reIntegrateRotationIntoRotationQuaternion: boolean;
  14175. /** @hidden */
  14176. _poseMatrix: Nullable<Matrix>;
  14177. /** @hidden */
  14178. _localMatrix: Matrix;
  14179. private _usePivotMatrix;
  14180. private _absolutePosition;
  14181. private _absoluteScaling;
  14182. private _absoluteRotationQuaternion;
  14183. private _pivotMatrix;
  14184. private _pivotMatrixInverse;
  14185. protected _postMultiplyPivotMatrix: boolean;
  14186. protected _isWorldMatrixFrozen: boolean;
  14187. /** @hidden */
  14188. _indexInSceneTransformNodesArray: number;
  14189. /**
  14190. * An event triggered after the world matrix is updated
  14191. */
  14192. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14193. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14194. /**
  14195. * Gets a string identifying the name of the class
  14196. * @returns "TransformNode" string
  14197. */
  14198. getClassName(): string;
  14199. /**
  14200. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14201. */
  14202. position: Vector3;
  14203. /**
  14204. * 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)).
  14205. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14206. */
  14207. rotation: Vector3;
  14208. /**
  14209. * 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)).
  14210. */
  14211. scaling: Vector3;
  14212. /**
  14213. * 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).
  14214. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14215. */
  14216. rotationQuaternion: Nullable<Quaternion>;
  14217. /**
  14218. * The forward direction of that transform in world space.
  14219. */
  14220. readonly forward: Vector3;
  14221. /**
  14222. * The up direction of that transform in world space.
  14223. */
  14224. readonly up: Vector3;
  14225. /**
  14226. * The right direction of that transform in world space.
  14227. */
  14228. readonly right: Vector3;
  14229. /**
  14230. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14231. * @param matrix the matrix to copy the pose from
  14232. * @returns this TransformNode.
  14233. */
  14234. updatePoseMatrix(matrix: Matrix): TransformNode;
  14235. /**
  14236. * Returns the mesh Pose matrix.
  14237. * @returns the pose matrix
  14238. */
  14239. getPoseMatrix(): Matrix;
  14240. /** @hidden */
  14241. _isSynchronized(): boolean;
  14242. /** @hidden */
  14243. _initCache(): void;
  14244. /**
  14245. * Flag the transform node as dirty (Forcing it to update everything)
  14246. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14247. * @returns this transform node
  14248. */
  14249. markAsDirty(property: string): TransformNode;
  14250. /**
  14251. * Returns the current mesh absolute position.
  14252. * Returns a Vector3.
  14253. */
  14254. readonly absolutePosition: Vector3;
  14255. /**
  14256. * Returns the current mesh absolute scaling.
  14257. * Returns a Vector3.
  14258. */
  14259. readonly absoluteScaling: Vector3;
  14260. /**
  14261. * Returns the current mesh absolute rotation.
  14262. * Returns a Quaternion.
  14263. */
  14264. readonly absoluteRotationQuaternion: Quaternion;
  14265. /**
  14266. * Sets a new matrix to apply before all other transformation
  14267. * @param matrix defines the transform matrix
  14268. * @returns the current TransformNode
  14269. */
  14270. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14271. /**
  14272. * Sets a new pivot matrix to the current node
  14273. * @param matrix defines the new pivot matrix to use
  14274. * @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
  14275. * @returns the current TransformNode
  14276. */
  14277. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14278. /**
  14279. * Returns the mesh pivot matrix.
  14280. * Default : Identity.
  14281. * @returns the matrix
  14282. */
  14283. getPivotMatrix(): Matrix;
  14284. /**
  14285. * Instantiate (when possible) or clone that node with its hierarchy
  14286. * @param newParent defines the new parent to use for the instance (or clone)
  14287. * @returns an instance (or a clone) of the current node with its hiearchy
  14288. */
  14289. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14290. /**
  14291. * Prevents the World matrix to be computed any longer
  14292. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14293. * @returns the TransformNode.
  14294. */
  14295. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14296. /**
  14297. * Allows back the World matrix computation.
  14298. * @returns the TransformNode.
  14299. */
  14300. unfreezeWorldMatrix(): this;
  14301. /**
  14302. * True if the World matrix has been frozen.
  14303. */
  14304. readonly isWorldMatrixFrozen: boolean;
  14305. /**
  14306. * Retuns the mesh absolute position in the World.
  14307. * @returns a Vector3.
  14308. */
  14309. getAbsolutePosition(): Vector3;
  14310. /**
  14311. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14312. * @param absolutePosition the absolute position to set
  14313. * @returns the TransformNode.
  14314. */
  14315. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14316. /**
  14317. * Sets the mesh position in its local space.
  14318. * @param vector3 the position to set in localspace
  14319. * @returns the TransformNode.
  14320. */
  14321. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14322. /**
  14323. * Returns the mesh position in the local space from the current World matrix values.
  14324. * @returns a new Vector3.
  14325. */
  14326. getPositionExpressedInLocalSpace(): Vector3;
  14327. /**
  14328. * Translates the mesh along the passed Vector3 in its local space.
  14329. * @param vector3 the distance to translate in localspace
  14330. * @returns the TransformNode.
  14331. */
  14332. locallyTranslate(vector3: Vector3): TransformNode;
  14333. private static _lookAtVectorCache;
  14334. /**
  14335. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14336. * @param targetPoint the position (must be in same space as current mesh) to look at
  14337. * @param yawCor optional yaw (y-axis) correction in radians
  14338. * @param pitchCor optional pitch (x-axis) correction in radians
  14339. * @param rollCor optional roll (z-axis) correction in radians
  14340. * @param space the choosen space of the target
  14341. * @returns the TransformNode.
  14342. */
  14343. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14344. /**
  14345. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14346. * This Vector3 is expressed in the World space.
  14347. * @param localAxis axis to rotate
  14348. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14349. */
  14350. getDirection(localAxis: Vector3): Vector3;
  14351. /**
  14352. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14353. * localAxis is expressed in the mesh local space.
  14354. * result is computed in the Wordl space from the mesh World matrix.
  14355. * @param localAxis axis to rotate
  14356. * @param result the resulting transformnode
  14357. * @returns this TransformNode.
  14358. */
  14359. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14360. /**
  14361. * Sets this transform node rotation to the given local axis.
  14362. * @param localAxis the axis in local space
  14363. * @param yawCor optional yaw (y-axis) correction in radians
  14364. * @param pitchCor optional pitch (x-axis) correction in radians
  14365. * @param rollCor optional roll (z-axis) correction in radians
  14366. * @returns this TransformNode
  14367. */
  14368. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14369. /**
  14370. * Sets a new pivot point to the current node
  14371. * @param point defines the new pivot point to use
  14372. * @param space defines if the point is in world or local space (local by default)
  14373. * @returns the current TransformNode
  14374. */
  14375. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14376. /**
  14377. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14378. * @returns the pivot point
  14379. */
  14380. getPivotPoint(): Vector3;
  14381. /**
  14382. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14383. * @param result the vector3 to store the result
  14384. * @returns this TransformNode.
  14385. */
  14386. getPivotPointToRef(result: Vector3): TransformNode;
  14387. /**
  14388. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14389. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14390. */
  14391. getAbsolutePivotPoint(): Vector3;
  14392. /**
  14393. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14394. * @param result vector3 to store the result
  14395. * @returns this TransformNode.
  14396. */
  14397. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14398. /**
  14399. * Defines the passed node as the parent of the current node.
  14400. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14401. * @see https://doc.babylonjs.com/how_to/parenting
  14402. * @param node the node ot set as the parent
  14403. * @returns this TransformNode.
  14404. */
  14405. setParent(node: Nullable<Node>): TransformNode;
  14406. private _nonUniformScaling;
  14407. /**
  14408. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14409. */
  14410. readonly nonUniformScaling: boolean;
  14411. /** @hidden */
  14412. _updateNonUniformScalingState(value: boolean): boolean;
  14413. /**
  14414. * Attach the current TransformNode to another TransformNode associated with a bone
  14415. * @param bone Bone affecting the TransformNode
  14416. * @param affectedTransformNode TransformNode associated with the bone
  14417. * @returns this object
  14418. */
  14419. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14420. /**
  14421. * Detach the transform node if its associated with a bone
  14422. * @returns this object
  14423. */
  14424. detachFromBone(): TransformNode;
  14425. private static _rotationAxisCache;
  14426. /**
  14427. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14428. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14429. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14430. * The passed axis is also normalized.
  14431. * @param axis the axis to rotate around
  14432. * @param amount the amount to rotate in radians
  14433. * @param space Space to rotate in (Default: local)
  14434. * @returns the TransformNode.
  14435. */
  14436. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14437. /**
  14438. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14439. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14440. * The passed axis is also normalized. .
  14441. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14442. * @param point the point to rotate around
  14443. * @param axis the axis to rotate around
  14444. * @param amount the amount to rotate in radians
  14445. * @returns the TransformNode
  14446. */
  14447. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14448. /**
  14449. * Translates the mesh along the axis vector for the passed distance in the given space.
  14450. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14451. * @param axis the axis to translate in
  14452. * @param distance the distance to translate
  14453. * @param space Space to rotate in (Default: local)
  14454. * @returns the TransformNode.
  14455. */
  14456. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14457. /**
  14458. * Adds a rotation step to the mesh current rotation.
  14459. * x, y, z are Euler angles expressed in radians.
  14460. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14461. * This means this rotation is made in the mesh local space only.
  14462. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14463. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14464. * ```javascript
  14465. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14466. * ```
  14467. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14468. * 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.
  14469. * @param x Rotation to add
  14470. * @param y Rotation to add
  14471. * @param z Rotation to add
  14472. * @returns the TransformNode.
  14473. */
  14474. addRotation(x: number, y: number, z: number): TransformNode;
  14475. /**
  14476. * @hidden
  14477. */
  14478. protected _getEffectiveParent(): Nullable<Node>;
  14479. /**
  14480. * Computes the world matrix of the node
  14481. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14482. * @returns the world matrix
  14483. */
  14484. computeWorldMatrix(force?: boolean): Matrix;
  14485. protected _afterComputeWorldMatrix(): void;
  14486. /**
  14487. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14488. * @param func callback function to add
  14489. *
  14490. * @returns the TransformNode.
  14491. */
  14492. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14493. /**
  14494. * Removes a registered callback function.
  14495. * @param func callback function to remove
  14496. * @returns the TransformNode.
  14497. */
  14498. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14499. /**
  14500. * Gets the position of the current mesh in camera space
  14501. * @param camera defines the camera to use
  14502. * @returns a position
  14503. */
  14504. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14505. /**
  14506. * Returns the distance from the mesh to the active camera
  14507. * @param camera defines the camera to use
  14508. * @returns the distance
  14509. */
  14510. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14511. /**
  14512. * Clone the current transform node
  14513. * @param name Name of the new clone
  14514. * @param newParent New parent for the clone
  14515. * @param doNotCloneChildren Do not clone children hierarchy
  14516. * @returns the new transform node
  14517. */
  14518. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14519. /**
  14520. * Serializes the objects information.
  14521. * @param currentSerializationObject defines the object to serialize in
  14522. * @returns the serialized object
  14523. */
  14524. serialize(currentSerializationObject?: any): any;
  14525. /**
  14526. * Returns a new TransformNode object parsed from the source provided.
  14527. * @param parsedTransformNode is the source.
  14528. * @param scene the scne the object belongs to
  14529. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14530. * @returns a new TransformNode object parsed from the source provided.
  14531. */
  14532. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14533. /**
  14534. * Get all child-transformNodes of this node
  14535. * @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
  14536. * @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
  14537. * @returns an array of TransformNode
  14538. */
  14539. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14540. /**
  14541. * Releases resources associated with this transform node.
  14542. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14543. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14544. */
  14545. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14546. /**
  14547. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14548. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14549. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14550. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14551. * @returns the current mesh
  14552. */
  14553. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14554. private _syncAbsoluteScalingAndRotation;
  14555. }
  14556. }
  14557. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14558. import { Observable } from "babylonjs/Misc/observable";
  14559. import { Nullable } from "babylonjs/types";
  14560. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14561. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14563. import { Ray } from "babylonjs/Culling/ray";
  14564. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14565. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14566. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14567. /**
  14568. * Defines the types of pose enabled controllers that are supported
  14569. */
  14570. export enum PoseEnabledControllerType {
  14571. /**
  14572. * HTC Vive
  14573. */
  14574. VIVE = 0,
  14575. /**
  14576. * Oculus Rift
  14577. */
  14578. OCULUS = 1,
  14579. /**
  14580. * Windows mixed reality
  14581. */
  14582. WINDOWS = 2,
  14583. /**
  14584. * Samsung gear VR
  14585. */
  14586. GEAR_VR = 3,
  14587. /**
  14588. * Google Daydream
  14589. */
  14590. DAYDREAM = 4,
  14591. /**
  14592. * Generic
  14593. */
  14594. GENERIC = 5
  14595. }
  14596. /**
  14597. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14598. */
  14599. export interface MutableGamepadButton {
  14600. /**
  14601. * Value of the button/trigger
  14602. */
  14603. value: number;
  14604. /**
  14605. * If the button/trigger is currently touched
  14606. */
  14607. touched: boolean;
  14608. /**
  14609. * If the button/trigger is currently pressed
  14610. */
  14611. pressed: boolean;
  14612. }
  14613. /**
  14614. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14615. * @hidden
  14616. */
  14617. export interface ExtendedGamepadButton extends GamepadButton {
  14618. /**
  14619. * If the button/trigger is currently pressed
  14620. */
  14621. readonly pressed: boolean;
  14622. /**
  14623. * If the button/trigger is currently touched
  14624. */
  14625. readonly touched: boolean;
  14626. /**
  14627. * Value of the button/trigger
  14628. */
  14629. readonly value: number;
  14630. }
  14631. /** @hidden */
  14632. export interface _GamePadFactory {
  14633. /**
  14634. * Returns wether or not the current gamepad can be created for this type of controller.
  14635. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14636. * @returns true if it can be created, otherwise false
  14637. */
  14638. canCreate(gamepadInfo: any): boolean;
  14639. /**
  14640. * Creates a new instance of the Gamepad.
  14641. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14642. * @returns the new gamepad instance
  14643. */
  14644. create(gamepadInfo: any): Gamepad;
  14645. }
  14646. /**
  14647. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14648. */
  14649. export class PoseEnabledControllerHelper {
  14650. /** @hidden */
  14651. static _ControllerFactories: _GamePadFactory[];
  14652. /** @hidden */
  14653. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14654. /**
  14655. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14656. * @param vrGamepad the gamepad to initialized
  14657. * @returns a vr controller of the type the gamepad identified as
  14658. */
  14659. static InitiateController(vrGamepad: any): Gamepad;
  14660. }
  14661. /**
  14662. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14663. */
  14664. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14665. /**
  14666. * If the controller is used in a webXR session
  14667. */
  14668. isXR: boolean;
  14669. private _deviceRoomPosition;
  14670. private _deviceRoomRotationQuaternion;
  14671. /**
  14672. * The device position in babylon space
  14673. */
  14674. devicePosition: Vector3;
  14675. /**
  14676. * The device rotation in babylon space
  14677. */
  14678. deviceRotationQuaternion: Quaternion;
  14679. /**
  14680. * The scale factor of the device in babylon space
  14681. */
  14682. deviceScaleFactor: number;
  14683. /**
  14684. * (Likely devicePosition should be used instead) The device position in its room space
  14685. */
  14686. position: Vector3;
  14687. /**
  14688. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14689. */
  14690. rotationQuaternion: Quaternion;
  14691. /**
  14692. * The type of controller (Eg. Windows mixed reality)
  14693. */
  14694. controllerType: PoseEnabledControllerType;
  14695. protected _calculatedPosition: Vector3;
  14696. private _calculatedRotation;
  14697. /**
  14698. * The raw pose from the device
  14699. */
  14700. rawPose: DevicePose;
  14701. private _trackPosition;
  14702. private _maxRotationDistFromHeadset;
  14703. private _draggedRoomRotation;
  14704. /**
  14705. * @hidden
  14706. */
  14707. _disableTrackPosition(fixedPosition: Vector3): void;
  14708. /**
  14709. * Internal, the mesh attached to the controller
  14710. * @hidden
  14711. */
  14712. _mesh: Nullable<AbstractMesh>;
  14713. private _poseControlledCamera;
  14714. private _leftHandSystemQuaternion;
  14715. /**
  14716. * Internal, matrix used to convert room space to babylon space
  14717. * @hidden
  14718. */
  14719. _deviceToWorld: Matrix;
  14720. /**
  14721. * Node to be used when casting a ray from the controller
  14722. * @hidden
  14723. */
  14724. _pointingPoseNode: Nullable<TransformNode>;
  14725. /**
  14726. * Name of the child mesh that can be used to cast a ray from the controller
  14727. */
  14728. static readonly POINTING_POSE: string;
  14729. /**
  14730. * Creates a new PoseEnabledController from a gamepad
  14731. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14732. */
  14733. constructor(browserGamepad: any);
  14734. private _workingMatrix;
  14735. /**
  14736. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14737. */
  14738. update(): void;
  14739. /**
  14740. * Updates only the pose device and mesh without doing any button event checking
  14741. */
  14742. protected _updatePoseAndMesh(): void;
  14743. /**
  14744. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14745. * @param poseData raw pose fromthe device
  14746. */
  14747. updateFromDevice(poseData: DevicePose): void;
  14748. /**
  14749. * @hidden
  14750. */
  14751. _meshAttachedObservable: Observable<AbstractMesh>;
  14752. /**
  14753. * Attaches a mesh to the controller
  14754. * @param mesh the mesh to be attached
  14755. */
  14756. attachToMesh(mesh: AbstractMesh): void;
  14757. /**
  14758. * Attaches the controllers mesh to a camera
  14759. * @param camera the camera the mesh should be attached to
  14760. */
  14761. attachToPoseControlledCamera(camera: TargetCamera): void;
  14762. /**
  14763. * Disposes of the controller
  14764. */
  14765. dispose(): void;
  14766. /**
  14767. * The mesh that is attached to the controller
  14768. */
  14769. readonly mesh: Nullable<AbstractMesh>;
  14770. /**
  14771. * Gets the ray of the controller in the direction the controller is pointing
  14772. * @param length the length the resulting ray should be
  14773. * @returns a ray in the direction the controller is pointing
  14774. */
  14775. getForwardRay(length?: number): Ray;
  14776. }
  14777. }
  14778. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14779. import { Observable } from "babylonjs/Misc/observable";
  14780. import { Scene } from "babylonjs/scene";
  14781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14782. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14783. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14784. import { Nullable } from "babylonjs/types";
  14785. /**
  14786. * Defines the WebVRController object that represents controllers tracked in 3D space
  14787. */
  14788. export abstract class WebVRController extends PoseEnabledController {
  14789. /**
  14790. * Internal, the default controller model for the controller
  14791. */
  14792. protected _defaultModel: Nullable<AbstractMesh>;
  14793. /**
  14794. * Fired when the trigger state has changed
  14795. */
  14796. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14797. /**
  14798. * Fired when the main button state has changed
  14799. */
  14800. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14801. /**
  14802. * Fired when the secondary button state has changed
  14803. */
  14804. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14805. /**
  14806. * Fired when the pad state has changed
  14807. */
  14808. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14809. /**
  14810. * Fired when controllers stick values have changed
  14811. */
  14812. onPadValuesChangedObservable: Observable<StickValues>;
  14813. /**
  14814. * Array of button availible on the controller
  14815. */
  14816. protected _buttons: Array<MutableGamepadButton>;
  14817. private _onButtonStateChange;
  14818. /**
  14819. * Fired when a controller button's state has changed
  14820. * @param callback the callback containing the button that was modified
  14821. */
  14822. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14823. /**
  14824. * X and Y axis corresponding to the controllers joystick
  14825. */
  14826. pad: StickValues;
  14827. /**
  14828. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14829. */
  14830. hand: string;
  14831. /**
  14832. * The default controller model for the controller
  14833. */
  14834. readonly defaultModel: Nullable<AbstractMesh>;
  14835. /**
  14836. * Creates a new WebVRController from a gamepad
  14837. * @param vrGamepad the gamepad that the WebVRController should be created from
  14838. */
  14839. constructor(vrGamepad: any);
  14840. /**
  14841. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14842. */
  14843. update(): void;
  14844. /**
  14845. * Function to be called when a button is modified
  14846. */
  14847. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14848. /**
  14849. * Loads a mesh and attaches it to the controller
  14850. * @param scene the scene the mesh should be added to
  14851. * @param meshLoaded callback for when the mesh has been loaded
  14852. */
  14853. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14854. private _setButtonValue;
  14855. private _changes;
  14856. private _checkChanges;
  14857. /**
  14858. * Disposes of th webVRCOntroller
  14859. */
  14860. dispose(): void;
  14861. }
  14862. }
  14863. declare module "babylonjs/Lights/hemisphericLight" {
  14864. import { Nullable } from "babylonjs/types";
  14865. import { Scene } from "babylonjs/scene";
  14866. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14867. import { Color3 } from "babylonjs/Maths/math.color";
  14868. import { Effect } from "babylonjs/Materials/effect";
  14869. import { Light } from "babylonjs/Lights/light";
  14870. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14871. /**
  14872. * The HemisphericLight simulates the ambient environment light,
  14873. * so the passed direction is the light reflection direction, not the incoming direction.
  14874. */
  14875. export class HemisphericLight extends Light {
  14876. /**
  14877. * The groundColor is the light in the opposite direction to the one specified during creation.
  14878. * 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.
  14879. */
  14880. groundColor: Color3;
  14881. /**
  14882. * The light reflection direction, not the incoming direction.
  14883. */
  14884. direction: Vector3;
  14885. /**
  14886. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14887. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14888. * The HemisphericLight can't cast shadows.
  14889. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14890. * @param name The friendly name of the light
  14891. * @param direction The direction of the light reflection
  14892. * @param scene The scene the light belongs to
  14893. */
  14894. constructor(name: string, direction: Vector3, scene: Scene);
  14895. protected _buildUniformLayout(): void;
  14896. /**
  14897. * Returns the string "HemisphericLight".
  14898. * @return The class name
  14899. */
  14900. getClassName(): string;
  14901. /**
  14902. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14903. * Returns the updated direction.
  14904. * @param target The target the direction should point to
  14905. * @return The computed direction
  14906. */
  14907. setDirectionToTarget(target: Vector3): Vector3;
  14908. /**
  14909. * Returns the shadow generator associated to the light.
  14910. * @returns Always null for hemispheric lights because it does not support shadows.
  14911. */
  14912. getShadowGenerator(): Nullable<IShadowGenerator>;
  14913. /**
  14914. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14915. * @param effect The effect to update
  14916. * @param lightIndex The index of the light in the effect to update
  14917. * @returns The hemispheric light
  14918. */
  14919. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14920. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14921. /**
  14922. * Computes the world matrix of the node
  14923. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14924. * @param useWasUpdatedFlag defines a reserved property
  14925. * @returns the world matrix
  14926. */
  14927. computeWorldMatrix(): Matrix;
  14928. /**
  14929. * Returns the integer 3.
  14930. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14931. */
  14932. getTypeID(): number;
  14933. /**
  14934. * Prepares the list of defines specific to the light type.
  14935. * @param defines the list of defines
  14936. * @param lightIndex defines the index of the light for the effect
  14937. */
  14938. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14939. }
  14940. }
  14941. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14942. /** @hidden */
  14943. export var vrMultiviewToSingleviewPixelShader: {
  14944. name: string;
  14945. shader: string;
  14946. };
  14947. }
  14948. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14949. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14950. import { Scene } from "babylonjs/scene";
  14951. /**
  14952. * Renders to multiple views with a single draw call
  14953. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14954. */
  14955. export class MultiviewRenderTarget extends RenderTargetTexture {
  14956. /**
  14957. * Creates a multiview render target
  14958. * @param scene scene used with the render target
  14959. * @param size the size of the render target (used for each view)
  14960. */
  14961. constructor(scene: Scene, size?: number | {
  14962. width: number;
  14963. height: number;
  14964. } | {
  14965. ratio: number;
  14966. });
  14967. /**
  14968. * @hidden
  14969. * @param faceIndex the face index, if its a cube texture
  14970. */
  14971. _bindFrameBuffer(faceIndex?: number): void;
  14972. /**
  14973. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14974. * @returns the view count
  14975. */
  14976. getViewCount(): number;
  14977. }
  14978. }
  14979. declare module "babylonjs/Maths/math.frustum" {
  14980. import { Matrix } from "babylonjs/Maths/math.vector";
  14981. import { DeepImmutable } from "babylonjs/types";
  14982. import { Plane } from "babylonjs/Maths/math.plane";
  14983. /**
  14984. * Represents a camera frustum
  14985. */
  14986. export class Frustum {
  14987. /**
  14988. * Gets the planes representing the frustum
  14989. * @param transform matrix to be applied to the returned planes
  14990. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14991. */
  14992. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14993. /**
  14994. * Gets the near frustum plane transformed by the transform matrix
  14995. * @param transform transformation matrix to be applied to the resulting frustum plane
  14996. * @param frustumPlane the resuling frustum plane
  14997. */
  14998. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14999. /**
  15000. * Gets the far frustum plane transformed by the transform matrix
  15001. * @param transform transformation matrix to be applied to the resulting frustum plane
  15002. * @param frustumPlane the resuling frustum plane
  15003. */
  15004. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15005. /**
  15006. * Gets the left frustum plane transformed by the transform matrix
  15007. * @param transform transformation matrix to be applied to the resulting frustum plane
  15008. * @param frustumPlane the resuling frustum plane
  15009. */
  15010. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15011. /**
  15012. * Gets the right frustum plane transformed by the transform matrix
  15013. * @param transform transformation matrix to be applied to the resulting frustum plane
  15014. * @param frustumPlane the resuling frustum plane
  15015. */
  15016. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15017. /**
  15018. * Gets the top frustum plane transformed by the transform matrix
  15019. * @param transform transformation matrix to be applied to the resulting frustum plane
  15020. * @param frustumPlane the resuling frustum plane
  15021. */
  15022. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15023. /**
  15024. * Gets the bottom frustum plane transformed by the transform matrix
  15025. * @param transform transformation matrix to be applied to the resulting frustum plane
  15026. * @param frustumPlane the resuling frustum plane
  15027. */
  15028. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15029. /**
  15030. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15031. * @param transform transformation matrix to be applied to the resulting frustum planes
  15032. * @param frustumPlanes the resuling frustum planes
  15033. */
  15034. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15035. }
  15036. }
  15037. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15038. import { Camera } from "babylonjs/Cameras/camera";
  15039. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15040. import { Nullable } from "babylonjs/types";
  15041. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15042. import { Matrix } from "babylonjs/Maths/math.vector";
  15043. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15044. module "babylonjs/Engines/engine" {
  15045. interface Engine {
  15046. /**
  15047. * Creates a new multiview render target
  15048. * @param width defines the width of the texture
  15049. * @param height defines the height of the texture
  15050. * @returns the created multiview texture
  15051. */
  15052. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15053. /**
  15054. * Binds a multiview framebuffer to be drawn to
  15055. * @param multiviewTexture texture to bind
  15056. */
  15057. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15058. }
  15059. }
  15060. module "babylonjs/Cameras/camera" {
  15061. interface Camera {
  15062. /**
  15063. * @hidden
  15064. * 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)
  15065. */
  15066. _useMultiviewToSingleView: boolean;
  15067. /**
  15068. * @hidden
  15069. * 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)
  15070. */
  15071. _multiviewTexture: Nullable<RenderTargetTexture>;
  15072. /**
  15073. * @hidden
  15074. * ensures the multiview texture of the camera exists and has the specified width/height
  15075. * @param width height to set on the multiview texture
  15076. * @param height width to set on the multiview texture
  15077. */
  15078. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15079. }
  15080. }
  15081. module "babylonjs/scene" {
  15082. interface Scene {
  15083. /** @hidden */
  15084. _transformMatrixR: Matrix;
  15085. /** @hidden */
  15086. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15087. /** @hidden */
  15088. _createMultiviewUbo(): void;
  15089. /** @hidden */
  15090. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15091. /** @hidden */
  15092. _renderMultiviewToSingleView(camera: Camera): void;
  15093. }
  15094. }
  15095. }
  15096. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15097. import { Camera } from "babylonjs/Cameras/camera";
  15098. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15099. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15100. import "babylonjs/Engines/Extensions/engine.multiview";
  15101. /**
  15102. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15103. * This will not be used for webXR as it supports displaying texture arrays directly
  15104. */
  15105. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15106. /**
  15107. * Initializes a VRMultiviewToSingleview
  15108. * @param name name of the post process
  15109. * @param camera camera to be applied to
  15110. * @param scaleFactor scaling factor to the size of the output texture
  15111. */
  15112. constructor(name: string, camera: Camera, scaleFactor: number);
  15113. }
  15114. }
  15115. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15116. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15117. import { Nullable } from "babylonjs/types";
  15118. import { Size } from "babylonjs/Maths/math.size";
  15119. import { Observable } from "babylonjs/Misc/observable";
  15120. module "babylonjs/Engines/engine" {
  15121. interface Engine {
  15122. /** @hidden */
  15123. _vrDisplay: any;
  15124. /** @hidden */
  15125. _vrSupported: boolean;
  15126. /** @hidden */
  15127. _oldSize: Size;
  15128. /** @hidden */
  15129. _oldHardwareScaleFactor: number;
  15130. /** @hidden */
  15131. _vrExclusivePointerMode: boolean;
  15132. /** @hidden */
  15133. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15134. /** @hidden */
  15135. _onVRDisplayPointerRestricted: () => void;
  15136. /** @hidden */
  15137. _onVRDisplayPointerUnrestricted: () => void;
  15138. /** @hidden */
  15139. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15140. /** @hidden */
  15141. _onVrDisplayDisconnect: Nullable<() => void>;
  15142. /** @hidden */
  15143. _onVrDisplayPresentChange: Nullable<() => void>;
  15144. /**
  15145. * Observable signaled when VR display mode changes
  15146. */
  15147. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15148. /**
  15149. * Observable signaled when VR request present is complete
  15150. */
  15151. onVRRequestPresentComplete: Observable<boolean>;
  15152. /**
  15153. * Observable signaled when VR request present starts
  15154. */
  15155. onVRRequestPresentStart: Observable<Engine>;
  15156. /**
  15157. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15158. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15159. */
  15160. isInVRExclusivePointerMode: boolean;
  15161. /**
  15162. * Gets a boolean indicating if a webVR device was detected
  15163. * @returns true if a webVR device was detected
  15164. */
  15165. isVRDevicePresent(): boolean;
  15166. /**
  15167. * Gets the current webVR device
  15168. * @returns the current webVR device (or null)
  15169. */
  15170. getVRDevice(): any;
  15171. /**
  15172. * Initializes a webVR display and starts listening to display change events
  15173. * The onVRDisplayChangedObservable will be notified upon these changes
  15174. * @returns A promise containing a VRDisplay and if vr is supported
  15175. */
  15176. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15177. /** @hidden */
  15178. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15179. /**
  15180. * Call this function to switch to webVR mode
  15181. * Will do nothing if webVR is not supported or if there is no webVR device
  15182. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15183. */
  15184. enableVR(): void;
  15185. /** @hidden */
  15186. _onVRFullScreenTriggered(): void;
  15187. }
  15188. }
  15189. }
  15190. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15191. import { Nullable } from "babylonjs/types";
  15192. import { Observable } from "babylonjs/Misc/observable";
  15193. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15194. import { Scene } from "babylonjs/scene";
  15195. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15196. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15197. import { Node } from "babylonjs/node";
  15198. import { Ray } from "babylonjs/Culling/ray";
  15199. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15200. import "babylonjs/Engines/Extensions/engine.webVR";
  15201. /**
  15202. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15203. * IMPORTANT!! The data is right-hand data.
  15204. * @export
  15205. * @interface DevicePose
  15206. */
  15207. export interface DevicePose {
  15208. /**
  15209. * The position of the device, values in array are [x,y,z].
  15210. */
  15211. readonly position: Nullable<Float32Array>;
  15212. /**
  15213. * The linearVelocity of the device, values in array are [x,y,z].
  15214. */
  15215. readonly linearVelocity: Nullable<Float32Array>;
  15216. /**
  15217. * The linearAcceleration of the device, values in array are [x,y,z].
  15218. */
  15219. readonly linearAcceleration: Nullable<Float32Array>;
  15220. /**
  15221. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15222. */
  15223. readonly orientation: Nullable<Float32Array>;
  15224. /**
  15225. * The angularVelocity of the device, values in array are [x,y,z].
  15226. */
  15227. readonly angularVelocity: Nullable<Float32Array>;
  15228. /**
  15229. * The angularAcceleration of the device, values in array are [x,y,z].
  15230. */
  15231. readonly angularAcceleration: Nullable<Float32Array>;
  15232. }
  15233. /**
  15234. * Interface representing a pose controlled object in Babylon.
  15235. * A pose controlled object has both regular pose values as well as pose values
  15236. * from an external device such as a VR head mounted display
  15237. */
  15238. export interface PoseControlled {
  15239. /**
  15240. * The position of the object in babylon space.
  15241. */
  15242. position: Vector3;
  15243. /**
  15244. * The rotation quaternion of the object in babylon space.
  15245. */
  15246. rotationQuaternion: Quaternion;
  15247. /**
  15248. * The position of the device in babylon space.
  15249. */
  15250. devicePosition?: Vector3;
  15251. /**
  15252. * The rotation quaternion of the device in babylon space.
  15253. */
  15254. deviceRotationQuaternion: Quaternion;
  15255. /**
  15256. * The raw pose coming from the device.
  15257. */
  15258. rawPose: Nullable<DevicePose>;
  15259. /**
  15260. * The scale of the device to be used when translating from device space to babylon space.
  15261. */
  15262. deviceScaleFactor: number;
  15263. /**
  15264. * Updates the poseControlled values based on the input device pose.
  15265. * @param poseData the pose data to update the object with
  15266. */
  15267. updateFromDevice(poseData: DevicePose): void;
  15268. }
  15269. /**
  15270. * Set of options to customize the webVRCamera
  15271. */
  15272. export interface WebVROptions {
  15273. /**
  15274. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15275. */
  15276. trackPosition?: boolean;
  15277. /**
  15278. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15279. */
  15280. positionScale?: number;
  15281. /**
  15282. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15283. */
  15284. displayName?: string;
  15285. /**
  15286. * Should the native controller meshes be initialized. (default: true)
  15287. */
  15288. controllerMeshes?: boolean;
  15289. /**
  15290. * Creating a default HemiLight only on controllers. (default: true)
  15291. */
  15292. defaultLightingOnControllers?: boolean;
  15293. /**
  15294. * If you don't want to use the default VR button of the helper. (default: false)
  15295. */
  15296. useCustomVRButton?: boolean;
  15297. /**
  15298. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15299. */
  15300. customVRButton?: HTMLButtonElement;
  15301. /**
  15302. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15303. */
  15304. rayLength?: number;
  15305. /**
  15306. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15307. */
  15308. defaultHeight?: number;
  15309. /**
  15310. * If multiview should be used if availible (default: false)
  15311. */
  15312. useMultiview?: boolean;
  15313. }
  15314. /**
  15315. * This represents a WebVR camera.
  15316. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15317. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15318. */
  15319. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15320. private webVROptions;
  15321. /**
  15322. * @hidden
  15323. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15324. */
  15325. _vrDevice: any;
  15326. /**
  15327. * The rawPose of the vrDevice.
  15328. */
  15329. rawPose: Nullable<DevicePose>;
  15330. private _onVREnabled;
  15331. private _specsVersion;
  15332. private _attached;
  15333. private _frameData;
  15334. protected _descendants: Array<Node>;
  15335. private _deviceRoomPosition;
  15336. /** @hidden */
  15337. _deviceRoomRotationQuaternion: Quaternion;
  15338. private _standingMatrix;
  15339. /**
  15340. * Represents device position in babylon space.
  15341. */
  15342. devicePosition: Vector3;
  15343. /**
  15344. * Represents device rotation in babylon space.
  15345. */
  15346. deviceRotationQuaternion: Quaternion;
  15347. /**
  15348. * The scale of the device to be used when translating from device space to babylon space.
  15349. */
  15350. deviceScaleFactor: number;
  15351. private _deviceToWorld;
  15352. private _worldToDevice;
  15353. /**
  15354. * References to the webVR controllers for the vrDevice.
  15355. */
  15356. controllers: Array<WebVRController>;
  15357. /**
  15358. * Emits an event when a controller is attached.
  15359. */
  15360. onControllersAttachedObservable: Observable<WebVRController[]>;
  15361. /**
  15362. * Emits an event when a controller's mesh has been loaded;
  15363. */
  15364. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15365. /**
  15366. * Emits an event when the HMD's pose has been updated.
  15367. */
  15368. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15369. private _poseSet;
  15370. /**
  15371. * If the rig cameras be used as parent instead of this camera.
  15372. */
  15373. rigParenting: boolean;
  15374. private _lightOnControllers;
  15375. private _defaultHeight?;
  15376. /**
  15377. * Instantiates a WebVRFreeCamera.
  15378. * @param name The name of the WebVRFreeCamera
  15379. * @param position The starting anchor position for the camera
  15380. * @param scene The scene the camera belongs to
  15381. * @param webVROptions a set of customizable options for the webVRCamera
  15382. */
  15383. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15384. /**
  15385. * Gets the device distance from the ground in meters.
  15386. * @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.
  15387. */
  15388. deviceDistanceToRoomGround(): number;
  15389. /**
  15390. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15391. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15392. */
  15393. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15394. /**
  15395. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15396. * @returns A promise with a boolean set to if the standing matrix is supported.
  15397. */
  15398. useStandingMatrixAsync(): Promise<boolean>;
  15399. /**
  15400. * Disposes the camera
  15401. */
  15402. dispose(): void;
  15403. /**
  15404. * Gets a vrController by name.
  15405. * @param name The name of the controller to retreive
  15406. * @returns the controller matching the name specified or null if not found
  15407. */
  15408. getControllerByName(name: string): Nullable<WebVRController>;
  15409. private _leftController;
  15410. /**
  15411. * The controller corresponding to the users left hand.
  15412. */
  15413. readonly leftController: Nullable<WebVRController>;
  15414. private _rightController;
  15415. /**
  15416. * The controller corresponding to the users right hand.
  15417. */
  15418. readonly rightController: Nullable<WebVRController>;
  15419. /**
  15420. * Casts a ray forward from the vrCamera's gaze.
  15421. * @param length Length of the ray (default: 100)
  15422. * @returns the ray corresponding to the gaze
  15423. */
  15424. getForwardRay(length?: number): Ray;
  15425. /**
  15426. * @hidden
  15427. * Updates the camera based on device's frame data
  15428. */
  15429. _checkInputs(): void;
  15430. /**
  15431. * Updates the poseControlled values based on the input device pose.
  15432. * @param poseData Pose coming from the device
  15433. */
  15434. updateFromDevice(poseData: DevicePose): void;
  15435. private _htmlElementAttached;
  15436. private _detachIfAttached;
  15437. /**
  15438. * WebVR's attach control will start broadcasting frames to the device.
  15439. * Note that in certain browsers (chrome for example) this function must be called
  15440. * within a user-interaction callback. Example:
  15441. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15442. *
  15443. * @param element html element to attach the vrDevice to
  15444. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15445. */
  15446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15447. /**
  15448. * Detaches the camera from the html element and disables VR
  15449. *
  15450. * @param element html element to detach from
  15451. */
  15452. detachControl(element: HTMLElement): void;
  15453. /**
  15454. * @returns the name of this class
  15455. */
  15456. getClassName(): string;
  15457. /**
  15458. * Calls resetPose on the vrDisplay
  15459. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15460. */
  15461. resetToCurrentRotation(): void;
  15462. /**
  15463. * @hidden
  15464. * Updates the rig cameras (left and right eye)
  15465. */
  15466. _updateRigCameras(): void;
  15467. private _workingVector;
  15468. private _oneVector;
  15469. private _workingMatrix;
  15470. private updateCacheCalled;
  15471. private _correctPositionIfNotTrackPosition;
  15472. /**
  15473. * @hidden
  15474. * Updates the cached values of the camera
  15475. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15476. */
  15477. _updateCache(ignoreParentClass?: boolean): void;
  15478. /**
  15479. * @hidden
  15480. * Get current device position in babylon world
  15481. */
  15482. _computeDevicePosition(): void;
  15483. /**
  15484. * Updates the current device position and rotation in the babylon world
  15485. */
  15486. update(): void;
  15487. /**
  15488. * @hidden
  15489. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15490. * @returns an identity matrix
  15491. */
  15492. _getViewMatrix(): Matrix;
  15493. private _tmpMatrix;
  15494. /**
  15495. * This function is called by the two RIG cameras.
  15496. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15497. * @hidden
  15498. */
  15499. _getWebVRViewMatrix(): Matrix;
  15500. /** @hidden */
  15501. _getWebVRProjectionMatrix(): Matrix;
  15502. private _onGamepadConnectedObserver;
  15503. private _onGamepadDisconnectedObserver;
  15504. private _updateCacheWhenTrackingDisabledObserver;
  15505. /**
  15506. * Initializes the controllers and their meshes
  15507. */
  15508. initControllers(): void;
  15509. }
  15510. }
  15511. declare module "babylonjs/PostProcesses/postProcess" {
  15512. import { Nullable } from "babylonjs/types";
  15513. import { SmartArray } from "babylonjs/Misc/smartArray";
  15514. import { Observable } from "babylonjs/Misc/observable";
  15515. import { Vector2 } from "babylonjs/Maths/math.vector";
  15516. import { Camera } from "babylonjs/Cameras/camera";
  15517. import { Effect } from "babylonjs/Materials/effect";
  15518. import "babylonjs/Shaders/postprocess.vertex";
  15519. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15520. import { Engine } from "babylonjs/Engines/engine";
  15521. import { Color4 } from "babylonjs/Maths/math.color";
  15522. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15524. /**
  15525. * Size options for a post process
  15526. */
  15527. export type PostProcessOptions = {
  15528. width: number;
  15529. height: number;
  15530. };
  15531. /**
  15532. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15533. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15534. */
  15535. export class PostProcess {
  15536. /** Name of the PostProcess. */
  15537. name: string;
  15538. /**
  15539. * Gets or sets the unique id of the post process
  15540. */
  15541. uniqueId: number;
  15542. /**
  15543. * Width of the texture to apply the post process on
  15544. */
  15545. width: number;
  15546. /**
  15547. * Height of the texture to apply the post process on
  15548. */
  15549. height: number;
  15550. /**
  15551. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15552. * @hidden
  15553. */
  15554. _outputTexture: Nullable<InternalTexture>;
  15555. /**
  15556. * Sampling mode used by the shader
  15557. * See https://doc.babylonjs.com/classes/3.1/texture
  15558. */
  15559. renderTargetSamplingMode: number;
  15560. /**
  15561. * Clear color to use when screen clearing
  15562. */
  15563. clearColor: Color4;
  15564. /**
  15565. * If the buffer needs to be cleared before applying the post process. (default: true)
  15566. * Should be set to false if shader will overwrite all previous pixels.
  15567. */
  15568. autoClear: boolean;
  15569. /**
  15570. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15571. */
  15572. alphaMode: number;
  15573. /**
  15574. * Sets the setAlphaBlendConstants of the babylon engine
  15575. */
  15576. alphaConstants: Color4;
  15577. /**
  15578. * Animations to be used for the post processing
  15579. */
  15580. animations: import("babylonjs/Animations/animation").Animation[];
  15581. /**
  15582. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15583. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15584. */
  15585. enablePixelPerfectMode: boolean;
  15586. /**
  15587. * Force the postprocess to be applied without taking in account viewport
  15588. */
  15589. forceFullscreenViewport: boolean;
  15590. /**
  15591. * List of inspectable custom properties (used by the Inspector)
  15592. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15593. */
  15594. inspectableCustomProperties: IInspectable[];
  15595. /**
  15596. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15597. *
  15598. * | Value | Type | Description |
  15599. * | ----- | ----------------------------------- | ----------- |
  15600. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15601. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15602. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15603. *
  15604. */
  15605. scaleMode: number;
  15606. /**
  15607. * Force textures to be a power of two (default: false)
  15608. */
  15609. alwaysForcePOT: boolean;
  15610. private _samples;
  15611. /**
  15612. * Number of sample textures (default: 1)
  15613. */
  15614. samples: number;
  15615. /**
  15616. * Modify the scale of the post process to be the same as the viewport (default: false)
  15617. */
  15618. adaptScaleToCurrentViewport: boolean;
  15619. private _camera;
  15620. private _scene;
  15621. private _engine;
  15622. private _options;
  15623. private _reusable;
  15624. private _textureType;
  15625. /**
  15626. * Smart array of input and output textures for the post process.
  15627. * @hidden
  15628. */
  15629. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15630. /**
  15631. * The index in _textures that corresponds to the output texture.
  15632. * @hidden
  15633. */
  15634. _currentRenderTextureInd: number;
  15635. private _effect;
  15636. private _samplers;
  15637. private _fragmentUrl;
  15638. private _vertexUrl;
  15639. private _parameters;
  15640. private _scaleRatio;
  15641. protected _indexParameters: any;
  15642. private _shareOutputWithPostProcess;
  15643. private _texelSize;
  15644. private _forcedOutputTexture;
  15645. /**
  15646. * Returns the fragment url or shader name used in the post process.
  15647. * @returns the fragment url or name in the shader store.
  15648. */
  15649. getEffectName(): string;
  15650. /**
  15651. * An event triggered when the postprocess is activated.
  15652. */
  15653. onActivateObservable: Observable<Camera>;
  15654. private _onActivateObserver;
  15655. /**
  15656. * A function that is added to the onActivateObservable
  15657. */
  15658. onActivate: Nullable<(camera: Camera) => void>;
  15659. /**
  15660. * An event triggered when the postprocess changes its size.
  15661. */
  15662. onSizeChangedObservable: Observable<PostProcess>;
  15663. private _onSizeChangedObserver;
  15664. /**
  15665. * A function that is added to the onSizeChangedObservable
  15666. */
  15667. onSizeChanged: (postProcess: PostProcess) => void;
  15668. /**
  15669. * An event triggered when the postprocess applies its effect.
  15670. */
  15671. onApplyObservable: Observable<Effect>;
  15672. private _onApplyObserver;
  15673. /**
  15674. * A function that is added to the onApplyObservable
  15675. */
  15676. onApply: (effect: Effect) => void;
  15677. /**
  15678. * An event triggered before rendering the postprocess
  15679. */
  15680. onBeforeRenderObservable: Observable<Effect>;
  15681. private _onBeforeRenderObserver;
  15682. /**
  15683. * A function that is added to the onBeforeRenderObservable
  15684. */
  15685. onBeforeRender: (effect: Effect) => void;
  15686. /**
  15687. * An event triggered after rendering the postprocess
  15688. */
  15689. onAfterRenderObservable: Observable<Effect>;
  15690. private _onAfterRenderObserver;
  15691. /**
  15692. * A function that is added to the onAfterRenderObservable
  15693. */
  15694. onAfterRender: (efect: Effect) => void;
  15695. /**
  15696. * 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
  15697. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15698. */
  15699. inputTexture: InternalTexture;
  15700. /**
  15701. * Gets the camera which post process is applied to.
  15702. * @returns The camera the post process is applied to.
  15703. */
  15704. getCamera(): Camera;
  15705. /**
  15706. * Gets the texel size of the postprocess.
  15707. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15708. */
  15709. readonly texelSize: Vector2;
  15710. /**
  15711. * Creates a new instance PostProcess
  15712. * @param name The name of the PostProcess.
  15713. * @param fragmentUrl The url of the fragment shader to be used.
  15714. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15715. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15716. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15717. * @param camera The camera to apply the render pass to.
  15718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15719. * @param engine The engine which the post process will be applied. (default: current engine)
  15720. * @param reusable If the post process can be reused on the same frame. (default: false)
  15721. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15722. * @param textureType Type of textures used when performing the post process. (default: 0)
  15723. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15724. * @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
  15725. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15726. */
  15727. constructor(
  15728. /** Name of the PostProcess. */
  15729. 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);
  15730. /**
  15731. * Gets a string idenfifying the name of the class
  15732. * @returns "PostProcess" string
  15733. */
  15734. getClassName(): string;
  15735. /**
  15736. * Gets the engine which this post process belongs to.
  15737. * @returns The engine the post process was enabled with.
  15738. */
  15739. getEngine(): Engine;
  15740. /**
  15741. * The effect that is created when initializing the post process.
  15742. * @returns The created effect corresponding the the postprocess.
  15743. */
  15744. getEffect(): Effect;
  15745. /**
  15746. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15747. * @param postProcess The post process to share the output with.
  15748. * @returns This post process.
  15749. */
  15750. shareOutputWith(postProcess: PostProcess): PostProcess;
  15751. /**
  15752. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15753. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15754. */
  15755. useOwnOutput(): void;
  15756. /**
  15757. * Updates the effect with the current post process compile time values and recompiles the shader.
  15758. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15759. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15760. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15761. * @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
  15762. * @param onCompiled Called when the shader has been compiled.
  15763. * @param onError Called if there is an error when compiling a shader.
  15764. */
  15765. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15766. /**
  15767. * The post process is reusable if it can be used multiple times within one frame.
  15768. * @returns If the post process is reusable
  15769. */
  15770. isReusable(): boolean;
  15771. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15772. markTextureDirty(): void;
  15773. /**
  15774. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15775. * 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.
  15776. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15777. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15778. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15779. * @returns The target texture that was bound to be written to.
  15780. */
  15781. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15782. /**
  15783. * If the post process is supported.
  15784. */
  15785. readonly isSupported: boolean;
  15786. /**
  15787. * The aspect ratio of the output texture.
  15788. */
  15789. readonly aspectRatio: number;
  15790. /**
  15791. * Get a value indicating if the post-process is ready to be used
  15792. * @returns true if the post-process is ready (shader is compiled)
  15793. */
  15794. isReady(): boolean;
  15795. /**
  15796. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15797. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15798. */
  15799. apply(): Nullable<Effect>;
  15800. private _disposeTextures;
  15801. /**
  15802. * Disposes the post process.
  15803. * @param camera The camera to dispose the post process on.
  15804. */
  15805. dispose(camera?: Camera): void;
  15806. }
  15807. }
  15808. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15809. /** @hidden */
  15810. export var kernelBlurVaryingDeclaration: {
  15811. name: string;
  15812. shader: string;
  15813. };
  15814. }
  15815. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15816. /** @hidden */
  15817. export var kernelBlurFragment: {
  15818. name: string;
  15819. shader: string;
  15820. };
  15821. }
  15822. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15823. /** @hidden */
  15824. export var kernelBlurFragment2: {
  15825. name: string;
  15826. shader: string;
  15827. };
  15828. }
  15829. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15830. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15831. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15832. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15833. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15834. /** @hidden */
  15835. export var kernelBlurPixelShader: {
  15836. name: string;
  15837. shader: string;
  15838. };
  15839. }
  15840. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15841. /** @hidden */
  15842. export var kernelBlurVertex: {
  15843. name: string;
  15844. shader: string;
  15845. };
  15846. }
  15847. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15848. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15849. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15850. /** @hidden */
  15851. export var kernelBlurVertexShader: {
  15852. name: string;
  15853. shader: string;
  15854. };
  15855. }
  15856. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15857. import { Vector2 } from "babylonjs/Maths/math.vector";
  15858. import { Nullable } from "babylonjs/types";
  15859. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15860. import { Camera } from "babylonjs/Cameras/camera";
  15861. import { Effect } from "babylonjs/Materials/effect";
  15862. import { Engine } from "babylonjs/Engines/engine";
  15863. import "babylonjs/Shaders/kernelBlur.fragment";
  15864. import "babylonjs/Shaders/kernelBlur.vertex";
  15865. /**
  15866. * The Blur Post Process which blurs an image based on a kernel and direction.
  15867. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15868. */
  15869. export class BlurPostProcess extends PostProcess {
  15870. /** The direction in which to blur the image. */
  15871. direction: Vector2;
  15872. private blockCompilation;
  15873. protected _kernel: number;
  15874. protected _idealKernel: number;
  15875. protected _packedFloat: boolean;
  15876. private _staticDefines;
  15877. /**
  15878. * Sets the length in pixels of the blur sample region
  15879. */
  15880. /**
  15881. * Gets the length in pixels of the blur sample region
  15882. */
  15883. kernel: number;
  15884. /**
  15885. * Sets wether or not the blur needs to unpack/repack floats
  15886. */
  15887. /**
  15888. * Gets wether or not the blur is unpacking/repacking floats
  15889. */
  15890. packedFloat: boolean;
  15891. /**
  15892. * Creates a new instance BlurPostProcess
  15893. * @param name The name of the effect.
  15894. * @param direction The direction in which to blur the image.
  15895. * @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.
  15896. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15897. * @param camera The camera to apply the render pass to.
  15898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15899. * @param engine The engine which the post process will be applied. (default: current engine)
  15900. * @param reusable If the post process can be reused on the same frame. (default: false)
  15901. * @param textureType Type of textures used when performing the post process. (default: 0)
  15902. * @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)
  15903. */
  15904. constructor(name: string,
  15905. /** The direction in which to blur the image. */
  15906. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15907. /**
  15908. * Updates the effect with the current post process compile time values and recompiles the shader.
  15909. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15910. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15911. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15912. * @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
  15913. * @param onCompiled Called when the shader has been compiled.
  15914. * @param onError Called if there is an error when compiling a shader.
  15915. */
  15916. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15917. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15918. /**
  15919. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15920. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15921. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15922. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15923. * The gaps between physical kernels are compensated for in the weighting of the samples
  15924. * @param idealKernel Ideal blur kernel.
  15925. * @return Nearest best kernel.
  15926. */
  15927. protected _nearestBestKernel(idealKernel: number): number;
  15928. /**
  15929. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15930. * @param x The point on the Gaussian distribution to sample.
  15931. * @return the value of the Gaussian function at x.
  15932. */
  15933. protected _gaussianWeight(x: number): number;
  15934. /**
  15935. * Generates a string that can be used as a floating point number in GLSL.
  15936. * @param x Value to print.
  15937. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15938. * @return GLSL float string.
  15939. */
  15940. protected _glslFloat(x: number, decimalFigures?: number): string;
  15941. }
  15942. }
  15943. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15944. import { Scene } from "babylonjs/scene";
  15945. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15946. import { Plane } from "babylonjs/Maths/math.plane";
  15947. /**
  15948. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15949. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15950. * You can then easily use it as a reflectionTexture on a flat surface.
  15951. * In case the surface is not a plane, please consider relying on reflection probes.
  15952. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15953. */
  15954. export class MirrorTexture extends RenderTargetTexture {
  15955. private scene;
  15956. /**
  15957. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15958. * 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.
  15959. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15960. */
  15961. mirrorPlane: Plane;
  15962. /**
  15963. * Define the blur ratio used to blur the reflection if needed.
  15964. */
  15965. blurRatio: number;
  15966. /**
  15967. * Define the adaptive blur kernel used to blur the reflection if needed.
  15968. * This will autocompute the closest best match for the `blurKernel`
  15969. */
  15970. adaptiveBlurKernel: number;
  15971. /**
  15972. * Define the blur kernel used to blur the reflection if needed.
  15973. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15974. */
  15975. blurKernel: number;
  15976. /**
  15977. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15978. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15979. */
  15980. blurKernelX: number;
  15981. /**
  15982. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15983. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15984. */
  15985. blurKernelY: number;
  15986. private _autoComputeBlurKernel;
  15987. protected _onRatioRescale(): void;
  15988. private _updateGammaSpace;
  15989. private _imageProcessingConfigChangeObserver;
  15990. private _transformMatrix;
  15991. private _mirrorMatrix;
  15992. private _savedViewMatrix;
  15993. private _blurX;
  15994. private _blurY;
  15995. private _adaptiveBlurKernel;
  15996. private _blurKernelX;
  15997. private _blurKernelY;
  15998. private _blurRatio;
  15999. /**
  16000. * Instantiates a Mirror Texture.
  16001. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16002. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16003. * You can then easily use it as a reflectionTexture on a flat surface.
  16004. * In case the surface is not a plane, please consider relying on reflection probes.
  16005. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16006. * @param name
  16007. * @param size
  16008. * @param scene
  16009. * @param generateMipMaps
  16010. * @param type
  16011. * @param samplingMode
  16012. * @param generateDepthBuffer
  16013. */
  16014. constructor(name: string, size: number | {
  16015. width: number;
  16016. height: number;
  16017. } | {
  16018. ratio: number;
  16019. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16020. private _preparePostProcesses;
  16021. /**
  16022. * Clone the mirror texture.
  16023. * @returns the cloned texture
  16024. */
  16025. clone(): MirrorTexture;
  16026. /**
  16027. * Serialize the texture to a JSON representation you could use in Parse later on
  16028. * @returns the serialized JSON representation
  16029. */
  16030. serialize(): any;
  16031. /**
  16032. * Dispose the texture and release its associated resources.
  16033. */
  16034. dispose(): void;
  16035. }
  16036. }
  16037. declare module "babylonjs/Materials/Textures/texture" {
  16038. import { Observable } from "babylonjs/Misc/observable";
  16039. import { Nullable } from "babylonjs/types";
  16040. import { Matrix } from "babylonjs/Maths/math.vector";
  16041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16042. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16043. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16044. import { Scene } from "babylonjs/scene";
  16045. /**
  16046. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16047. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16048. */
  16049. export class Texture extends BaseTexture {
  16050. /**
  16051. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16052. */
  16053. static SerializeBuffers: boolean;
  16054. /** @hidden */
  16055. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16056. /** @hidden */
  16057. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16058. /** @hidden */
  16059. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16060. /** nearest is mag = nearest and min = nearest and mip = linear */
  16061. static readonly NEAREST_SAMPLINGMODE: number;
  16062. /** nearest is mag = nearest and min = nearest and mip = linear */
  16063. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16064. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16065. static readonly BILINEAR_SAMPLINGMODE: number;
  16066. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16067. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16068. /** Trilinear is mag = linear and min = linear and mip = linear */
  16069. static readonly TRILINEAR_SAMPLINGMODE: number;
  16070. /** Trilinear is mag = linear and min = linear and mip = linear */
  16071. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16072. /** mag = nearest and min = nearest and mip = nearest */
  16073. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16074. /** mag = nearest and min = linear and mip = nearest */
  16075. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16076. /** mag = nearest and min = linear and mip = linear */
  16077. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16078. /** mag = nearest and min = linear and mip = none */
  16079. static readonly NEAREST_LINEAR: number;
  16080. /** mag = nearest and min = nearest and mip = none */
  16081. static readonly NEAREST_NEAREST: number;
  16082. /** mag = linear and min = nearest and mip = nearest */
  16083. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16084. /** mag = linear and min = nearest and mip = linear */
  16085. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16086. /** mag = linear and min = linear and mip = none */
  16087. static readonly LINEAR_LINEAR: number;
  16088. /** mag = linear and min = nearest and mip = none */
  16089. static readonly LINEAR_NEAREST: number;
  16090. /** Explicit coordinates mode */
  16091. static readonly EXPLICIT_MODE: number;
  16092. /** Spherical coordinates mode */
  16093. static readonly SPHERICAL_MODE: number;
  16094. /** Planar coordinates mode */
  16095. static readonly PLANAR_MODE: number;
  16096. /** Cubic coordinates mode */
  16097. static readonly CUBIC_MODE: number;
  16098. /** Projection coordinates mode */
  16099. static readonly PROJECTION_MODE: number;
  16100. /** Inverse Cubic coordinates mode */
  16101. static readonly SKYBOX_MODE: number;
  16102. /** Inverse Cubic coordinates mode */
  16103. static readonly INVCUBIC_MODE: number;
  16104. /** Equirectangular coordinates mode */
  16105. static readonly EQUIRECTANGULAR_MODE: number;
  16106. /** Equirectangular Fixed coordinates mode */
  16107. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16108. /** Equirectangular Fixed Mirrored coordinates mode */
  16109. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16110. /** Texture is not repeating outside of 0..1 UVs */
  16111. static readonly CLAMP_ADDRESSMODE: number;
  16112. /** Texture is repeating outside of 0..1 UVs */
  16113. static readonly WRAP_ADDRESSMODE: number;
  16114. /** Texture is repeating and mirrored */
  16115. static readonly MIRROR_ADDRESSMODE: number;
  16116. /**
  16117. * 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
  16118. */
  16119. static UseSerializedUrlIfAny: boolean;
  16120. /**
  16121. * Define the url of the texture.
  16122. */
  16123. url: Nullable<string>;
  16124. /**
  16125. * Define an offset on the texture to offset the u coordinates of the UVs
  16126. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16127. */
  16128. uOffset: number;
  16129. /**
  16130. * Define an offset on the texture to offset the v coordinates of the UVs
  16131. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16132. */
  16133. vOffset: number;
  16134. /**
  16135. * Define an offset on the texture to scale the u coordinates of the UVs
  16136. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16137. */
  16138. uScale: number;
  16139. /**
  16140. * Define an offset on the texture to scale the v coordinates of the UVs
  16141. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16142. */
  16143. vScale: number;
  16144. /**
  16145. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16146. * @see http://doc.babylonjs.com/how_to/more_materials
  16147. */
  16148. uAng: number;
  16149. /**
  16150. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16151. * @see http://doc.babylonjs.com/how_to/more_materials
  16152. */
  16153. vAng: number;
  16154. /**
  16155. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16156. * @see http://doc.babylonjs.com/how_to/more_materials
  16157. */
  16158. wAng: number;
  16159. /**
  16160. * Defines the center of rotation (U)
  16161. */
  16162. uRotationCenter: number;
  16163. /**
  16164. * Defines the center of rotation (V)
  16165. */
  16166. vRotationCenter: number;
  16167. /**
  16168. * Defines the center of rotation (W)
  16169. */
  16170. wRotationCenter: number;
  16171. /**
  16172. * Are mip maps generated for this texture or not.
  16173. */
  16174. readonly noMipmap: boolean;
  16175. /**
  16176. * List of inspectable custom properties (used by the Inspector)
  16177. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16178. */
  16179. inspectableCustomProperties: Nullable<IInspectable[]>;
  16180. private _noMipmap;
  16181. /** @hidden */
  16182. _invertY: boolean;
  16183. private _rowGenerationMatrix;
  16184. private _cachedTextureMatrix;
  16185. private _projectionModeMatrix;
  16186. private _t0;
  16187. private _t1;
  16188. private _t2;
  16189. private _cachedUOffset;
  16190. private _cachedVOffset;
  16191. private _cachedUScale;
  16192. private _cachedVScale;
  16193. private _cachedUAng;
  16194. private _cachedVAng;
  16195. private _cachedWAng;
  16196. private _cachedProjectionMatrixId;
  16197. private _cachedCoordinatesMode;
  16198. /** @hidden */
  16199. protected _initialSamplingMode: number;
  16200. /** @hidden */
  16201. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16202. private _deleteBuffer;
  16203. protected _format: Nullable<number>;
  16204. private _delayedOnLoad;
  16205. private _delayedOnError;
  16206. private _mimeType?;
  16207. /**
  16208. * Observable triggered once the texture has been loaded.
  16209. */
  16210. onLoadObservable: Observable<Texture>;
  16211. protected _isBlocking: boolean;
  16212. /**
  16213. * Is the texture preventing material to render while loading.
  16214. * If false, a default texture will be used instead of the loading one during the preparation step.
  16215. */
  16216. isBlocking: boolean;
  16217. /**
  16218. * Get the current sampling mode associated with the texture.
  16219. */
  16220. readonly samplingMode: number;
  16221. /**
  16222. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16223. */
  16224. readonly invertY: boolean;
  16225. /**
  16226. * Instantiates a new texture.
  16227. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16228. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16229. * @param url defines the url of the picture to load as a texture
  16230. * @param scene defines the scene or engine the texture will belong to
  16231. * @param noMipmap defines if the texture will require mip maps or not
  16232. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16233. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16234. * @param onLoad defines a callback triggered when the texture has been loaded
  16235. * @param onError defines a callback triggered when an error occurred during the loading session
  16236. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16237. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16238. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16239. * @param mimeType defines an optional mime type information
  16240. */
  16241. 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);
  16242. /**
  16243. * Update the url (and optional buffer) of this texture if url was null during construction.
  16244. * @param url the url of the texture
  16245. * @param buffer the buffer of the texture (defaults to null)
  16246. * @param onLoad callback called when the texture is loaded (defaults to null)
  16247. */
  16248. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16249. /**
  16250. * Finish the loading sequence of a texture flagged as delayed load.
  16251. * @hidden
  16252. */
  16253. delayLoad(): void;
  16254. private _prepareRowForTextureGeneration;
  16255. /**
  16256. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16257. * @returns the transform matrix of the texture.
  16258. */
  16259. getTextureMatrix(): Matrix;
  16260. /**
  16261. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16262. * @returns The reflection texture transform
  16263. */
  16264. getReflectionTextureMatrix(): Matrix;
  16265. /**
  16266. * Clones the texture.
  16267. * @returns the cloned texture
  16268. */
  16269. clone(): Texture;
  16270. /**
  16271. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16272. * @returns The JSON representation of the texture
  16273. */
  16274. serialize(): any;
  16275. /**
  16276. * Get the current class name of the texture useful for serialization or dynamic coding.
  16277. * @returns "Texture"
  16278. */
  16279. getClassName(): string;
  16280. /**
  16281. * Dispose the texture and release its associated resources.
  16282. */
  16283. dispose(): void;
  16284. /**
  16285. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16286. * @param parsedTexture Define the JSON representation of the texture
  16287. * @param scene Define the scene the parsed texture should be instantiated in
  16288. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16289. * @returns The parsed texture if successful
  16290. */
  16291. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16292. /**
  16293. * Creates a texture from its base 64 representation.
  16294. * @param data Define the base64 payload without the data: prefix
  16295. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16296. * @param scene Define the scene the texture should belong to
  16297. * @param noMipmap Forces the texture to not create mip map information if true
  16298. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16299. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16300. * @param onLoad define a callback triggered when the texture has been loaded
  16301. * @param onError define a callback triggered when an error occurred during the loading session
  16302. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16303. * @returns the created texture
  16304. */
  16305. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16306. /**
  16307. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16308. * @param data Define the base64 payload without the data: prefix
  16309. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16310. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16311. * @param scene Define the scene the texture should belong to
  16312. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16313. * @param noMipmap Forces the texture to not create mip map information if true
  16314. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16315. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16316. * @param onLoad define a callback triggered when the texture has been loaded
  16317. * @param onError define a callback triggered when an error occurred during the loading session
  16318. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16319. * @returns the created texture
  16320. */
  16321. 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;
  16322. }
  16323. }
  16324. declare module "babylonjs/PostProcesses/postProcessManager" {
  16325. import { Nullable } from "babylonjs/types";
  16326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16327. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16328. import { Scene } from "babylonjs/scene";
  16329. /**
  16330. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16331. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16332. */
  16333. export class PostProcessManager {
  16334. private _scene;
  16335. private _indexBuffer;
  16336. private _vertexBuffers;
  16337. /**
  16338. * Creates a new instance PostProcess
  16339. * @param scene The scene that the post process is associated with.
  16340. */
  16341. constructor(scene: Scene);
  16342. private _prepareBuffers;
  16343. private _buildIndexBuffer;
  16344. /**
  16345. * Rebuilds the vertex buffers of the manager.
  16346. * @hidden
  16347. */
  16348. _rebuild(): void;
  16349. /**
  16350. * Prepares a frame to be run through a post process.
  16351. * @param sourceTexture The input texture to the post procesess. (default: null)
  16352. * @param postProcesses An array of post processes to be run. (default: null)
  16353. * @returns True if the post processes were able to be run.
  16354. * @hidden
  16355. */
  16356. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16357. /**
  16358. * Manually render a set of post processes to a texture.
  16359. * @param postProcesses An array of post processes to be run.
  16360. * @param targetTexture The target texture to render to.
  16361. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16362. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16363. * @param lodLevel defines which lod of the texture to render to
  16364. */
  16365. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16366. /**
  16367. * Finalize the result of the output of the postprocesses.
  16368. * @param doNotPresent If true the result will not be displayed to the screen.
  16369. * @param targetTexture The target texture to render to.
  16370. * @param faceIndex The index of the face to bind the target texture to.
  16371. * @param postProcesses The array of post processes to render.
  16372. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16373. * @hidden
  16374. */
  16375. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16376. /**
  16377. * Disposes of the post process manager.
  16378. */
  16379. dispose(): void;
  16380. }
  16381. }
  16382. declare module "babylonjs/Misc/gradients" {
  16383. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16384. /** Interface used by value gradients (color, factor, ...) */
  16385. export interface IValueGradient {
  16386. /**
  16387. * Gets or sets the gradient value (between 0 and 1)
  16388. */
  16389. gradient: number;
  16390. }
  16391. /** Class used to store color4 gradient */
  16392. export class ColorGradient implements IValueGradient {
  16393. /**
  16394. * Gets or sets the gradient value (between 0 and 1)
  16395. */
  16396. gradient: number;
  16397. /**
  16398. * Gets or sets first associated color
  16399. */
  16400. color1: Color4;
  16401. /**
  16402. * Gets or sets second associated color
  16403. */
  16404. color2?: Color4;
  16405. /**
  16406. * Will get a color picked randomly between color1 and color2.
  16407. * If color2 is undefined then color1 will be used
  16408. * @param result defines the target Color4 to store the result in
  16409. */
  16410. getColorToRef(result: Color4): void;
  16411. }
  16412. /** Class used to store color 3 gradient */
  16413. export class Color3Gradient implements IValueGradient {
  16414. /**
  16415. * Gets or sets the gradient value (between 0 and 1)
  16416. */
  16417. gradient: number;
  16418. /**
  16419. * Gets or sets the associated color
  16420. */
  16421. color: Color3;
  16422. }
  16423. /** Class used to store factor gradient */
  16424. export class FactorGradient implements IValueGradient {
  16425. /**
  16426. * Gets or sets the gradient value (between 0 and 1)
  16427. */
  16428. gradient: number;
  16429. /**
  16430. * Gets or sets first associated factor
  16431. */
  16432. factor1: number;
  16433. /**
  16434. * Gets or sets second associated factor
  16435. */
  16436. factor2?: number;
  16437. /**
  16438. * Will get a number picked randomly between factor1 and factor2.
  16439. * If factor2 is undefined then factor1 will be used
  16440. * @returns the picked number
  16441. */
  16442. getFactor(): number;
  16443. }
  16444. /**
  16445. * Helper used to simplify some generic gradient tasks
  16446. */
  16447. export class GradientHelper {
  16448. /**
  16449. * Gets the current gradient from an array of IValueGradient
  16450. * @param ratio defines the current ratio to get
  16451. * @param gradients defines the array of IValueGradient
  16452. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16453. */
  16454. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16455. }
  16456. }
  16457. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16458. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16459. import { Nullable } from "babylonjs/types";
  16460. module "babylonjs/Engines/thinEngine" {
  16461. interface ThinEngine {
  16462. /**
  16463. * Creates a dynamic texture
  16464. * @param width defines the width of the texture
  16465. * @param height defines the height of the texture
  16466. * @param generateMipMaps defines if the engine should generate the mip levels
  16467. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16468. * @returns the dynamic texture inside an InternalTexture
  16469. */
  16470. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16471. /**
  16472. * Update the content of a dynamic texture
  16473. * @param texture defines the texture to update
  16474. * @param canvas defines the canvas containing the source
  16475. * @param invertY defines if data must be stored with Y axis inverted
  16476. * @param premulAlpha defines if alpha is stored as premultiplied
  16477. * @param format defines the format of the data
  16478. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16479. */
  16480. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16481. }
  16482. }
  16483. }
  16484. declare module "babylonjs/Misc/canvasGenerator" {
  16485. /**
  16486. * Helper class used to generate a canvas to manipulate images
  16487. */
  16488. export class CanvasGenerator {
  16489. /**
  16490. * Create a new canvas (or offscreen canvas depending on the context)
  16491. * @param width defines the expected width
  16492. * @param height defines the expected height
  16493. * @return a new canvas or offscreen canvas
  16494. */
  16495. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16496. }
  16497. }
  16498. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16499. import { Scene } from "babylonjs/scene";
  16500. import { Texture } from "babylonjs/Materials/Textures/texture";
  16501. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16502. /**
  16503. * A class extending Texture allowing drawing on a texture
  16504. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16505. */
  16506. export class DynamicTexture extends Texture {
  16507. private _generateMipMaps;
  16508. private _canvas;
  16509. private _context;
  16510. private _engine;
  16511. /**
  16512. * Creates a DynamicTexture
  16513. * @param name defines the name of the texture
  16514. * @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
  16515. * @param scene defines the scene where you want the texture
  16516. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16517. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16518. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16519. */
  16520. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16521. /**
  16522. * Get the current class name of the texture useful for serialization or dynamic coding.
  16523. * @returns "DynamicTexture"
  16524. */
  16525. getClassName(): string;
  16526. /**
  16527. * Gets the current state of canRescale
  16528. */
  16529. readonly canRescale: boolean;
  16530. private _recreate;
  16531. /**
  16532. * Scales the texture
  16533. * @param ratio the scale factor to apply to both width and height
  16534. */
  16535. scale(ratio: number): void;
  16536. /**
  16537. * Resizes the texture
  16538. * @param width the new width
  16539. * @param height the new height
  16540. */
  16541. scaleTo(width: number, height: number): void;
  16542. /**
  16543. * Gets the context of the canvas used by the texture
  16544. * @returns the canvas context of the dynamic texture
  16545. */
  16546. getContext(): CanvasRenderingContext2D;
  16547. /**
  16548. * Clears the texture
  16549. */
  16550. clear(): void;
  16551. /**
  16552. * Updates the texture
  16553. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16554. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16555. */
  16556. update(invertY?: boolean, premulAlpha?: boolean): void;
  16557. /**
  16558. * Draws text onto the texture
  16559. * @param text defines the text to be drawn
  16560. * @param x defines the placement of the text from the left
  16561. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16562. * @param font defines the font to be used with font-style, font-size, font-name
  16563. * @param color defines the color used for the text
  16564. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16565. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16566. * @param update defines whether texture is immediately update (default is true)
  16567. */
  16568. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16569. /**
  16570. * Clones the texture
  16571. * @returns the clone of the texture.
  16572. */
  16573. clone(): DynamicTexture;
  16574. /**
  16575. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16576. * @returns a serialized dynamic texture object
  16577. */
  16578. serialize(): any;
  16579. /** @hidden */
  16580. _rebuild(): void;
  16581. }
  16582. }
  16583. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16584. import { Scene } from "babylonjs/scene";
  16585. import { ISceneComponent } from "babylonjs/sceneComponent";
  16586. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16587. module "babylonjs/abstractScene" {
  16588. interface AbstractScene {
  16589. /**
  16590. * The list of procedural textures added to the scene
  16591. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16592. */
  16593. proceduralTextures: Array<ProceduralTexture>;
  16594. }
  16595. }
  16596. /**
  16597. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16598. * in a given scene.
  16599. */
  16600. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16601. /**
  16602. * The component name helpfull to identify the component in the list of scene components.
  16603. */
  16604. readonly name: string;
  16605. /**
  16606. * The scene the component belongs to.
  16607. */
  16608. scene: Scene;
  16609. /**
  16610. * Creates a new instance of the component for the given scene
  16611. * @param scene Defines the scene to register the component in
  16612. */
  16613. constructor(scene: Scene);
  16614. /**
  16615. * Registers the component in a given scene
  16616. */
  16617. register(): void;
  16618. /**
  16619. * Rebuilds the elements related to this component in case of
  16620. * context lost for instance.
  16621. */
  16622. rebuild(): void;
  16623. /**
  16624. * Disposes the component and the associated ressources.
  16625. */
  16626. dispose(): void;
  16627. private _beforeClear;
  16628. }
  16629. }
  16630. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16631. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16632. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16633. module "babylonjs/Engines/thinEngine" {
  16634. interface ThinEngine {
  16635. /**
  16636. * Creates a new render target cube texture
  16637. * @param size defines the size of the texture
  16638. * @param options defines the options used to create the texture
  16639. * @returns a new render target cube texture stored in an InternalTexture
  16640. */
  16641. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16642. }
  16643. }
  16644. }
  16645. declare module "babylonjs/Shaders/procedural.vertex" {
  16646. /** @hidden */
  16647. export var proceduralVertexShader: {
  16648. name: string;
  16649. shader: string;
  16650. };
  16651. }
  16652. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16653. import { Observable } from "babylonjs/Misc/observable";
  16654. import { Nullable } from "babylonjs/types";
  16655. import { Scene } from "babylonjs/scene";
  16656. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16657. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16658. import { Effect } from "babylonjs/Materials/effect";
  16659. import { Texture } from "babylonjs/Materials/Textures/texture";
  16660. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16661. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16662. import "babylonjs/Shaders/procedural.vertex";
  16663. /**
  16664. * 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.
  16665. * This is the base class of any Procedural texture and contains most of the shareable code.
  16666. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16667. */
  16668. export class ProceduralTexture extends Texture {
  16669. isCube: boolean;
  16670. /**
  16671. * Define if the texture is enabled or not (disabled texture will not render)
  16672. */
  16673. isEnabled: boolean;
  16674. /**
  16675. * Define if the texture must be cleared before rendering (default is true)
  16676. */
  16677. autoClear: boolean;
  16678. /**
  16679. * Callback called when the texture is generated
  16680. */
  16681. onGenerated: () => void;
  16682. /**
  16683. * Event raised when the texture is generated
  16684. */
  16685. onGeneratedObservable: Observable<ProceduralTexture>;
  16686. /** @hidden */
  16687. _generateMipMaps: boolean;
  16688. /** @hidden **/
  16689. _effect: Effect;
  16690. /** @hidden */
  16691. _textures: {
  16692. [key: string]: Texture;
  16693. };
  16694. private _size;
  16695. private _currentRefreshId;
  16696. private _refreshRate;
  16697. private _vertexBuffers;
  16698. private _indexBuffer;
  16699. private _uniforms;
  16700. private _samplers;
  16701. private _fragment;
  16702. private _floats;
  16703. private _ints;
  16704. private _floatsArrays;
  16705. private _colors3;
  16706. private _colors4;
  16707. private _vectors2;
  16708. private _vectors3;
  16709. private _matrices;
  16710. private _fallbackTexture;
  16711. private _fallbackTextureUsed;
  16712. private _engine;
  16713. private _cachedDefines;
  16714. private _contentUpdateId;
  16715. private _contentData;
  16716. /**
  16717. * Instantiates a new procedural texture.
  16718. * 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.
  16719. * This is the base class of any Procedural texture and contains most of the shareable code.
  16720. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16721. * @param name Define the name of the texture
  16722. * @param size Define the size of the texture to create
  16723. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16724. * @param scene Define the scene the texture belongs to
  16725. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16726. * @param generateMipMaps Define if the texture should creates mip maps or not
  16727. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16728. */
  16729. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16730. /**
  16731. * The effect that is created when initializing the post process.
  16732. * @returns The created effect corresponding the the postprocess.
  16733. */
  16734. getEffect(): Effect;
  16735. /**
  16736. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16737. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16738. */
  16739. getContent(): Nullable<ArrayBufferView>;
  16740. private _createIndexBuffer;
  16741. /** @hidden */
  16742. _rebuild(): void;
  16743. /**
  16744. * Resets the texture in order to recreate its associated resources.
  16745. * This can be called in case of context loss
  16746. */
  16747. reset(): void;
  16748. protected _getDefines(): string;
  16749. /**
  16750. * Is the texture ready to be used ? (rendered at least once)
  16751. * @returns true if ready, otherwise, false.
  16752. */
  16753. isReady(): boolean;
  16754. /**
  16755. * Resets the refresh counter of the texture and start bak from scratch.
  16756. * Could be useful to regenerate the texture if it is setup to render only once.
  16757. */
  16758. resetRefreshCounter(): void;
  16759. /**
  16760. * Set the fragment shader to use in order to render the texture.
  16761. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16762. */
  16763. setFragment(fragment: any): void;
  16764. /**
  16765. * Define the refresh rate of the texture or the rendering frequency.
  16766. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16767. */
  16768. refreshRate: number;
  16769. /** @hidden */
  16770. _shouldRender(): boolean;
  16771. /**
  16772. * Get the size the texture is rendering at.
  16773. * @returns the size (texture is always squared)
  16774. */
  16775. getRenderSize(): number;
  16776. /**
  16777. * Resize the texture to new value.
  16778. * @param size Define the new size the texture should have
  16779. * @param generateMipMaps Define whether the new texture should create mip maps
  16780. */
  16781. resize(size: number, generateMipMaps: boolean): void;
  16782. private _checkUniform;
  16783. /**
  16784. * Set a texture in the shader program used to render.
  16785. * @param name Define the name of the uniform samplers as defined in the shader
  16786. * @param texture Define the texture to bind to this sampler
  16787. * @return the texture itself allowing "fluent" like uniform updates
  16788. */
  16789. setTexture(name: string, texture: Texture): ProceduralTexture;
  16790. /**
  16791. * Set a float in the shader.
  16792. * @param name Define the name of the uniform as defined in the shader
  16793. * @param value Define the value to give to the uniform
  16794. * @return the texture itself allowing "fluent" like uniform updates
  16795. */
  16796. setFloat(name: string, value: number): ProceduralTexture;
  16797. /**
  16798. * Set a int in the shader.
  16799. * @param name Define the name of the uniform as defined in the shader
  16800. * @param value Define the value to give to the uniform
  16801. * @return the texture itself allowing "fluent" like uniform updates
  16802. */
  16803. setInt(name: string, value: number): ProceduralTexture;
  16804. /**
  16805. * Set an array of floats in the shader.
  16806. * @param name Define the name of the uniform as defined in the shader
  16807. * @param value Define the value to give to the uniform
  16808. * @return the texture itself allowing "fluent" like uniform updates
  16809. */
  16810. setFloats(name: string, value: number[]): ProceduralTexture;
  16811. /**
  16812. * Set a vec3 in the shader from a Color3.
  16813. * @param name Define the name of the uniform as defined in the shader
  16814. * @param value Define the value to give to the uniform
  16815. * @return the texture itself allowing "fluent" like uniform updates
  16816. */
  16817. setColor3(name: string, value: Color3): ProceduralTexture;
  16818. /**
  16819. * Set a vec4 in the shader from a Color4.
  16820. * @param name Define the name of the uniform as defined in the shader
  16821. * @param value Define the value to give to the uniform
  16822. * @return the texture itself allowing "fluent" like uniform updates
  16823. */
  16824. setColor4(name: string, value: Color4): ProceduralTexture;
  16825. /**
  16826. * Set a vec2 in the shader from a Vector2.
  16827. * @param name Define the name of the uniform as defined in the shader
  16828. * @param value Define the value to give to the uniform
  16829. * @return the texture itself allowing "fluent" like uniform updates
  16830. */
  16831. setVector2(name: string, value: Vector2): ProceduralTexture;
  16832. /**
  16833. * Set a vec3 in the shader from a Vector3.
  16834. * @param name Define the name of the uniform as defined in the shader
  16835. * @param value Define the value to give to the uniform
  16836. * @return the texture itself allowing "fluent" like uniform updates
  16837. */
  16838. setVector3(name: string, value: Vector3): ProceduralTexture;
  16839. /**
  16840. * Set a mat4 in the shader from a MAtrix.
  16841. * @param name Define the name of the uniform as defined in the shader
  16842. * @param value Define the value to give to the uniform
  16843. * @return the texture itself allowing "fluent" like uniform updates
  16844. */
  16845. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16846. /**
  16847. * Render the texture to its associated render target.
  16848. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16849. */
  16850. render(useCameraPostProcess?: boolean): void;
  16851. /**
  16852. * Clone the texture.
  16853. * @returns the cloned texture
  16854. */
  16855. clone(): ProceduralTexture;
  16856. /**
  16857. * Dispose the texture and release its asoociated resources.
  16858. */
  16859. dispose(): void;
  16860. }
  16861. }
  16862. declare module "babylonjs/Particles/baseParticleSystem" {
  16863. import { Nullable } from "babylonjs/types";
  16864. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16866. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16867. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16868. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16869. import { Scene } from "babylonjs/scene";
  16870. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16871. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16872. import { Texture } from "babylonjs/Materials/Textures/texture";
  16873. import { Color4 } from "babylonjs/Maths/math.color";
  16874. import { Animation } from "babylonjs/Animations/animation";
  16875. /**
  16876. * This represents the base class for particle system in Babylon.
  16877. * 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.
  16878. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16879. * @example https://doc.babylonjs.com/babylon101/particles
  16880. */
  16881. export class BaseParticleSystem {
  16882. /**
  16883. * Source color is added to the destination color without alpha affecting the result
  16884. */
  16885. static BLENDMODE_ONEONE: number;
  16886. /**
  16887. * Blend current color and particle color using particle’s alpha
  16888. */
  16889. static BLENDMODE_STANDARD: number;
  16890. /**
  16891. * Add current color and particle color multiplied by particle’s alpha
  16892. */
  16893. static BLENDMODE_ADD: number;
  16894. /**
  16895. * Multiply current color with particle color
  16896. */
  16897. static BLENDMODE_MULTIPLY: number;
  16898. /**
  16899. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16900. */
  16901. static BLENDMODE_MULTIPLYADD: number;
  16902. /**
  16903. * List of animations used by the particle system.
  16904. */
  16905. animations: Animation[];
  16906. /**
  16907. * The id of the Particle system.
  16908. */
  16909. id: string;
  16910. /**
  16911. * The friendly name of the Particle system.
  16912. */
  16913. name: string;
  16914. /**
  16915. * The rendering group used by the Particle system to chose when to render.
  16916. */
  16917. renderingGroupId: number;
  16918. /**
  16919. * The emitter represents the Mesh or position we are attaching the particle system to.
  16920. */
  16921. emitter: Nullable<AbstractMesh | Vector3>;
  16922. /**
  16923. * The maximum number of particles to emit per frame
  16924. */
  16925. emitRate: number;
  16926. /**
  16927. * If you want to launch only a few particles at once, that can be done, as well.
  16928. */
  16929. manualEmitCount: number;
  16930. /**
  16931. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16932. */
  16933. updateSpeed: number;
  16934. /**
  16935. * The amount of time the particle system is running (depends of the overall update speed).
  16936. */
  16937. targetStopDuration: number;
  16938. /**
  16939. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16940. */
  16941. disposeOnStop: boolean;
  16942. /**
  16943. * Minimum power of emitting particles.
  16944. */
  16945. minEmitPower: number;
  16946. /**
  16947. * Maximum power of emitting particles.
  16948. */
  16949. maxEmitPower: number;
  16950. /**
  16951. * Minimum life time of emitting particles.
  16952. */
  16953. minLifeTime: number;
  16954. /**
  16955. * Maximum life time of emitting particles.
  16956. */
  16957. maxLifeTime: number;
  16958. /**
  16959. * Minimum Size of emitting particles.
  16960. */
  16961. minSize: number;
  16962. /**
  16963. * Maximum Size of emitting particles.
  16964. */
  16965. maxSize: number;
  16966. /**
  16967. * Minimum scale of emitting particles on X axis.
  16968. */
  16969. minScaleX: number;
  16970. /**
  16971. * Maximum scale of emitting particles on X axis.
  16972. */
  16973. maxScaleX: number;
  16974. /**
  16975. * Minimum scale of emitting particles on Y axis.
  16976. */
  16977. minScaleY: number;
  16978. /**
  16979. * Maximum scale of emitting particles on Y axis.
  16980. */
  16981. maxScaleY: number;
  16982. /**
  16983. * Gets or sets the minimal initial rotation in radians.
  16984. */
  16985. minInitialRotation: number;
  16986. /**
  16987. * Gets or sets the maximal initial rotation in radians.
  16988. */
  16989. maxInitialRotation: number;
  16990. /**
  16991. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16992. */
  16993. minAngularSpeed: number;
  16994. /**
  16995. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16996. */
  16997. maxAngularSpeed: number;
  16998. /**
  16999. * The texture used to render each particle. (this can be a spritesheet)
  17000. */
  17001. particleTexture: Nullable<Texture>;
  17002. /**
  17003. * The layer mask we are rendering the particles through.
  17004. */
  17005. layerMask: number;
  17006. /**
  17007. * This can help using your own shader to render the particle system.
  17008. * The according effect will be created
  17009. */
  17010. customShader: any;
  17011. /**
  17012. * By default particle system starts as soon as they are created. This prevents the
  17013. * automatic start to happen and let you decide when to start emitting particles.
  17014. */
  17015. preventAutoStart: boolean;
  17016. private _noiseTexture;
  17017. /**
  17018. * Gets or sets a texture used to add random noise to particle positions
  17019. */
  17020. noiseTexture: Nullable<ProceduralTexture>;
  17021. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17022. noiseStrength: Vector3;
  17023. /**
  17024. * Callback triggered when the particle animation is ending.
  17025. */
  17026. onAnimationEnd: Nullable<() => void>;
  17027. /**
  17028. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17029. */
  17030. blendMode: number;
  17031. /**
  17032. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17033. * to override the particles.
  17034. */
  17035. forceDepthWrite: boolean;
  17036. /** 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 */
  17037. preWarmCycles: number;
  17038. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17039. preWarmStepOffset: number;
  17040. /**
  17041. * 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)
  17042. */
  17043. spriteCellChangeSpeed: number;
  17044. /**
  17045. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17046. */
  17047. startSpriteCellID: number;
  17048. /**
  17049. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17050. */
  17051. endSpriteCellID: number;
  17052. /**
  17053. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17054. */
  17055. spriteCellWidth: number;
  17056. /**
  17057. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17058. */
  17059. spriteCellHeight: number;
  17060. /**
  17061. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17062. */
  17063. spriteRandomStartCell: boolean;
  17064. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17065. translationPivot: Vector2;
  17066. /** @hidden */
  17067. protected _isAnimationSheetEnabled: boolean;
  17068. /**
  17069. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17070. */
  17071. beginAnimationOnStart: boolean;
  17072. /**
  17073. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17074. */
  17075. beginAnimationFrom: number;
  17076. /**
  17077. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17078. */
  17079. beginAnimationTo: number;
  17080. /**
  17081. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17082. */
  17083. beginAnimationLoop: boolean;
  17084. /**
  17085. * Gets or sets a world offset applied to all particles
  17086. */
  17087. worldOffset: Vector3;
  17088. /**
  17089. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17090. */
  17091. isAnimationSheetEnabled: boolean;
  17092. /**
  17093. * Get hosting scene
  17094. * @returns the scene
  17095. */
  17096. getScene(): Scene;
  17097. /**
  17098. * You can use gravity if you want to give an orientation to your particles.
  17099. */
  17100. gravity: Vector3;
  17101. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17102. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17103. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17104. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17105. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17106. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17107. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17108. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17109. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17110. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17111. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17112. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17113. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17114. /**
  17115. * Defines the delay in milliseconds before starting the system (0 by default)
  17116. */
  17117. startDelay: number;
  17118. /**
  17119. * Gets the current list of drag gradients.
  17120. * You must use addDragGradient and removeDragGradient to udpate this list
  17121. * @returns the list of drag gradients
  17122. */
  17123. getDragGradients(): Nullable<Array<FactorGradient>>;
  17124. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17125. limitVelocityDamping: number;
  17126. /**
  17127. * Gets the current list of limit velocity gradients.
  17128. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17129. * @returns the list of limit velocity gradients
  17130. */
  17131. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17132. /**
  17133. * Gets the current list of color gradients.
  17134. * You must use addColorGradient and removeColorGradient to udpate this list
  17135. * @returns the list of color gradients
  17136. */
  17137. getColorGradients(): Nullable<Array<ColorGradient>>;
  17138. /**
  17139. * Gets the current list of size gradients.
  17140. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17141. * @returns the list of size gradients
  17142. */
  17143. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17144. /**
  17145. * Gets the current list of color remap gradients.
  17146. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17147. * @returns the list of color remap gradients
  17148. */
  17149. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17150. /**
  17151. * Gets the current list of alpha remap gradients.
  17152. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17153. * @returns the list of alpha remap gradients
  17154. */
  17155. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17156. /**
  17157. * Gets the current list of life time gradients.
  17158. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17159. * @returns the list of life time gradients
  17160. */
  17161. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17162. /**
  17163. * Gets the current list of angular speed gradients.
  17164. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17165. * @returns the list of angular speed gradients
  17166. */
  17167. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17168. /**
  17169. * Gets the current list of velocity gradients.
  17170. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17171. * @returns the list of velocity gradients
  17172. */
  17173. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17174. /**
  17175. * Gets the current list of start size gradients.
  17176. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17177. * @returns the list of start size gradients
  17178. */
  17179. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17180. /**
  17181. * Gets the current list of emit rate gradients.
  17182. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17183. * @returns the list of emit rate gradients
  17184. */
  17185. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17186. /**
  17187. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17188. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17189. */
  17190. direction1: Vector3;
  17191. /**
  17192. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17193. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17194. */
  17195. direction2: Vector3;
  17196. /**
  17197. * 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.
  17198. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17199. */
  17200. minEmitBox: Vector3;
  17201. /**
  17202. * 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.
  17203. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17204. */
  17205. maxEmitBox: Vector3;
  17206. /**
  17207. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17208. */
  17209. color1: Color4;
  17210. /**
  17211. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17212. */
  17213. color2: Color4;
  17214. /**
  17215. * Color the particle will have at the end of its lifetime
  17216. */
  17217. colorDead: Color4;
  17218. /**
  17219. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17220. */
  17221. textureMask: Color4;
  17222. /**
  17223. * The particle emitter type defines the emitter used by the particle system.
  17224. * It can be for example box, sphere, or cone...
  17225. */
  17226. particleEmitterType: IParticleEmitterType;
  17227. /** @hidden */
  17228. _isSubEmitter: boolean;
  17229. /**
  17230. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17231. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17232. */
  17233. billboardMode: number;
  17234. protected _isBillboardBased: boolean;
  17235. /**
  17236. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17237. */
  17238. isBillboardBased: boolean;
  17239. /**
  17240. * The scene the particle system belongs to.
  17241. */
  17242. protected _scene: Scene;
  17243. /**
  17244. * Local cache of defines for image processing.
  17245. */
  17246. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17247. /**
  17248. * Default configuration related to image processing available in the standard Material.
  17249. */
  17250. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17251. /**
  17252. * Gets the image processing configuration used either in this material.
  17253. */
  17254. /**
  17255. * Sets the Default image processing configuration used either in the this material.
  17256. *
  17257. * If sets to null, the scene one is in use.
  17258. */
  17259. imageProcessingConfiguration: ImageProcessingConfiguration;
  17260. /**
  17261. * Attaches a new image processing configuration to the Standard Material.
  17262. * @param configuration
  17263. */
  17264. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17265. /** @hidden */
  17266. protected _reset(): void;
  17267. /** @hidden */
  17268. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17269. /**
  17270. * Instantiates a particle system.
  17271. * 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.
  17272. * @param name The name of the particle system
  17273. */
  17274. constructor(name: string);
  17275. /**
  17276. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17277. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17278. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17279. * @returns the emitter
  17280. */
  17281. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17282. /**
  17283. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17284. * @param radius The radius of the hemisphere to emit from
  17285. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17286. * @returns the emitter
  17287. */
  17288. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17289. /**
  17290. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17291. * @param radius The radius of the sphere to emit from
  17292. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17293. * @returns the emitter
  17294. */
  17295. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17296. /**
  17297. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17298. * @param radius The radius of the sphere to emit from
  17299. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17300. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17301. * @returns the emitter
  17302. */
  17303. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17304. /**
  17305. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17306. * @param radius The radius of the emission cylinder
  17307. * @param height The height of the emission cylinder
  17308. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17309. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17310. * @returns the emitter
  17311. */
  17312. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17313. /**
  17314. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17315. * @param radius The radius of the cylinder to emit from
  17316. * @param height The height of the emission cylinder
  17317. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17318. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17319. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17320. * @returns the emitter
  17321. */
  17322. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17323. /**
  17324. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17325. * @param radius The radius of the cone to emit from
  17326. * @param angle The base angle of the cone
  17327. * @returns the emitter
  17328. */
  17329. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17330. /**
  17331. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17332. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17333. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17334. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17335. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17336. * @returns the emitter
  17337. */
  17338. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17339. }
  17340. }
  17341. declare module "babylonjs/Particles/subEmitter" {
  17342. import { Scene } from "babylonjs/scene";
  17343. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17344. /**
  17345. * Type of sub emitter
  17346. */
  17347. export enum SubEmitterType {
  17348. /**
  17349. * Attached to the particle over it's lifetime
  17350. */
  17351. ATTACHED = 0,
  17352. /**
  17353. * Created when the particle dies
  17354. */
  17355. END = 1
  17356. }
  17357. /**
  17358. * Sub emitter class used to emit particles from an existing particle
  17359. */
  17360. export class SubEmitter {
  17361. /**
  17362. * the particle system to be used by the sub emitter
  17363. */
  17364. particleSystem: ParticleSystem;
  17365. /**
  17366. * Type of the submitter (Default: END)
  17367. */
  17368. type: SubEmitterType;
  17369. /**
  17370. * 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)
  17371. * Note: This only is supported when using an emitter of type Mesh
  17372. */
  17373. inheritDirection: boolean;
  17374. /**
  17375. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17376. */
  17377. inheritedVelocityAmount: number;
  17378. /**
  17379. * Creates a sub emitter
  17380. * @param particleSystem the particle system to be used by the sub emitter
  17381. */
  17382. constructor(
  17383. /**
  17384. * the particle system to be used by the sub emitter
  17385. */
  17386. particleSystem: ParticleSystem);
  17387. /**
  17388. * Clones the sub emitter
  17389. * @returns the cloned sub emitter
  17390. */
  17391. clone(): SubEmitter;
  17392. /**
  17393. * Serialize current object to a JSON object
  17394. * @returns the serialized object
  17395. */
  17396. serialize(): any;
  17397. /** @hidden */
  17398. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17399. /**
  17400. * Creates a new SubEmitter from a serialized JSON version
  17401. * @param serializationObject defines the JSON object to read from
  17402. * @param scene defines the hosting scene
  17403. * @param rootUrl defines the rootUrl for data loading
  17404. * @returns a new SubEmitter
  17405. */
  17406. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17407. /** Release associated resources */
  17408. dispose(): void;
  17409. }
  17410. }
  17411. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17412. /** @hidden */
  17413. export var clipPlaneFragmentDeclaration: {
  17414. name: string;
  17415. shader: string;
  17416. };
  17417. }
  17418. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17419. /** @hidden */
  17420. export var imageProcessingDeclaration: {
  17421. name: string;
  17422. shader: string;
  17423. };
  17424. }
  17425. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17426. /** @hidden */
  17427. export var imageProcessingFunctions: {
  17428. name: string;
  17429. shader: string;
  17430. };
  17431. }
  17432. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17433. /** @hidden */
  17434. export var clipPlaneFragment: {
  17435. name: string;
  17436. shader: string;
  17437. };
  17438. }
  17439. declare module "babylonjs/Shaders/particles.fragment" {
  17440. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17441. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17442. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17443. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17444. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17445. /** @hidden */
  17446. export var particlesPixelShader: {
  17447. name: string;
  17448. shader: string;
  17449. };
  17450. }
  17451. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17452. /** @hidden */
  17453. export var clipPlaneVertexDeclaration: {
  17454. name: string;
  17455. shader: string;
  17456. };
  17457. }
  17458. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17459. /** @hidden */
  17460. export var clipPlaneVertex: {
  17461. name: string;
  17462. shader: string;
  17463. };
  17464. }
  17465. declare module "babylonjs/Shaders/particles.vertex" {
  17466. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17467. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17468. /** @hidden */
  17469. export var particlesVertexShader: {
  17470. name: string;
  17471. shader: string;
  17472. };
  17473. }
  17474. declare module "babylonjs/Particles/particleSystem" {
  17475. import { Nullable } from "babylonjs/types";
  17476. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17477. import { Observable } from "babylonjs/Misc/observable";
  17478. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17479. import { Effect } from "babylonjs/Materials/effect";
  17480. import { Scene, IDisposable } from "babylonjs/scene";
  17481. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17482. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17483. import { Particle } from "babylonjs/Particles/particle";
  17484. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17485. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17486. import "babylonjs/Shaders/particles.fragment";
  17487. import "babylonjs/Shaders/particles.vertex";
  17488. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17489. /**
  17490. * This represents a particle system in Babylon.
  17491. * 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.
  17492. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17493. * @example https://doc.babylonjs.com/babylon101/particles
  17494. */
  17495. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17496. /**
  17497. * Billboard mode will only apply to Y axis
  17498. */
  17499. static readonly BILLBOARDMODE_Y: number;
  17500. /**
  17501. * Billboard mode will apply to all axes
  17502. */
  17503. static readonly BILLBOARDMODE_ALL: number;
  17504. /**
  17505. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17506. */
  17507. static readonly BILLBOARDMODE_STRETCHED: number;
  17508. /**
  17509. * This function can be defined to provide custom update for active particles.
  17510. * This function will be called instead of regular update (age, position, color, etc.).
  17511. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17512. */
  17513. updateFunction: (particles: Particle[]) => void;
  17514. private _emitterWorldMatrix;
  17515. /**
  17516. * This function can be defined to specify initial direction for every new particle.
  17517. * It by default use the emitterType defined function
  17518. */
  17519. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17520. /**
  17521. * This function can be defined to specify initial position for every new particle.
  17522. * It by default use the emitterType defined function
  17523. */
  17524. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17525. /**
  17526. * @hidden
  17527. */
  17528. _inheritedVelocityOffset: Vector3;
  17529. /**
  17530. * An event triggered when the system is disposed
  17531. */
  17532. onDisposeObservable: Observable<ParticleSystem>;
  17533. private _onDisposeObserver;
  17534. /**
  17535. * Sets a callback that will be triggered when the system is disposed
  17536. */
  17537. onDispose: () => void;
  17538. private _particles;
  17539. private _epsilon;
  17540. private _capacity;
  17541. private _stockParticles;
  17542. private _newPartsExcess;
  17543. private _vertexData;
  17544. private _vertexBuffer;
  17545. private _vertexBuffers;
  17546. private _spriteBuffer;
  17547. private _indexBuffer;
  17548. private _effect;
  17549. private _customEffect;
  17550. private _cachedDefines;
  17551. private _scaledColorStep;
  17552. private _colorDiff;
  17553. private _scaledDirection;
  17554. private _scaledGravity;
  17555. private _currentRenderId;
  17556. private _alive;
  17557. private _useInstancing;
  17558. private _started;
  17559. private _stopped;
  17560. private _actualFrame;
  17561. private _scaledUpdateSpeed;
  17562. private _vertexBufferSize;
  17563. /** @hidden */
  17564. _currentEmitRateGradient: Nullable<FactorGradient>;
  17565. /** @hidden */
  17566. _currentEmitRate1: number;
  17567. /** @hidden */
  17568. _currentEmitRate2: number;
  17569. /** @hidden */
  17570. _currentStartSizeGradient: Nullable<FactorGradient>;
  17571. /** @hidden */
  17572. _currentStartSize1: number;
  17573. /** @hidden */
  17574. _currentStartSize2: number;
  17575. private readonly _rawTextureWidth;
  17576. private _rampGradientsTexture;
  17577. private _useRampGradients;
  17578. /** Gets or sets a boolean indicating that ramp gradients must be used
  17579. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17580. */
  17581. useRampGradients: boolean;
  17582. /**
  17583. * 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.
  17584. * 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: [])
  17585. */
  17586. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17587. private _subEmitters;
  17588. /**
  17589. * @hidden
  17590. * If the particle systems emitter should be disposed when the particle system is disposed
  17591. */
  17592. _disposeEmitterOnDispose: boolean;
  17593. /**
  17594. * The current active Sub-systems, this property is used by the root particle system only.
  17595. */
  17596. activeSubSystems: Array<ParticleSystem>;
  17597. private _rootParticleSystem;
  17598. /**
  17599. * Gets the current list of active particles
  17600. */
  17601. readonly particles: Particle[];
  17602. /**
  17603. * Returns the string "ParticleSystem"
  17604. * @returns a string containing the class name
  17605. */
  17606. getClassName(): string;
  17607. /**
  17608. * Instantiates a particle system.
  17609. * 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.
  17610. * @param name The name of the particle system
  17611. * @param capacity The max number of particles alive at the same time
  17612. * @param scene The scene the particle system belongs to
  17613. * @param customEffect a custom effect used to change the way particles are rendered by default
  17614. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17615. * @param epsilon Offset used to render the particles
  17616. */
  17617. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17618. private _addFactorGradient;
  17619. private _removeFactorGradient;
  17620. /**
  17621. * Adds a new life time gradient
  17622. * @param gradient defines the gradient to use (between 0 and 1)
  17623. * @param factor defines the life time factor to affect to the specified gradient
  17624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17625. * @returns the current particle system
  17626. */
  17627. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17628. /**
  17629. * Remove a specific life time gradient
  17630. * @param gradient defines the gradient to remove
  17631. * @returns the current particle system
  17632. */
  17633. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17634. /**
  17635. * Adds a new size gradient
  17636. * @param gradient defines the gradient to use (between 0 and 1)
  17637. * @param factor defines the size factor to affect to the specified gradient
  17638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17639. * @returns the current particle system
  17640. */
  17641. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17642. /**
  17643. * Remove a specific size gradient
  17644. * @param gradient defines the gradient to remove
  17645. * @returns the current particle system
  17646. */
  17647. removeSizeGradient(gradient: number): IParticleSystem;
  17648. /**
  17649. * Adds a new color remap gradient
  17650. * @param gradient defines the gradient to use (between 0 and 1)
  17651. * @param min defines the color remap minimal range
  17652. * @param max defines the color remap maximal range
  17653. * @returns the current particle system
  17654. */
  17655. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17656. /**
  17657. * Remove a specific color remap gradient
  17658. * @param gradient defines the gradient to remove
  17659. * @returns the current particle system
  17660. */
  17661. removeColorRemapGradient(gradient: number): IParticleSystem;
  17662. /**
  17663. * Adds a new alpha remap gradient
  17664. * @param gradient defines the gradient to use (between 0 and 1)
  17665. * @param min defines the alpha remap minimal range
  17666. * @param max defines the alpha remap maximal range
  17667. * @returns the current particle system
  17668. */
  17669. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17670. /**
  17671. * Remove a specific alpha remap gradient
  17672. * @param gradient defines the gradient to remove
  17673. * @returns the current particle system
  17674. */
  17675. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17676. /**
  17677. * Adds a new angular speed gradient
  17678. * @param gradient defines the gradient to use (between 0 and 1)
  17679. * @param factor defines the angular speed to affect to the specified gradient
  17680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17681. * @returns the current particle system
  17682. */
  17683. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17684. /**
  17685. * Remove a specific angular speed gradient
  17686. * @param gradient defines the gradient to remove
  17687. * @returns the current particle system
  17688. */
  17689. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17690. /**
  17691. * Adds a new velocity gradient
  17692. * @param gradient defines the gradient to use (between 0 and 1)
  17693. * @param factor defines the velocity to affect to the specified gradient
  17694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17695. * @returns the current particle system
  17696. */
  17697. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17698. /**
  17699. * Remove a specific velocity gradient
  17700. * @param gradient defines the gradient to remove
  17701. * @returns the current particle system
  17702. */
  17703. removeVelocityGradient(gradient: number): IParticleSystem;
  17704. /**
  17705. * Adds a new limit velocity gradient
  17706. * @param gradient defines the gradient to use (between 0 and 1)
  17707. * @param factor defines the limit velocity value to affect to the specified gradient
  17708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17709. * @returns the current particle system
  17710. */
  17711. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17712. /**
  17713. * Remove a specific limit velocity gradient
  17714. * @param gradient defines the gradient to remove
  17715. * @returns the current particle system
  17716. */
  17717. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17718. /**
  17719. * Adds a new drag gradient
  17720. * @param gradient defines the gradient to use (between 0 and 1)
  17721. * @param factor defines the drag value to affect to the specified gradient
  17722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17723. * @returns the current particle system
  17724. */
  17725. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17726. /**
  17727. * Remove a specific drag gradient
  17728. * @param gradient defines the gradient to remove
  17729. * @returns the current particle system
  17730. */
  17731. removeDragGradient(gradient: number): IParticleSystem;
  17732. /**
  17733. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17734. * @param gradient defines the gradient to use (between 0 and 1)
  17735. * @param factor defines the emit rate value to affect to the specified gradient
  17736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17737. * @returns the current particle system
  17738. */
  17739. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17740. /**
  17741. * Remove a specific emit rate gradient
  17742. * @param gradient defines the gradient to remove
  17743. * @returns the current particle system
  17744. */
  17745. removeEmitRateGradient(gradient: number): IParticleSystem;
  17746. /**
  17747. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17748. * @param gradient defines the gradient to use (between 0 and 1)
  17749. * @param factor defines the start size value to affect to the specified gradient
  17750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17751. * @returns the current particle system
  17752. */
  17753. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17754. /**
  17755. * Remove a specific start size gradient
  17756. * @param gradient defines the gradient to remove
  17757. * @returns the current particle system
  17758. */
  17759. removeStartSizeGradient(gradient: number): IParticleSystem;
  17760. private _createRampGradientTexture;
  17761. /**
  17762. * Gets the current list of ramp gradients.
  17763. * You must use addRampGradient and removeRampGradient to udpate this list
  17764. * @returns the list of ramp gradients
  17765. */
  17766. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17767. /**
  17768. * Adds a new ramp gradient used to remap particle colors
  17769. * @param gradient defines the gradient to use (between 0 and 1)
  17770. * @param color defines the color to affect to the specified gradient
  17771. * @returns the current particle system
  17772. */
  17773. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17774. /**
  17775. * Remove a specific ramp gradient
  17776. * @param gradient defines the gradient to remove
  17777. * @returns the current particle system
  17778. */
  17779. removeRampGradient(gradient: number): ParticleSystem;
  17780. /**
  17781. * Adds a new color gradient
  17782. * @param gradient defines the gradient to use (between 0 and 1)
  17783. * @param color1 defines the color to affect to the specified gradient
  17784. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17785. * @returns this particle system
  17786. */
  17787. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17788. /**
  17789. * Remove a specific color gradient
  17790. * @param gradient defines the gradient to remove
  17791. * @returns this particle system
  17792. */
  17793. removeColorGradient(gradient: number): IParticleSystem;
  17794. private _fetchR;
  17795. protected _reset(): void;
  17796. private _resetEffect;
  17797. private _createVertexBuffers;
  17798. private _createIndexBuffer;
  17799. /**
  17800. * Gets the maximum number of particles active at the same time.
  17801. * @returns The max number of active particles.
  17802. */
  17803. getCapacity(): number;
  17804. /**
  17805. * Gets whether there are still active particles in the system.
  17806. * @returns True if it is alive, otherwise false.
  17807. */
  17808. isAlive(): boolean;
  17809. /**
  17810. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17811. * @returns True if it has been started, otherwise false.
  17812. */
  17813. isStarted(): boolean;
  17814. private _prepareSubEmitterInternalArray;
  17815. /**
  17816. * Starts the particle system and begins to emit
  17817. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17818. */
  17819. start(delay?: number): void;
  17820. /**
  17821. * Stops the particle system.
  17822. * @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.
  17823. */
  17824. stop(stopSubEmitters?: boolean): void;
  17825. /**
  17826. * Remove all active particles
  17827. */
  17828. reset(): void;
  17829. /**
  17830. * @hidden (for internal use only)
  17831. */
  17832. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17833. /**
  17834. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17835. * Its lifetime will start back at 0.
  17836. */
  17837. recycleParticle: (particle: Particle) => void;
  17838. private _stopSubEmitters;
  17839. private _createParticle;
  17840. private _removeFromRoot;
  17841. private _emitFromParticle;
  17842. private _update;
  17843. /** @hidden */
  17844. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17845. /** @hidden */
  17846. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17847. /** @hidden */
  17848. private _getEffect;
  17849. /**
  17850. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17851. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17852. */
  17853. animate(preWarmOnly?: boolean): void;
  17854. private _appendParticleVertices;
  17855. /**
  17856. * Rebuilds the particle system.
  17857. */
  17858. rebuild(): void;
  17859. /**
  17860. * Is this system ready to be used/rendered
  17861. * @return true if the system is ready
  17862. */
  17863. isReady(): boolean;
  17864. private _render;
  17865. /**
  17866. * Renders the particle system in its current state.
  17867. * @returns the current number of particles
  17868. */
  17869. render(): number;
  17870. /**
  17871. * Disposes the particle system and free the associated resources
  17872. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17873. */
  17874. dispose(disposeTexture?: boolean): void;
  17875. /**
  17876. * Clones the particle system.
  17877. * @param name The name of the cloned object
  17878. * @param newEmitter The new emitter to use
  17879. * @returns the cloned particle system
  17880. */
  17881. clone(name: string, newEmitter: any): ParticleSystem;
  17882. /**
  17883. * Serializes the particle system to a JSON object.
  17884. * @returns the JSON object
  17885. */
  17886. serialize(): any;
  17887. /** @hidden */
  17888. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17889. /** @hidden */
  17890. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17891. /**
  17892. * Parses a JSON object to create a particle system.
  17893. * @param parsedParticleSystem The JSON object to parse
  17894. * @param scene The scene to create the particle system in
  17895. * @param rootUrl The root url to use to load external dependencies like texture
  17896. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17897. * @returns the Parsed particle system
  17898. */
  17899. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17900. }
  17901. }
  17902. declare module "babylonjs/Particles/particle" {
  17903. import { Nullable } from "babylonjs/types";
  17904. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17905. import { Color4 } from "babylonjs/Maths/math.color";
  17906. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17907. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17908. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17909. /**
  17910. * A particle represents one of the element emitted by a particle system.
  17911. * This is mainly define by its coordinates, direction, velocity and age.
  17912. */
  17913. export class Particle {
  17914. /**
  17915. * The particle system the particle belongs to.
  17916. */
  17917. particleSystem: ParticleSystem;
  17918. private static _Count;
  17919. /**
  17920. * Unique ID of the particle
  17921. */
  17922. id: number;
  17923. /**
  17924. * The world position of the particle in the scene.
  17925. */
  17926. position: Vector3;
  17927. /**
  17928. * The world direction of the particle in the scene.
  17929. */
  17930. direction: Vector3;
  17931. /**
  17932. * The color of the particle.
  17933. */
  17934. color: Color4;
  17935. /**
  17936. * The color change of the particle per step.
  17937. */
  17938. colorStep: Color4;
  17939. /**
  17940. * Defines how long will the life of the particle be.
  17941. */
  17942. lifeTime: number;
  17943. /**
  17944. * The current age of the particle.
  17945. */
  17946. age: number;
  17947. /**
  17948. * The current size of the particle.
  17949. */
  17950. size: number;
  17951. /**
  17952. * The current scale of the particle.
  17953. */
  17954. scale: Vector2;
  17955. /**
  17956. * The current angle of the particle.
  17957. */
  17958. angle: number;
  17959. /**
  17960. * Defines how fast is the angle changing.
  17961. */
  17962. angularSpeed: number;
  17963. /**
  17964. * Defines the cell index used by the particle to be rendered from a sprite.
  17965. */
  17966. cellIndex: number;
  17967. /**
  17968. * The information required to support color remapping
  17969. */
  17970. remapData: Vector4;
  17971. /** @hidden */
  17972. _randomCellOffset?: number;
  17973. /** @hidden */
  17974. _initialDirection: Nullable<Vector3>;
  17975. /** @hidden */
  17976. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17977. /** @hidden */
  17978. _initialStartSpriteCellID: number;
  17979. /** @hidden */
  17980. _initialEndSpriteCellID: number;
  17981. /** @hidden */
  17982. _currentColorGradient: Nullable<ColorGradient>;
  17983. /** @hidden */
  17984. _currentColor1: Color4;
  17985. /** @hidden */
  17986. _currentColor2: Color4;
  17987. /** @hidden */
  17988. _currentSizeGradient: Nullable<FactorGradient>;
  17989. /** @hidden */
  17990. _currentSize1: number;
  17991. /** @hidden */
  17992. _currentSize2: number;
  17993. /** @hidden */
  17994. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17995. /** @hidden */
  17996. _currentAngularSpeed1: number;
  17997. /** @hidden */
  17998. _currentAngularSpeed2: number;
  17999. /** @hidden */
  18000. _currentVelocityGradient: Nullable<FactorGradient>;
  18001. /** @hidden */
  18002. _currentVelocity1: number;
  18003. /** @hidden */
  18004. _currentVelocity2: number;
  18005. /** @hidden */
  18006. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18007. /** @hidden */
  18008. _currentLimitVelocity1: number;
  18009. /** @hidden */
  18010. _currentLimitVelocity2: number;
  18011. /** @hidden */
  18012. _currentDragGradient: Nullable<FactorGradient>;
  18013. /** @hidden */
  18014. _currentDrag1: number;
  18015. /** @hidden */
  18016. _currentDrag2: number;
  18017. /** @hidden */
  18018. _randomNoiseCoordinates1: Vector3;
  18019. /** @hidden */
  18020. _randomNoiseCoordinates2: Vector3;
  18021. /**
  18022. * Creates a new instance Particle
  18023. * @param particleSystem the particle system the particle belongs to
  18024. */
  18025. constructor(
  18026. /**
  18027. * The particle system the particle belongs to.
  18028. */
  18029. particleSystem: ParticleSystem);
  18030. private updateCellInfoFromSystem;
  18031. /**
  18032. * Defines how the sprite cell index is updated for the particle
  18033. */
  18034. updateCellIndex(): void;
  18035. /** @hidden */
  18036. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18037. /** @hidden */
  18038. _inheritParticleInfoToSubEmitters(): void;
  18039. /** @hidden */
  18040. _reset(): void;
  18041. /**
  18042. * Copy the properties of particle to another one.
  18043. * @param other the particle to copy the information to.
  18044. */
  18045. copyTo(other: Particle): void;
  18046. }
  18047. }
  18048. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18049. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18050. import { Effect } from "babylonjs/Materials/effect";
  18051. import { Particle } from "babylonjs/Particles/particle";
  18052. /**
  18053. * Particle emitter represents a volume emitting particles.
  18054. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18055. */
  18056. export interface IParticleEmitterType {
  18057. /**
  18058. * Called by the particle System when the direction is computed for the created particle.
  18059. * @param worldMatrix is the world matrix of the particle system
  18060. * @param directionToUpdate is the direction vector to update with the result
  18061. * @param particle is the particle we are computed the direction for
  18062. */
  18063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18064. /**
  18065. * Called by the particle System when the position is computed for the created particle.
  18066. * @param worldMatrix is the world matrix of the particle system
  18067. * @param positionToUpdate is the position vector to update with the result
  18068. * @param particle is the particle we are computed the position for
  18069. */
  18070. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18071. /**
  18072. * Clones the current emitter and returns a copy of it
  18073. * @returns the new emitter
  18074. */
  18075. clone(): IParticleEmitterType;
  18076. /**
  18077. * Called by the GPUParticleSystem to setup the update shader
  18078. * @param effect defines the update shader
  18079. */
  18080. applyToShader(effect: Effect): void;
  18081. /**
  18082. * Returns a string to use to update the GPU particles update shader
  18083. * @returns the effect defines string
  18084. */
  18085. getEffectDefines(): string;
  18086. /**
  18087. * Returns a string representing the class name
  18088. * @returns a string containing the class name
  18089. */
  18090. getClassName(): string;
  18091. /**
  18092. * Serializes the particle system to a JSON object.
  18093. * @returns the JSON object
  18094. */
  18095. serialize(): any;
  18096. /**
  18097. * Parse properties from a JSON object
  18098. * @param serializationObject defines the JSON object
  18099. */
  18100. parse(serializationObject: any): void;
  18101. }
  18102. }
  18103. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18104. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18105. import { Effect } from "babylonjs/Materials/effect";
  18106. import { Particle } from "babylonjs/Particles/particle";
  18107. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18108. /**
  18109. * Particle emitter emitting particles from the inside of a box.
  18110. * It emits the particles randomly between 2 given directions.
  18111. */
  18112. export class BoxParticleEmitter implements IParticleEmitterType {
  18113. /**
  18114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18115. */
  18116. direction1: Vector3;
  18117. /**
  18118. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18119. */
  18120. direction2: Vector3;
  18121. /**
  18122. * 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.
  18123. */
  18124. minEmitBox: Vector3;
  18125. /**
  18126. * 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.
  18127. */
  18128. maxEmitBox: Vector3;
  18129. /**
  18130. * Creates a new instance BoxParticleEmitter
  18131. */
  18132. constructor();
  18133. /**
  18134. * Called by the particle System when the direction is computed for the created particle.
  18135. * @param worldMatrix is the world matrix of the particle system
  18136. * @param directionToUpdate is the direction vector to update with the result
  18137. * @param particle is the particle we are computed the direction for
  18138. */
  18139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18140. /**
  18141. * Called by the particle System when the position is computed for the created particle.
  18142. * @param worldMatrix is the world matrix of the particle system
  18143. * @param positionToUpdate is the position vector to update with the result
  18144. * @param particle is the particle we are computed the position for
  18145. */
  18146. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18147. /**
  18148. * Clones the current emitter and returns a copy of it
  18149. * @returns the new emitter
  18150. */
  18151. clone(): BoxParticleEmitter;
  18152. /**
  18153. * Called by the GPUParticleSystem to setup the update shader
  18154. * @param effect defines the update shader
  18155. */
  18156. applyToShader(effect: Effect): void;
  18157. /**
  18158. * Returns a string to use to update the GPU particles update shader
  18159. * @returns a string containng the defines string
  18160. */
  18161. getEffectDefines(): string;
  18162. /**
  18163. * Returns the string "BoxParticleEmitter"
  18164. * @returns a string containing the class name
  18165. */
  18166. getClassName(): string;
  18167. /**
  18168. * Serializes the particle system to a JSON object.
  18169. * @returns the JSON object
  18170. */
  18171. serialize(): any;
  18172. /**
  18173. * Parse properties from a JSON object
  18174. * @param serializationObject defines the JSON object
  18175. */
  18176. parse(serializationObject: any): void;
  18177. }
  18178. }
  18179. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18180. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18181. import { Effect } from "babylonjs/Materials/effect";
  18182. import { Particle } from "babylonjs/Particles/particle";
  18183. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18184. /**
  18185. * Particle emitter emitting particles from the inside of a cone.
  18186. * It emits the particles alongside the cone volume from the base to the particle.
  18187. * The emission direction might be randomized.
  18188. */
  18189. export class ConeParticleEmitter implements IParticleEmitterType {
  18190. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18191. directionRandomizer: number;
  18192. private _radius;
  18193. private _angle;
  18194. private _height;
  18195. /**
  18196. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18197. */
  18198. radiusRange: number;
  18199. /**
  18200. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18201. */
  18202. heightRange: number;
  18203. /**
  18204. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18205. */
  18206. emitFromSpawnPointOnly: boolean;
  18207. /**
  18208. * Gets or sets the radius of the emission cone
  18209. */
  18210. radius: number;
  18211. /**
  18212. * Gets or sets the angle of the emission cone
  18213. */
  18214. angle: number;
  18215. private _buildHeight;
  18216. /**
  18217. * Creates a new instance ConeParticleEmitter
  18218. * @param radius the radius of the emission cone (1 by default)
  18219. * @param angle the cone base angle (PI by default)
  18220. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18221. */
  18222. constructor(radius?: number, angle?: number,
  18223. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18224. directionRandomizer?: number);
  18225. /**
  18226. * Called by the particle System when the direction is computed for the created particle.
  18227. * @param worldMatrix is the world matrix of the particle system
  18228. * @param directionToUpdate is the direction vector to update with the result
  18229. * @param particle is the particle we are computed the direction for
  18230. */
  18231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18232. /**
  18233. * Called by the particle System when the position is computed for the created particle.
  18234. * @param worldMatrix is the world matrix of the particle system
  18235. * @param positionToUpdate is the position vector to update with the result
  18236. * @param particle is the particle we are computed the position for
  18237. */
  18238. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18239. /**
  18240. * Clones the current emitter and returns a copy of it
  18241. * @returns the new emitter
  18242. */
  18243. clone(): ConeParticleEmitter;
  18244. /**
  18245. * Called by the GPUParticleSystem to setup the update shader
  18246. * @param effect defines the update shader
  18247. */
  18248. applyToShader(effect: Effect): void;
  18249. /**
  18250. * Returns a string to use to update the GPU particles update shader
  18251. * @returns a string containng the defines string
  18252. */
  18253. getEffectDefines(): string;
  18254. /**
  18255. * Returns the string "ConeParticleEmitter"
  18256. * @returns a string containing the class name
  18257. */
  18258. getClassName(): string;
  18259. /**
  18260. * Serializes the particle system to a JSON object.
  18261. * @returns the JSON object
  18262. */
  18263. serialize(): any;
  18264. /**
  18265. * Parse properties from a JSON object
  18266. * @param serializationObject defines the JSON object
  18267. */
  18268. parse(serializationObject: any): void;
  18269. }
  18270. }
  18271. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18272. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18273. import { Effect } from "babylonjs/Materials/effect";
  18274. import { Particle } from "babylonjs/Particles/particle";
  18275. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18276. /**
  18277. * Particle emitter emitting particles from the inside of a cylinder.
  18278. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18279. */
  18280. export class CylinderParticleEmitter implements IParticleEmitterType {
  18281. /**
  18282. * The radius of the emission cylinder.
  18283. */
  18284. radius: number;
  18285. /**
  18286. * The height of the emission cylinder.
  18287. */
  18288. height: number;
  18289. /**
  18290. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18291. */
  18292. radiusRange: number;
  18293. /**
  18294. * How much to randomize the particle direction [0-1].
  18295. */
  18296. directionRandomizer: number;
  18297. /**
  18298. * Creates a new instance CylinderParticleEmitter
  18299. * @param radius the radius of the emission cylinder (1 by default)
  18300. * @param height the height of the emission cylinder (1 by default)
  18301. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18302. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18303. */
  18304. constructor(
  18305. /**
  18306. * The radius of the emission cylinder.
  18307. */
  18308. radius?: number,
  18309. /**
  18310. * The height of the emission cylinder.
  18311. */
  18312. height?: number,
  18313. /**
  18314. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18315. */
  18316. radiusRange?: number,
  18317. /**
  18318. * How much to randomize the particle direction [0-1].
  18319. */
  18320. directionRandomizer?: number);
  18321. /**
  18322. * Called by the particle System when the direction is computed for the created particle.
  18323. * @param worldMatrix is the world matrix of the particle system
  18324. * @param directionToUpdate is the direction vector to update with the result
  18325. * @param particle is the particle we are computed the direction for
  18326. */
  18327. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18328. /**
  18329. * Called by the particle System when the position is computed for the created particle.
  18330. * @param worldMatrix is the world matrix of the particle system
  18331. * @param positionToUpdate is the position vector to update with the result
  18332. * @param particle is the particle we are computed the position for
  18333. */
  18334. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18335. /**
  18336. * Clones the current emitter and returns a copy of it
  18337. * @returns the new emitter
  18338. */
  18339. clone(): CylinderParticleEmitter;
  18340. /**
  18341. * Called by the GPUParticleSystem to setup the update shader
  18342. * @param effect defines the update shader
  18343. */
  18344. applyToShader(effect: Effect): void;
  18345. /**
  18346. * Returns a string to use to update the GPU particles update shader
  18347. * @returns a string containng the defines string
  18348. */
  18349. getEffectDefines(): string;
  18350. /**
  18351. * Returns the string "CylinderParticleEmitter"
  18352. * @returns a string containing the class name
  18353. */
  18354. getClassName(): string;
  18355. /**
  18356. * Serializes the particle system to a JSON object.
  18357. * @returns the JSON object
  18358. */
  18359. serialize(): any;
  18360. /**
  18361. * Parse properties from a JSON object
  18362. * @param serializationObject defines the JSON object
  18363. */
  18364. parse(serializationObject: any): void;
  18365. }
  18366. /**
  18367. * Particle emitter emitting particles from the inside of a cylinder.
  18368. * It emits the particles randomly between two vectors.
  18369. */
  18370. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18371. /**
  18372. * The min limit of the emission direction.
  18373. */
  18374. direction1: Vector3;
  18375. /**
  18376. * The max limit of the emission direction.
  18377. */
  18378. direction2: Vector3;
  18379. /**
  18380. * Creates a new instance CylinderDirectedParticleEmitter
  18381. * @param radius the radius of the emission cylinder (1 by default)
  18382. * @param height the height of the emission cylinder (1 by default)
  18383. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18384. * @param direction1 the min limit of the emission direction (up vector by default)
  18385. * @param direction2 the max limit of the emission direction (up vector by default)
  18386. */
  18387. constructor(radius?: number, height?: number, radiusRange?: number,
  18388. /**
  18389. * The min limit of the emission direction.
  18390. */
  18391. direction1?: Vector3,
  18392. /**
  18393. * The max limit of the emission direction.
  18394. */
  18395. direction2?: Vector3);
  18396. /**
  18397. * Called by the particle System when the direction is computed for the created particle.
  18398. * @param worldMatrix is the world matrix of the particle system
  18399. * @param directionToUpdate is the direction vector to update with the result
  18400. * @param particle is the particle we are computed the direction for
  18401. */
  18402. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18403. /**
  18404. * Clones the current emitter and returns a copy of it
  18405. * @returns the new emitter
  18406. */
  18407. clone(): CylinderDirectedParticleEmitter;
  18408. /**
  18409. * Called by the GPUParticleSystem to setup the update shader
  18410. * @param effect defines the update shader
  18411. */
  18412. applyToShader(effect: Effect): void;
  18413. /**
  18414. * Returns a string to use to update the GPU particles update shader
  18415. * @returns a string containng the defines string
  18416. */
  18417. getEffectDefines(): string;
  18418. /**
  18419. * Returns the string "CylinderDirectedParticleEmitter"
  18420. * @returns a string containing the class name
  18421. */
  18422. getClassName(): string;
  18423. /**
  18424. * Serializes the particle system to a JSON object.
  18425. * @returns the JSON object
  18426. */
  18427. serialize(): any;
  18428. /**
  18429. * Parse properties from a JSON object
  18430. * @param serializationObject defines the JSON object
  18431. */
  18432. parse(serializationObject: any): void;
  18433. }
  18434. }
  18435. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18436. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18437. import { Effect } from "babylonjs/Materials/effect";
  18438. import { Particle } from "babylonjs/Particles/particle";
  18439. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18440. /**
  18441. * Particle emitter emitting particles from the inside of a hemisphere.
  18442. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18443. */
  18444. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18445. /**
  18446. * The radius of the emission hemisphere.
  18447. */
  18448. radius: number;
  18449. /**
  18450. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18451. */
  18452. radiusRange: number;
  18453. /**
  18454. * How much to randomize the particle direction [0-1].
  18455. */
  18456. directionRandomizer: number;
  18457. /**
  18458. * Creates a new instance HemisphericParticleEmitter
  18459. * @param radius the radius of the emission hemisphere (1 by default)
  18460. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18461. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18462. */
  18463. constructor(
  18464. /**
  18465. * The radius of the emission hemisphere.
  18466. */
  18467. radius?: number,
  18468. /**
  18469. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18470. */
  18471. radiusRange?: number,
  18472. /**
  18473. * How much to randomize the particle direction [0-1].
  18474. */
  18475. directionRandomizer?: number);
  18476. /**
  18477. * Called by the particle System when the direction is computed for the created particle.
  18478. * @param worldMatrix is the world matrix of the particle system
  18479. * @param directionToUpdate is the direction vector to update with the result
  18480. * @param particle is the particle we are computed the direction for
  18481. */
  18482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18483. /**
  18484. * Called by the particle System when the position is computed for the created particle.
  18485. * @param worldMatrix is the world matrix of the particle system
  18486. * @param positionToUpdate is the position vector to update with the result
  18487. * @param particle is the particle we are computed the position for
  18488. */
  18489. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18490. /**
  18491. * Clones the current emitter and returns a copy of it
  18492. * @returns the new emitter
  18493. */
  18494. clone(): HemisphericParticleEmitter;
  18495. /**
  18496. * Called by the GPUParticleSystem to setup the update shader
  18497. * @param effect defines the update shader
  18498. */
  18499. applyToShader(effect: Effect): void;
  18500. /**
  18501. * Returns a string to use to update the GPU particles update shader
  18502. * @returns a string containng the defines string
  18503. */
  18504. getEffectDefines(): string;
  18505. /**
  18506. * Returns the string "HemisphericParticleEmitter"
  18507. * @returns a string containing the class name
  18508. */
  18509. getClassName(): string;
  18510. /**
  18511. * Serializes the particle system to a JSON object.
  18512. * @returns the JSON object
  18513. */
  18514. serialize(): any;
  18515. /**
  18516. * Parse properties from a JSON object
  18517. * @param serializationObject defines the JSON object
  18518. */
  18519. parse(serializationObject: any): void;
  18520. }
  18521. }
  18522. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18523. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18524. import { Effect } from "babylonjs/Materials/effect";
  18525. import { Particle } from "babylonjs/Particles/particle";
  18526. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18527. /**
  18528. * Particle emitter emitting particles from a point.
  18529. * It emits the particles randomly between 2 given directions.
  18530. */
  18531. export class PointParticleEmitter implements IParticleEmitterType {
  18532. /**
  18533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18534. */
  18535. direction1: Vector3;
  18536. /**
  18537. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18538. */
  18539. direction2: Vector3;
  18540. /**
  18541. * Creates a new instance PointParticleEmitter
  18542. */
  18543. constructor();
  18544. /**
  18545. * Called by the particle System when the direction is computed for the created particle.
  18546. * @param worldMatrix is the world matrix of the particle system
  18547. * @param directionToUpdate is the direction vector to update with the result
  18548. * @param particle is the particle we are computed the direction for
  18549. */
  18550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18551. /**
  18552. * Called by the particle System when the position is computed for the created particle.
  18553. * @param worldMatrix is the world matrix of the particle system
  18554. * @param positionToUpdate is the position vector to update with the result
  18555. * @param particle is the particle we are computed the position for
  18556. */
  18557. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18558. /**
  18559. * Clones the current emitter and returns a copy of it
  18560. * @returns the new emitter
  18561. */
  18562. clone(): PointParticleEmitter;
  18563. /**
  18564. * Called by the GPUParticleSystem to setup the update shader
  18565. * @param effect defines the update shader
  18566. */
  18567. applyToShader(effect: Effect): void;
  18568. /**
  18569. * Returns a string to use to update the GPU particles update shader
  18570. * @returns a string containng the defines string
  18571. */
  18572. getEffectDefines(): string;
  18573. /**
  18574. * Returns the string "PointParticleEmitter"
  18575. * @returns a string containing the class name
  18576. */
  18577. getClassName(): string;
  18578. /**
  18579. * Serializes the particle system to a JSON object.
  18580. * @returns the JSON object
  18581. */
  18582. serialize(): any;
  18583. /**
  18584. * Parse properties from a JSON object
  18585. * @param serializationObject defines the JSON object
  18586. */
  18587. parse(serializationObject: any): void;
  18588. }
  18589. }
  18590. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18591. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18592. import { Effect } from "babylonjs/Materials/effect";
  18593. import { Particle } from "babylonjs/Particles/particle";
  18594. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18595. /**
  18596. * Particle emitter emitting particles from the inside of a sphere.
  18597. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18598. */
  18599. export class SphereParticleEmitter implements IParticleEmitterType {
  18600. /**
  18601. * The radius of the emission sphere.
  18602. */
  18603. radius: number;
  18604. /**
  18605. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18606. */
  18607. radiusRange: number;
  18608. /**
  18609. * How much to randomize the particle direction [0-1].
  18610. */
  18611. directionRandomizer: number;
  18612. /**
  18613. * Creates a new instance SphereParticleEmitter
  18614. * @param radius the radius of the emission sphere (1 by default)
  18615. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18616. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18617. */
  18618. constructor(
  18619. /**
  18620. * The radius of the emission sphere.
  18621. */
  18622. radius?: number,
  18623. /**
  18624. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18625. */
  18626. radiusRange?: number,
  18627. /**
  18628. * How much to randomize the particle direction [0-1].
  18629. */
  18630. directionRandomizer?: number);
  18631. /**
  18632. * Called by the particle System when the direction is computed for the created particle.
  18633. * @param worldMatrix is the world matrix of the particle system
  18634. * @param directionToUpdate is the direction vector to update with the result
  18635. * @param particle is the particle we are computed the direction for
  18636. */
  18637. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18638. /**
  18639. * Called by the particle System when the position is computed for the created particle.
  18640. * @param worldMatrix is the world matrix of the particle system
  18641. * @param positionToUpdate is the position vector to update with the result
  18642. * @param particle is the particle we are computed the position for
  18643. */
  18644. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18645. /**
  18646. * Clones the current emitter and returns a copy of it
  18647. * @returns the new emitter
  18648. */
  18649. clone(): SphereParticleEmitter;
  18650. /**
  18651. * Called by the GPUParticleSystem to setup the update shader
  18652. * @param effect defines the update shader
  18653. */
  18654. applyToShader(effect: Effect): void;
  18655. /**
  18656. * Returns a string to use to update the GPU particles update shader
  18657. * @returns a string containng the defines string
  18658. */
  18659. getEffectDefines(): string;
  18660. /**
  18661. * Returns the string "SphereParticleEmitter"
  18662. * @returns a string containing the class name
  18663. */
  18664. getClassName(): string;
  18665. /**
  18666. * Serializes the particle system to a JSON object.
  18667. * @returns the JSON object
  18668. */
  18669. serialize(): any;
  18670. /**
  18671. * Parse properties from a JSON object
  18672. * @param serializationObject defines the JSON object
  18673. */
  18674. parse(serializationObject: any): void;
  18675. }
  18676. /**
  18677. * Particle emitter emitting particles from the inside of a sphere.
  18678. * It emits the particles randomly between two vectors.
  18679. */
  18680. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18681. /**
  18682. * The min limit of the emission direction.
  18683. */
  18684. direction1: Vector3;
  18685. /**
  18686. * The max limit of the emission direction.
  18687. */
  18688. direction2: Vector3;
  18689. /**
  18690. * Creates a new instance SphereDirectedParticleEmitter
  18691. * @param radius the radius of the emission sphere (1 by default)
  18692. * @param direction1 the min limit of the emission direction (up vector by default)
  18693. * @param direction2 the max limit of the emission direction (up vector by default)
  18694. */
  18695. constructor(radius?: number,
  18696. /**
  18697. * The min limit of the emission direction.
  18698. */
  18699. direction1?: Vector3,
  18700. /**
  18701. * The max limit of the emission direction.
  18702. */
  18703. direction2?: Vector3);
  18704. /**
  18705. * Called by the particle System when the direction is computed for the created particle.
  18706. * @param worldMatrix is the world matrix of the particle system
  18707. * @param directionToUpdate is the direction vector to update with the result
  18708. * @param particle is the particle we are computed the direction for
  18709. */
  18710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18711. /**
  18712. * Clones the current emitter and returns a copy of it
  18713. * @returns the new emitter
  18714. */
  18715. clone(): SphereDirectedParticleEmitter;
  18716. /**
  18717. * Called by the GPUParticleSystem to setup the update shader
  18718. * @param effect defines the update shader
  18719. */
  18720. applyToShader(effect: Effect): void;
  18721. /**
  18722. * Returns a string to use to update the GPU particles update shader
  18723. * @returns a string containng the defines string
  18724. */
  18725. getEffectDefines(): string;
  18726. /**
  18727. * Returns the string "SphereDirectedParticleEmitter"
  18728. * @returns a string containing the class name
  18729. */
  18730. getClassName(): string;
  18731. /**
  18732. * Serializes the particle system to a JSON object.
  18733. * @returns the JSON object
  18734. */
  18735. serialize(): any;
  18736. /**
  18737. * Parse properties from a JSON object
  18738. * @param serializationObject defines the JSON object
  18739. */
  18740. parse(serializationObject: any): void;
  18741. }
  18742. }
  18743. declare module "babylonjs/Particles/EmitterTypes/index" {
  18744. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18745. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18746. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18747. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18748. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18749. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18750. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18751. }
  18752. declare module "babylonjs/Particles/IParticleSystem" {
  18753. import { Nullable } from "babylonjs/types";
  18754. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18755. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18758. import { Texture } from "babylonjs/Materials/Textures/texture";
  18759. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18760. import { Scene } from "babylonjs/scene";
  18761. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18762. import { Animation } from "babylonjs/Animations/animation";
  18763. /**
  18764. * Interface representing a particle system in Babylon.js.
  18765. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18766. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18767. */
  18768. export interface IParticleSystem {
  18769. /**
  18770. * List of animations used by the particle system.
  18771. */
  18772. animations: Animation[];
  18773. /**
  18774. * The id of the Particle system.
  18775. */
  18776. id: string;
  18777. /**
  18778. * The name of the Particle system.
  18779. */
  18780. name: string;
  18781. /**
  18782. * The emitter represents the Mesh or position we are attaching the particle system to.
  18783. */
  18784. emitter: Nullable<AbstractMesh | Vector3>;
  18785. /**
  18786. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18787. */
  18788. isBillboardBased: boolean;
  18789. /**
  18790. * The rendering group used by the Particle system to chose when to render.
  18791. */
  18792. renderingGroupId: number;
  18793. /**
  18794. * The layer mask we are rendering the particles through.
  18795. */
  18796. layerMask: number;
  18797. /**
  18798. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18799. */
  18800. updateSpeed: number;
  18801. /**
  18802. * The amount of time the particle system is running (depends of the overall update speed).
  18803. */
  18804. targetStopDuration: number;
  18805. /**
  18806. * The texture used to render each particle. (this can be a spritesheet)
  18807. */
  18808. particleTexture: Nullable<Texture>;
  18809. /**
  18810. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18811. */
  18812. blendMode: number;
  18813. /**
  18814. * Minimum life time of emitting particles.
  18815. */
  18816. minLifeTime: number;
  18817. /**
  18818. * Maximum life time of emitting particles.
  18819. */
  18820. maxLifeTime: number;
  18821. /**
  18822. * Minimum Size of emitting particles.
  18823. */
  18824. minSize: number;
  18825. /**
  18826. * Maximum Size of emitting particles.
  18827. */
  18828. maxSize: number;
  18829. /**
  18830. * Minimum scale of emitting particles on X axis.
  18831. */
  18832. minScaleX: number;
  18833. /**
  18834. * Maximum scale of emitting particles on X axis.
  18835. */
  18836. maxScaleX: number;
  18837. /**
  18838. * Minimum scale of emitting particles on Y axis.
  18839. */
  18840. minScaleY: number;
  18841. /**
  18842. * Maximum scale of emitting particles on Y axis.
  18843. */
  18844. maxScaleY: number;
  18845. /**
  18846. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18847. */
  18848. color1: Color4;
  18849. /**
  18850. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18851. */
  18852. color2: Color4;
  18853. /**
  18854. * Color the particle will have at the end of its lifetime.
  18855. */
  18856. colorDead: Color4;
  18857. /**
  18858. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18859. */
  18860. emitRate: number;
  18861. /**
  18862. * You can use gravity if you want to give an orientation to your particles.
  18863. */
  18864. gravity: Vector3;
  18865. /**
  18866. * Minimum power of emitting particles.
  18867. */
  18868. minEmitPower: number;
  18869. /**
  18870. * Maximum power of emitting particles.
  18871. */
  18872. maxEmitPower: number;
  18873. /**
  18874. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18875. */
  18876. minAngularSpeed: number;
  18877. /**
  18878. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18879. */
  18880. maxAngularSpeed: number;
  18881. /**
  18882. * Gets or sets the minimal initial rotation in radians.
  18883. */
  18884. minInitialRotation: number;
  18885. /**
  18886. * Gets or sets the maximal initial rotation in radians.
  18887. */
  18888. maxInitialRotation: number;
  18889. /**
  18890. * The particle emitter type defines the emitter used by the particle system.
  18891. * It can be for example box, sphere, or cone...
  18892. */
  18893. particleEmitterType: Nullable<IParticleEmitterType>;
  18894. /**
  18895. * Defines the delay in milliseconds before starting the system (0 by default)
  18896. */
  18897. startDelay: number;
  18898. /**
  18899. * 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
  18900. */
  18901. preWarmCycles: number;
  18902. /**
  18903. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18904. */
  18905. preWarmStepOffset: number;
  18906. /**
  18907. * 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)
  18908. */
  18909. spriteCellChangeSpeed: number;
  18910. /**
  18911. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18912. */
  18913. startSpriteCellID: number;
  18914. /**
  18915. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18916. */
  18917. endSpriteCellID: number;
  18918. /**
  18919. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18920. */
  18921. spriteCellWidth: number;
  18922. /**
  18923. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18924. */
  18925. spriteCellHeight: number;
  18926. /**
  18927. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18928. */
  18929. spriteRandomStartCell: boolean;
  18930. /**
  18931. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18932. */
  18933. isAnimationSheetEnabled: boolean;
  18934. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18935. translationPivot: Vector2;
  18936. /**
  18937. * Gets or sets a texture used to add random noise to particle positions
  18938. */
  18939. noiseTexture: Nullable<BaseTexture>;
  18940. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18941. noiseStrength: Vector3;
  18942. /**
  18943. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18944. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18945. */
  18946. billboardMode: number;
  18947. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18948. limitVelocityDamping: number;
  18949. /**
  18950. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18951. */
  18952. beginAnimationOnStart: boolean;
  18953. /**
  18954. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18955. */
  18956. beginAnimationFrom: number;
  18957. /**
  18958. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18959. */
  18960. beginAnimationTo: number;
  18961. /**
  18962. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18963. */
  18964. beginAnimationLoop: boolean;
  18965. /**
  18966. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18967. */
  18968. disposeOnStop: boolean;
  18969. /**
  18970. * Gets the maximum number of particles active at the same time.
  18971. * @returns The max number of active particles.
  18972. */
  18973. getCapacity(): number;
  18974. /**
  18975. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18976. * @returns True if it has been started, otherwise false.
  18977. */
  18978. isStarted(): boolean;
  18979. /**
  18980. * Animates the particle system for this frame.
  18981. */
  18982. animate(): void;
  18983. /**
  18984. * Renders the particle system in its current state.
  18985. * @returns the current number of particles
  18986. */
  18987. render(): number;
  18988. /**
  18989. * Dispose the particle system and frees its associated resources.
  18990. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18991. */
  18992. dispose(disposeTexture?: boolean): void;
  18993. /**
  18994. * Clones the particle system.
  18995. * @param name The name of the cloned object
  18996. * @param newEmitter The new emitter to use
  18997. * @returns the cloned particle system
  18998. */
  18999. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19000. /**
  19001. * Serializes the particle system to a JSON object.
  19002. * @returns the JSON object
  19003. */
  19004. serialize(): any;
  19005. /**
  19006. * Rebuild the particle system
  19007. */
  19008. rebuild(): void;
  19009. /**
  19010. * Starts the particle system and begins to emit
  19011. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19012. */
  19013. start(delay?: number): void;
  19014. /**
  19015. * Stops the particle system.
  19016. */
  19017. stop(): void;
  19018. /**
  19019. * Remove all active particles
  19020. */
  19021. reset(): void;
  19022. /**
  19023. * Is this system ready to be used/rendered
  19024. * @return true if the system is ready
  19025. */
  19026. isReady(): boolean;
  19027. /**
  19028. * Adds a new color gradient
  19029. * @param gradient defines the gradient to use (between 0 and 1)
  19030. * @param color1 defines the color to affect to the specified gradient
  19031. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19032. * @returns the current particle system
  19033. */
  19034. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19035. /**
  19036. * Remove a specific color gradient
  19037. * @param gradient defines the gradient to remove
  19038. * @returns the current particle system
  19039. */
  19040. removeColorGradient(gradient: number): IParticleSystem;
  19041. /**
  19042. * Adds a new size gradient
  19043. * @param gradient defines the gradient to use (between 0 and 1)
  19044. * @param factor defines the size factor to affect to the specified gradient
  19045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19046. * @returns the current particle system
  19047. */
  19048. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19049. /**
  19050. * Remove a specific size gradient
  19051. * @param gradient defines the gradient to remove
  19052. * @returns the current particle system
  19053. */
  19054. removeSizeGradient(gradient: number): IParticleSystem;
  19055. /**
  19056. * Gets the current list of color gradients.
  19057. * You must use addColorGradient and removeColorGradient to udpate this list
  19058. * @returns the list of color gradients
  19059. */
  19060. getColorGradients(): Nullable<Array<ColorGradient>>;
  19061. /**
  19062. * Gets the current list of size gradients.
  19063. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19064. * @returns the list of size gradients
  19065. */
  19066. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19067. /**
  19068. * Gets the current list of angular speed gradients.
  19069. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19070. * @returns the list of angular speed gradients
  19071. */
  19072. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19073. /**
  19074. * Adds a new angular speed gradient
  19075. * @param gradient defines the gradient to use (between 0 and 1)
  19076. * @param factor defines the angular speed to affect to the specified gradient
  19077. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19078. * @returns the current particle system
  19079. */
  19080. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19081. /**
  19082. * Remove a specific angular speed gradient
  19083. * @param gradient defines the gradient to remove
  19084. * @returns the current particle system
  19085. */
  19086. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19087. /**
  19088. * Gets the current list of velocity gradients.
  19089. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19090. * @returns the list of velocity gradients
  19091. */
  19092. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19093. /**
  19094. * Adds a new velocity gradient
  19095. * @param gradient defines the gradient to use (between 0 and 1)
  19096. * @param factor defines the velocity to affect to the specified gradient
  19097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19098. * @returns the current particle system
  19099. */
  19100. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19101. /**
  19102. * Remove a specific velocity gradient
  19103. * @param gradient defines the gradient to remove
  19104. * @returns the current particle system
  19105. */
  19106. removeVelocityGradient(gradient: number): IParticleSystem;
  19107. /**
  19108. * Gets the current list of limit velocity gradients.
  19109. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19110. * @returns the list of limit velocity gradients
  19111. */
  19112. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19113. /**
  19114. * Adds a new limit velocity gradient
  19115. * @param gradient defines the gradient to use (between 0 and 1)
  19116. * @param factor defines the limit velocity to affect to the specified gradient
  19117. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19118. * @returns the current particle system
  19119. */
  19120. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19121. /**
  19122. * Remove a specific limit velocity gradient
  19123. * @param gradient defines the gradient to remove
  19124. * @returns the current particle system
  19125. */
  19126. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19127. /**
  19128. * Adds a new drag gradient
  19129. * @param gradient defines the gradient to use (between 0 and 1)
  19130. * @param factor defines the drag to affect to the specified gradient
  19131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19132. * @returns the current particle system
  19133. */
  19134. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19135. /**
  19136. * Remove a specific drag gradient
  19137. * @param gradient defines the gradient to remove
  19138. * @returns the current particle system
  19139. */
  19140. removeDragGradient(gradient: number): IParticleSystem;
  19141. /**
  19142. * Gets the current list of drag gradients.
  19143. * You must use addDragGradient and removeDragGradient to udpate this list
  19144. * @returns the list of drag gradients
  19145. */
  19146. getDragGradients(): Nullable<Array<FactorGradient>>;
  19147. /**
  19148. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19149. * @param gradient defines the gradient to use (between 0 and 1)
  19150. * @param factor defines the emit rate to affect to the specified gradient
  19151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19152. * @returns the current particle system
  19153. */
  19154. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19155. /**
  19156. * Remove a specific emit rate gradient
  19157. * @param gradient defines the gradient to remove
  19158. * @returns the current particle system
  19159. */
  19160. removeEmitRateGradient(gradient: number): IParticleSystem;
  19161. /**
  19162. * Gets the current list of emit rate gradients.
  19163. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19164. * @returns the list of emit rate gradients
  19165. */
  19166. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19167. /**
  19168. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19169. * @param gradient defines the gradient to use (between 0 and 1)
  19170. * @param factor defines the start size to affect to the specified gradient
  19171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19172. * @returns the current particle system
  19173. */
  19174. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19175. /**
  19176. * Remove a specific start size gradient
  19177. * @param gradient defines the gradient to remove
  19178. * @returns the current particle system
  19179. */
  19180. removeStartSizeGradient(gradient: number): IParticleSystem;
  19181. /**
  19182. * Gets the current list of start size gradients.
  19183. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19184. * @returns the list of start size gradients
  19185. */
  19186. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19187. /**
  19188. * Adds a new life time gradient
  19189. * @param gradient defines the gradient to use (between 0 and 1)
  19190. * @param factor defines the life time factor to affect to the specified gradient
  19191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19192. * @returns the current particle system
  19193. */
  19194. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19195. /**
  19196. * Remove a specific life time gradient
  19197. * @param gradient defines the gradient to remove
  19198. * @returns the current particle system
  19199. */
  19200. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19201. /**
  19202. * Gets the current list of life time gradients.
  19203. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19204. * @returns the list of life time gradients
  19205. */
  19206. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19207. /**
  19208. * Gets the current list of color gradients.
  19209. * You must use addColorGradient and removeColorGradient to udpate this list
  19210. * @returns the list of color gradients
  19211. */
  19212. getColorGradients(): Nullable<Array<ColorGradient>>;
  19213. /**
  19214. * Adds a new ramp gradient used to remap particle colors
  19215. * @param gradient defines the gradient to use (between 0 and 1)
  19216. * @param color defines the color to affect to the specified gradient
  19217. * @returns the current particle system
  19218. */
  19219. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19220. /**
  19221. * Gets the current list of ramp gradients.
  19222. * You must use addRampGradient and removeRampGradient to udpate this list
  19223. * @returns the list of ramp gradients
  19224. */
  19225. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19226. /** Gets or sets a boolean indicating that ramp gradients must be used
  19227. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19228. */
  19229. useRampGradients: boolean;
  19230. /**
  19231. * Adds a new color remap gradient
  19232. * @param gradient defines the gradient to use (between 0 and 1)
  19233. * @param min defines the color remap minimal range
  19234. * @param max defines the color remap maximal range
  19235. * @returns the current particle system
  19236. */
  19237. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19238. /**
  19239. * Gets the current list of color remap gradients.
  19240. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19241. * @returns the list of color remap gradients
  19242. */
  19243. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19244. /**
  19245. * Adds a new alpha remap gradient
  19246. * @param gradient defines the gradient to use (between 0 and 1)
  19247. * @param min defines the alpha remap minimal range
  19248. * @param max defines the alpha remap maximal range
  19249. * @returns the current particle system
  19250. */
  19251. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19252. /**
  19253. * Gets the current list of alpha remap gradients.
  19254. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19255. * @returns the list of alpha remap gradients
  19256. */
  19257. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19258. /**
  19259. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19260. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19261. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19262. * @returns the emitter
  19263. */
  19264. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19265. /**
  19266. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19267. * @param radius The radius of the hemisphere to emit from
  19268. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19269. * @returns the emitter
  19270. */
  19271. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19272. /**
  19273. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19274. * @param radius The radius of the sphere to emit from
  19275. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19276. * @returns the emitter
  19277. */
  19278. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19279. /**
  19280. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19281. * @param radius The radius of the sphere to emit from
  19282. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19283. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19284. * @returns the emitter
  19285. */
  19286. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19287. /**
  19288. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19289. * @param radius The radius of the emission cylinder
  19290. * @param height The height of the emission cylinder
  19291. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19292. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19293. * @returns the emitter
  19294. */
  19295. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19296. /**
  19297. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19298. * @param radius The radius of the cylinder to emit from
  19299. * @param height The height of the emission cylinder
  19300. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19301. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19302. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19303. * @returns the emitter
  19304. */
  19305. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19306. /**
  19307. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19308. * @param radius The radius of the cone to emit from
  19309. * @param angle The base angle of the cone
  19310. * @returns the emitter
  19311. */
  19312. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19313. /**
  19314. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19315. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19316. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19317. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19318. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19319. * @returns the emitter
  19320. */
  19321. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19322. /**
  19323. * Get hosting scene
  19324. * @returns the scene
  19325. */
  19326. getScene(): Scene;
  19327. }
  19328. }
  19329. declare module "babylonjs/Meshes/instancedMesh" {
  19330. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19331. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19332. import { Camera } from "babylonjs/Cameras/camera";
  19333. import { Node } from "babylonjs/node";
  19334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19335. import { Mesh } from "babylonjs/Meshes/mesh";
  19336. import { Material } from "babylonjs/Materials/material";
  19337. import { Skeleton } from "babylonjs/Bones/skeleton";
  19338. import { Light } from "babylonjs/Lights/light";
  19339. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19340. /**
  19341. * Creates an instance based on a source mesh.
  19342. */
  19343. export class InstancedMesh extends AbstractMesh {
  19344. private _sourceMesh;
  19345. private _currentLOD;
  19346. /** @hidden */
  19347. _indexInSourceMeshInstanceArray: number;
  19348. constructor(name: string, source: Mesh);
  19349. /**
  19350. * Returns the string "InstancedMesh".
  19351. */
  19352. getClassName(): string;
  19353. /** Gets the list of lights affecting that mesh */
  19354. readonly lightSources: Light[];
  19355. _resyncLightSources(): void;
  19356. _resyncLighSource(light: Light): void;
  19357. _removeLightSource(light: Light, dispose: boolean): void;
  19358. /**
  19359. * If the source mesh receives shadows
  19360. */
  19361. readonly receiveShadows: boolean;
  19362. /**
  19363. * The material of the source mesh
  19364. */
  19365. readonly material: Nullable<Material>;
  19366. /**
  19367. * Visibility of the source mesh
  19368. */
  19369. readonly visibility: number;
  19370. /**
  19371. * Skeleton of the source mesh
  19372. */
  19373. readonly skeleton: Nullable<Skeleton>;
  19374. /**
  19375. * Rendering ground id of the source mesh
  19376. */
  19377. renderingGroupId: number;
  19378. /**
  19379. * Returns the total number of vertices (integer).
  19380. */
  19381. getTotalVertices(): number;
  19382. /**
  19383. * Returns a positive integer : the total number of indices in this mesh geometry.
  19384. * @returns the numner of indices or zero if the mesh has no geometry.
  19385. */
  19386. getTotalIndices(): number;
  19387. /**
  19388. * The source mesh of the instance
  19389. */
  19390. readonly sourceMesh: Mesh;
  19391. /**
  19392. * Is this node ready to be used/rendered
  19393. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19394. * @return {boolean} is it ready
  19395. */
  19396. isReady(completeCheck?: boolean): boolean;
  19397. /**
  19398. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19399. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19400. * @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.
  19401. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19402. */
  19403. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19404. /**
  19405. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19406. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19407. * The `data` are either a numeric array either a Float32Array.
  19408. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19409. * 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).
  19410. * Note that a new underlying VertexBuffer object is created each call.
  19411. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19412. *
  19413. * Possible `kind` values :
  19414. * - VertexBuffer.PositionKind
  19415. * - VertexBuffer.UVKind
  19416. * - VertexBuffer.UV2Kind
  19417. * - VertexBuffer.UV3Kind
  19418. * - VertexBuffer.UV4Kind
  19419. * - VertexBuffer.UV5Kind
  19420. * - VertexBuffer.UV6Kind
  19421. * - VertexBuffer.ColorKind
  19422. * - VertexBuffer.MatricesIndicesKind
  19423. * - VertexBuffer.MatricesIndicesExtraKind
  19424. * - VertexBuffer.MatricesWeightsKind
  19425. * - VertexBuffer.MatricesWeightsExtraKind
  19426. *
  19427. * Returns the Mesh.
  19428. */
  19429. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19430. /**
  19431. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19432. * If the mesh has no geometry, it is simply returned as it is.
  19433. * The `data` are either a numeric array either a Float32Array.
  19434. * No new underlying VertexBuffer object is created.
  19435. * 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.
  19436. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19437. *
  19438. * Possible `kind` values :
  19439. * - VertexBuffer.PositionKind
  19440. * - VertexBuffer.UVKind
  19441. * - VertexBuffer.UV2Kind
  19442. * - VertexBuffer.UV3Kind
  19443. * - VertexBuffer.UV4Kind
  19444. * - VertexBuffer.UV5Kind
  19445. * - VertexBuffer.UV6Kind
  19446. * - VertexBuffer.ColorKind
  19447. * - VertexBuffer.MatricesIndicesKind
  19448. * - VertexBuffer.MatricesIndicesExtraKind
  19449. * - VertexBuffer.MatricesWeightsKind
  19450. * - VertexBuffer.MatricesWeightsExtraKind
  19451. *
  19452. * Returns the Mesh.
  19453. */
  19454. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19455. /**
  19456. * Sets the mesh indices.
  19457. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19458. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19459. * This method creates a new index buffer each call.
  19460. * Returns the Mesh.
  19461. */
  19462. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19463. /**
  19464. * Boolean : True if the mesh owns the requested kind of data.
  19465. */
  19466. isVerticesDataPresent(kind: string): boolean;
  19467. /**
  19468. * Returns an array of indices (IndicesArray).
  19469. */
  19470. getIndices(): Nullable<IndicesArray>;
  19471. readonly _positions: Nullable<Vector3[]>;
  19472. /**
  19473. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19474. * This means the mesh underlying bounding box and sphere are recomputed.
  19475. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19476. * @returns the current mesh
  19477. */
  19478. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19479. /** @hidden */
  19480. _preActivate(): InstancedMesh;
  19481. /** @hidden */
  19482. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19483. /** @hidden */
  19484. _postActivate(): void;
  19485. getWorldMatrix(): Matrix;
  19486. readonly isAnInstance: boolean;
  19487. /**
  19488. * Returns the current associated LOD AbstractMesh.
  19489. */
  19490. getLOD(camera: Camera): AbstractMesh;
  19491. /** @hidden */
  19492. _syncSubMeshes(): InstancedMesh;
  19493. /** @hidden */
  19494. _generatePointsArray(): boolean;
  19495. /**
  19496. * Creates a new InstancedMesh from the current mesh.
  19497. * - name (string) : the cloned mesh name
  19498. * - newParent (optional Node) : the optional Node to parent the clone to.
  19499. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19500. *
  19501. * Returns the clone.
  19502. */
  19503. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19504. /**
  19505. * Disposes the InstancedMesh.
  19506. * Returns nothing.
  19507. */
  19508. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19509. }
  19510. module "babylonjs/Meshes/mesh" {
  19511. interface Mesh {
  19512. /**
  19513. * Register a custom buffer that will be instanced
  19514. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19515. * @param kind defines the buffer kind
  19516. * @param stride defines the stride in floats
  19517. */
  19518. registerInstancedBuffer(kind: string, stride: number): void;
  19519. /** @hidden */
  19520. _userInstancedBuffersStorage: {
  19521. data: {
  19522. [key: string]: Float32Array;
  19523. };
  19524. sizes: {
  19525. [key: string]: number;
  19526. };
  19527. vertexBuffers: {
  19528. [key: string]: Nullable<VertexBuffer>;
  19529. };
  19530. strides: {
  19531. [key: string]: number;
  19532. };
  19533. };
  19534. }
  19535. }
  19536. module "babylonjs/Meshes/abstractMesh" {
  19537. interface AbstractMesh {
  19538. /**
  19539. * Object used to store instanced buffers defined by user
  19540. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19541. */
  19542. instancedBuffers: {
  19543. [key: string]: any;
  19544. };
  19545. }
  19546. }
  19547. }
  19548. declare module "babylonjs/Materials/shaderMaterial" {
  19549. import { Scene } from "babylonjs/scene";
  19550. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19552. import { Mesh } from "babylonjs/Meshes/mesh";
  19553. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19554. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19555. import { Texture } from "babylonjs/Materials/Textures/texture";
  19556. import { Material } from "babylonjs/Materials/material";
  19557. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19558. /**
  19559. * Defines the options associated with the creation of a shader material.
  19560. */
  19561. export interface IShaderMaterialOptions {
  19562. /**
  19563. * Does the material work in alpha blend mode
  19564. */
  19565. needAlphaBlending: boolean;
  19566. /**
  19567. * Does the material work in alpha test mode
  19568. */
  19569. needAlphaTesting: boolean;
  19570. /**
  19571. * The list of attribute names used in the shader
  19572. */
  19573. attributes: string[];
  19574. /**
  19575. * The list of unifrom names used in the shader
  19576. */
  19577. uniforms: string[];
  19578. /**
  19579. * The list of UBO names used in the shader
  19580. */
  19581. uniformBuffers: string[];
  19582. /**
  19583. * The list of sampler names used in the shader
  19584. */
  19585. samplers: string[];
  19586. /**
  19587. * The list of defines used in the shader
  19588. */
  19589. defines: string[];
  19590. }
  19591. /**
  19592. * 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.
  19593. *
  19594. * This returned material effects how the mesh will look based on the code in the shaders.
  19595. *
  19596. * @see http://doc.babylonjs.com/how_to/shader_material
  19597. */
  19598. export class ShaderMaterial extends Material {
  19599. private _shaderPath;
  19600. private _options;
  19601. private _textures;
  19602. private _textureArrays;
  19603. private _floats;
  19604. private _ints;
  19605. private _floatsArrays;
  19606. private _colors3;
  19607. private _colors3Arrays;
  19608. private _colors4;
  19609. private _colors4Arrays;
  19610. private _vectors2;
  19611. private _vectors3;
  19612. private _vectors4;
  19613. private _matrices;
  19614. private _matrices3x3;
  19615. private _matrices2x2;
  19616. private _vectors2Arrays;
  19617. private _vectors3Arrays;
  19618. private _vectors4Arrays;
  19619. private _cachedWorldViewMatrix;
  19620. private _cachedWorldViewProjectionMatrix;
  19621. private _renderId;
  19622. /**
  19623. * Instantiate a new shader material.
  19624. * 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.
  19625. * This returned material effects how the mesh will look based on the code in the shaders.
  19626. * @see http://doc.babylonjs.com/how_to/shader_material
  19627. * @param name Define the name of the material in the scene
  19628. * @param scene Define the scene the material belongs to
  19629. * @param shaderPath Defines the route to the shader code in one of three ways:
  19630. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19631. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19632. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19633. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19634. * @param options Define the options used to create the shader
  19635. */
  19636. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19637. /**
  19638. * Gets the options used to compile the shader.
  19639. * They can be modified to trigger a new compilation
  19640. */
  19641. readonly options: IShaderMaterialOptions;
  19642. /**
  19643. * Gets the current class name of the material e.g. "ShaderMaterial"
  19644. * Mainly use in serialization.
  19645. * @returns the class name
  19646. */
  19647. getClassName(): string;
  19648. /**
  19649. * Specifies if the material will require alpha blending
  19650. * @returns a boolean specifying if alpha blending is needed
  19651. */
  19652. needAlphaBlending(): boolean;
  19653. /**
  19654. * Specifies if this material should be rendered in alpha test mode
  19655. * @returns a boolean specifying if an alpha test is needed.
  19656. */
  19657. needAlphaTesting(): boolean;
  19658. private _checkUniform;
  19659. /**
  19660. * Set a texture in the shader.
  19661. * @param name Define the name of the uniform samplers as defined in the shader
  19662. * @param texture Define the texture to bind to this sampler
  19663. * @return the material itself allowing "fluent" like uniform updates
  19664. */
  19665. setTexture(name: string, texture: Texture): ShaderMaterial;
  19666. /**
  19667. * Set a texture array in the shader.
  19668. * @param name Define the name of the uniform sampler array as defined in the shader
  19669. * @param textures Define the list of textures to bind to this sampler
  19670. * @return the material itself allowing "fluent" like uniform updates
  19671. */
  19672. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19673. /**
  19674. * Set a float in the shader.
  19675. * @param name Define the name of the uniform as defined in the shader
  19676. * @param value Define the value to give to the uniform
  19677. * @return the material itself allowing "fluent" like uniform updates
  19678. */
  19679. setFloat(name: string, value: number): ShaderMaterial;
  19680. /**
  19681. * Set a int in the shader.
  19682. * @param name Define the name of the uniform as defined in the shader
  19683. * @param value Define the value to give to the uniform
  19684. * @return the material itself allowing "fluent" like uniform updates
  19685. */
  19686. setInt(name: string, value: number): ShaderMaterial;
  19687. /**
  19688. * Set an array of floats in the shader.
  19689. * @param name Define the name of the uniform as defined in the shader
  19690. * @param value Define the value to give to the uniform
  19691. * @return the material itself allowing "fluent" like uniform updates
  19692. */
  19693. setFloats(name: string, value: number[]): ShaderMaterial;
  19694. /**
  19695. * Set a vec3 in the shader from a Color3.
  19696. * @param name Define the name of the uniform as defined in the shader
  19697. * @param value Define the value to give to the uniform
  19698. * @return the material itself allowing "fluent" like uniform updates
  19699. */
  19700. setColor3(name: string, value: Color3): ShaderMaterial;
  19701. /**
  19702. * Set a vec3 array in the shader from a Color3 array.
  19703. * @param name Define the name of the uniform as defined in the shader
  19704. * @param value Define the value to give to the uniform
  19705. * @return the material itself allowing "fluent" like uniform updates
  19706. */
  19707. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19708. /**
  19709. * Set a vec4 in the shader from a Color4.
  19710. * @param name Define the name of the uniform as defined in the shader
  19711. * @param value Define the value to give to the uniform
  19712. * @return the material itself allowing "fluent" like uniform updates
  19713. */
  19714. setColor4(name: string, value: Color4): ShaderMaterial;
  19715. /**
  19716. * Set a vec4 array in the shader from a Color4 array.
  19717. * @param name Define the name of the uniform as defined in the shader
  19718. * @param value Define the value to give to the uniform
  19719. * @return the material itself allowing "fluent" like uniform updates
  19720. */
  19721. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19722. /**
  19723. * Set a vec2 in the shader from a Vector2.
  19724. * @param name Define the name of the uniform as defined in the shader
  19725. * @param value Define the value to give to the uniform
  19726. * @return the material itself allowing "fluent" like uniform updates
  19727. */
  19728. setVector2(name: string, value: Vector2): ShaderMaterial;
  19729. /**
  19730. * Set a vec3 in the shader from a Vector3.
  19731. * @param name Define the name of the uniform as defined in the shader
  19732. * @param value Define the value to give to the uniform
  19733. * @return the material itself allowing "fluent" like uniform updates
  19734. */
  19735. setVector3(name: string, value: Vector3): ShaderMaterial;
  19736. /**
  19737. * Set a vec4 in the shader from a Vector4.
  19738. * @param name Define the name of the uniform as defined in the shader
  19739. * @param value Define the value to give to the uniform
  19740. * @return the material itself allowing "fluent" like uniform updates
  19741. */
  19742. setVector4(name: string, value: Vector4): ShaderMaterial;
  19743. /**
  19744. * Set a mat4 in the shader from a Matrix.
  19745. * @param name Define the name of the uniform as defined in the shader
  19746. * @param value Define the value to give to the uniform
  19747. * @return the material itself allowing "fluent" like uniform updates
  19748. */
  19749. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19750. /**
  19751. * Set a mat3 in the shader from a Float32Array.
  19752. * @param name Define the name of the uniform as defined in the shader
  19753. * @param value Define the value to give to the uniform
  19754. * @return the material itself allowing "fluent" like uniform updates
  19755. */
  19756. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19757. /**
  19758. * Set a mat2 in the shader from a Float32Array.
  19759. * @param name Define the name of the uniform as defined in the shader
  19760. * @param value Define the value to give to the uniform
  19761. * @return the material itself allowing "fluent" like uniform updates
  19762. */
  19763. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19764. /**
  19765. * Set a vec2 array in the shader from a number array.
  19766. * @param name Define the name of the uniform as defined in the shader
  19767. * @param value Define the value to give to the uniform
  19768. * @return the material itself allowing "fluent" like uniform updates
  19769. */
  19770. setArray2(name: string, value: number[]): ShaderMaterial;
  19771. /**
  19772. * Set a vec3 array in the shader from a number array.
  19773. * @param name Define the name of the uniform as defined in the shader
  19774. * @param value Define the value to give to the uniform
  19775. * @return the material itself allowing "fluent" like uniform updates
  19776. */
  19777. setArray3(name: string, value: number[]): ShaderMaterial;
  19778. /**
  19779. * Set a vec4 array in the shader from a number array.
  19780. * @param name Define the name of the uniform as defined in the shader
  19781. * @param value Define the value to give to the uniform
  19782. * @return the material itself allowing "fluent" like uniform updates
  19783. */
  19784. setArray4(name: string, value: number[]): ShaderMaterial;
  19785. private _checkCache;
  19786. /**
  19787. * Specifies that the submesh is ready to be used
  19788. * @param mesh defines the mesh to check
  19789. * @param subMesh defines which submesh to check
  19790. * @param useInstances specifies that instances should be used
  19791. * @returns a boolean indicating that the submesh is ready or not
  19792. */
  19793. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19794. /**
  19795. * Checks if the material is ready to render the requested mesh
  19796. * @param mesh Define the mesh to render
  19797. * @param useInstances Define whether or not the material is used with instances
  19798. * @returns true if ready, otherwise false
  19799. */
  19800. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19801. /**
  19802. * Binds the world matrix to the material
  19803. * @param world defines the world transformation matrix
  19804. */
  19805. bindOnlyWorldMatrix(world: Matrix): void;
  19806. /**
  19807. * Binds the material to the mesh
  19808. * @param world defines the world transformation matrix
  19809. * @param mesh defines the mesh to bind the material to
  19810. */
  19811. bind(world: Matrix, mesh?: Mesh): void;
  19812. /**
  19813. * Gets the active textures from the material
  19814. * @returns an array of textures
  19815. */
  19816. getActiveTextures(): BaseTexture[];
  19817. /**
  19818. * Specifies if the material uses a texture
  19819. * @param texture defines the texture to check against the material
  19820. * @returns a boolean specifying if the material uses the texture
  19821. */
  19822. hasTexture(texture: BaseTexture): boolean;
  19823. /**
  19824. * Makes a duplicate of the material, and gives it a new name
  19825. * @param name defines the new name for the duplicated material
  19826. * @returns the cloned material
  19827. */
  19828. clone(name: string): ShaderMaterial;
  19829. /**
  19830. * Disposes the material
  19831. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19832. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19833. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19834. */
  19835. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19836. /**
  19837. * Serializes this material in a JSON representation
  19838. * @returns the serialized material object
  19839. */
  19840. serialize(): any;
  19841. /**
  19842. * Creates a shader material from parsed shader material data
  19843. * @param source defines the JSON represnetation of the material
  19844. * @param scene defines the hosting scene
  19845. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19846. * @returns a new material
  19847. */
  19848. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19849. }
  19850. }
  19851. declare module "babylonjs/Shaders/color.fragment" {
  19852. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19853. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19854. /** @hidden */
  19855. export var colorPixelShader: {
  19856. name: string;
  19857. shader: string;
  19858. };
  19859. }
  19860. declare module "babylonjs/Shaders/color.vertex" {
  19861. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19862. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19863. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19864. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19865. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19866. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19867. /** @hidden */
  19868. export var colorVertexShader: {
  19869. name: string;
  19870. shader: string;
  19871. };
  19872. }
  19873. declare module "babylonjs/Meshes/linesMesh" {
  19874. import { Nullable } from "babylonjs/types";
  19875. import { Scene } from "babylonjs/scene";
  19876. import { Color3 } from "babylonjs/Maths/math.color";
  19877. import { Node } from "babylonjs/node";
  19878. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19879. import { Mesh } from "babylonjs/Meshes/mesh";
  19880. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19881. import { Effect } from "babylonjs/Materials/effect";
  19882. import { Material } from "babylonjs/Materials/material";
  19883. import "babylonjs/Shaders/color.fragment";
  19884. import "babylonjs/Shaders/color.vertex";
  19885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19886. /**
  19887. * Line mesh
  19888. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19889. */
  19890. export class LinesMesh extends Mesh {
  19891. /**
  19892. * If vertex color should be applied to the mesh
  19893. */
  19894. readonly useVertexColor?: boolean | undefined;
  19895. /**
  19896. * If vertex alpha should be applied to the mesh
  19897. */
  19898. readonly useVertexAlpha?: boolean | undefined;
  19899. /**
  19900. * Color of the line (Default: White)
  19901. */
  19902. color: Color3;
  19903. /**
  19904. * Alpha of the line (Default: 1)
  19905. */
  19906. alpha: number;
  19907. /**
  19908. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19909. * This margin is expressed in world space coordinates, so its value may vary.
  19910. * Default value is 0.1
  19911. */
  19912. intersectionThreshold: number;
  19913. private _colorShader;
  19914. private color4;
  19915. /**
  19916. * Creates a new LinesMesh
  19917. * @param name defines the name
  19918. * @param scene defines the hosting scene
  19919. * @param parent defines the parent mesh if any
  19920. * @param source defines the optional source LinesMesh used to clone data from
  19921. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19922. * When false, achieved by calling a clone(), also passing False.
  19923. * This will make creation of children, recursive.
  19924. * @param useVertexColor defines if this LinesMesh supports vertex color
  19925. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19926. */
  19927. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19928. /**
  19929. * If vertex color should be applied to the mesh
  19930. */
  19931. useVertexColor?: boolean | undefined,
  19932. /**
  19933. * If vertex alpha should be applied to the mesh
  19934. */
  19935. useVertexAlpha?: boolean | undefined);
  19936. private _addClipPlaneDefine;
  19937. private _removeClipPlaneDefine;
  19938. isReady(): boolean;
  19939. /**
  19940. * Returns the string "LineMesh"
  19941. */
  19942. getClassName(): string;
  19943. /**
  19944. * @hidden
  19945. */
  19946. /**
  19947. * @hidden
  19948. */
  19949. material: Material;
  19950. /**
  19951. * @hidden
  19952. */
  19953. readonly checkCollisions: boolean;
  19954. /** @hidden */
  19955. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19956. /** @hidden */
  19957. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19958. /**
  19959. * Disposes of the line mesh
  19960. * @param doNotRecurse If children should be disposed
  19961. */
  19962. dispose(doNotRecurse?: boolean): void;
  19963. /**
  19964. * Returns a new LineMesh object cloned from the current one.
  19965. */
  19966. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19967. /**
  19968. * Creates a new InstancedLinesMesh object from the mesh model.
  19969. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19970. * @param name defines the name of the new instance
  19971. * @returns a new InstancedLinesMesh
  19972. */
  19973. createInstance(name: string): InstancedLinesMesh;
  19974. }
  19975. /**
  19976. * Creates an instance based on a source LinesMesh
  19977. */
  19978. export class InstancedLinesMesh extends InstancedMesh {
  19979. /**
  19980. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19981. * This margin is expressed in world space coordinates, so its value may vary.
  19982. * Initilized with the intersectionThreshold value of the source LinesMesh
  19983. */
  19984. intersectionThreshold: number;
  19985. constructor(name: string, source: LinesMesh);
  19986. /**
  19987. * Returns the string "InstancedLinesMesh".
  19988. */
  19989. getClassName(): string;
  19990. }
  19991. }
  19992. declare module "babylonjs/Shaders/line.fragment" {
  19993. /** @hidden */
  19994. export var linePixelShader: {
  19995. name: string;
  19996. shader: string;
  19997. };
  19998. }
  19999. declare module "babylonjs/Shaders/line.vertex" {
  20000. /** @hidden */
  20001. export var lineVertexShader: {
  20002. name: string;
  20003. shader: string;
  20004. };
  20005. }
  20006. declare module "babylonjs/Rendering/edgesRenderer" {
  20007. import { Nullable } from "babylonjs/types";
  20008. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20010. import { Vector3 } from "babylonjs/Maths/math.vector";
  20011. import { IDisposable } from "babylonjs/scene";
  20012. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20013. import "babylonjs/Shaders/line.fragment";
  20014. import "babylonjs/Shaders/line.vertex";
  20015. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20016. module "babylonjs/Meshes/abstractMesh" {
  20017. interface AbstractMesh {
  20018. /**
  20019. * Gets the edgesRenderer associated with the mesh
  20020. */
  20021. edgesRenderer: Nullable<EdgesRenderer>;
  20022. }
  20023. }
  20024. module "babylonjs/Meshes/linesMesh" {
  20025. interface LinesMesh {
  20026. /**
  20027. * Enables the edge rendering mode on the mesh.
  20028. * This mode makes the mesh edges visible
  20029. * @param epsilon defines the maximal distance between two angles to detect a face
  20030. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20031. * @returns the currentAbstractMesh
  20032. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20033. */
  20034. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20035. }
  20036. }
  20037. module "babylonjs/Meshes/linesMesh" {
  20038. interface InstancedLinesMesh {
  20039. /**
  20040. * Enables the edge rendering mode on the mesh.
  20041. * This mode makes the mesh edges visible
  20042. * @param epsilon defines the maximal distance between two angles to detect a face
  20043. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20044. * @returns the current InstancedLinesMesh
  20045. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20046. */
  20047. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20048. }
  20049. }
  20050. /**
  20051. * Defines the minimum contract an Edges renderer should follow.
  20052. */
  20053. export interface IEdgesRenderer extends IDisposable {
  20054. /**
  20055. * Gets or sets a boolean indicating if the edgesRenderer is active
  20056. */
  20057. isEnabled: boolean;
  20058. /**
  20059. * Renders the edges of the attached mesh,
  20060. */
  20061. render(): void;
  20062. /**
  20063. * Checks wether or not the edges renderer is ready to render.
  20064. * @return true if ready, otherwise false.
  20065. */
  20066. isReady(): boolean;
  20067. }
  20068. /**
  20069. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20070. */
  20071. export class EdgesRenderer implements IEdgesRenderer {
  20072. /**
  20073. * Define the size of the edges with an orthographic camera
  20074. */
  20075. edgesWidthScalerForOrthographic: number;
  20076. /**
  20077. * Define the size of the edges with a perspective camera
  20078. */
  20079. edgesWidthScalerForPerspective: number;
  20080. protected _source: AbstractMesh;
  20081. protected _linesPositions: number[];
  20082. protected _linesNormals: number[];
  20083. protected _linesIndices: number[];
  20084. protected _epsilon: number;
  20085. protected _indicesCount: number;
  20086. protected _lineShader: ShaderMaterial;
  20087. protected _ib: DataBuffer;
  20088. protected _buffers: {
  20089. [key: string]: Nullable<VertexBuffer>;
  20090. };
  20091. protected _checkVerticesInsteadOfIndices: boolean;
  20092. private _meshRebuildObserver;
  20093. private _meshDisposeObserver;
  20094. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20095. isEnabled: boolean;
  20096. /**
  20097. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20098. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20099. * @param source Mesh used to create edges
  20100. * @param epsilon sum of angles in adjacency to check for edge
  20101. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20102. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20103. */
  20104. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20105. protected _prepareRessources(): void;
  20106. /** @hidden */
  20107. _rebuild(): void;
  20108. /**
  20109. * Releases the required resources for the edges renderer
  20110. */
  20111. dispose(): void;
  20112. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20113. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20114. /**
  20115. * Checks if the pair of p0 and p1 is en edge
  20116. * @param faceIndex
  20117. * @param edge
  20118. * @param faceNormals
  20119. * @param p0
  20120. * @param p1
  20121. * @private
  20122. */
  20123. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20124. /**
  20125. * push line into the position, normal and index buffer
  20126. * @protected
  20127. */
  20128. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20129. /**
  20130. * Generates lines edges from adjacencjes
  20131. * @private
  20132. */
  20133. _generateEdgesLines(): void;
  20134. /**
  20135. * Checks wether or not the edges renderer is ready to render.
  20136. * @return true if ready, otherwise false.
  20137. */
  20138. isReady(): boolean;
  20139. /**
  20140. * Renders the edges of the attached mesh,
  20141. */
  20142. render(): void;
  20143. }
  20144. /**
  20145. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20146. */
  20147. export class LineEdgesRenderer extends EdgesRenderer {
  20148. /**
  20149. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20150. * @param source LineMesh used to generate edges
  20151. * @param epsilon not important (specified angle for edge detection)
  20152. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20153. */
  20154. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20155. /**
  20156. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20157. */
  20158. _generateEdgesLines(): void;
  20159. }
  20160. }
  20161. declare module "babylonjs/Rendering/renderingGroup" {
  20162. import { SmartArray } from "babylonjs/Misc/smartArray";
  20163. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20165. import { Nullable } from "babylonjs/types";
  20166. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20167. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20168. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20169. import { Material } from "babylonjs/Materials/material";
  20170. import { Scene } from "babylonjs/scene";
  20171. /**
  20172. * This represents the object necessary to create a rendering group.
  20173. * This is exclusively used and created by the rendering manager.
  20174. * To modify the behavior, you use the available helpers in your scene or meshes.
  20175. * @hidden
  20176. */
  20177. export class RenderingGroup {
  20178. index: number;
  20179. private static _zeroVector;
  20180. private _scene;
  20181. private _opaqueSubMeshes;
  20182. private _transparentSubMeshes;
  20183. private _alphaTestSubMeshes;
  20184. private _depthOnlySubMeshes;
  20185. private _particleSystems;
  20186. private _spriteManagers;
  20187. private _opaqueSortCompareFn;
  20188. private _alphaTestSortCompareFn;
  20189. private _transparentSortCompareFn;
  20190. private _renderOpaque;
  20191. private _renderAlphaTest;
  20192. private _renderTransparent;
  20193. /** @hidden */
  20194. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20195. onBeforeTransparentRendering: () => void;
  20196. /**
  20197. * Set the opaque sort comparison function.
  20198. * If null the sub meshes will be render in the order they were created
  20199. */
  20200. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20201. /**
  20202. * Set the alpha test sort comparison function.
  20203. * If null the sub meshes will be render in the order they were created
  20204. */
  20205. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20206. /**
  20207. * Set the transparent sort comparison function.
  20208. * If null the sub meshes will be render in the order they were created
  20209. */
  20210. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20211. /**
  20212. * Creates a new rendering group.
  20213. * @param index The rendering group index
  20214. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20215. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20216. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20217. */
  20218. 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>);
  20219. /**
  20220. * Render all the sub meshes contained in the group.
  20221. * @param customRenderFunction Used to override the default render behaviour of the group.
  20222. * @returns true if rendered some submeshes.
  20223. */
  20224. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20225. /**
  20226. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20227. * @param subMeshes The submeshes to render
  20228. */
  20229. private renderOpaqueSorted;
  20230. /**
  20231. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20232. * @param subMeshes The submeshes to render
  20233. */
  20234. private renderAlphaTestSorted;
  20235. /**
  20236. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20237. * @param subMeshes The submeshes to render
  20238. */
  20239. private renderTransparentSorted;
  20240. /**
  20241. * Renders the submeshes in a specified order.
  20242. * @param subMeshes The submeshes to sort before render
  20243. * @param sortCompareFn The comparison function use to sort
  20244. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20245. * @param transparent Specifies to activate blending if true
  20246. */
  20247. private static renderSorted;
  20248. /**
  20249. * Renders the submeshes in the order they were dispatched (no sort applied).
  20250. * @param subMeshes The submeshes to render
  20251. */
  20252. private static renderUnsorted;
  20253. /**
  20254. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20255. * are rendered back to front if in the same alpha index.
  20256. *
  20257. * @param a The first submesh
  20258. * @param b The second submesh
  20259. * @returns The result of the comparison
  20260. */
  20261. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20262. /**
  20263. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20264. * are rendered back to front.
  20265. *
  20266. * @param a The first submesh
  20267. * @param b The second submesh
  20268. * @returns The result of the comparison
  20269. */
  20270. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20271. /**
  20272. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20273. * are rendered front to back (prevent overdraw).
  20274. *
  20275. * @param a The first submesh
  20276. * @param b The second submesh
  20277. * @returns The result of the comparison
  20278. */
  20279. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20280. /**
  20281. * Resets the different lists of submeshes to prepare a new frame.
  20282. */
  20283. prepare(): void;
  20284. dispose(): void;
  20285. /**
  20286. * Inserts the submesh in its correct queue depending on its material.
  20287. * @param subMesh The submesh to dispatch
  20288. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20289. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20290. */
  20291. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20292. dispatchSprites(spriteManager: ISpriteManager): void;
  20293. dispatchParticles(particleSystem: IParticleSystem): void;
  20294. private _renderParticles;
  20295. private _renderSprites;
  20296. }
  20297. }
  20298. declare module "babylonjs/Rendering/renderingManager" {
  20299. import { Nullable } from "babylonjs/types";
  20300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20301. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20302. import { SmartArray } from "babylonjs/Misc/smartArray";
  20303. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20304. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20305. import { Material } from "babylonjs/Materials/material";
  20306. import { Scene } from "babylonjs/scene";
  20307. import { Camera } from "babylonjs/Cameras/camera";
  20308. /**
  20309. * Interface describing the different options available in the rendering manager
  20310. * regarding Auto Clear between groups.
  20311. */
  20312. export interface IRenderingManagerAutoClearSetup {
  20313. /**
  20314. * Defines whether or not autoclear is enable.
  20315. */
  20316. autoClear: boolean;
  20317. /**
  20318. * Defines whether or not to autoclear the depth buffer.
  20319. */
  20320. depth: boolean;
  20321. /**
  20322. * Defines whether or not to autoclear the stencil buffer.
  20323. */
  20324. stencil: boolean;
  20325. }
  20326. /**
  20327. * This class is used by the onRenderingGroupObservable
  20328. */
  20329. export class RenderingGroupInfo {
  20330. /**
  20331. * The Scene that being rendered
  20332. */
  20333. scene: Scene;
  20334. /**
  20335. * The camera currently used for the rendering pass
  20336. */
  20337. camera: Nullable<Camera>;
  20338. /**
  20339. * The ID of the renderingGroup being processed
  20340. */
  20341. renderingGroupId: number;
  20342. }
  20343. /**
  20344. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20345. * It is enable to manage the different groups as well as the different necessary sort functions.
  20346. * This should not be used directly aside of the few static configurations
  20347. */
  20348. export class RenderingManager {
  20349. /**
  20350. * The max id used for rendering groups (not included)
  20351. */
  20352. static MAX_RENDERINGGROUPS: number;
  20353. /**
  20354. * The min id used for rendering groups (included)
  20355. */
  20356. static MIN_RENDERINGGROUPS: number;
  20357. /**
  20358. * Used to globally prevent autoclearing scenes.
  20359. */
  20360. static AUTOCLEAR: boolean;
  20361. /**
  20362. * @hidden
  20363. */
  20364. _useSceneAutoClearSetup: boolean;
  20365. private _scene;
  20366. private _renderingGroups;
  20367. private _depthStencilBufferAlreadyCleaned;
  20368. private _autoClearDepthStencil;
  20369. private _customOpaqueSortCompareFn;
  20370. private _customAlphaTestSortCompareFn;
  20371. private _customTransparentSortCompareFn;
  20372. private _renderingGroupInfo;
  20373. /**
  20374. * Instantiates a new rendering group for a particular scene
  20375. * @param scene Defines the scene the groups belongs to
  20376. */
  20377. constructor(scene: Scene);
  20378. private _clearDepthStencilBuffer;
  20379. /**
  20380. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20381. * @hidden
  20382. */
  20383. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20384. /**
  20385. * Resets the different information of the group to prepare a new frame
  20386. * @hidden
  20387. */
  20388. reset(): void;
  20389. /**
  20390. * Dispose and release the group and its associated resources.
  20391. * @hidden
  20392. */
  20393. dispose(): void;
  20394. /**
  20395. * Clear the info related to rendering groups preventing retention points during dispose.
  20396. */
  20397. freeRenderingGroups(): void;
  20398. private _prepareRenderingGroup;
  20399. /**
  20400. * Add a sprite manager to the rendering manager in order to render it this frame.
  20401. * @param spriteManager Define the sprite manager to render
  20402. */
  20403. dispatchSprites(spriteManager: ISpriteManager): void;
  20404. /**
  20405. * Add a particle system to the rendering manager in order to render it this frame.
  20406. * @param particleSystem Define the particle system to render
  20407. */
  20408. dispatchParticles(particleSystem: IParticleSystem): void;
  20409. /**
  20410. * Add a submesh to the manager in order to render it this frame
  20411. * @param subMesh The submesh to dispatch
  20412. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20413. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20414. */
  20415. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20416. /**
  20417. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20418. * This allowed control for front to back rendering or reversly depending of the special needs.
  20419. *
  20420. * @param renderingGroupId The rendering group id corresponding to its index
  20421. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20422. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20423. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20424. */
  20425. 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;
  20426. /**
  20427. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20428. *
  20429. * @param renderingGroupId The rendering group id corresponding to its index
  20430. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20431. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20432. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20433. */
  20434. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20435. /**
  20436. * Gets the current auto clear configuration for one rendering group of the rendering
  20437. * manager.
  20438. * @param index the rendering group index to get the information for
  20439. * @returns The auto clear setup for the requested rendering group
  20440. */
  20441. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20442. }
  20443. }
  20444. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20445. import { Observable } from "babylonjs/Misc/observable";
  20446. import { SmartArray } from "babylonjs/Misc/smartArray";
  20447. import { Nullable } from "babylonjs/types";
  20448. import { Camera } from "babylonjs/Cameras/camera";
  20449. import { Scene } from "babylonjs/scene";
  20450. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20451. import { Color4 } from "babylonjs/Maths/math.color";
  20452. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20454. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20456. import { Texture } from "babylonjs/Materials/Textures/texture";
  20457. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20458. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20459. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20460. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20461. import { Engine } from "babylonjs/Engines/engine";
  20462. /**
  20463. * This Helps creating a texture that will be created from a camera in your scene.
  20464. * It is basically a dynamic texture that could be used to create special effects for instance.
  20465. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20466. */
  20467. export class RenderTargetTexture extends Texture {
  20468. isCube: boolean;
  20469. /**
  20470. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20471. */
  20472. static readonly REFRESHRATE_RENDER_ONCE: number;
  20473. /**
  20474. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20475. */
  20476. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20477. /**
  20478. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20479. * the central point of your effect and can save a lot of performances.
  20480. */
  20481. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20482. /**
  20483. * Use this predicate to dynamically define the list of mesh you want to render.
  20484. * If set, the renderList property will be overwritten.
  20485. */
  20486. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20487. private _renderList;
  20488. /**
  20489. * Use this list to define the list of mesh you want to render.
  20490. */
  20491. renderList: Nullable<Array<AbstractMesh>>;
  20492. private _hookArray;
  20493. /**
  20494. * Define if particles should be rendered in your texture.
  20495. */
  20496. renderParticles: boolean;
  20497. /**
  20498. * Define if sprites should be rendered in your texture.
  20499. */
  20500. renderSprites: boolean;
  20501. /**
  20502. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20503. */
  20504. coordinatesMode: number;
  20505. /**
  20506. * Define the camera used to render the texture.
  20507. */
  20508. activeCamera: Nullable<Camera>;
  20509. /**
  20510. * Override the render function of the texture with your own one.
  20511. */
  20512. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20513. /**
  20514. * Define if camera post processes should be use while rendering the texture.
  20515. */
  20516. useCameraPostProcesses: boolean;
  20517. /**
  20518. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20519. */
  20520. ignoreCameraViewport: boolean;
  20521. private _postProcessManager;
  20522. private _postProcesses;
  20523. private _resizeObserver;
  20524. /**
  20525. * An event triggered when the texture is unbind.
  20526. */
  20527. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20528. /**
  20529. * An event triggered when the texture is unbind.
  20530. */
  20531. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20532. private _onAfterUnbindObserver;
  20533. /**
  20534. * Set a after unbind callback in the texture.
  20535. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20536. */
  20537. onAfterUnbind: () => void;
  20538. /**
  20539. * An event triggered before rendering the texture
  20540. */
  20541. onBeforeRenderObservable: Observable<number>;
  20542. private _onBeforeRenderObserver;
  20543. /**
  20544. * Set a before render callback in the texture.
  20545. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20546. */
  20547. onBeforeRender: (faceIndex: number) => void;
  20548. /**
  20549. * An event triggered after rendering the texture
  20550. */
  20551. onAfterRenderObservable: Observable<number>;
  20552. private _onAfterRenderObserver;
  20553. /**
  20554. * Set a after render callback in the texture.
  20555. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20556. */
  20557. onAfterRender: (faceIndex: number) => void;
  20558. /**
  20559. * An event triggered after the texture clear
  20560. */
  20561. onClearObservable: Observable<Engine>;
  20562. private _onClearObserver;
  20563. /**
  20564. * Set a clear callback in the texture.
  20565. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20566. */
  20567. onClear: (Engine: Engine) => void;
  20568. /**
  20569. * An event triggered when the texture is resized.
  20570. */
  20571. onResizeObservable: Observable<RenderTargetTexture>;
  20572. /**
  20573. * Define the clear color of the Render Target if it should be different from the scene.
  20574. */
  20575. clearColor: Color4;
  20576. protected _size: number | {
  20577. width: number;
  20578. height: number;
  20579. };
  20580. protected _initialSizeParameter: number | {
  20581. width: number;
  20582. height: number;
  20583. } | {
  20584. ratio: number;
  20585. };
  20586. protected _sizeRatio: Nullable<number>;
  20587. /** @hidden */
  20588. _generateMipMaps: boolean;
  20589. protected _renderingManager: RenderingManager;
  20590. /** @hidden */
  20591. _waitingRenderList: string[];
  20592. protected _doNotChangeAspectRatio: boolean;
  20593. protected _currentRefreshId: number;
  20594. protected _refreshRate: number;
  20595. protected _textureMatrix: Matrix;
  20596. protected _samples: number;
  20597. protected _renderTargetOptions: RenderTargetCreationOptions;
  20598. /**
  20599. * Gets render target creation options that were used.
  20600. */
  20601. readonly renderTargetOptions: RenderTargetCreationOptions;
  20602. protected _engine: Engine;
  20603. protected _onRatioRescale(): void;
  20604. /**
  20605. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20606. * It must define where the camera used to render the texture is set
  20607. */
  20608. boundingBoxPosition: Vector3;
  20609. private _boundingBoxSize;
  20610. /**
  20611. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20612. * When defined, the cubemap will switch to local mode
  20613. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20614. * @example https://www.babylonjs-playground.com/#RNASML
  20615. */
  20616. boundingBoxSize: Vector3;
  20617. /**
  20618. * In case the RTT has been created with a depth texture, get the associated
  20619. * depth texture.
  20620. * Otherwise, return null.
  20621. */
  20622. depthStencilTexture: Nullable<InternalTexture>;
  20623. /**
  20624. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20625. * or used a shadow, depth texture...
  20626. * @param name The friendly name of the texture
  20627. * @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)
  20628. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20629. * @param generateMipMaps True if mip maps need to be generated after render.
  20630. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20631. * @param type The type of the buffer in the RTT (int, half float, float...)
  20632. * @param isCube True if a cube texture needs to be created
  20633. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20634. * @param generateDepthBuffer True to generate a depth buffer
  20635. * @param generateStencilBuffer True to generate a stencil buffer
  20636. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20637. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20638. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20639. */
  20640. constructor(name: string, size: number | {
  20641. width: number;
  20642. height: number;
  20643. } | {
  20644. ratio: number;
  20645. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20646. /**
  20647. * Creates a depth stencil texture.
  20648. * This is only available in WebGL 2 or with the depth texture extension available.
  20649. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20650. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20651. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20652. */
  20653. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20654. private _processSizeParameter;
  20655. /**
  20656. * Define the number of samples to use in case of MSAA.
  20657. * It defaults to one meaning no MSAA has been enabled.
  20658. */
  20659. samples: number;
  20660. /**
  20661. * Resets the refresh counter of the texture and start bak from scratch.
  20662. * Could be useful to regenerate the texture if it is setup to render only once.
  20663. */
  20664. resetRefreshCounter(): void;
  20665. /**
  20666. * Define the refresh rate of the texture or the rendering frequency.
  20667. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20668. */
  20669. refreshRate: number;
  20670. /**
  20671. * Adds a post process to the render target rendering passes.
  20672. * @param postProcess define the post process to add
  20673. */
  20674. addPostProcess(postProcess: PostProcess): void;
  20675. /**
  20676. * Clear all the post processes attached to the render target
  20677. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20678. */
  20679. clearPostProcesses(dispose?: boolean): void;
  20680. /**
  20681. * Remove one of the post process from the list of attached post processes to the texture
  20682. * @param postProcess define the post process to remove from the list
  20683. */
  20684. removePostProcess(postProcess: PostProcess): void;
  20685. /** @hidden */
  20686. _shouldRender(): boolean;
  20687. /**
  20688. * Gets the actual render size of the texture.
  20689. * @returns the width of the render size
  20690. */
  20691. getRenderSize(): number;
  20692. /**
  20693. * Gets the actual render width of the texture.
  20694. * @returns the width of the render size
  20695. */
  20696. getRenderWidth(): number;
  20697. /**
  20698. * Gets the actual render height of the texture.
  20699. * @returns the height of the render size
  20700. */
  20701. getRenderHeight(): number;
  20702. /**
  20703. * Get if the texture can be rescaled or not.
  20704. */
  20705. readonly canRescale: boolean;
  20706. /**
  20707. * Resize the texture using a ratio.
  20708. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20709. */
  20710. scale(ratio: number): void;
  20711. /**
  20712. * Get the texture reflection matrix used to rotate/transform the reflection.
  20713. * @returns the reflection matrix
  20714. */
  20715. getReflectionTextureMatrix(): Matrix;
  20716. /**
  20717. * Resize the texture to a new desired size.
  20718. * Be carrefull as it will recreate all the data in the new texture.
  20719. * @param size Define the new size. It can be:
  20720. * - a number for squared texture,
  20721. * - an object containing { width: number, height: number }
  20722. * - or an object containing a ratio { ratio: number }
  20723. */
  20724. resize(size: number | {
  20725. width: number;
  20726. height: number;
  20727. } | {
  20728. ratio: number;
  20729. }): void;
  20730. /**
  20731. * Renders all the objects from the render list into the texture.
  20732. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20733. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20734. */
  20735. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20736. private _bestReflectionRenderTargetDimension;
  20737. /**
  20738. * @hidden
  20739. * @param faceIndex face index to bind to if this is a cubetexture
  20740. */
  20741. _bindFrameBuffer(faceIndex?: number): void;
  20742. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20743. private renderToTarget;
  20744. /**
  20745. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20746. * This allowed control for front to back rendering or reversly depending of the special needs.
  20747. *
  20748. * @param renderingGroupId The rendering group id corresponding to its index
  20749. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20750. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20751. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20752. */
  20753. 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;
  20754. /**
  20755. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20756. *
  20757. * @param renderingGroupId The rendering group id corresponding to its index
  20758. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20759. */
  20760. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20761. /**
  20762. * Clones the texture.
  20763. * @returns the cloned texture
  20764. */
  20765. clone(): RenderTargetTexture;
  20766. /**
  20767. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20768. * @returns The JSON representation of the texture
  20769. */
  20770. serialize(): any;
  20771. /**
  20772. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20773. */
  20774. disposeFramebufferObjects(): void;
  20775. /**
  20776. * Dispose the texture and release its associated resources.
  20777. */
  20778. dispose(): void;
  20779. /** @hidden */
  20780. _rebuild(): void;
  20781. /**
  20782. * Clear the info related to rendering groups preventing retention point in material dispose.
  20783. */
  20784. freeRenderingGroups(): void;
  20785. /**
  20786. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20787. * @returns the view count
  20788. */
  20789. getViewCount(): number;
  20790. }
  20791. }
  20792. declare module "babylonjs/Materials/material" {
  20793. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20794. import { SmartArray } from "babylonjs/Misc/smartArray";
  20795. import { Observable } from "babylonjs/Misc/observable";
  20796. import { Nullable } from "babylonjs/types";
  20797. import { Scene } from "babylonjs/scene";
  20798. import { Matrix } from "babylonjs/Maths/math.vector";
  20799. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20801. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20802. import { Effect } from "babylonjs/Materials/effect";
  20803. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20804. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20805. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20806. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20807. import { Mesh } from "babylonjs/Meshes/mesh";
  20808. import { Animation } from "babylonjs/Animations/animation";
  20809. /**
  20810. * Options for compiling materials.
  20811. */
  20812. export interface IMaterialCompilationOptions {
  20813. /**
  20814. * Defines whether clip planes are enabled.
  20815. */
  20816. clipPlane: boolean;
  20817. /**
  20818. * Defines whether instances are enabled.
  20819. */
  20820. useInstances: boolean;
  20821. }
  20822. /**
  20823. * Base class for the main features of a material in Babylon.js
  20824. */
  20825. export class Material implements IAnimatable {
  20826. /**
  20827. * Returns the triangle fill mode
  20828. */
  20829. static readonly TriangleFillMode: number;
  20830. /**
  20831. * Returns the wireframe mode
  20832. */
  20833. static readonly WireFrameFillMode: number;
  20834. /**
  20835. * Returns the point fill mode
  20836. */
  20837. static readonly PointFillMode: number;
  20838. /**
  20839. * Returns the point list draw mode
  20840. */
  20841. static readonly PointListDrawMode: number;
  20842. /**
  20843. * Returns the line list draw mode
  20844. */
  20845. static readonly LineListDrawMode: number;
  20846. /**
  20847. * Returns the line loop draw mode
  20848. */
  20849. static readonly LineLoopDrawMode: number;
  20850. /**
  20851. * Returns the line strip draw mode
  20852. */
  20853. static readonly LineStripDrawMode: number;
  20854. /**
  20855. * Returns the triangle strip draw mode
  20856. */
  20857. static readonly TriangleStripDrawMode: number;
  20858. /**
  20859. * Returns the triangle fan draw mode
  20860. */
  20861. static readonly TriangleFanDrawMode: number;
  20862. /**
  20863. * Stores the clock-wise side orientation
  20864. */
  20865. static readonly ClockWiseSideOrientation: number;
  20866. /**
  20867. * Stores the counter clock-wise side orientation
  20868. */
  20869. static readonly CounterClockWiseSideOrientation: number;
  20870. /**
  20871. * The dirty texture flag value
  20872. */
  20873. static readonly TextureDirtyFlag: number;
  20874. /**
  20875. * The dirty light flag value
  20876. */
  20877. static readonly LightDirtyFlag: number;
  20878. /**
  20879. * The dirty fresnel flag value
  20880. */
  20881. static readonly FresnelDirtyFlag: number;
  20882. /**
  20883. * The dirty attribute flag value
  20884. */
  20885. static readonly AttributesDirtyFlag: number;
  20886. /**
  20887. * The dirty misc flag value
  20888. */
  20889. static readonly MiscDirtyFlag: number;
  20890. /**
  20891. * The all dirty flag value
  20892. */
  20893. static readonly AllDirtyFlag: number;
  20894. /**
  20895. * The ID of the material
  20896. */
  20897. id: string;
  20898. /**
  20899. * Gets or sets the unique id of the material
  20900. */
  20901. uniqueId: number;
  20902. /**
  20903. * The name of the material
  20904. */
  20905. name: string;
  20906. /**
  20907. * Gets or sets user defined metadata
  20908. */
  20909. metadata: any;
  20910. /**
  20911. * For internal use only. Please do not use.
  20912. */
  20913. reservedDataStore: any;
  20914. /**
  20915. * Specifies if the ready state should be checked on each call
  20916. */
  20917. checkReadyOnEveryCall: boolean;
  20918. /**
  20919. * Specifies if the ready state should be checked once
  20920. */
  20921. checkReadyOnlyOnce: boolean;
  20922. /**
  20923. * The state of the material
  20924. */
  20925. state: string;
  20926. /**
  20927. * The alpha value of the material
  20928. */
  20929. protected _alpha: number;
  20930. /**
  20931. * List of inspectable custom properties (used by the Inspector)
  20932. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20933. */
  20934. inspectableCustomProperties: IInspectable[];
  20935. /**
  20936. * Sets the alpha value of the material
  20937. */
  20938. /**
  20939. * Gets the alpha value of the material
  20940. */
  20941. alpha: number;
  20942. /**
  20943. * Specifies if back face culling is enabled
  20944. */
  20945. protected _backFaceCulling: boolean;
  20946. /**
  20947. * Sets the back-face culling state
  20948. */
  20949. /**
  20950. * Gets the back-face culling state
  20951. */
  20952. backFaceCulling: boolean;
  20953. /**
  20954. * Stores the value for side orientation
  20955. */
  20956. sideOrientation: number;
  20957. /**
  20958. * Callback triggered when the material is compiled
  20959. */
  20960. onCompiled: Nullable<(effect: Effect) => void>;
  20961. /**
  20962. * Callback triggered when an error occurs
  20963. */
  20964. onError: Nullable<(effect: Effect, errors: string) => void>;
  20965. /**
  20966. * Callback triggered to get the render target textures
  20967. */
  20968. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20969. /**
  20970. * Gets a boolean indicating that current material needs to register RTT
  20971. */
  20972. readonly hasRenderTargetTextures: boolean;
  20973. /**
  20974. * Specifies if the material should be serialized
  20975. */
  20976. doNotSerialize: boolean;
  20977. /**
  20978. * @hidden
  20979. */
  20980. _storeEffectOnSubMeshes: boolean;
  20981. /**
  20982. * Stores the animations for the material
  20983. */
  20984. animations: Nullable<Array<Animation>>;
  20985. /**
  20986. * An event triggered when the material is disposed
  20987. */
  20988. onDisposeObservable: Observable<Material>;
  20989. /**
  20990. * An observer which watches for dispose events
  20991. */
  20992. private _onDisposeObserver;
  20993. private _onUnBindObservable;
  20994. /**
  20995. * Called during a dispose event
  20996. */
  20997. onDispose: () => void;
  20998. private _onBindObservable;
  20999. /**
  21000. * An event triggered when the material is bound
  21001. */
  21002. readonly onBindObservable: Observable<AbstractMesh>;
  21003. /**
  21004. * An observer which watches for bind events
  21005. */
  21006. private _onBindObserver;
  21007. /**
  21008. * Called during a bind event
  21009. */
  21010. onBind: (Mesh: AbstractMesh) => void;
  21011. /**
  21012. * An event triggered when the material is unbound
  21013. */
  21014. readonly onUnBindObservable: Observable<Material>;
  21015. /**
  21016. * Stores the value of the alpha mode
  21017. */
  21018. private _alphaMode;
  21019. /**
  21020. * Sets the value of the alpha mode.
  21021. *
  21022. * | Value | Type | Description |
  21023. * | --- | --- | --- |
  21024. * | 0 | ALPHA_DISABLE | |
  21025. * | 1 | ALPHA_ADD | |
  21026. * | 2 | ALPHA_COMBINE | |
  21027. * | 3 | ALPHA_SUBTRACT | |
  21028. * | 4 | ALPHA_MULTIPLY | |
  21029. * | 5 | ALPHA_MAXIMIZED | |
  21030. * | 6 | ALPHA_ONEONE | |
  21031. * | 7 | ALPHA_PREMULTIPLIED | |
  21032. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21033. * | 9 | ALPHA_INTERPOLATE | |
  21034. * | 10 | ALPHA_SCREENMODE | |
  21035. *
  21036. */
  21037. /**
  21038. * Gets the value of the alpha mode
  21039. */
  21040. alphaMode: number;
  21041. /**
  21042. * Stores the state of the need depth pre-pass value
  21043. */
  21044. private _needDepthPrePass;
  21045. /**
  21046. * Sets the need depth pre-pass value
  21047. */
  21048. /**
  21049. * Gets the depth pre-pass value
  21050. */
  21051. needDepthPrePass: boolean;
  21052. /**
  21053. * Specifies if depth writing should be disabled
  21054. */
  21055. disableDepthWrite: boolean;
  21056. /**
  21057. * Specifies if depth writing should be forced
  21058. */
  21059. forceDepthWrite: boolean;
  21060. /**
  21061. * Specifies if there should be a separate pass for culling
  21062. */
  21063. separateCullingPass: boolean;
  21064. /**
  21065. * Stores the state specifing if fog should be enabled
  21066. */
  21067. private _fogEnabled;
  21068. /**
  21069. * Sets the state for enabling fog
  21070. */
  21071. /**
  21072. * Gets the value of the fog enabled state
  21073. */
  21074. fogEnabled: boolean;
  21075. /**
  21076. * Stores the size of points
  21077. */
  21078. pointSize: number;
  21079. /**
  21080. * Stores the z offset value
  21081. */
  21082. zOffset: number;
  21083. /**
  21084. * Gets a value specifying if wireframe mode is enabled
  21085. */
  21086. /**
  21087. * Sets the state of wireframe mode
  21088. */
  21089. wireframe: boolean;
  21090. /**
  21091. * Gets the value specifying if point clouds are enabled
  21092. */
  21093. /**
  21094. * Sets the state of point cloud mode
  21095. */
  21096. pointsCloud: boolean;
  21097. /**
  21098. * Gets the material fill mode
  21099. */
  21100. /**
  21101. * Sets the material fill mode
  21102. */
  21103. fillMode: number;
  21104. /**
  21105. * @hidden
  21106. * Stores the effects for the material
  21107. */
  21108. _effect: Nullable<Effect>;
  21109. /**
  21110. * @hidden
  21111. * Specifies if the material was previously ready
  21112. */
  21113. _wasPreviouslyReady: boolean;
  21114. /**
  21115. * Specifies if uniform buffers should be used
  21116. */
  21117. private _useUBO;
  21118. /**
  21119. * Stores a reference to the scene
  21120. */
  21121. private _scene;
  21122. /**
  21123. * Stores the fill mode state
  21124. */
  21125. private _fillMode;
  21126. /**
  21127. * Specifies if the depth write state should be cached
  21128. */
  21129. private _cachedDepthWriteState;
  21130. /**
  21131. * Stores the uniform buffer
  21132. */
  21133. protected _uniformBuffer: UniformBuffer;
  21134. /** @hidden */
  21135. _indexInSceneMaterialArray: number;
  21136. /** @hidden */
  21137. meshMap: Nullable<{
  21138. [id: string]: AbstractMesh | undefined;
  21139. }>;
  21140. /**
  21141. * Creates a material instance
  21142. * @param name defines the name of the material
  21143. * @param scene defines the scene to reference
  21144. * @param doNotAdd specifies if the material should be added to the scene
  21145. */
  21146. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21147. /**
  21148. * Returns a string representation of the current material
  21149. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21150. * @returns a string with material information
  21151. */
  21152. toString(fullDetails?: boolean): string;
  21153. /**
  21154. * Gets the class name of the material
  21155. * @returns a string with the class name of the material
  21156. */
  21157. getClassName(): string;
  21158. /**
  21159. * Specifies if updates for the material been locked
  21160. */
  21161. readonly isFrozen: boolean;
  21162. /**
  21163. * Locks updates for the material
  21164. */
  21165. freeze(): void;
  21166. /**
  21167. * Unlocks updates for the material
  21168. */
  21169. unfreeze(): void;
  21170. /**
  21171. * Specifies if the material is ready to be used
  21172. * @param mesh defines the mesh to check
  21173. * @param useInstances specifies if instances should be used
  21174. * @returns a boolean indicating if the material is ready to be used
  21175. */
  21176. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21177. /**
  21178. * Specifies that the submesh is ready to be used
  21179. * @param mesh defines the mesh to check
  21180. * @param subMesh defines which submesh to check
  21181. * @param useInstances specifies that instances should be used
  21182. * @returns a boolean indicating that the submesh is ready or not
  21183. */
  21184. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21185. /**
  21186. * Returns the material effect
  21187. * @returns the effect associated with the material
  21188. */
  21189. getEffect(): Nullable<Effect>;
  21190. /**
  21191. * Returns the current scene
  21192. * @returns a Scene
  21193. */
  21194. getScene(): Scene;
  21195. /**
  21196. * Specifies if the material will require alpha blending
  21197. * @returns a boolean specifying if alpha blending is needed
  21198. */
  21199. needAlphaBlending(): boolean;
  21200. /**
  21201. * Specifies if the mesh will require alpha blending
  21202. * @param mesh defines the mesh to check
  21203. * @returns a boolean specifying if alpha blending is needed for the mesh
  21204. */
  21205. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21206. /**
  21207. * Specifies if this material should be rendered in alpha test mode
  21208. * @returns a boolean specifying if an alpha test is needed.
  21209. */
  21210. needAlphaTesting(): boolean;
  21211. /**
  21212. * Gets the texture used for the alpha test
  21213. * @returns the texture to use for alpha testing
  21214. */
  21215. getAlphaTestTexture(): Nullable<BaseTexture>;
  21216. /**
  21217. * Marks the material to indicate that it needs to be re-calculated
  21218. */
  21219. markDirty(): void;
  21220. /** @hidden */
  21221. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21222. /**
  21223. * Binds the material to the mesh
  21224. * @param world defines the world transformation matrix
  21225. * @param mesh defines the mesh to bind the material to
  21226. */
  21227. bind(world: Matrix, mesh?: Mesh): void;
  21228. /**
  21229. * Binds the submesh to the material
  21230. * @param world defines the world transformation matrix
  21231. * @param mesh defines the mesh containing the submesh
  21232. * @param subMesh defines the submesh to bind the material to
  21233. */
  21234. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21235. /**
  21236. * Binds the world matrix to the material
  21237. * @param world defines the world transformation matrix
  21238. */
  21239. bindOnlyWorldMatrix(world: Matrix): void;
  21240. /**
  21241. * Binds the scene's uniform buffer to the effect.
  21242. * @param effect defines the effect to bind to the scene uniform buffer
  21243. * @param sceneUbo defines the uniform buffer storing scene data
  21244. */
  21245. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21246. /**
  21247. * Binds the view matrix to the effect
  21248. * @param effect defines the effect to bind the view matrix to
  21249. */
  21250. bindView(effect: Effect): void;
  21251. /**
  21252. * Binds the view projection matrix to the effect
  21253. * @param effect defines the effect to bind the view projection matrix to
  21254. */
  21255. bindViewProjection(effect: Effect): void;
  21256. /**
  21257. * Specifies if material alpha testing should be turned on for the mesh
  21258. * @param mesh defines the mesh to check
  21259. */
  21260. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21261. /**
  21262. * Processes to execute after binding the material to a mesh
  21263. * @param mesh defines the rendered mesh
  21264. */
  21265. protected _afterBind(mesh?: Mesh): void;
  21266. /**
  21267. * Unbinds the material from the mesh
  21268. */
  21269. unbind(): void;
  21270. /**
  21271. * Gets the active textures from the material
  21272. * @returns an array of textures
  21273. */
  21274. getActiveTextures(): BaseTexture[];
  21275. /**
  21276. * Specifies if the material uses a texture
  21277. * @param texture defines the texture to check against the material
  21278. * @returns a boolean specifying if the material uses the texture
  21279. */
  21280. hasTexture(texture: BaseTexture): boolean;
  21281. /**
  21282. * Makes a duplicate of the material, and gives it a new name
  21283. * @param name defines the new name for the duplicated material
  21284. * @returns the cloned material
  21285. */
  21286. clone(name: string): Nullable<Material>;
  21287. /**
  21288. * Gets the meshes bound to the material
  21289. * @returns an array of meshes bound to the material
  21290. */
  21291. getBindedMeshes(): AbstractMesh[];
  21292. /**
  21293. * Force shader compilation
  21294. * @param mesh defines the mesh associated with this material
  21295. * @param onCompiled defines a function to execute once the material is compiled
  21296. * @param options defines the options to configure the compilation
  21297. * @param onError defines a function to execute if the material fails compiling
  21298. */
  21299. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21300. /**
  21301. * Force shader compilation
  21302. * @param mesh defines the mesh that will use this material
  21303. * @param options defines additional options for compiling the shaders
  21304. * @returns a promise that resolves when the compilation completes
  21305. */
  21306. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21307. private static readonly _AllDirtyCallBack;
  21308. private static readonly _ImageProcessingDirtyCallBack;
  21309. private static readonly _TextureDirtyCallBack;
  21310. private static readonly _FresnelDirtyCallBack;
  21311. private static readonly _MiscDirtyCallBack;
  21312. private static readonly _LightsDirtyCallBack;
  21313. private static readonly _AttributeDirtyCallBack;
  21314. private static _FresnelAndMiscDirtyCallBack;
  21315. private static _TextureAndMiscDirtyCallBack;
  21316. private static readonly _DirtyCallbackArray;
  21317. private static readonly _RunDirtyCallBacks;
  21318. /**
  21319. * Marks a define in the material to indicate that it needs to be re-computed
  21320. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21321. */
  21322. markAsDirty(flag: number): void;
  21323. /**
  21324. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21325. * @param func defines a function which checks material defines against the submeshes
  21326. */
  21327. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21328. /**
  21329. * Indicates that we need to re-calculated for all submeshes
  21330. */
  21331. protected _markAllSubMeshesAsAllDirty(): void;
  21332. /**
  21333. * Indicates that image processing needs to be re-calculated for all submeshes
  21334. */
  21335. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21336. /**
  21337. * Indicates that textures need to be re-calculated for all submeshes
  21338. */
  21339. protected _markAllSubMeshesAsTexturesDirty(): void;
  21340. /**
  21341. * Indicates that fresnel needs to be re-calculated for all submeshes
  21342. */
  21343. protected _markAllSubMeshesAsFresnelDirty(): void;
  21344. /**
  21345. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21346. */
  21347. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21348. /**
  21349. * Indicates that lights need to be re-calculated for all submeshes
  21350. */
  21351. protected _markAllSubMeshesAsLightsDirty(): void;
  21352. /**
  21353. * Indicates that attributes need to be re-calculated for all submeshes
  21354. */
  21355. protected _markAllSubMeshesAsAttributesDirty(): void;
  21356. /**
  21357. * Indicates that misc needs to be re-calculated for all submeshes
  21358. */
  21359. protected _markAllSubMeshesAsMiscDirty(): void;
  21360. /**
  21361. * Indicates that textures and misc need to be re-calculated for all submeshes
  21362. */
  21363. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21364. /**
  21365. * Disposes the material
  21366. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21367. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21368. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21369. */
  21370. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21371. /** @hidden */
  21372. private releaseVertexArrayObject;
  21373. /**
  21374. * Serializes this material
  21375. * @returns the serialized material object
  21376. */
  21377. serialize(): any;
  21378. /**
  21379. * Creates a material from parsed material data
  21380. * @param parsedMaterial defines parsed material data
  21381. * @param scene defines the hosting scene
  21382. * @param rootUrl defines the root URL to use to load textures
  21383. * @returns a new material
  21384. */
  21385. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21386. }
  21387. }
  21388. declare module "babylonjs/Materials/multiMaterial" {
  21389. import { Nullable } from "babylonjs/types";
  21390. import { Scene } from "babylonjs/scene";
  21391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21392. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21394. import { Material } from "babylonjs/Materials/material";
  21395. /**
  21396. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21397. * separate meshes. This can be use to improve performances.
  21398. * @see http://doc.babylonjs.com/how_to/multi_materials
  21399. */
  21400. export class MultiMaterial extends Material {
  21401. private _subMaterials;
  21402. /**
  21403. * Gets or Sets the list of Materials used within the multi material.
  21404. * They need to be ordered according to the submeshes order in the associated mesh
  21405. */
  21406. subMaterials: Nullable<Material>[];
  21407. /**
  21408. * Function used to align with Node.getChildren()
  21409. * @returns the list of Materials used within the multi material
  21410. */
  21411. getChildren(): Nullable<Material>[];
  21412. /**
  21413. * Instantiates a new Multi Material
  21414. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21415. * separate meshes. This can be use to improve performances.
  21416. * @see http://doc.babylonjs.com/how_to/multi_materials
  21417. * @param name Define the name in the scene
  21418. * @param scene Define the scene the material belongs to
  21419. */
  21420. constructor(name: string, scene: Scene);
  21421. private _hookArray;
  21422. /**
  21423. * Get one of the submaterial by its index in the submaterials array
  21424. * @param index The index to look the sub material at
  21425. * @returns The Material if the index has been defined
  21426. */
  21427. getSubMaterial(index: number): Nullable<Material>;
  21428. /**
  21429. * Get the list of active textures for the whole sub materials list.
  21430. * @returns All the textures that will be used during the rendering
  21431. */
  21432. getActiveTextures(): BaseTexture[];
  21433. /**
  21434. * Gets the current class name of the material e.g. "MultiMaterial"
  21435. * Mainly use in serialization.
  21436. * @returns the class name
  21437. */
  21438. getClassName(): string;
  21439. /**
  21440. * Checks if the material is ready to render the requested sub mesh
  21441. * @param mesh Define the mesh the submesh belongs to
  21442. * @param subMesh Define the sub mesh to look readyness for
  21443. * @param useInstances Define whether or not the material is used with instances
  21444. * @returns true if ready, otherwise false
  21445. */
  21446. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21447. /**
  21448. * Clones the current material and its related sub materials
  21449. * @param name Define the name of the newly cloned material
  21450. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21451. * @returns the cloned material
  21452. */
  21453. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21454. /**
  21455. * Serializes the materials into a JSON representation.
  21456. * @returns the JSON representation
  21457. */
  21458. serialize(): any;
  21459. /**
  21460. * Dispose the material and release its associated resources
  21461. * @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)
  21462. * @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)
  21463. * @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)
  21464. */
  21465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21466. /**
  21467. * Creates a MultiMaterial from parsed MultiMaterial data.
  21468. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21469. * @param scene defines the hosting scene
  21470. * @returns a new MultiMaterial
  21471. */
  21472. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21473. }
  21474. }
  21475. declare module "babylonjs/Meshes/subMesh" {
  21476. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21477. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21478. import { Engine } from "babylonjs/Engines/engine";
  21479. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21480. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21481. import { Effect } from "babylonjs/Materials/effect";
  21482. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21483. import { Plane } from "babylonjs/Maths/math.plane";
  21484. import { Collider } from "babylonjs/Collisions/collider";
  21485. import { Material } from "babylonjs/Materials/material";
  21486. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21488. import { Mesh } from "babylonjs/Meshes/mesh";
  21489. import { Ray } from "babylonjs/Culling/ray";
  21490. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21491. /**
  21492. * Base class for submeshes
  21493. */
  21494. export class BaseSubMesh {
  21495. /** @hidden */
  21496. _materialDefines: Nullable<MaterialDefines>;
  21497. /** @hidden */
  21498. _materialEffect: Nullable<Effect>;
  21499. /**
  21500. * Gets associated effect
  21501. */
  21502. readonly effect: Nullable<Effect>;
  21503. /**
  21504. * Sets associated effect (effect used to render this submesh)
  21505. * @param effect defines the effect to associate with
  21506. * @param defines defines the set of defines used to compile this effect
  21507. */
  21508. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21509. }
  21510. /**
  21511. * Defines a subdivision inside a mesh
  21512. */
  21513. export class SubMesh extends BaseSubMesh implements ICullable {
  21514. /** the material index to use */
  21515. materialIndex: number;
  21516. /** vertex index start */
  21517. verticesStart: number;
  21518. /** vertices count */
  21519. verticesCount: number;
  21520. /** index start */
  21521. indexStart: number;
  21522. /** indices count */
  21523. indexCount: number;
  21524. /** @hidden */
  21525. _linesIndexCount: number;
  21526. private _mesh;
  21527. private _renderingMesh;
  21528. private _boundingInfo;
  21529. private _linesIndexBuffer;
  21530. /** @hidden */
  21531. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21532. /** @hidden */
  21533. _trianglePlanes: Plane[];
  21534. /** @hidden */
  21535. _lastColliderTransformMatrix: Nullable<Matrix>;
  21536. /** @hidden */
  21537. _renderId: number;
  21538. /** @hidden */
  21539. _alphaIndex: number;
  21540. /** @hidden */
  21541. _distanceToCamera: number;
  21542. /** @hidden */
  21543. _id: number;
  21544. private _currentMaterial;
  21545. /**
  21546. * Add a new submesh to a mesh
  21547. * @param materialIndex defines the material index to use
  21548. * @param verticesStart defines vertex index start
  21549. * @param verticesCount defines vertices count
  21550. * @param indexStart defines index start
  21551. * @param indexCount defines indices count
  21552. * @param mesh defines the parent mesh
  21553. * @param renderingMesh defines an optional rendering mesh
  21554. * @param createBoundingBox defines if bounding box should be created for this submesh
  21555. * @returns the new submesh
  21556. */
  21557. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21558. /**
  21559. * Creates a new submesh
  21560. * @param materialIndex defines the material index to use
  21561. * @param verticesStart defines vertex index start
  21562. * @param verticesCount defines vertices count
  21563. * @param indexStart defines index start
  21564. * @param indexCount defines indices count
  21565. * @param mesh defines the parent mesh
  21566. * @param renderingMesh defines an optional rendering mesh
  21567. * @param createBoundingBox defines if bounding box should be created for this submesh
  21568. */
  21569. constructor(
  21570. /** the material index to use */
  21571. materialIndex: number,
  21572. /** vertex index start */
  21573. verticesStart: number,
  21574. /** vertices count */
  21575. verticesCount: number,
  21576. /** index start */
  21577. indexStart: number,
  21578. /** indices count */
  21579. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21580. /**
  21581. * Returns true if this submesh covers the entire parent mesh
  21582. * @ignorenaming
  21583. */
  21584. readonly IsGlobal: boolean;
  21585. /**
  21586. * Returns the submesh BoudingInfo object
  21587. * @returns current bounding info (or mesh's one if the submesh is global)
  21588. */
  21589. getBoundingInfo(): BoundingInfo;
  21590. /**
  21591. * Sets the submesh BoundingInfo
  21592. * @param boundingInfo defines the new bounding info to use
  21593. * @returns the SubMesh
  21594. */
  21595. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21596. /**
  21597. * Returns the mesh of the current submesh
  21598. * @return the parent mesh
  21599. */
  21600. getMesh(): AbstractMesh;
  21601. /**
  21602. * Returns the rendering mesh of the submesh
  21603. * @returns the rendering mesh (could be different from parent mesh)
  21604. */
  21605. getRenderingMesh(): Mesh;
  21606. /**
  21607. * Returns the submesh material
  21608. * @returns null or the current material
  21609. */
  21610. getMaterial(): Nullable<Material>;
  21611. /**
  21612. * Sets a new updated BoundingInfo object to the submesh
  21613. * @param data defines an optional position array to use to determine the bounding info
  21614. * @returns the SubMesh
  21615. */
  21616. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21617. /** @hidden */
  21618. _checkCollision(collider: Collider): boolean;
  21619. /**
  21620. * Updates the submesh BoundingInfo
  21621. * @param world defines the world matrix to use to update the bounding info
  21622. * @returns the submesh
  21623. */
  21624. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21625. /**
  21626. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21627. * @param frustumPlanes defines the frustum planes
  21628. * @returns true if the submesh is intersecting with the frustum
  21629. */
  21630. isInFrustum(frustumPlanes: Plane[]): boolean;
  21631. /**
  21632. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21633. * @param frustumPlanes defines the frustum planes
  21634. * @returns true if the submesh is inside the frustum
  21635. */
  21636. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21637. /**
  21638. * Renders the submesh
  21639. * @param enableAlphaMode defines if alpha needs to be used
  21640. * @returns the submesh
  21641. */
  21642. render(enableAlphaMode: boolean): SubMesh;
  21643. /**
  21644. * @hidden
  21645. */
  21646. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21647. /**
  21648. * Checks if the submesh intersects with a ray
  21649. * @param ray defines the ray to test
  21650. * @returns true is the passed ray intersects the submesh bounding box
  21651. */
  21652. canIntersects(ray: Ray): boolean;
  21653. /**
  21654. * Intersects current submesh with a ray
  21655. * @param ray defines the ray to test
  21656. * @param positions defines mesh's positions array
  21657. * @param indices defines mesh's indices array
  21658. * @param fastCheck defines if only bounding info should be used
  21659. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21660. * @returns intersection info or null if no intersection
  21661. */
  21662. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21663. /** @hidden */
  21664. private _intersectLines;
  21665. /** @hidden */
  21666. private _intersectUnIndexedLines;
  21667. /** @hidden */
  21668. private _intersectTriangles;
  21669. /** @hidden */
  21670. private _intersectUnIndexedTriangles;
  21671. /** @hidden */
  21672. _rebuild(): void;
  21673. /**
  21674. * Creates a new submesh from the passed mesh
  21675. * @param newMesh defines the new hosting mesh
  21676. * @param newRenderingMesh defines an optional rendering mesh
  21677. * @returns the new submesh
  21678. */
  21679. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21680. /**
  21681. * Release associated resources
  21682. */
  21683. dispose(): void;
  21684. /**
  21685. * Gets the class name
  21686. * @returns the string "SubMesh".
  21687. */
  21688. getClassName(): string;
  21689. /**
  21690. * Creates a new submesh from indices data
  21691. * @param materialIndex the index of the main mesh material
  21692. * @param startIndex the index where to start the copy in the mesh indices array
  21693. * @param indexCount the number of indices to copy then from the startIndex
  21694. * @param mesh the main mesh to create the submesh from
  21695. * @param renderingMesh the optional rendering mesh
  21696. * @returns a new submesh
  21697. */
  21698. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21699. }
  21700. }
  21701. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21702. /**
  21703. * Class used to represent data loading progression
  21704. */
  21705. export class SceneLoaderFlags {
  21706. private static _ForceFullSceneLoadingForIncremental;
  21707. private static _ShowLoadingScreen;
  21708. private static _CleanBoneMatrixWeights;
  21709. private static _loggingLevel;
  21710. /**
  21711. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21712. */
  21713. static ForceFullSceneLoadingForIncremental: boolean;
  21714. /**
  21715. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21716. */
  21717. static ShowLoadingScreen: boolean;
  21718. /**
  21719. * Defines the current logging level (while loading the scene)
  21720. * @ignorenaming
  21721. */
  21722. static loggingLevel: number;
  21723. /**
  21724. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21725. */
  21726. static CleanBoneMatrixWeights: boolean;
  21727. }
  21728. }
  21729. declare module "babylonjs/Meshes/geometry" {
  21730. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21731. import { Scene } from "babylonjs/scene";
  21732. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21733. import { Engine } from "babylonjs/Engines/engine";
  21734. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21735. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21736. import { Effect } from "babylonjs/Materials/effect";
  21737. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21738. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21739. import { Mesh } from "babylonjs/Meshes/mesh";
  21740. /**
  21741. * Class used to store geometry data (vertex buffers + index buffer)
  21742. */
  21743. export class Geometry implements IGetSetVerticesData {
  21744. /**
  21745. * Gets or sets the ID of the geometry
  21746. */
  21747. id: string;
  21748. /**
  21749. * Gets or sets the unique ID of the geometry
  21750. */
  21751. uniqueId: number;
  21752. /**
  21753. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21754. */
  21755. delayLoadState: number;
  21756. /**
  21757. * Gets the file containing the data to load when running in delay load state
  21758. */
  21759. delayLoadingFile: Nullable<string>;
  21760. /**
  21761. * Callback called when the geometry is updated
  21762. */
  21763. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21764. private _scene;
  21765. private _engine;
  21766. private _meshes;
  21767. private _totalVertices;
  21768. /** @hidden */
  21769. _indices: IndicesArray;
  21770. /** @hidden */
  21771. _vertexBuffers: {
  21772. [key: string]: VertexBuffer;
  21773. };
  21774. private _isDisposed;
  21775. private _extend;
  21776. private _boundingBias;
  21777. /** @hidden */
  21778. _delayInfo: Array<string>;
  21779. private _indexBuffer;
  21780. private _indexBufferIsUpdatable;
  21781. /** @hidden */
  21782. _boundingInfo: Nullable<BoundingInfo>;
  21783. /** @hidden */
  21784. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21785. /** @hidden */
  21786. _softwareSkinningFrameId: number;
  21787. private _vertexArrayObjects;
  21788. private _updatable;
  21789. /** @hidden */
  21790. _positions: Nullable<Vector3[]>;
  21791. /**
  21792. * 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
  21793. */
  21794. /**
  21795. * 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
  21796. */
  21797. boundingBias: Vector2;
  21798. /**
  21799. * Static function used to attach a new empty geometry to a mesh
  21800. * @param mesh defines the mesh to attach the geometry to
  21801. * @returns the new Geometry
  21802. */
  21803. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21804. /**
  21805. * Creates a new geometry
  21806. * @param id defines the unique ID
  21807. * @param scene defines the hosting scene
  21808. * @param vertexData defines the VertexData used to get geometry data
  21809. * @param updatable defines if geometry must be updatable (false by default)
  21810. * @param mesh defines the mesh that will be associated with the geometry
  21811. */
  21812. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21813. /**
  21814. * Gets the current extend of the geometry
  21815. */
  21816. readonly extend: {
  21817. minimum: Vector3;
  21818. maximum: Vector3;
  21819. };
  21820. /**
  21821. * Gets the hosting scene
  21822. * @returns the hosting Scene
  21823. */
  21824. getScene(): Scene;
  21825. /**
  21826. * Gets the hosting engine
  21827. * @returns the hosting Engine
  21828. */
  21829. getEngine(): Engine;
  21830. /**
  21831. * Defines if the geometry is ready to use
  21832. * @returns true if the geometry is ready to be used
  21833. */
  21834. isReady(): boolean;
  21835. /**
  21836. * Gets a value indicating that the geometry should not be serialized
  21837. */
  21838. readonly doNotSerialize: boolean;
  21839. /** @hidden */
  21840. _rebuild(): void;
  21841. /**
  21842. * Affects all geometry data in one call
  21843. * @param vertexData defines the geometry data
  21844. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21845. */
  21846. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21847. /**
  21848. * Set specific vertex data
  21849. * @param kind defines the data kind (Position, normal, etc...)
  21850. * @param data defines the vertex data to use
  21851. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21852. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21853. */
  21854. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21855. /**
  21856. * Removes a specific vertex data
  21857. * @param kind defines the data kind (Position, normal, etc...)
  21858. */
  21859. removeVerticesData(kind: string): void;
  21860. /**
  21861. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21862. * @param buffer defines the vertex buffer to use
  21863. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21864. */
  21865. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21866. /**
  21867. * Update a specific vertex buffer
  21868. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21869. * It will do nothing if the buffer is not updatable
  21870. * @param kind defines the data kind (Position, normal, etc...)
  21871. * @param data defines the data to use
  21872. * @param offset defines the offset in the target buffer where to store the data
  21873. * @param useBytes set to true if the offset is in bytes
  21874. */
  21875. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21876. /**
  21877. * Update a specific vertex buffer
  21878. * This function will create a new buffer if the current one is not updatable
  21879. * @param kind defines the data kind (Position, normal, etc...)
  21880. * @param data defines the data to use
  21881. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21882. */
  21883. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21884. private _updateBoundingInfo;
  21885. /** @hidden */
  21886. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21887. /**
  21888. * Gets total number of vertices
  21889. * @returns the total number of vertices
  21890. */
  21891. getTotalVertices(): number;
  21892. /**
  21893. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21894. * @param kind defines the data kind (Position, normal, etc...)
  21895. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21896. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21897. * @returns a float array containing vertex data
  21898. */
  21899. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21900. /**
  21901. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21902. * @param kind defines the data kind (Position, normal, etc...)
  21903. * @returns true if the vertex buffer with the specified kind is updatable
  21904. */
  21905. isVertexBufferUpdatable(kind: string): boolean;
  21906. /**
  21907. * Gets a specific vertex buffer
  21908. * @param kind defines the data kind (Position, normal, etc...)
  21909. * @returns a VertexBuffer
  21910. */
  21911. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21912. /**
  21913. * Returns all vertex buffers
  21914. * @return an object holding all vertex buffers indexed by kind
  21915. */
  21916. getVertexBuffers(): Nullable<{
  21917. [key: string]: VertexBuffer;
  21918. }>;
  21919. /**
  21920. * Gets a boolean indicating if specific vertex buffer is present
  21921. * @param kind defines the data kind (Position, normal, etc...)
  21922. * @returns true if data is present
  21923. */
  21924. isVerticesDataPresent(kind: string): boolean;
  21925. /**
  21926. * Gets a list of all attached data kinds (Position, normal, etc...)
  21927. * @returns a list of string containing all kinds
  21928. */
  21929. getVerticesDataKinds(): string[];
  21930. /**
  21931. * Update index buffer
  21932. * @param indices defines the indices to store in the index buffer
  21933. * @param offset defines the offset in the target buffer where to store the data
  21934. * @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)
  21935. */
  21936. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21937. /**
  21938. * Creates a new index buffer
  21939. * @param indices defines the indices to store in the index buffer
  21940. * @param totalVertices defines the total number of vertices (could be null)
  21941. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21942. */
  21943. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21944. /**
  21945. * Return the total number of indices
  21946. * @returns the total number of indices
  21947. */
  21948. getTotalIndices(): number;
  21949. /**
  21950. * Gets the index buffer array
  21951. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21952. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21953. * @returns the index buffer array
  21954. */
  21955. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21956. /**
  21957. * Gets the index buffer
  21958. * @return the index buffer
  21959. */
  21960. getIndexBuffer(): Nullable<DataBuffer>;
  21961. /** @hidden */
  21962. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21963. /**
  21964. * Release the associated resources for a specific mesh
  21965. * @param mesh defines the source mesh
  21966. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21967. */
  21968. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21969. /**
  21970. * Apply current geometry to a given mesh
  21971. * @param mesh defines the mesh to apply geometry to
  21972. */
  21973. applyToMesh(mesh: Mesh): void;
  21974. private _updateExtend;
  21975. private _applyToMesh;
  21976. private notifyUpdate;
  21977. /**
  21978. * Load the geometry if it was flagged as delay loaded
  21979. * @param scene defines the hosting scene
  21980. * @param onLoaded defines a callback called when the geometry is loaded
  21981. */
  21982. load(scene: Scene, onLoaded?: () => void): void;
  21983. private _queueLoad;
  21984. /**
  21985. * Invert the geometry to move from a right handed system to a left handed one.
  21986. */
  21987. toLeftHanded(): void;
  21988. /** @hidden */
  21989. _resetPointsArrayCache(): void;
  21990. /** @hidden */
  21991. _generatePointsArray(): boolean;
  21992. /**
  21993. * Gets a value indicating if the geometry is disposed
  21994. * @returns true if the geometry was disposed
  21995. */
  21996. isDisposed(): boolean;
  21997. private _disposeVertexArrayObjects;
  21998. /**
  21999. * Free all associated resources
  22000. */
  22001. dispose(): void;
  22002. /**
  22003. * Clone the current geometry into a new geometry
  22004. * @param id defines the unique ID of the new geometry
  22005. * @returns a new geometry object
  22006. */
  22007. copy(id: string): Geometry;
  22008. /**
  22009. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22010. * @return a JSON representation of the current geometry data (without the vertices data)
  22011. */
  22012. serialize(): any;
  22013. private toNumberArray;
  22014. /**
  22015. * Serialize all vertices data into a JSON oject
  22016. * @returns a JSON representation of the current geometry data
  22017. */
  22018. serializeVerticeData(): any;
  22019. /**
  22020. * Extracts a clone of a mesh geometry
  22021. * @param mesh defines the source mesh
  22022. * @param id defines the unique ID of the new geometry object
  22023. * @returns the new geometry object
  22024. */
  22025. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22026. /**
  22027. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22028. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22029. * Be aware Math.random() could cause collisions, but:
  22030. * "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"
  22031. * @returns a string containing a new GUID
  22032. */
  22033. static RandomId(): string;
  22034. /** @hidden */
  22035. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22036. private static _CleanMatricesWeights;
  22037. /**
  22038. * Create a new geometry from persisted data (Using .babylon file format)
  22039. * @param parsedVertexData defines the persisted data
  22040. * @param scene defines the hosting scene
  22041. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22042. * @returns the new geometry object
  22043. */
  22044. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22045. }
  22046. }
  22047. declare module "babylonjs/Meshes/mesh.vertexData" {
  22048. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22049. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22050. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22051. import { Geometry } from "babylonjs/Meshes/geometry";
  22052. import { Mesh } from "babylonjs/Meshes/mesh";
  22053. /**
  22054. * Define an interface for all classes that will get and set the data on vertices
  22055. */
  22056. export interface IGetSetVerticesData {
  22057. /**
  22058. * Gets a boolean indicating if specific vertex data is present
  22059. * @param kind defines the vertex data kind to use
  22060. * @returns true is data kind is present
  22061. */
  22062. isVerticesDataPresent(kind: string): boolean;
  22063. /**
  22064. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22065. * @param kind defines the data kind (Position, normal, etc...)
  22066. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22067. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22068. * @returns a float array containing vertex data
  22069. */
  22070. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22071. /**
  22072. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22073. * @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.
  22074. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22075. * @returns the indices array or an empty array if the mesh has no geometry
  22076. */
  22077. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22078. /**
  22079. * Set specific vertex data
  22080. * @param kind defines the data kind (Position, normal, etc...)
  22081. * @param data defines the vertex data to use
  22082. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22083. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22084. */
  22085. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22086. /**
  22087. * Update a specific associated vertex buffer
  22088. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22089. * - VertexBuffer.PositionKind
  22090. * - VertexBuffer.UVKind
  22091. * - VertexBuffer.UV2Kind
  22092. * - VertexBuffer.UV3Kind
  22093. * - VertexBuffer.UV4Kind
  22094. * - VertexBuffer.UV5Kind
  22095. * - VertexBuffer.UV6Kind
  22096. * - VertexBuffer.ColorKind
  22097. * - VertexBuffer.MatricesIndicesKind
  22098. * - VertexBuffer.MatricesIndicesExtraKind
  22099. * - VertexBuffer.MatricesWeightsKind
  22100. * - VertexBuffer.MatricesWeightsExtraKind
  22101. * @param data defines the data source
  22102. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22103. * @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)
  22104. */
  22105. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22106. /**
  22107. * Creates a new index buffer
  22108. * @param indices defines the indices to store in the index buffer
  22109. * @param totalVertices defines the total number of vertices (could be null)
  22110. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22111. */
  22112. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22113. }
  22114. /**
  22115. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22116. */
  22117. export class VertexData {
  22118. /**
  22119. * Mesh side orientation : usually the external or front surface
  22120. */
  22121. static readonly FRONTSIDE: number;
  22122. /**
  22123. * Mesh side orientation : usually the internal or back surface
  22124. */
  22125. static readonly BACKSIDE: number;
  22126. /**
  22127. * Mesh side orientation : both internal and external or front and back surfaces
  22128. */
  22129. static readonly DOUBLESIDE: number;
  22130. /**
  22131. * Mesh side orientation : by default, `FRONTSIDE`
  22132. */
  22133. static readonly DEFAULTSIDE: number;
  22134. /**
  22135. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22136. */
  22137. positions: Nullable<FloatArray>;
  22138. /**
  22139. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22140. */
  22141. normals: Nullable<FloatArray>;
  22142. /**
  22143. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22144. */
  22145. tangents: Nullable<FloatArray>;
  22146. /**
  22147. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22148. */
  22149. uvs: Nullable<FloatArray>;
  22150. /**
  22151. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22152. */
  22153. uvs2: Nullable<FloatArray>;
  22154. /**
  22155. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22156. */
  22157. uvs3: Nullable<FloatArray>;
  22158. /**
  22159. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22160. */
  22161. uvs4: Nullable<FloatArray>;
  22162. /**
  22163. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22164. */
  22165. uvs5: Nullable<FloatArray>;
  22166. /**
  22167. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22168. */
  22169. uvs6: Nullable<FloatArray>;
  22170. /**
  22171. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22172. */
  22173. colors: Nullable<FloatArray>;
  22174. /**
  22175. * 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).
  22176. */
  22177. matricesIndices: Nullable<FloatArray>;
  22178. /**
  22179. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22180. */
  22181. matricesWeights: Nullable<FloatArray>;
  22182. /**
  22183. * An array extending the number of possible indices
  22184. */
  22185. matricesIndicesExtra: Nullable<FloatArray>;
  22186. /**
  22187. * An array extending the number of possible weights when the number of indices is extended
  22188. */
  22189. matricesWeightsExtra: Nullable<FloatArray>;
  22190. /**
  22191. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22192. */
  22193. indices: Nullable<IndicesArray>;
  22194. /**
  22195. * Uses the passed data array to set the set the values for the specified kind of data
  22196. * @param data a linear array of floating numbers
  22197. * @param kind the type of data that is being set, eg positions, colors etc
  22198. */
  22199. set(data: FloatArray, kind: string): void;
  22200. /**
  22201. * Associates the vertexData to the passed Mesh.
  22202. * Sets it as updatable or not (default `false`)
  22203. * @param mesh the mesh the vertexData is applied to
  22204. * @param updatable when used and having the value true allows new data to update the vertexData
  22205. * @returns the VertexData
  22206. */
  22207. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22208. /**
  22209. * Associates the vertexData to the passed Geometry.
  22210. * Sets it as updatable or not (default `false`)
  22211. * @param geometry the geometry the vertexData is applied to
  22212. * @param updatable when used and having the value true allows new data to update the vertexData
  22213. * @returns VertexData
  22214. */
  22215. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22216. /**
  22217. * Updates the associated mesh
  22218. * @param mesh the mesh to be updated
  22219. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22220. * @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
  22221. * @returns VertexData
  22222. */
  22223. updateMesh(mesh: Mesh): VertexData;
  22224. /**
  22225. * Updates the associated geometry
  22226. * @param geometry the geometry to be updated
  22227. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22228. * @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
  22229. * @returns VertexData.
  22230. */
  22231. updateGeometry(geometry: Geometry): VertexData;
  22232. private _applyTo;
  22233. private _update;
  22234. /**
  22235. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22236. * @param matrix the transforming matrix
  22237. * @returns the VertexData
  22238. */
  22239. transform(matrix: Matrix): VertexData;
  22240. /**
  22241. * Merges the passed VertexData into the current one
  22242. * @param other the VertexData to be merged into the current one
  22243. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22244. * @returns the modified VertexData
  22245. */
  22246. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22247. private _mergeElement;
  22248. private _validate;
  22249. /**
  22250. * Serializes the VertexData
  22251. * @returns a serialized object
  22252. */
  22253. serialize(): any;
  22254. /**
  22255. * Extracts the vertexData from a mesh
  22256. * @param mesh the mesh from which to extract the VertexData
  22257. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22258. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22259. * @returns the object VertexData associated to the passed mesh
  22260. */
  22261. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22262. /**
  22263. * Extracts the vertexData from the geometry
  22264. * @param geometry the geometry from which to extract the VertexData
  22265. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22266. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22267. * @returns the object VertexData associated to the passed mesh
  22268. */
  22269. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22270. private static _ExtractFrom;
  22271. /**
  22272. * Creates the VertexData for a Ribbon
  22273. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22274. * * pathArray array of paths, each of which an array of successive Vector3
  22275. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22276. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22277. * * 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
  22278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22279. * * 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)
  22280. * * 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)
  22281. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22282. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22283. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22284. * @returns the VertexData of the ribbon
  22285. */
  22286. static CreateRibbon(options: {
  22287. pathArray: Vector3[][];
  22288. closeArray?: boolean;
  22289. closePath?: boolean;
  22290. offset?: number;
  22291. sideOrientation?: number;
  22292. frontUVs?: Vector4;
  22293. backUVs?: Vector4;
  22294. invertUV?: boolean;
  22295. uvs?: Vector2[];
  22296. colors?: Color4[];
  22297. }): VertexData;
  22298. /**
  22299. * Creates the VertexData for a box
  22300. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22301. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22302. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22303. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22304. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22305. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22306. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22308. * * 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)
  22309. * * 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)
  22310. * @returns the VertexData of the box
  22311. */
  22312. static CreateBox(options: {
  22313. size?: number;
  22314. width?: number;
  22315. height?: number;
  22316. depth?: number;
  22317. faceUV?: Vector4[];
  22318. faceColors?: Color4[];
  22319. sideOrientation?: number;
  22320. frontUVs?: Vector4;
  22321. backUVs?: Vector4;
  22322. }): VertexData;
  22323. /**
  22324. * Creates the VertexData for a tiled box
  22325. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22326. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22327. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22328. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22329. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22330. * @returns the VertexData of the box
  22331. */
  22332. static CreateTiledBox(options: {
  22333. pattern?: number;
  22334. width?: number;
  22335. height?: number;
  22336. depth?: number;
  22337. tileSize?: number;
  22338. tileWidth?: number;
  22339. tileHeight?: number;
  22340. alignHorizontal?: number;
  22341. alignVertical?: number;
  22342. faceUV?: Vector4[];
  22343. faceColors?: Color4[];
  22344. sideOrientation?: number;
  22345. }): VertexData;
  22346. /**
  22347. * Creates the VertexData for a tiled plane
  22348. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22349. * * pattern a limited pattern arrangement depending on the number
  22350. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22351. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22352. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22354. * * 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)
  22355. * * 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)
  22356. * @returns the VertexData of the tiled plane
  22357. */
  22358. static CreateTiledPlane(options: {
  22359. pattern?: number;
  22360. tileSize?: number;
  22361. tileWidth?: number;
  22362. tileHeight?: number;
  22363. size?: number;
  22364. width?: number;
  22365. height?: number;
  22366. alignHorizontal?: number;
  22367. alignVertical?: number;
  22368. sideOrientation?: number;
  22369. frontUVs?: Vector4;
  22370. backUVs?: Vector4;
  22371. }): VertexData;
  22372. /**
  22373. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22374. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22375. * * segments sets the number of horizontal strips optional, default 32
  22376. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22377. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22378. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22379. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22380. * * 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
  22381. * * 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
  22382. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22383. * * 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)
  22384. * * 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)
  22385. * @returns the VertexData of the ellipsoid
  22386. */
  22387. static CreateSphere(options: {
  22388. segments?: number;
  22389. diameter?: number;
  22390. diameterX?: number;
  22391. diameterY?: number;
  22392. diameterZ?: number;
  22393. arc?: number;
  22394. slice?: number;
  22395. sideOrientation?: number;
  22396. frontUVs?: Vector4;
  22397. backUVs?: Vector4;
  22398. }): VertexData;
  22399. /**
  22400. * Creates the VertexData for a cylinder, cone or prism
  22401. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22402. * * height sets the height (y direction) of the cylinder, optional, default 2
  22403. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22404. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22405. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22406. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22407. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22408. * * 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
  22409. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22410. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22411. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22412. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22414. * * 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)
  22415. * * 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)
  22416. * @returns the VertexData of the cylinder, cone or prism
  22417. */
  22418. static CreateCylinder(options: {
  22419. height?: number;
  22420. diameterTop?: number;
  22421. diameterBottom?: number;
  22422. diameter?: number;
  22423. tessellation?: number;
  22424. subdivisions?: number;
  22425. arc?: number;
  22426. faceColors?: Color4[];
  22427. faceUV?: Vector4[];
  22428. hasRings?: boolean;
  22429. enclose?: boolean;
  22430. sideOrientation?: number;
  22431. frontUVs?: Vector4;
  22432. backUVs?: Vector4;
  22433. }): VertexData;
  22434. /**
  22435. * Creates the VertexData for a torus
  22436. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22437. * * diameter the diameter of the torus, optional default 1
  22438. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22439. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22440. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22441. * * 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)
  22442. * * 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)
  22443. * @returns the VertexData of the torus
  22444. */
  22445. static CreateTorus(options: {
  22446. diameter?: number;
  22447. thickness?: number;
  22448. tessellation?: number;
  22449. sideOrientation?: number;
  22450. frontUVs?: Vector4;
  22451. backUVs?: Vector4;
  22452. }): VertexData;
  22453. /**
  22454. * Creates the VertexData of the LineSystem
  22455. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22456. * - lines an array of lines, each line being an array of successive Vector3
  22457. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22458. * @returns the VertexData of the LineSystem
  22459. */
  22460. static CreateLineSystem(options: {
  22461. lines: Vector3[][];
  22462. colors?: Nullable<Color4[][]>;
  22463. }): VertexData;
  22464. /**
  22465. * Create the VertexData for a DashedLines
  22466. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22467. * - points an array successive Vector3
  22468. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22469. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22470. * - dashNb the intended total number of dashes, optional, default 200
  22471. * @returns the VertexData for the DashedLines
  22472. */
  22473. static CreateDashedLines(options: {
  22474. points: Vector3[];
  22475. dashSize?: number;
  22476. gapSize?: number;
  22477. dashNb?: number;
  22478. }): VertexData;
  22479. /**
  22480. * Creates the VertexData for a Ground
  22481. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22482. * - width the width (x direction) of the ground, optional, default 1
  22483. * - height the height (z direction) of the ground, optional, default 1
  22484. * - subdivisions the number of subdivisions per side, optional, default 1
  22485. * @returns the VertexData of the Ground
  22486. */
  22487. static CreateGround(options: {
  22488. width?: number;
  22489. height?: number;
  22490. subdivisions?: number;
  22491. subdivisionsX?: number;
  22492. subdivisionsY?: number;
  22493. }): VertexData;
  22494. /**
  22495. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22496. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22497. * * xmin the ground minimum X coordinate, optional, default -1
  22498. * * zmin the ground minimum Z coordinate, optional, default -1
  22499. * * xmax the ground maximum X coordinate, optional, default 1
  22500. * * zmax the ground maximum Z coordinate, optional, default 1
  22501. * * 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}
  22502. * * 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}
  22503. * @returns the VertexData of the TiledGround
  22504. */
  22505. static CreateTiledGround(options: {
  22506. xmin: number;
  22507. zmin: number;
  22508. xmax: number;
  22509. zmax: number;
  22510. subdivisions?: {
  22511. w: number;
  22512. h: number;
  22513. };
  22514. precision?: {
  22515. w: number;
  22516. h: number;
  22517. };
  22518. }): VertexData;
  22519. /**
  22520. * Creates the VertexData of the Ground designed from a heightmap
  22521. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22522. * * width the width (x direction) of the ground
  22523. * * height the height (z direction) of the ground
  22524. * * subdivisions the number of subdivisions per side
  22525. * * minHeight the minimum altitude on the ground, optional, default 0
  22526. * * maxHeight the maximum altitude on the ground, optional default 1
  22527. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22528. * * buffer the array holding the image color data
  22529. * * bufferWidth the width of image
  22530. * * bufferHeight the height of image
  22531. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22532. * @returns the VertexData of the Ground designed from a heightmap
  22533. */
  22534. static CreateGroundFromHeightMap(options: {
  22535. width: number;
  22536. height: number;
  22537. subdivisions: number;
  22538. minHeight: number;
  22539. maxHeight: number;
  22540. colorFilter: Color3;
  22541. buffer: Uint8Array;
  22542. bufferWidth: number;
  22543. bufferHeight: number;
  22544. alphaFilter: number;
  22545. }): VertexData;
  22546. /**
  22547. * Creates the VertexData for a Plane
  22548. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22549. * * size sets the width and height of the plane to the value of size, optional default 1
  22550. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22551. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22553. * * 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)
  22554. * * 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)
  22555. * @returns the VertexData of the box
  22556. */
  22557. static CreatePlane(options: {
  22558. size?: number;
  22559. width?: number;
  22560. height?: number;
  22561. sideOrientation?: number;
  22562. frontUVs?: Vector4;
  22563. backUVs?: Vector4;
  22564. }): VertexData;
  22565. /**
  22566. * Creates the VertexData of the Disc or regular Polygon
  22567. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22568. * * radius the radius of the disc, optional default 0.5
  22569. * * tessellation the number of polygon sides, optional, default 64
  22570. * * 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
  22571. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22572. * * 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)
  22573. * * 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)
  22574. * @returns the VertexData of the box
  22575. */
  22576. static CreateDisc(options: {
  22577. radius?: number;
  22578. tessellation?: number;
  22579. arc?: number;
  22580. sideOrientation?: number;
  22581. frontUVs?: Vector4;
  22582. backUVs?: Vector4;
  22583. }): VertexData;
  22584. /**
  22585. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22586. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22587. * @param polygon a mesh built from polygonTriangulation.build()
  22588. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22589. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22590. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22591. * @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)
  22592. * @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)
  22593. * @returns the VertexData of the Polygon
  22594. */
  22595. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22596. /**
  22597. * Creates the VertexData of the IcoSphere
  22598. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22599. * * radius the radius of the IcoSphere, optional default 1
  22600. * * radiusX allows stretching in the x direction, optional, default radius
  22601. * * radiusY allows stretching in the y direction, optional, default radius
  22602. * * radiusZ allows stretching in the z direction, optional, default radius
  22603. * * flat when true creates a flat shaded mesh, optional, default true
  22604. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22605. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22606. * * 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)
  22607. * * 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)
  22608. * @returns the VertexData of the IcoSphere
  22609. */
  22610. static CreateIcoSphere(options: {
  22611. radius?: number;
  22612. radiusX?: number;
  22613. radiusY?: number;
  22614. radiusZ?: number;
  22615. flat?: boolean;
  22616. subdivisions?: number;
  22617. sideOrientation?: number;
  22618. frontUVs?: Vector4;
  22619. backUVs?: Vector4;
  22620. }): VertexData;
  22621. /**
  22622. * Creates the VertexData for a Polyhedron
  22623. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22624. * * type provided types are:
  22625. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22626. * * 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)
  22627. * * size the size of the IcoSphere, optional default 1
  22628. * * sizeX allows stretching in the x direction, optional, default size
  22629. * * sizeY allows stretching in the y direction, optional, default size
  22630. * * sizeZ allows stretching in the z direction, optional, default size
  22631. * * 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
  22632. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22633. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22634. * * flat when true creates a flat shaded mesh, optional, default true
  22635. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22636. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22637. * * 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)
  22638. * * 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)
  22639. * @returns the VertexData of the Polyhedron
  22640. */
  22641. static CreatePolyhedron(options: {
  22642. type?: number;
  22643. size?: number;
  22644. sizeX?: number;
  22645. sizeY?: number;
  22646. sizeZ?: number;
  22647. custom?: any;
  22648. faceUV?: Vector4[];
  22649. faceColors?: Color4[];
  22650. flat?: boolean;
  22651. sideOrientation?: number;
  22652. frontUVs?: Vector4;
  22653. backUVs?: Vector4;
  22654. }): VertexData;
  22655. /**
  22656. * Creates the VertexData for a TorusKnot
  22657. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22658. * * radius the radius of the torus knot, optional, default 2
  22659. * * tube the thickness of the tube, optional, default 0.5
  22660. * * radialSegments the number of sides on each tube segments, optional, default 32
  22661. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22662. * * p the number of windings around the z axis, optional, default 2
  22663. * * q the number of windings around the x axis, optional, default 3
  22664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22665. * * 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)
  22666. * * 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)
  22667. * @returns the VertexData of the Torus Knot
  22668. */
  22669. static CreateTorusKnot(options: {
  22670. radius?: number;
  22671. tube?: number;
  22672. radialSegments?: number;
  22673. tubularSegments?: number;
  22674. p?: number;
  22675. q?: number;
  22676. sideOrientation?: number;
  22677. frontUVs?: Vector4;
  22678. backUVs?: Vector4;
  22679. }): VertexData;
  22680. /**
  22681. * Compute normals for given positions and indices
  22682. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22683. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22684. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22685. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22686. * * facetNormals : optional array of facet normals (vector3)
  22687. * * facetPositions : optional array of facet positions (vector3)
  22688. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22689. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22690. * * bInfo : optional bounding info, required for facetPartitioning computation
  22691. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22692. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22693. * * useRightHandedSystem: optional boolean to for right handed system computation
  22694. * * depthSort : optional boolean to enable the facet depth sort computation
  22695. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22696. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22697. */
  22698. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22699. facetNormals?: any;
  22700. facetPositions?: any;
  22701. facetPartitioning?: any;
  22702. ratio?: number;
  22703. bInfo?: any;
  22704. bbSize?: Vector3;
  22705. subDiv?: any;
  22706. useRightHandedSystem?: boolean;
  22707. depthSort?: boolean;
  22708. distanceTo?: Vector3;
  22709. depthSortedFacets?: any;
  22710. }): void;
  22711. /** @hidden */
  22712. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22713. /**
  22714. * Applies VertexData created from the imported parameters to the geometry
  22715. * @param parsedVertexData the parsed data from an imported file
  22716. * @param geometry the geometry to apply the VertexData to
  22717. */
  22718. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22719. }
  22720. }
  22721. declare module "babylonjs/Morph/morphTarget" {
  22722. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22723. import { Observable } from "babylonjs/Misc/observable";
  22724. import { Nullable, FloatArray } from "babylonjs/types";
  22725. import { Scene } from "babylonjs/scene";
  22726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22727. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22728. /**
  22729. * Defines a target to use with MorphTargetManager
  22730. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22731. */
  22732. export class MorphTarget implements IAnimatable {
  22733. /** defines the name of the target */
  22734. name: string;
  22735. /**
  22736. * Gets or sets the list of animations
  22737. */
  22738. animations: import("babylonjs/Animations/animation").Animation[];
  22739. private _scene;
  22740. private _positions;
  22741. private _normals;
  22742. private _tangents;
  22743. private _uvs;
  22744. private _influence;
  22745. /**
  22746. * Observable raised when the influence changes
  22747. */
  22748. onInfluenceChanged: Observable<boolean>;
  22749. /** @hidden */
  22750. _onDataLayoutChanged: Observable<void>;
  22751. /**
  22752. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22753. */
  22754. influence: number;
  22755. /**
  22756. * Gets or sets the id of the morph Target
  22757. */
  22758. id: string;
  22759. private _animationPropertiesOverride;
  22760. /**
  22761. * Gets or sets the animation properties override
  22762. */
  22763. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22764. /**
  22765. * Creates a new MorphTarget
  22766. * @param name defines the name of the target
  22767. * @param influence defines the influence to use
  22768. * @param scene defines the scene the morphtarget belongs to
  22769. */
  22770. constructor(
  22771. /** defines the name of the target */
  22772. name: string, influence?: number, scene?: Nullable<Scene>);
  22773. /**
  22774. * Gets a boolean defining if the target contains position data
  22775. */
  22776. readonly hasPositions: boolean;
  22777. /**
  22778. * Gets a boolean defining if the target contains normal data
  22779. */
  22780. readonly hasNormals: boolean;
  22781. /**
  22782. * Gets a boolean defining if the target contains tangent data
  22783. */
  22784. readonly hasTangents: boolean;
  22785. /**
  22786. * Gets a boolean defining if the target contains texture coordinates data
  22787. */
  22788. readonly hasUVs: boolean;
  22789. /**
  22790. * Affects position data to this target
  22791. * @param data defines the position data to use
  22792. */
  22793. setPositions(data: Nullable<FloatArray>): void;
  22794. /**
  22795. * Gets the position data stored in this target
  22796. * @returns a FloatArray containing the position data (or null if not present)
  22797. */
  22798. getPositions(): Nullable<FloatArray>;
  22799. /**
  22800. * Affects normal data to this target
  22801. * @param data defines the normal data to use
  22802. */
  22803. setNormals(data: Nullable<FloatArray>): void;
  22804. /**
  22805. * Gets the normal data stored in this target
  22806. * @returns a FloatArray containing the normal data (or null if not present)
  22807. */
  22808. getNormals(): Nullable<FloatArray>;
  22809. /**
  22810. * Affects tangent data to this target
  22811. * @param data defines the tangent data to use
  22812. */
  22813. setTangents(data: Nullable<FloatArray>): void;
  22814. /**
  22815. * Gets the tangent data stored in this target
  22816. * @returns a FloatArray containing the tangent data (or null if not present)
  22817. */
  22818. getTangents(): Nullable<FloatArray>;
  22819. /**
  22820. * Affects texture coordinates data to this target
  22821. * @param data defines the texture coordinates data to use
  22822. */
  22823. setUVs(data: Nullable<FloatArray>): void;
  22824. /**
  22825. * Gets the texture coordinates data stored in this target
  22826. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22827. */
  22828. getUVs(): Nullable<FloatArray>;
  22829. /**
  22830. * Serializes the current target into a Serialization object
  22831. * @returns the serialized object
  22832. */
  22833. serialize(): any;
  22834. /**
  22835. * Returns the string "MorphTarget"
  22836. * @returns "MorphTarget"
  22837. */
  22838. getClassName(): string;
  22839. /**
  22840. * Creates a new target from serialized data
  22841. * @param serializationObject defines the serialized data to use
  22842. * @returns a new MorphTarget
  22843. */
  22844. static Parse(serializationObject: any): MorphTarget;
  22845. /**
  22846. * Creates a MorphTarget from mesh data
  22847. * @param mesh defines the source mesh
  22848. * @param name defines the name to use for the new target
  22849. * @param influence defines the influence to attach to the target
  22850. * @returns a new MorphTarget
  22851. */
  22852. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22853. }
  22854. }
  22855. declare module "babylonjs/Morph/morphTargetManager" {
  22856. import { Nullable } from "babylonjs/types";
  22857. import { Scene } from "babylonjs/scene";
  22858. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22859. /**
  22860. * This class is used to deform meshes using morphing between different targets
  22861. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22862. */
  22863. export class MorphTargetManager {
  22864. private _targets;
  22865. private _targetInfluenceChangedObservers;
  22866. private _targetDataLayoutChangedObservers;
  22867. private _activeTargets;
  22868. private _scene;
  22869. private _influences;
  22870. private _supportsNormals;
  22871. private _supportsTangents;
  22872. private _supportsUVs;
  22873. private _vertexCount;
  22874. private _uniqueId;
  22875. private _tempInfluences;
  22876. /**
  22877. * Gets or sets a boolean indicating if normals must be morphed
  22878. */
  22879. enableNormalMorphing: boolean;
  22880. /**
  22881. * Gets or sets a boolean indicating if tangents must be morphed
  22882. */
  22883. enableTangentMorphing: boolean;
  22884. /**
  22885. * Gets or sets a boolean indicating if UV must be morphed
  22886. */
  22887. enableUVMorphing: boolean;
  22888. /**
  22889. * Creates a new MorphTargetManager
  22890. * @param scene defines the current scene
  22891. */
  22892. constructor(scene?: Nullable<Scene>);
  22893. /**
  22894. * Gets the unique ID of this manager
  22895. */
  22896. readonly uniqueId: number;
  22897. /**
  22898. * Gets the number of vertices handled by this manager
  22899. */
  22900. readonly vertexCount: number;
  22901. /**
  22902. * Gets a boolean indicating if this manager supports morphing of normals
  22903. */
  22904. readonly supportsNormals: boolean;
  22905. /**
  22906. * Gets a boolean indicating if this manager supports morphing of tangents
  22907. */
  22908. readonly supportsTangents: boolean;
  22909. /**
  22910. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22911. */
  22912. readonly supportsUVs: boolean;
  22913. /**
  22914. * Gets the number of targets stored in this manager
  22915. */
  22916. readonly numTargets: number;
  22917. /**
  22918. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22919. */
  22920. readonly numInfluencers: number;
  22921. /**
  22922. * Gets the list of influences (one per target)
  22923. */
  22924. readonly influences: Float32Array;
  22925. /**
  22926. * Gets the active target at specified index. An active target is a target with an influence > 0
  22927. * @param index defines the index to check
  22928. * @returns the requested target
  22929. */
  22930. getActiveTarget(index: number): MorphTarget;
  22931. /**
  22932. * Gets the target at specified index
  22933. * @param index defines the index to check
  22934. * @returns the requested target
  22935. */
  22936. getTarget(index: number): MorphTarget;
  22937. /**
  22938. * Add a new target to this manager
  22939. * @param target defines the target to add
  22940. */
  22941. addTarget(target: MorphTarget): void;
  22942. /**
  22943. * Removes a target from the manager
  22944. * @param target defines the target to remove
  22945. */
  22946. removeTarget(target: MorphTarget): void;
  22947. /**
  22948. * Serializes the current manager into a Serialization object
  22949. * @returns the serialized object
  22950. */
  22951. serialize(): any;
  22952. private _syncActiveTargets;
  22953. /**
  22954. * Syncrhonize the targets with all the meshes using this morph target manager
  22955. */
  22956. synchronize(): void;
  22957. /**
  22958. * Creates a new MorphTargetManager from serialized data
  22959. * @param serializationObject defines the serialized data
  22960. * @param scene defines the hosting scene
  22961. * @returns the new MorphTargetManager
  22962. */
  22963. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22964. }
  22965. }
  22966. declare module "babylonjs/Meshes/meshLODLevel" {
  22967. import { Mesh } from "babylonjs/Meshes/mesh";
  22968. import { Nullable } from "babylonjs/types";
  22969. /**
  22970. * Class used to represent a specific level of detail of a mesh
  22971. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22972. */
  22973. export class MeshLODLevel {
  22974. /** Defines the distance where this level should start being displayed */
  22975. distance: number;
  22976. /** Defines the mesh to use to render this level */
  22977. mesh: Nullable<Mesh>;
  22978. /**
  22979. * Creates a new LOD level
  22980. * @param distance defines the distance where this level should star being displayed
  22981. * @param mesh defines the mesh to use to render this level
  22982. */
  22983. constructor(
  22984. /** Defines the distance where this level should start being displayed */
  22985. distance: number,
  22986. /** Defines the mesh to use to render this level */
  22987. mesh: Nullable<Mesh>);
  22988. }
  22989. }
  22990. declare module "babylonjs/Meshes/groundMesh" {
  22991. import { Scene } from "babylonjs/scene";
  22992. import { Vector3 } from "babylonjs/Maths/math.vector";
  22993. import { Mesh } from "babylonjs/Meshes/mesh";
  22994. /**
  22995. * Mesh representing the gorund
  22996. */
  22997. export class GroundMesh extends Mesh {
  22998. /** If octree should be generated */
  22999. generateOctree: boolean;
  23000. private _heightQuads;
  23001. /** @hidden */
  23002. _subdivisionsX: number;
  23003. /** @hidden */
  23004. _subdivisionsY: number;
  23005. /** @hidden */
  23006. _width: number;
  23007. /** @hidden */
  23008. _height: number;
  23009. /** @hidden */
  23010. _minX: number;
  23011. /** @hidden */
  23012. _maxX: number;
  23013. /** @hidden */
  23014. _minZ: number;
  23015. /** @hidden */
  23016. _maxZ: number;
  23017. constructor(name: string, scene: Scene);
  23018. /**
  23019. * "GroundMesh"
  23020. * @returns "GroundMesh"
  23021. */
  23022. getClassName(): string;
  23023. /**
  23024. * The minimum of x and y subdivisions
  23025. */
  23026. readonly subdivisions: number;
  23027. /**
  23028. * X subdivisions
  23029. */
  23030. readonly subdivisionsX: number;
  23031. /**
  23032. * Y subdivisions
  23033. */
  23034. readonly subdivisionsY: number;
  23035. /**
  23036. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23037. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23038. * @param chunksCount the number of subdivisions for x and y
  23039. * @param octreeBlocksSize (Default: 32)
  23040. */
  23041. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23042. /**
  23043. * Returns a height (y) value in the Worl system :
  23044. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23045. * @param x x coordinate
  23046. * @param z z coordinate
  23047. * @returns the ground y position if (x, z) are outside the ground surface.
  23048. */
  23049. getHeightAtCoordinates(x: number, z: number): number;
  23050. /**
  23051. * Returns a normalized vector (Vector3) orthogonal to the ground
  23052. * at the ground coordinates (x, z) expressed in the World system.
  23053. * @param x x coordinate
  23054. * @param z z coordinate
  23055. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23056. */
  23057. getNormalAtCoordinates(x: number, z: number): Vector3;
  23058. /**
  23059. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23060. * at the ground coordinates (x, z) expressed in the World system.
  23061. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23062. * @param x x coordinate
  23063. * @param z z coordinate
  23064. * @param ref vector to store the result
  23065. * @returns the GroundMesh.
  23066. */
  23067. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23068. /**
  23069. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23070. * if the ground has been updated.
  23071. * This can be used in the render loop.
  23072. * @returns the GroundMesh.
  23073. */
  23074. updateCoordinateHeights(): GroundMesh;
  23075. private _getFacetAt;
  23076. private _initHeightQuads;
  23077. private _computeHeightQuads;
  23078. /**
  23079. * Serializes this ground mesh
  23080. * @param serializationObject object to write serialization to
  23081. */
  23082. serialize(serializationObject: any): void;
  23083. /**
  23084. * Parses a serialized ground mesh
  23085. * @param parsedMesh the serialized mesh
  23086. * @param scene the scene to create the ground mesh in
  23087. * @returns the created ground mesh
  23088. */
  23089. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23090. }
  23091. }
  23092. declare module "babylonjs/Physics/physicsJoint" {
  23093. import { Vector3 } from "babylonjs/Maths/math.vector";
  23094. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23095. /**
  23096. * Interface for Physics-Joint data
  23097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23098. */
  23099. export interface PhysicsJointData {
  23100. /**
  23101. * The main pivot of the joint
  23102. */
  23103. mainPivot?: Vector3;
  23104. /**
  23105. * The connected pivot of the joint
  23106. */
  23107. connectedPivot?: Vector3;
  23108. /**
  23109. * The main axis of the joint
  23110. */
  23111. mainAxis?: Vector3;
  23112. /**
  23113. * The connected axis of the joint
  23114. */
  23115. connectedAxis?: Vector3;
  23116. /**
  23117. * The collision of the joint
  23118. */
  23119. collision?: boolean;
  23120. /**
  23121. * Native Oimo/Cannon/Energy data
  23122. */
  23123. nativeParams?: any;
  23124. }
  23125. /**
  23126. * This is a holder class for the physics joint created by the physics plugin
  23127. * It holds a set of functions to control the underlying joint
  23128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23129. */
  23130. export class PhysicsJoint {
  23131. /**
  23132. * The type of the physics joint
  23133. */
  23134. type: number;
  23135. /**
  23136. * The data for the physics joint
  23137. */
  23138. jointData: PhysicsJointData;
  23139. private _physicsJoint;
  23140. protected _physicsPlugin: IPhysicsEnginePlugin;
  23141. /**
  23142. * Initializes the physics joint
  23143. * @param type The type of the physics joint
  23144. * @param jointData The data for the physics joint
  23145. */
  23146. constructor(
  23147. /**
  23148. * The type of the physics joint
  23149. */
  23150. type: number,
  23151. /**
  23152. * The data for the physics joint
  23153. */
  23154. jointData: PhysicsJointData);
  23155. /**
  23156. * Gets the physics joint
  23157. */
  23158. /**
  23159. * Sets the physics joint
  23160. */
  23161. physicsJoint: any;
  23162. /**
  23163. * Sets the physics plugin
  23164. */
  23165. physicsPlugin: IPhysicsEnginePlugin;
  23166. /**
  23167. * Execute a function that is physics-plugin specific.
  23168. * @param {Function} func the function that will be executed.
  23169. * It accepts two parameters: the physics world and the physics joint
  23170. */
  23171. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23172. /**
  23173. * Distance-Joint type
  23174. */
  23175. static DistanceJoint: number;
  23176. /**
  23177. * Hinge-Joint type
  23178. */
  23179. static HingeJoint: number;
  23180. /**
  23181. * Ball-and-Socket joint type
  23182. */
  23183. static BallAndSocketJoint: number;
  23184. /**
  23185. * Wheel-Joint type
  23186. */
  23187. static WheelJoint: number;
  23188. /**
  23189. * Slider-Joint type
  23190. */
  23191. static SliderJoint: number;
  23192. /**
  23193. * Prismatic-Joint type
  23194. */
  23195. static PrismaticJoint: number;
  23196. /**
  23197. * Universal-Joint type
  23198. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23199. */
  23200. static UniversalJoint: number;
  23201. /**
  23202. * Hinge-Joint 2 type
  23203. */
  23204. static Hinge2Joint: number;
  23205. /**
  23206. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23207. */
  23208. static PointToPointJoint: number;
  23209. /**
  23210. * Spring-Joint type
  23211. */
  23212. static SpringJoint: number;
  23213. /**
  23214. * Lock-Joint type
  23215. */
  23216. static LockJoint: number;
  23217. }
  23218. /**
  23219. * A class representing a physics distance joint
  23220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23221. */
  23222. export class DistanceJoint extends PhysicsJoint {
  23223. /**
  23224. *
  23225. * @param jointData The data for the Distance-Joint
  23226. */
  23227. constructor(jointData: DistanceJointData);
  23228. /**
  23229. * Update the predefined distance.
  23230. * @param maxDistance The maximum preferred distance
  23231. * @param minDistance The minimum preferred distance
  23232. */
  23233. updateDistance(maxDistance: number, minDistance?: number): void;
  23234. }
  23235. /**
  23236. * Represents a Motor-Enabled Joint
  23237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23238. */
  23239. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23240. /**
  23241. * Initializes the Motor-Enabled Joint
  23242. * @param type The type of the joint
  23243. * @param jointData The physica joint data for the joint
  23244. */
  23245. constructor(type: number, jointData: PhysicsJointData);
  23246. /**
  23247. * Set the motor values.
  23248. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23249. * @param force the force to apply
  23250. * @param maxForce max force for this motor.
  23251. */
  23252. setMotor(force?: number, maxForce?: number): void;
  23253. /**
  23254. * Set the motor's limits.
  23255. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23256. * @param upperLimit The upper limit of the motor
  23257. * @param lowerLimit The lower limit of the motor
  23258. */
  23259. setLimit(upperLimit: number, lowerLimit?: number): void;
  23260. }
  23261. /**
  23262. * This class represents a single physics Hinge-Joint
  23263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23264. */
  23265. export class HingeJoint extends MotorEnabledJoint {
  23266. /**
  23267. * Initializes the Hinge-Joint
  23268. * @param jointData The joint data for the Hinge-Joint
  23269. */
  23270. constructor(jointData: PhysicsJointData);
  23271. /**
  23272. * Set the motor values.
  23273. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23274. * @param {number} force the force to apply
  23275. * @param {number} maxForce max force for this motor.
  23276. */
  23277. setMotor(force?: number, maxForce?: number): void;
  23278. /**
  23279. * Set the motor's limits.
  23280. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23281. * @param upperLimit The upper limit of the motor
  23282. * @param lowerLimit The lower limit of the motor
  23283. */
  23284. setLimit(upperLimit: number, lowerLimit?: number): void;
  23285. }
  23286. /**
  23287. * This class represents a dual hinge physics joint (same as wheel joint)
  23288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23289. */
  23290. export class Hinge2Joint extends MotorEnabledJoint {
  23291. /**
  23292. * Initializes the Hinge2-Joint
  23293. * @param jointData The joint data for the Hinge2-Joint
  23294. */
  23295. constructor(jointData: PhysicsJointData);
  23296. /**
  23297. * Set the motor values.
  23298. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23299. * @param {number} targetSpeed the speed the motor is to reach
  23300. * @param {number} maxForce max force for this motor.
  23301. * @param {motorIndex} the motor's index, 0 or 1.
  23302. */
  23303. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23304. /**
  23305. * Set the motor limits.
  23306. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23307. * @param {number} upperLimit the upper limit
  23308. * @param {number} lowerLimit lower limit
  23309. * @param {motorIndex} the motor's index, 0 or 1.
  23310. */
  23311. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23312. }
  23313. /**
  23314. * Interface for a motor enabled joint
  23315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23316. */
  23317. export interface IMotorEnabledJoint {
  23318. /**
  23319. * Physics joint
  23320. */
  23321. physicsJoint: any;
  23322. /**
  23323. * Sets the motor of the motor-enabled joint
  23324. * @param force The force of the motor
  23325. * @param maxForce The maximum force of the motor
  23326. * @param motorIndex The index of the motor
  23327. */
  23328. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23329. /**
  23330. * Sets the limit of the motor
  23331. * @param upperLimit The upper limit of the motor
  23332. * @param lowerLimit The lower limit of the motor
  23333. * @param motorIndex The index of the motor
  23334. */
  23335. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23336. }
  23337. /**
  23338. * Joint data for a Distance-Joint
  23339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23340. */
  23341. export interface DistanceJointData extends PhysicsJointData {
  23342. /**
  23343. * Max distance the 2 joint objects can be apart
  23344. */
  23345. maxDistance: number;
  23346. }
  23347. /**
  23348. * Joint data from a spring joint
  23349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23350. */
  23351. export interface SpringJointData extends PhysicsJointData {
  23352. /**
  23353. * Length of the spring
  23354. */
  23355. length: number;
  23356. /**
  23357. * Stiffness of the spring
  23358. */
  23359. stiffness: number;
  23360. /**
  23361. * Damping of the spring
  23362. */
  23363. damping: number;
  23364. /** this callback will be called when applying the force to the impostors. */
  23365. forceApplicationCallback: () => void;
  23366. }
  23367. }
  23368. declare module "babylonjs/Physics/physicsRaycastResult" {
  23369. import { Vector3 } from "babylonjs/Maths/math.vector";
  23370. /**
  23371. * Holds the data for the raycast result
  23372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23373. */
  23374. export class PhysicsRaycastResult {
  23375. private _hasHit;
  23376. private _hitDistance;
  23377. private _hitNormalWorld;
  23378. private _hitPointWorld;
  23379. private _rayFromWorld;
  23380. private _rayToWorld;
  23381. /**
  23382. * Gets if there was a hit
  23383. */
  23384. readonly hasHit: boolean;
  23385. /**
  23386. * Gets the distance from the hit
  23387. */
  23388. readonly hitDistance: number;
  23389. /**
  23390. * Gets the hit normal/direction in the world
  23391. */
  23392. readonly hitNormalWorld: Vector3;
  23393. /**
  23394. * Gets the hit point in the world
  23395. */
  23396. readonly hitPointWorld: Vector3;
  23397. /**
  23398. * Gets the ray "start point" of the ray in the world
  23399. */
  23400. readonly rayFromWorld: Vector3;
  23401. /**
  23402. * Gets the ray "end point" of the ray in the world
  23403. */
  23404. readonly rayToWorld: Vector3;
  23405. /**
  23406. * Sets the hit data (normal & point in world space)
  23407. * @param hitNormalWorld defines the normal in world space
  23408. * @param hitPointWorld defines the point in world space
  23409. */
  23410. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23411. /**
  23412. * Sets the distance from the start point to the hit point
  23413. * @param distance
  23414. */
  23415. setHitDistance(distance: number): void;
  23416. /**
  23417. * Calculates the distance manually
  23418. */
  23419. calculateHitDistance(): void;
  23420. /**
  23421. * Resets all the values to default
  23422. * @param from The from point on world space
  23423. * @param to The to point on world space
  23424. */
  23425. reset(from?: Vector3, to?: Vector3): void;
  23426. }
  23427. /**
  23428. * Interface for the size containing width and height
  23429. */
  23430. interface IXYZ {
  23431. /**
  23432. * X
  23433. */
  23434. x: number;
  23435. /**
  23436. * Y
  23437. */
  23438. y: number;
  23439. /**
  23440. * Z
  23441. */
  23442. z: number;
  23443. }
  23444. }
  23445. declare module "babylonjs/Physics/IPhysicsEngine" {
  23446. import { Nullable } from "babylonjs/types";
  23447. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23449. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23450. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23451. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23452. /**
  23453. * Interface used to describe a physics joint
  23454. */
  23455. export interface PhysicsImpostorJoint {
  23456. /** Defines the main impostor to which the joint is linked */
  23457. mainImpostor: PhysicsImpostor;
  23458. /** Defines the impostor that is connected to the main impostor using this joint */
  23459. connectedImpostor: PhysicsImpostor;
  23460. /** Defines the joint itself */
  23461. joint: PhysicsJoint;
  23462. }
  23463. /** @hidden */
  23464. export interface IPhysicsEnginePlugin {
  23465. world: any;
  23466. name: string;
  23467. setGravity(gravity: Vector3): void;
  23468. setTimeStep(timeStep: number): void;
  23469. getTimeStep(): number;
  23470. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23471. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23472. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23473. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23474. removePhysicsBody(impostor: PhysicsImpostor): void;
  23475. generateJoint(joint: PhysicsImpostorJoint): void;
  23476. removeJoint(joint: PhysicsImpostorJoint): void;
  23477. isSupported(): boolean;
  23478. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23479. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23480. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23481. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23482. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23483. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23484. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23485. getBodyMass(impostor: PhysicsImpostor): number;
  23486. getBodyFriction(impostor: PhysicsImpostor): number;
  23487. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23488. getBodyRestitution(impostor: PhysicsImpostor): number;
  23489. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23490. getBodyPressure?(impostor: PhysicsImpostor): number;
  23491. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23492. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23493. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23494. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23495. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23496. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23497. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23498. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23499. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23500. sleepBody(impostor: PhysicsImpostor): void;
  23501. wakeUpBody(impostor: PhysicsImpostor): void;
  23502. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23503. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23504. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23505. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23506. getRadius(impostor: PhysicsImpostor): number;
  23507. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23508. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23509. dispose(): void;
  23510. }
  23511. /**
  23512. * Interface used to define a physics engine
  23513. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23514. */
  23515. export interface IPhysicsEngine {
  23516. /**
  23517. * Gets the gravity vector used by the simulation
  23518. */
  23519. gravity: Vector3;
  23520. /**
  23521. * Sets the gravity vector used by the simulation
  23522. * @param gravity defines the gravity vector to use
  23523. */
  23524. setGravity(gravity: Vector3): void;
  23525. /**
  23526. * Set the time step of the physics engine.
  23527. * Default is 1/60.
  23528. * To slow it down, enter 1/600 for example.
  23529. * To speed it up, 1/30
  23530. * @param newTimeStep the new timestep to apply to this world.
  23531. */
  23532. setTimeStep(newTimeStep: number): void;
  23533. /**
  23534. * Get the time step of the physics engine.
  23535. * @returns the current time step
  23536. */
  23537. getTimeStep(): number;
  23538. /**
  23539. * Release all resources
  23540. */
  23541. dispose(): void;
  23542. /**
  23543. * Gets the name of the current physics plugin
  23544. * @returns the name of the plugin
  23545. */
  23546. getPhysicsPluginName(): string;
  23547. /**
  23548. * Adding a new impostor for the impostor tracking.
  23549. * This will be done by the impostor itself.
  23550. * @param impostor the impostor to add
  23551. */
  23552. addImpostor(impostor: PhysicsImpostor): void;
  23553. /**
  23554. * Remove an impostor from the engine.
  23555. * This impostor and its mesh will not longer be updated by the physics engine.
  23556. * @param impostor the impostor to remove
  23557. */
  23558. removeImpostor(impostor: PhysicsImpostor): void;
  23559. /**
  23560. * Add a joint to the physics engine
  23561. * @param mainImpostor defines the main impostor to which the joint is added.
  23562. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23563. * @param joint defines the joint that will connect both impostors.
  23564. */
  23565. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23566. /**
  23567. * Removes a joint from the simulation
  23568. * @param mainImpostor defines the impostor used with the joint
  23569. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23570. * @param joint defines the joint to remove
  23571. */
  23572. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23573. /**
  23574. * Gets the current plugin used to run the simulation
  23575. * @returns current plugin
  23576. */
  23577. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23578. /**
  23579. * Gets the list of physic impostors
  23580. * @returns an array of PhysicsImpostor
  23581. */
  23582. getImpostors(): Array<PhysicsImpostor>;
  23583. /**
  23584. * Gets the impostor for a physics enabled object
  23585. * @param object defines the object impersonated by the impostor
  23586. * @returns the PhysicsImpostor or null if not found
  23587. */
  23588. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23589. /**
  23590. * Gets the impostor for a physics body object
  23591. * @param body defines physics body used by the impostor
  23592. * @returns the PhysicsImpostor or null if not found
  23593. */
  23594. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23595. /**
  23596. * Does a raycast in the physics world
  23597. * @param from when should the ray start?
  23598. * @param to when should the ray end?
  23599. * @returns PhysicsRaycastResult
  23600. */
  23601. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23602. /**
  23603. * Called by the scene. No need to call it.
  23604. * @param delta defines the timespam between frames
  23605. */
  23606. _step(delta: number): void;
  23607. }
  23608. }
  23609. declare module "babylonjs/Physics/physicsImpostor" {
  23610. import { Nullable, IndicesArray } from "babylonjs/types";
  23611. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23612. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23614. import { Scene } from "babylonjs/scene";
  23615. import { Bone } from "babylonjs/Bones/bone";
  23616. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23617. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23618. import { Space } from "babylonjs/Maths/math.axis";
  23619. /**
  23620. * The interface for the physics imposter parameters
  23621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23622. */
  23623. export interface PhysicsImpostorParameters {
  23624. /**
  23625. * The mass of the physics imposter
  23626. */
  23627. mass: number;
  23628. /**
  23629. * The friction of the physics imposter
  23630. */
  23631. friction?: number;
  23632. /**
  23633. * The coefficient of restitution of the physics imposter
  23634. */
  23635. restitution?: number;
  23636. /**
  23637. * The native options of the physics imposter
  23638. */
  23639. nativeOptions?: any;
  23640. /**
  23641. * Specifies if the parent should be ignored
  23642. */
  23643. ignoreParent?: boolean;
  23644. /**
  23645. * Specifies if bi-directional transformations should be disabled
  23646. */
  23647. disableBidirectionalTransformation?: boolean;
  23648. /**
  23649. * The pressure inside the physics imposter, soft object only
  23650. */
  23651. pressure?: number;
  23652. /**
  23653. * The stiffness the physics imposter, soft object only
  23654. */
  23655. stiffness?: number;
  23656. /**
  23657. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23658. */
  23659. velocityIterations?: number;
  23660. /**
  23661. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23662. */
  23663. positionIterations?: number;
  23664. /**
  23665. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23666. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23667. * Add to fix multiple points
  23668. */
  23669. fixedPoints?: number;
  23670. /**
  23671. * The collision margin around a soft object
  23672. */
  23673. margin?: number;
  23674. /**
  23675. * The collision margin around a soft object
  23676. */
  23677. damping?: number;
  23678. /**
  23679. * The path for a rope based on an extrusion
  23680. */
  23681. path?: any;
  23682. /**
  23683. * The shape of an extrusion used for a rope based on an extrusion
  23684. */
  23685. shape?: any;
  23686. }
  23687. /**
  23688. * Interface for a physics-enabled object
  23689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23690. */
  23691. export interface IPhysicsEnabledObject {
  23692. /**
  23693. * The position of the physics-enabled object
  23694. */
  23695. position: Vector3;
  23696. /**
  23697. * The rotation of the physics-enabled object
  23698. */
  23699. rotationQuaternion: Nullable<Quaternion>;
  23700. /**
  23701. * The scale of the physics-enabled object
  23702. */
  23703. scaling: Vector3;
  23704. /**
  23705. * The rotation of the physics-enabled object
  23706. */
  23707. rotation?: Vector3;
  23708. /**
  23709. * The parent of the physics-enabled object
  23710. */
  23711. parent?: any;
  23712. /**
  23713. * The bounding info of the physics-enabled object
  23714. * @returns The bounding info of the physics-enabled object
  23715. */
  23716. getBoundingInfo(): BoundingInfo;
  23717. /**
  23718. * Computes the world matrix
  23719. * @param force Specifies if the world matrix should be computed by force
  23720. * @returns A world matrix
  23721. */
  23722. computeWorldMatrix(force: boolean): Matrix;
  23723. /**
  23724. * Gets the world matrix
  23725. * @returns A world matrix
  23726. */
  23727. getWorldMatrix?(): Matrix;
  23728. /**
  23729. * Gets the child meshes
  23730. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23731. * @returns An array of abstract meshes
  23732. */
  23733. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23734. /**
  23735. * Gets the vertex data
  23736. * @param kind The type of vertex data
  23737. * @returns A nullable array of numbers, or a float32 array
  23738. */
  23739. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23740. /**
  23741. * Gets the indices from the mesh
  23742. * @returns A nullable array of index arrays
  23743. */
  23744. getIndices?(): Nullable<IndicesArray>;
  23745. /**
  23746. * Gets the scene from the mesh
  23747. * @returns the indices array or null
  23748. */
  23749. getScene?(): Scene;
  23750. /**
  23751. * Gets the absolute position from the mesh
  23752. * @returns the absolute position
  23753. */
  23754. getAbsolutePosition(): Vector3;
  23755. /**
  23756. * Gets the absolute pivot point from the mesh
  23757. * @returns the absolute pivot point
  23758. */
  23759. getAbsolutePivotPoint(): Vector3;
  23760. /**
  23761. * Rotates the mesh
  23762. * @param axis The axis of rotation
  23763. * @param amount The amount of rotation
  23764. * @param space The space of the rotation
  23765. * @returns The rotation transform node
  23766. */
  23767. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23768. /**
  23769. * Translates the mesh
  23770. * @param axis The axis of translation
  23771. * @param distance The distance of translation
  23772. * @param space The space of the translation
  23773. * @returns The transform node
  23774. */
  23775. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23776. /**
  23777. * Sets the absolute position of the mesh
  23778. * @param absolutePosition The absolute position of the mesh
  23779. * @returns The transform node
  23780. */
  23781. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23782. /**
  23783. * Gets the class name of the mesh
  23784. * @returns The class name
  23785. */
  23786. getClassName(): string;
  23787. }
  23788. /**
  23789. * Represents a physics imposter
  23790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23791. */
  23792. export class PhysicsImpostor {
  23793. /**
  23794. * The physics-enabled object used as the physics imposter
  23795. */
  23796. object: IPhysicsEnabledObject;
  23797. /**
  23798. * The type of the physics imposter
  23799. */
  23800. type: number;
  23801. private _options;
  23802. private _scene?;
  23803. /**
  23804. * The default object size of the imposter
  23805. */
  23806. static DEFAULT_OBJECT_SIZE: Vector3;
  23807. /**
  23808. * The identity quaternion of the imposter
  23809. */
  23810. static IDENTITY_QUATERNION: Quaternion;
  23811. /** @hidden */
  23812. _pluginData: any;
  23813. private _physicsEngine;
  23814. private _physicsBody;
  23815. private _bodyUpdateRequired;
  23816. private _onBeforePhysicsStepCallbacks;
  23817. private _onAfterPhysicsStepCallbacks;
  23818. /** @hidden */
  23819. _onPhysicsCollideCallbacks: Array<{
  23820. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23821. otherImpostors: Array<PhysicsImpostor>;
  23822. }>;
  23823. private _deltaPosition;
  23824. private _deltaRotation;
  23825. private _deltaRotationConjugated;
  23826. /** @hidden */
  23827. _isFromLine: boolean;
  23828. private _parent;
  23829. private _isDisposed;
  23830. private static _tmpVecs;
  23831. private static _tmpQuat;
  23832. /**
  23833. * Specifies if the physics imposter is disposed
  23834. */
  23835. readonly isDisposed: boolean;
  23836. /**
  23837. * Gets the mass of the physics imposter
  23838. */
  23839. mass: number;
  23840. /**
  23841. * Gets the coefficient of friction
  23842. */
  23843. /**
  23844. * Sets the coefficient of friction
  23845. */
  23846. friction: number;
  23847. /**
  23848. * Gets the coefficient of restitution
  23849. */
  23850. /**
  23851. * Sets the coefficient of restitution
  23852. */
  23853. restitution: number;
  23854. /**
  23855. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23856. */
  23857. /**
  23858. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23859. */
  23860. pressure: number;
  23861. /**
  23862. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23863. */
  23864. /**
  23865. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23866. */
  23867. stiffness: number;
  23868. /**
  23869. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23870. */
  23871. /**
  23872. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23873. */
  23874. velocityIterations: number;
  23875. /**
  23876. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23877. */
  23878. /**
  23879. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23880. */
  23881. positionIterations: number;
  23882. /**
  23883. * The unique id of the physics imposter
  23884. * set by the physics engine when adding this impostor to the array
  23885. */
  23886. uniqueId: number;
  23887. /**
  23888. * @hidden
  23889. */
  23890. soft: boolean;
  23891. /**
  23892. * @hidden
  23893. */
  23894. segments: number;
  23895. private _joints;
  23896. /**
  23897. * Initializes the physics imposter
  23898. * @param object The physics-enabled object used as the physics imposter
  23899. * @param type The type of the physics imposter
  23900. * @param _options The options for the physics imposter
  23901. * @param _scene The Babylon scene
  23902. */
  23903. constructor(
  23904. /**
  23905. * The physics-enabled object used as the physics imposter
  23906. */
  23907. object: IPhysicsEnabledObject,
  23908. /**
  23909. * The type of the physics imposter
  23910. */
  23911. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23912. /**
  23913. * This function will completly initialize this impostor.
  23914. * It will create a new body - but only if this mesh has no parent.
  23915. * If it has, this impostor will not be used other than to define the impostor
  23916. * of the child mesh.
  23917. * @hidden
  23918. */
  23919. _init(): void;
  23920. private _getPhysicsParent;
  23921. /**
  23922. * Should a new body be generated.
  23923. * @returns boolean specifying if body initialization is required
  23924. */
  23925. isBodyInitRequired(): boolean;
  23926. /**
  23927. * Sets the updated scaling
  23928. * @param updated Specifies if the scaling is updated
  23929. */
  23930. setScalingUpdated(): void;
  23931. /**
  23932. * Force a regeneration of this or the parent's impostor's body.
  23933. * Use under cautious - This will remove all joints already implemented.
  23934. */
  23935. forceUpdate(): void;
  23936. /**
  23937. * Gets the body that holds this impostor. Either its own, or its parent.
  23938. */
  23939. /**
  23940. * Set the physics body. Used mainly by the physics engine/plugin
  23941. */
  23942. physicsBody: any;
  23943. /**
  23944. * Get the parent of the physics imposter
  23945. * @returns Physics imposter or null
  23946. */
  23947. /**
  23948. * Sets the parent of the physics imposter
  23949. */
  23950. parent: Nullable<PhysicsImpostor>;
  23951. /**
  23952. * Resets the update flags
  23953. */
  23954. resetUpdateFlags(): void;
  23955. /**
  23956. * Gets the object extend size
  23957. * @returns the object extend size
  23958. */
  23959. getObjectExtendSize(): Vector3;
  23960. /**
  23961. * Gets the object center
  23962. * @returns The object center
  23963. */
  23964. getObjectCenter(): Vector3;
  23965. /**
  23966. * Get a specific parametes from the options parameter
  23967. * @param paramName The object parameter name
  23968. * @returns The object parameter
  23969. */
  23970. getParam(paramName: string): any;
  23971. /**
  23972. * Sets a specific parameter in the options given to the physics plugin
  23973. * @param paramName The parameter name
  23974. * @param value The value of the parameter
  23975. */
  23976. setParam(paramName: string, value: number): void;
  23977. /**
  23978. * Specifically change the body's mass option. Won't recreate the physics body object
  23979. * @param mass The mass of the physics imposter
  23980. */
  23981. setMass(mass: number): void;
  23982. /**
  23983. * Gets the linear velocity
  23984. * @returns linear velocity or null
  23985. */
  23986. getLinearVelocity(): Nullable<Vector3>;
  23987. /**
  23988. * Sets the linear velocity
  23989. * @param velocity linear velocity or null
  23990. */
  23991. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23992. /**
  23993. * Gets the angular velocity
  23994. * @returns angular velocity or null
  23995. */
  23996. getAngularVelocity(): Nullable<Vector3>;
  23997. /**
  23998. * Sets the angular velocity
  23999. * @param velocity The velocity or null
  24000. */
  24001. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24002. /**
  24003. * Execute a function with the physics plugin native code
  24004. * Provide a function the will have two variables - the world object and the physics body object
  24005. * @param func The function to execute with the physics plugin native code
  24006. */
  24007. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24008. /**
  24009. * Register a function that will be executed before the physics world is stepping forward
  24010. * @param func The function to execute before the physics world is stepped forward
  24011. */
  24012. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24013. /**
  24014. * Unregister a function that will be executed before the physics world is stepping forward
  24015. * @param func The function to execute before the physics world is stepped forward
  24016. */
  24017. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24018. /**
  24019. * Register a function that will be executed after the physics step
  24020. * @param func The function to execute after physics step
  24021. */
  24022. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24023. /**
  24024. * Unregisters a function that will be executed after the physics step
  24025. * @param func The function to execute after physics step
  24026. */
  24027. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24028. /**
  24029. * register a function that will be executed when this impostor collides against a different body
  24030. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24031. * @param func Callback that is executed on collision
  24032. */
  24033. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24034. /**
  24035. * Unregisters the physics imposter on contact
  24036. * @param collideAgainst The physics object to collide against
  24037. * @param func Callback to execute on collision
  24038. */
  24039. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24040. private _tmpQuat;
  24041. private _tmpQuat2;
  24042. /**
  24043. * Get the parent rotation
  24044. * @returns The parent rotation
  24045. */
  24046. getParentsRotation(): Quaternion;
  24047. /**
  24048. * this function is executed by the physics engine.
  24049. */
  24050. beforeStep: () => void;
  24051. /**
  24052. * this function is executed by the physics engine
  24053. */
  24054. afterStep: () => void;
  24055. /**
  24056. * Legacy collision detection event support
  24057. */
  24058. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24059. /**
  24060. * event and body object due to cannon's event-based architecture.
  24061. */
  24062. onCollide: (e: {
  24063. body: any;
  24064. }) => void;
  24065. /**
  24066. * Apply a force
  24067. * @param force The force to apply
  24068. * @param contactPoint The contact point for the force
  24069. * @returns The physics imposter
  24070. */
  24071. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24072. /**
  24073. * Apply an impulse
  24074. * @param force The impulse force
  24075. * @param contactPoint The contact point for the impulse force
  24076. * @returns The physics imposter
  24077. */
  24078. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24079. /**
  24080. * A help function to create a joint
  24081. * @param otherImpostor A physics imposter used to create a joint
  24082. * @param jointType The type of joint
  24083. * @param jointData The data for the joint
  24084. * @returns The physics imposter
  24085. */
  24086. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24087. /**
  24088. * Add a joint to this impostor with a different impostor
  24089. * @param otherImpostor A physics imposter used to add a joint
  24090. * @param joint The joint to add
  24091. * @returns The physics imposter
  24092. */
  24093. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24094. /**
  24095. * Add an anchor to a cloth impostor
  24096. * @param otherImpostor rigid impostor to anchor to
  24097. * @param width ratio across width from 0 to 1
  24098. * @param height ratio up height from 0 to 1
  24099. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24100. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24101. * @returns impostor the soft imposter
  24102. */
  24103. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24104. /**
  24105. * Add a hook to a rope impostor
  24106. * @param otherImpostor rigid impostor to anchor to
  24107. * @param length ratio across rope from 0 to 1
  24108. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24109. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24110. * @returns impostor the rope imposter
  24111. */
  24112. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24113. /**
  24114. * Will keep this body still, in a sleep mode.
  24115. * @returns the physics imposter
  24116. */
  24117. sleep(): PhysicsImpostor;
  24118. /**
  24119. * Wake the body up.
  24120. * @returns The physics imposter
  24121. */
  24122. wakeUp(): PhysicsImpostor;
  24123. /**
  24124. * Clones the physics imposter
  24125. * @param newObject The physics imposter clones to this physics-enabled object
  24126. * @returns A nullable physics imposter
  24127. */
  24128. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24129. /**
  24130. * Disposes the physics imposter
  24131. */
  24132. dispose(): void;
  24133. /**
  24134. * Sets the delta position
  24135. * @param position The delta position amount
  24136. */
  24137. setDeltaPosition(position: Vector3): void;
  24138. /**
  24139. * Sets the delta rotation
  24140. * @param rotation The delta rotation amount
  24141. */
  24142. setDeltaRotation(rotation: Quaternion): void;
  24143. /**
  24144. * Gets the box size of the physics imposter and stores the result in the input parameter
  24145. * @param result Stores the box size
  24146. * @returns The physics imposter
  24147. */
  24148. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24149. /**
  24150. * Gets the radius of the physics imposter
  24151. * @returns Radius of the physics imposter
  24152. */
  24153. getRadius(): number;
  24154. /**
  24155. * Sync a bone with this impostor
  24156. * @param bone The bone to sync to the impostor.
  24157. * @param boneMesh The mesh that the bone is influencing.
  24158. * @param jointPivot The pivot of the joint / bone in local space.
  24159. * @param distToJoint Optional distance from the impostor to the joint.
  24160. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24161. */
  24162. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24163. /**
  24164. * Sync impostor to a bone
  24165. * @param bone The bone that the impostor will be synced to.
  24166. * @param boneMesh The mesh that the bone is influencing.
  24167. * @param jointPivot The pivot of the joint / bone in local space.
  24168. * @param distToJoint Optional distance from the impostor to the joint.
  24169. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24170. * @param boneAxis Optional vector3 axis the bone is aligned with
  24171. */
  24172. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24173. /**
  24174. * No-Imposter type
  24175. */
  24176. static NoImpostor: number;
  24177. /**
  24178. * Sphere-Imposter type
  24179. */
  24180. static SphereImpostor: number;
  24181. /**
  24182. * Box-Imposter type
  24183. */
  24184. static BoxImpostor: number;
  24185. /**
  24186. * Plane-Imposter type
  24187. */
  24188. static PlaneImpostor: number;
  24189. /**
  24190. * Mesh-imposter type
  24191. */
  24192. static MeshImpostor: number;
  24193. /**
  24194. * Capsule-Impostor type (Ammo.js plugin only)
  24195. */
  24196. static CapsuleImpostor: number;
  24197. /**
  24198. * Cylinder-Imposter type
  24199. */
  24200. static CylinderImpostor: number;
  24201. /**
  24202. * Particle-Imposter type
  24203. */
  24204. static ParticleImpostor: number;
  24205. /**
  24206. * Heightmap-Imposter type
  24207. */
  24208. static HeightmapImpostor: number;
  24209. /**
  24210. * ConvexHull-Impostor type (Ammo.js plugin only)
  24211. */
  24212. static ConvexHullImpostor: number;
  24213. /**
  24214. * Rope-Imposter type
  24215. */
  24216. static RopeImpostor: number;
  24217. /**
  24218. * Cloth-Imposter type
  24219. */
  24220. static ClothImpostor: number;
  24221. /**
  24222. * Softbody-Imposter type
  24223. */
  24224. static SoftbodyImpostor: number;
  24225. }
  24226. }
  24227. declare module "babylonjs/Meshes/mesh" {
  24228. import { Observable } from "babylonjs/Misc/observable";
  24229. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24230. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24231. import { Camera } from "babylonjs/Cameras/camera";
  24232. import { Scene } from "babylonjs/scene";
  24233. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24234. import { Color4 } from "babylonjs/Maths/math.color";
  24235. import { Engine } from "babylonjs/Engines/engine";
  24236. import { Node } from "babylonjs/node";
  24237. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24238. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24239. import { Buffer } from "babylonjs/Meshes/buffer";
  24240. import { Geometry } from "babylonjs/Meshes/geometry";
  24241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24243. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24244. import { Effect } from "babylonjs/Materials/effect";
  24245. import { Material } from "babylonjs/Materials/material";
  24246. import { Skeleton } from "babylonjs/Bones/skeleton";
  24247. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24248. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24249. import { Path3D } from "babylonjs/Maths/math.path";
  24250. import { Plane } from "babylonjs/Maths/math.plane";
  24251. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24252. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24253. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24254. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24255. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24256. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24257. /**
  24258. * @hidden
  24259. **/
  24260. export class _CreationDataStorage {
  24261. closePath?: boolean;
  24262. closeArray?: boolean;
  24263. idx: number[];
  24264. dashSize: number;
  24265. gapSize: number;
  24266. path3D: Path3D;
  24267. pathArray: Vector3[][];
  24268. arc: number;
  24269. radius: number;
  24270. cap: number;
  24271. tessellation: number;
  24272. }
  24273. /**
  24274. * @hidden
  24275. **/
  24276. class _InstanceDataStorage {
  24277. visibleInstances: any;
  24278. batchCache: _InstancesBatch;
  24279. instancesBufferSize: number;
  24280. instancesBuffer: Nullable<Buffer>;
  24281. instancesData: Float32Array;
  24282. overridenInstanceCount: number;
  24283. isFrozen: boolean;
  24284. previousBatch: Nullable<_InstancesBatch>;
  24285. hardwareInstancedRendering: boolean;
  24286. sideOrientation: number;
  24287. }
  24288. /**
  24289. * @hidden
  24290. **/
  24291. export class _InstancesBatch {
  24292. mustReturn: boolean;
  24293. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24294. renderSelf: boolean[];
  24295. hardwareInstancedRendering: boolean[];
  24296. }
  24297. /**
  24298. * Class used to represent renderable models
  24299. */
  24300. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24301. /**
  24302. * Mesh side orientation : usually the external or front surface
  24303. */
  24304. static readonly FRONTSIDE: number;
  24305. /**
  24306. * Mesh side orientation : usually the internal or back surface
  24307. */
  24308. static readonly BACKSIDE: number;
  24309. /**
  24310. * Mesh side orientation : both internal and external or front and back surfaces
  24311. */
  24312. static readonly DOUBLESIDE: number;
  24313. /**
  24314. * Mesh side orientation : by default, `FRONTSIDE`
  24315. */
  24316. static readonly DEFAULTSIDE: number;
  24317. /**
  24318. * Mesh cap setting : no cap
  24319. */
  24320. static readonly NO_CAP: number;
  24321. /**
  24322. * Mesh cap setting : one cap at the beginning of the mesh
  24323. */
  24324. static readonly CAP_START: number;
  24325. /**
  24326. * Mesh cap setting : one cap at the end of the mesh
  24327. */
  24328. static readonly CAP_END: number;
  24329. /**
  24330. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24331. */
  24332. static readonly CAP_ALL: number;
  24333. /**
  24334. * Mesh pattern setting : no flip or rotate
  24335. */
  24336. static readonly NO_FLIP: number;
  24337. /**
  24338. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24339. */
  24340. static readonly FLIP_TILE: number;
  24341. /**
  24342. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24343. */
  24344. static readonly ROTATE_TILE: number;
  24345. /**
  24346. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24347. */
  24348. static readonly FLIP_ROW: number;
  24349. /**
  24350. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24351. */
  24352. static readonly ROTATE_ROW: number;
  24353. /**
  24354. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24355. */
  24356. static readonly FLIP_N_ROTATE_TILE: number;
  24357. /**
  24358. * Mesh pattern setting : rotate pattern and rotate
  24359. */
  24360. static readonly FLIP_N_ROTATE_ROW: number;
  24361. /**
  24362. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24363. */
  24364. static readonly CENTER: number;
  24365. /**
  24366. * Mesh tile positioning : part tiles on left
  24367. */
  24368. static readonly LEFT: number;
  24369. /**
  24370. * Mesh tile positioning : part tiles on right
  24371. */
  24372. static readonly RIGHT: number;
  24373. /**
  24374. * Mesh tile positioning : part tiles on top
  24375. */
  24376. static readonly TOP: number;
  24377. /**
  24378. * Mesh tile positioning : part tiles on bottom
  24379. */
  24380. static readonly BOTTOM: number;
  24381. /**
  24382. * Gets the default side orientation.
  24383. * @param orientation the orientation to value to attempt to get
  24384. * @returns the default orientation
  24385. * @hidden
  24386. */
  24387. static _GetDefaultSideOrientation(orientation?: number): number;
  24388. private _internalMeshDataInfo;
  24389. /**
  24390. * An event triggered before rendering the mesh
  24391. */
  24392. readonly onBeforeRenderObservable: Observable<Mesh>;
  24393. /**
  24394. * An event triggered before binding the mesh
  24395. */
  24396. readonly onBeforeBindObservable: Observable<Mesh>;
  24397. /**
  24398. * An event triggered after rendering the mesh
  24399. */
  24400. readonly onAfterRenderObservable: Observable<Mesh>;
  24401. /**
  24402. * An event triggered before drawing the mesh
  24403. */
  24404. readonly onBeforeDrawObservable: Observable<Mesh>;
  24405. private _onBeforeDrawObserver;
  24406. /**
  24407. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24408. */
  24409. onBeforeDraw: () => void;
  24410. readonly hasInstances: boolean;
  24411. /**
  24412. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24413. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24414. */
  24415. delayLoadState: number;
  24416. /**
  24417. * Gets the list of instances created from this mesh
  24418. * it is not supposed to be modified manually.
  24419. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24420. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24421. */
  24422. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24423. /**
  24424. * Gets the file containing delay loading data for this mesh
  24425. */
  24426. delayLoadingFile: string;
  24427. /** @hidden */
  24428. _binaryInfo: any;
  24429. /**
  24430. * User defined function used to change how LOD level selection is done
  24431. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24432. */
  24433. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24434. /**
  24435. * Gets or sets the morph target manager
  24436. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24437. */
  24438. morphTargetManager: Nullable<MorphTargetManager>;
  24439. /** @hidden */
  24440. _creationDataStorage: Nullable<_CreationDataStorage>;
  24441. /** @hidden */
  24442. _geometry: Nullable<Geometry>;
  24443. /** @hidden */
  24444. _delayInfo: Array<string>;
  24445. /** @hidden */
  24446. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24447. /** @hidden */
  24448. _instanceDataStorage: _InstanceDataStorage;
  24449. private _effectiveMaterial;
  24450. /** @hidden */
  24451. _shouldGenerateFlatShading: boolean;
  24452. /** @hidden */
  24453. _originalBuilderSideOrientation: number;
  24454. /**
  24455. * Use this property to change the original side orientation defined at construction time
  24456. */
  24457. overrideMaterialSideOrientation: Nullable<number>;
  24458. /**
  24459. * Gets the source mesh (the one used to clone this one from)
  24460. */
  24461. readonly source: Nullable<Mesh>;
  24462. /**
  24463. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24464. */
  24465. isUnIndexed: boolean;
  24466. /**
  24467. * @constructor
  24468. * @param name The value used by scene.getMeshByName() to do a lookup.
  24469. * @param scene The scene to add this mesh to.
  24470. * @param parent The parent of this mesh, if it has one
  24471. * @param source An optional Mesh from which geometry is shared, cloned.
  24472. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24473. * When false, achieved by calling a clone(), also passing False.
  24474. * This will make creation of children, recursive.
  24475. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24476. */
  24477. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24478. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24479. /**
  24480. * Gets the class name
  24481. * @returns the string "Mesh".
  24482. */
  24483. getClassName(): string;
  24484. /** @hidden */
  24485. readonly _isMesh: boolean;
  24486. /**
  24487. * Returns a description of this mesh
  24488. * @param fullDetails define if full details about this mesh must be used
  24489. * @returns a descriptive string representing this mesh
  24490. */
  24491. toString(fullDetails?: boolean): string;
  24492. /** @hidden */
  24493. _unBindEffect(): void;
  24494. /**
  24495. * Gets a boolean indicating if this mesh has LOD
  24496. */
  24497. readonly hasLODLevels: boolean;
  24498. /**
  24499. * Gets the list of MeshLODLevel associated with the current mesh
  24500. * @returns an array of MeshLODLevel
  24501. */
  24502. getLODLevels(): MeshLODLevel[];
  24503. private _sortLODLevels;
  24504. /**
  24505. * Add a mesh as LOD level triggered at the given distance.
  24506. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24507. * @param distance The distance from the center of the object to show this level
  24508. * @param mesh The mesh to be added as LOD level (can be null)
  24509. * @return This mesh (for chaining)
  24510. */
  24511. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24512. /**
  24513. * Returns the LOD level mesh at the passed distance or null if not found.
  24514. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24515. * @param distance The distance from the center of the object to show this level
  24516. * @returns a Mesh or `null`
  24517. */
  24518. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24519. /**
  24520. * Remove a mesh from the LOD array
  24521. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24522. * @param mesh defines the mesh to be removed
  24523. * @return This mesh (for chaining)
  24524. */
  24525. removeLODLevel(mesh: Mesh): Mesh;
  24526. /**
  24527. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24528. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24529. * @param camera defines the camera to use to compute distance
  24530. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24531. * @return This mesh (for chaining)
  24532. */
  24533. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24534. /**
  24535. * Gets the mesh internal Geometry object
  24536. */
  24537. readonly geometry: Nullable<Geometry>;
  24538. /**
  24539. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24540. * @returns the total number of vertices
  24541. */
  24542. getTotalVertices(): number;
  24543. /**
  24544. * Returns the content of an associated vertex buffer
  24545. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24546. * - VertexBuffer.PositionKind
  24547. * - VertexBuffer.UVKind
  24548. * - VertexBuffer.UV2Kind
  24549. * - VertexBuffer.UV3Kind
  24550. * - VertexBuffer.UV4Kind
  24551. * - VertexBuffer.UV5Kind
  24552. * - VertexBuffer.UV6Kind
  24553. * - VertexBuffer.ColorKind
  24554. * - VertexBuffer.MatricesIndicesKind
  24555. * - VertexBuffer.MatricesIndicesExtraKind
  24556. * - VertexBuffer.MatricesWeightsKind
  24557. * - VertexBuffer.MatricesWeightsExtraKind
  24558. * @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
  24559. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24560. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24561. */
  24562. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24563. /**
  24564. * Returns the mesh VertexBuffer object from the requested `kind`
  24565. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24566. * - VertexBuffer.PositionKind
  24567. * - VertexBuffer.NormalKind
  24568. * - VertexBuffer.UVKind
  24569. * - VertexBuffer.UV2Kind
  24570. * - VertexBuffer.UV3Kind
  24571. * - VertexBuffer.UV4Kind
  24572. * - VertexBuffer.UV5Kind
  24573. * - VertexBuffer.UV6Kind
  24574. * - VertexBuffer.ColorKind
  24575. * - VertexBuffer.MatricesIndicesKind
  24576. * - VertexBuffer.MatricesIndicesExtraKind
  24577. * - VertexBuffer.MatricesWeightsKind
  24578. * - VertexBuffer.MatricesWeightsExtraKind
  24579. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24580. */
  24581. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24582. /**
  24583. * Tests if a specific vertex buffer is associated with this mesh
  24584. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24585. * - VertexBuffer.PositionKind
  24586. * - VertexBuffer.NormalKind
  24587. * - VertexBuffer.UVKind
  24588. * - VertexBuffer.UV2Kind
  24589. * - VertexBuffer.UV3Kind
  24590. * - VertexBuffer.UV4Kind
  24591. * - VertexBuffer.UV5Kind
  24592. * - VertexBuffer.UV6Kind
  24593. * - VertexBuffer.ColorKind
  24594. * - VertexBuffer.MatricesIndicesKind
  24595. * - VertexBuffer.MatricesIndicesExtraKind
  24596. * - VertexBuffer.MatricesWeightsKind
  24597. * - VertexBuffer.MatricesWeightsExtraKind
  24598. * @returns a boolean
  24599. */
  24600. isVerticesDataPresent(kind: string): boolean;
  24601. /**
  24602. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24603. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24604. * - VertexBuffer.PositionKind
  24605. * - VertexBuffer.UVKind
  24606. * - VertexBuffer.UV2Kind
  24607. * - VertexBuffer.UV3Kind
  24608. * - VertexBuffer.UV4Kind
  24609. * - VertexBuffer.UV5Kind
  24610. * - VertexBuffer.UV6Kind
  24611. * - VertexBuffer.ColorKind
  24612. * - VertexBuffer.MatricesIndicesKind
  24613. * - VertexBuffer.MatricesIndicesExtraKind
  24614. * - VertexBuffer.MatricesWeightsKind
  24615. * - VertexBuffer.MatricesWeightsExtraKind
  24616. * @returns a boolean
  24617. */
  24618. isVertexBufferUpdatable(kind: string): boolean;
  24619. /**
  24620. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24621. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24622. * - VertexBuffer.PositionKind
  24623. * - VertexBuffer.NormalKind
  24624. * - VertexBuffer.UVKind
  24625. * - VertexBuffer.UV2Kind
  24626. * - VertexBuffer.UV3Kind
  24627. * - VertexBuffer.UV4Kind
  24628. * - VertexBuffer.UV5Kind
  24629. * - VertexBuffer.UV6Kind
  24630. * - VertexBuffer.ColorKind
  24631. * - VertexBuffer.MatricesIndicesKind
  24632. * - VertexBuffer.MatricesIndicesExtraKind
  24633. * - VertexBuffer.MatricesWeightsKind
  24634. * - VertexBuffer.MatricesWeightsExtraKind
  24635. * @returns an array of strings
  24636. */
  24637. getVerticesDataKinds(): string[];
  24638. /**
  24639. * Returns a positive integer : the total number of indices in this mesh geometry.
  24640. * @returns the numner of indices or zero if the mesh has no geometry.
  24641. */
  24642. getTotalIndices(): number;
  24643. /**
  24644. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24645. * @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.
  24646. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24647. * @returns the indices array or an empty array if the mesh has no geometry
  24648. */
  24649. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24650. readonly isBlocked: boolean;
  24651. /**
  24652. * Determine if the current mesh is ready to be rendered
  24653. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24654. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24655. * @returns true if all associated assets are ready (material, textures, shaders)
  24656. */
  24657. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24658. /**
  24659. * 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.
  24660. */
  24661. readonly areNormalsFrozen: boolean;
  24662. /**
  24663. * 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.
  24664. * @returns the current mesh
  24665. */
  24666. freezeNormals(): Mesh;
  24667. /**
  24668. * 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
  24669. * @returns the current mesh
  24670. */
  24671. unfreezeNormals(): Mesh;
  24672. /**
  24673. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24674. */
  24675. overridenInstanceCount: number;
  24676. /** @hidden */
  24677. _preActivate(): Mesh;
  24678. /** @hidden */
  24679. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24680. /** @hidden */
  24681. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24682. /**
  24683. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24684. * This means the mesh underlying bounding box and sphere are recomputed.
  24685. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24686. * @returns the current mesh
  24687. */
  24688. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24689. /** @hidden */
  24690. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24691. /**
  24692. * This function will subdivide the mesh into multiple submeshes
  24693. * @param count defines the expected number of submeshes
  24694. */
  24695. subdivide(count: number): void;
  24696. /**
  24697. * Copy a FloatArray into a specific associated vertex buffer
  24698. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24699. * - VertexBuffer.PositionKind
  24700. * - VertexBuffer.UVKind
  24701. * - VertexBuffer.UV2Kind
  24702. * - VertexBuffer.UV3Kind
  24703. * - VertexBuffer.UV4Kind
  24704. * - VertexBuffer.UV5Kind
  24705. * - VertexBuffer.UV6Kind
  24706. * - VertexBuffer.ColorKind
  24707. * - VertexBuffer.MatricesIndicesKind
  24708. * - VertexBuffer.MatricesIndicesExtraKind
  24709. * - VertexBuffer.MatricesWeightsKind
  24710. * - VertexBuffer.MatricesWeightsExtraKind
  24711. * @param data defines the data source
  24712. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24713. * @param stride defines the data stride size (can be null)
  24714. * @returns the current mesh
  24715. */
  24716. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24717. /**
  24718. * Delete a vertex buffer associated with this mesh
  24719. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24720. * - VertexBuffer.PositionKind
  24721. * - VertexBuffer.UVKind
  24722. * - VertexBuffer.UV2Kind
  24723. * - VertexBuffer.UV3Kind
  24724. * - VertexBuffer.UV4Kind
  24725. * - VertexBuffer.UV5Kind
  24726. * - VertexBuffer.UV6Kind
  24727. * - VertexBuffer.ColorKind
  24728. * - VertexBuffer.MatricesIndicesKind
  24729. * - VertexBuffer.MatricesIndicesExtraKind
  24730. * - VertexBuffer.MatricesWeightsKind
  24731. * - VertexBuffer.MatricesWeightsExtraKind
  24732. */
  24733. removeVerticesData(kind: string): void;
  24734. /**
  24735. * Flags an associated vertex buffer as updatable
  24736. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24737. * - VertexBuffer.PositionKind
  24738. * - VertexBuffer.UVKind
  24739. * - VertexBuffer.UV2Kind
  24740. * - VertexBuffer.UV3Kind
  24741. * - VertexBuffer.UV4Kind
  24742. * - VertexBuffer.UV5Kind
  24743. * - VertexBuffer.UV6Kind
  24744. * - VertexBuffer.ColorKind
  24745. * - VertexBuffer.MatricesIndicesKind
  24746. * - VertexBuffer.MatricesIndicesExtraKind
  24747. * - VertexBuffer.MatricesWeightsKind
  24748. * - VertexBuffer.MatricesWeightsExtraKind
  24749. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24750. */
  24751. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24752. /**
  24753. * Sets the mesh global Vertex Buffer
  24754. * @param buffer defines the buffer to use
  24755. * @returns the current mesh
  24756. */
  24757. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24758. /**
  24759. * Update a specific associated vertex buffer
  24760. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24761. * - VertexBuffer.PositionKind
  24762. * - VertexBuffer.UVKind
  24763. * - VertexBuffer.UV2Kind
  24764. * - VertexBuffer.UV3Kind
  24765. * - VertexBuffer.UV4Kind
  24766. * - VertexBuffer.UV5Kind
  24767. * - VertexBuffer.UV6Kind
  24768. * - VertexBuffer.ColorKind
  24769. * - VertexBuffer.MatricesIndicesKind
  24770. * - VertexBuffer.MatricesIndicesExtraKind
  24771. * - VertexBuffer.MatricesWeightsKind
  24772. * - VertexBuffer.MatricesWeightsExtraKind
  24773. * @param data defines the data source
  24774. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24775. * @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)
  24776. * @returns the current mesh
  24777. */
  24778. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24779. /**
  24780. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24781. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24782. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24783. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24784. * @returns the current mesh
  24785. */
  24786. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24787. /**
  24788. * Creates a un-shared specific occurence of the geometry for the mesh.
  24789. * @returns the current mesh
  24790. */
  24791. makeGeometryUnique(): Mesh;
  24792. /**
  24793. * Set the index buffer of this mesh
  24794. * @param indices defines the source data
  24795. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24796. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24797. * @returns the current mesh
  24798. */
  24799. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24800. /**
  24801. * Update the current index buffer
  24802. * @param indices defines the source data
  24803. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24804. * @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)
  24805. * @returns the current mesh
  24806. */
  24807. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24808. /**
  24809. * Invert the geometry to move from a right handed system to a left handed one.
  24810. * @returns the current mesh
  24811. */
  24812. toLeftHanded(): Mesh;
  24813. /** @hidden */
  24814. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24815. /** @hidden */
  24816. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24817. /**
  24818. * Registers for this mesh a javascript function called just before the rendering process
  24819. * @param func defines the function to call before rendering this mesh
  24820. * @returns the current mesh
  24821. */
  24822. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24823. /**
  24824. * Disposes a previously registered javascript function called before the rendering
  24825. * @param func defines the function to remove
  24826. * @returns the current mesh
  24827. */
  24828. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24829. /**
  24830. * Registers for this mesh a javascript function called just after the rendering is complete
  24831. * @param func defines the function to call after rendering this mesh
  24832. * @returns the current mesh
  24833. */
  24834. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24835. /**
  24836. * Disposes a previously registered javascript function called after the rendering.
  24837. * @param func defines the function to remove
  24838. * @returns the current mesh
  24839. */
  24840. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24841. /** @hidden */
  24842. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24843. /** @hidden */
  24844. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24845. /** @hidden */
  24846. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24847. /** @hidden */
  24848. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24849. /** @hidden */
  24850. _rebuild(): void;
  24851. /** @hidden */
  24852. _freeze(): void;
  24853. /** @hidden */
  24854. _unFreeze(): void;
  24855. /**
  24856. * 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
  24857. * @param subMesh defines the subMesh to render
  24858. * @param enableAlphaMode defines if alpha mode can be changed
  24859. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24860. * @returns the current mesh
  24861. */
  24862. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24863. private _onBeforeDraw;
  24864. /**
  24865. * Renormalize the mesh and patch it up if there are no weights
  24866. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24867. * However in the case of zero weights then we set just a single influence to 1.
  24868. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24869. */
  24870. cleanMatrixWeights(): void;
  24871. private normalizeSkinFourWeights;
  24872. private normalizeSkinWeightsAndExtra;
  24873. /**
  24874. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24875. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24876. * the user know there was an issue with importing the mesh
  24877. * @returns a validation object with skinned, valid and report string
  24878. */
  24879. validateSkinning(): {
  24880. skinned: boolean;
  24881. valid: boolean;
  24882. report: string;
  24883. };
  24884. /** @hidden */
  24885. _checkDelayState(): Mesh;
  24886. private _queueLoad;
  24887. /**
  24888. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24889. * A mesh is in the frustum if its bounding box intersects the frustum
  24890. * @param frustumPlanes defines the frustum to test
  24891. * @returns true if the mesh is in the frustum planes
  24892. */
  24893. isInFrustum(frustumPlanes: Plane[]): boolean;
  24894. /**
  24895. * Sets the mesh material by the material or multiMaterial `id` property
  24896. * @param id is a string identifying the material or the multiMaterial
  24897. * @returns the current mesh
  24898. */
  24899. setMaterialByID(id: string): Mesh;
  24900. /**
  24901. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24902. * @returns an array of IAnimatable
  24903. */
  24904. getAnimatables(): IAnimatable[];
  24905. /**
  24906. * Modifies the mesh geometry according to the passed transformation matrix.
  24907. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24908. * The mesh normals are modified using the same transformation.
  24909. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24910. * @param transform defines the transform matrix to use
  24911. * @see http://doc.babylonjs.com/resources/baking_transformations
  24912. * @returns the current mesh
  24913. */
  24914. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24915. /**
  24916. * Modifies the mesh geometry according to its own current World Matrix.
  24917. * The mesh World Matrix is then reset.
  24918. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24919. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24920. * @see http://doc.babylonjs.com/resources/baking_transformations
  24921. * @returns the current mesh
  24922. */
  24923. bakeCurrentTransformIntoVertices(): Mesh;
  24924. /** @hidden */
  24925. readonly _positions: Nullable<Vector3[]>;
  24926. /** @hidden */
  24927. _resetPointsArrayCache(): Mesh;
  24928. /** @hidden */
  24929. _generatePointsArray(): boolean;
  24930. /**
  24931. * Returns a new Mesh object generated from the current mesh properties.
  24932. * This method must not get confused with createInstance()
  24933. * @param name is a string, the name given to the new mesh
  24934. * @param newParent can be any Node object (default `null`)
  24935. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24936. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24937. * @returns a new mesh
  24938. */
  24939. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24940. /**
  24941. * Releases resources associated with this mesh.
  24942. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24943. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24944. */
  24945. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24946. /** @hidden */
  24947. _disposeInstanceSpecificData(): void;
  24948. /**
  24949. * Modifies the mesh geometry according to a displacement map.
  24950. * 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.
  24951. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24952. * @param url is a string, the URL from the image file is to be downloaded.
  24953. * @param minHeight is the lower limit of the displacement.
  24954. * @param maxHeight is the upper limit of the displacement.
  24955. * @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.
  24956. * @param uvOffset is an optional vector2 used to offset UV.
  24957. * @param uvScale is an optional vector2 used to scale UV.
  24958. * @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.
  24959. * @returns the Mesh.
  24960. */
  24961. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24962. /**
  24963. * Modifies the mesh geometry according to a displacementMap buffer.
  24964. * 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.
  24965. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24966. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24967. * @param heightMapWidth is the width of the buffer image.
  24968. * @param heightMapHeight is the height of the buffer image.
  24969. * @param minHeight is the lower limit of the displacement.
  24970. * @param maxHeight is the upper limit of the displacement.
  24971. * @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.
  24972. * @param uvOffset is an optional vector2 used to offset UV.
  24973. * @param uvScale is an optional vector2 used to scale UV.
  24974. * @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.
  24975. * @returns the Mesh.
  24976. */
  24977. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24978. /**
  24979. * Modify the mesh to get a flat shading rendering.
  24980. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24981. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24982. * @returns current mesh
  24983. */
  24984. convertToFlatShadedMesh(): Mesh;
  24985. /**
  24986. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24987. * In other words, more vertices, no more indices and a single bigger VBO.
  24988. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24989. * @returns current mesh
  24990. */
  24991. convertToUnIndexedMesh(): Mesh;
  24992. /**
  24993. * Inverses facet orientations.
  24994. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24995. * @param flipNormals will also inverts the normals
  24996. * @returns current mesh
  24997. */
  24998. flipFaces(flipNormals?: boolean): Mesh;
  24999. /**
  25000. * Increase the number of facets and hence vertices in a mesh
  25001. * Vertex normals are interpolated from existing vertex normals
  25002. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25003. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25004. */
  25005. increaseVertices(numberPerEdge: number): void;
  25006. /**
  25007. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25008. * This will undo any application of covertToFlatShadedMesh
  25009. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25010. */
  25011. forceSharedVertices(): void;
  25012. /** @hidden */
  25013. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25014. /** @hidden */
  25015. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25016. /**
  25017. * Creates a new InstancedMesh object from the mesh model.
  25018. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25019. * @param name defines the name of the new instance
  25020. * @returns a new InstancedMesh
  25021. */
  25022. createInstance(name: string): InstancedMesh;
  25023. /**
  25024. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25025. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25026. * @returns the current mesh
  25027. */
  25028. synchronizeInstances(): Mesh;
  25029. /**
  25030. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25031. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25032. * This should be used together with the simplification to avoid disappearing triangles.
  25033. * @param successCallback an optional success callback to be called after the optimization finished.
  25034. * @returns the current mesh
  25035. */
  25036. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25037. /**
  25038. * Serialize current mesh
  25039. * @param serializationObject defines the object which will receive the serialization data
  25040. */
  25041. serialize(serializationObject: any): void;
  25042. /** @hidden */
  25043. _syncGeometryWithMorphTargetManager(): void;
  25044. /** @hidden */
  25045. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25046. /**
  25047. * Returns a new Mesh object parsed from the source provided.
  25048. * @param parsedMesh is the source
  25049. * @param scene defines the hosting scene
  25050. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25051. * @returns a new Mesh
  25052. */
  25053. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25054. /**
  25055. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25056. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25057. * @param name defines the name of the mesh to create
  25058. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25059. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25060. * @param closePath creates a seam between the first and the last points of each path of the path array
  25061. * @param offset is taken in account only if the `pathArray` is containing a single path
  25062. * @param scene defines the hosting scene
  25063. * @param updatable defines if the mesh must be flagged as updatable
  25064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25065. * @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)
  25066. * @returns a new Mesh
  25067. */
  25068. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25069. /**
  25070. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25071. * @param name defines the name of the mesh to create
  25072. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25073. * @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
  25074. * @param scene defines the hosting scene
  25075. * @param updatable defines if the mesh must be flagged as updatable
  25076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25077. * @returns a new Mesh
  25078. */
  25079. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25080. /**
  25081. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25082. * @param name defines the name of the mesh to create
  25083. * @param size sets the size (float) of each box side (default 1)
  25084. * @param scene defines the hosting scene
  25085. * @param updatable defines if the mesh must be flagged as updatable
  25086. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25087. * @returns a new Mesh
  25088. */
  25089. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25090. /**
  25091. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25092. * @param name defines the name of the mesh to create
  25093. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25094. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25095. * @param scene defines the hosting scene
  25096. * @param updatable defines if the mesh must be flagged as updatable
  25097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25098. * @returns a new Mesh
  25099. */
  25100. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25101. /**
  25102. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25103. * @param name defines the name of the mesh to create
  25104. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25105. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25106. * @param scene defines the hosting scene
  25107. * @returns a new Mesh
  25108. */
  25109. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25110. /**
  25111. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25112. * @param name defines the name of the mesh to create
  25113. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25114. * @param diameterTop set the top cap diameter (floats, default 1)
  25115. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25116. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25117. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25118. * @param scene defines the hosting scene
  25119. * @param updatable defines if the mesh must be flagged as updatable
  25120. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25121. * @returns a new Mesh
  25122. */
  25123. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25124. /**
  25125. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25126. * @param name defines the name of the mesh to create
  25127. * @param diameter sets the diameter size (float) of the torus (default 1)
  25128. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25129. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25130. * @param scene defines the hosting scene
  25131. * @param updatable defines if the mesh must be flagged as updatable
  25132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25133. * @returns a new Mesh
  25134. */
  25135. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25136. /**
  25137. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25138. * @param name defines the name of the mesh to create
  25139. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25140. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25141. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25142. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25143. * @param p the number of windings on X axis (positive integers, default 2)
  25144. * @param q the number of windings on Y axis (positive integers, default 3)
  25145. * @param scene defines the hosting scene
  25146. * @param updatable defines if the mesh must be flagged as updatable
  25147. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25148. * @returns a new Mesh
  25149. */
  25150. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25151. /**
  25152. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25153. * @param name defines the name of the mesh to create
  25154. * @param points is an array successive Vector3
  25155. * @param scene defines the hosting scene
  25156. * @param updatable defines if the mesh must be flagged as updatable
  25157. * @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).
  25158. * @returns a new Mesh
  25159. */
  25160. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25161. /**
  25162. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25163. * @param name defines the name of the mesh to create
  25164. * @param points is an array successive Vector3
  25165. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25166. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25167. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25168. * @param scene defines the hosting scene
  25169. * @param updatable defines if the mesh must be flagged as updatable
  25170. * @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)
  25171. * @returns a new Mesh
  25172. */
  25173. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25174. /**
  25175. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25176. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25177. * 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.
  25178. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25179. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25180. * Remember you can only change the shape positions, not their number when updating a polygon.
  25181. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25182. * @param name defines the name of the mesh to create
  25183. * @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
  25184. * @param scene defines the hosting scene
  25185. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25186. * @param updatable defines if the mesh must be flagged as updatable
  25187. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25188. * @param earcutInjection can be used to inject your own earcut reference
  25189. * @returns a new Mesh
  25190. */
  25191. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25192. /**
  25193. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25194. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25195. * @param name defines the name of the mesh to create
  25196. * @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
  25197. * @param depth defines the height of extrusion
  25198. * @param scene defines the hosting scene
  25199. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25200. * @param updatable defines if the mesh must be flagged as updatable
  25201. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25202. * @param earcutInjection can be used to inject your own earcut reference
  25203. * @returns a new Mesh
  25204. */
  25205. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25206. /**
  25207. * Creates an extruded shape mesh.
  25208. * 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
  25209. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25210. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25211. * @param name defines the name of the mesh to create
  25212. * @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
  25213. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25214. * @param scale is the value to scale the shape
  25215. * @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
  25216. * @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
  25217. * @param scene defines the hosting scene
  25218. * @param updatable defines if the mesh must be flagged as updatable
  25219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25220. * @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)
  25221. * @returns a new Mesh
  25222. */
  25223. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25224. /**
  25225. * Creates an custom extruded shape mesh.
  25226. * The custom extrusion is a parametric shape.
  25227. * It has no predefined shape. Its final shape will depend on the input parameters.
  25228. * Please consider using the same method from the MeshBuilder class instead
  25229. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25230. * @param name defines the name of the mesh to create
  25231. * @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
  25232. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25233. * @param scaleFunction is a custom Javascript function called on each path point
  25234. * @param rotationFunction is a custom Javascript function called on each path point
  25235. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25236. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25237. * @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
  25238. * @param scene defines the hosting scene
  25239. * @param updatable defines if the mesh must be flagged as updatable
  25240. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25241. * @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)
  25242. * @returns a new Mesh
  25243. */
  25244. 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;
  25245. /**
  25246. * Creates lathe mesh.
  25247. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25248. * Please consider using the same method from the MeshBuilder class instead
  25249. * @param name defines the name of the mesh to create
  25250. * @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
  25251. * @param radius is the radius value of the lathe
  25252. * @param tessellation is the side number of the lathe.
  25253. * @param scene defines the hosting scene
  25254. * @param updatable defines if the mesh must be flagged as updatable
  25255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25256. * @returns a new Mesh
  25257. */
  25258. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25259. /**
  25260. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25261. * @param name defines the name of the mesh to create
  25262. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25263. * @param scene defines the hosting scene
  25264. * @param updatable defines if the mesh must be flagged as updatable
  25265. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25266. * @returns a new Mesh
  25267. */
  25268. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25269. /**
  25270. * Creates a ground mesh.
  25271. * Please consider using the same method from the MeshBuilder class instead
  25272. * @param name defines the name of the mesh to create
  25273. * @param width set the width of the ground
  25274. * @param height set the height of the ground
  25275. * @param subdivisions sets the number of subdivisions per side
  25276. * @param scene defines the hosting scene
  25277. * @param updatable defines if the mesh must be flagged as updatable
  25278. * @returns a new Mesh
  25279. */
  25280. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25281. /**
  25282. * Creates a tiled ground mesh.
  25283. * Please consider using the same method from the MeshBuilder class instead
  25284. * @param name defines the name of the mesh to create
  25285. * @param xmin set the ground minimum X coordinate
  25286. * @param zmin set the ground minimum Y coordinate
  25287. * @param xmax set the ground maximum X coordinate
  25288. * @param zmax set the ground maximum Z coordinate
  25289. * @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
  25290. * @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
  25291. * @param scene defines the hosting scene
  25292. * @param updatable defines if the mesh must be flagged as updatable
  25293. * @returns a new Mesh
  25294. */
  25295. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25296. w: number;
  25297. h: number;
  25298. }, precision: {
  25299. w: number;
  25300. h: number;
  25301. }, scene: Scene, updatable?: boolean): Mesh;
  25302. /**
  25303. * Creates a ground mesh from a height map.
  25304. * Please consider using the same method from the MeshBuilder class instead
  25305. * @see http://doc.babylonjs.com/babylon101/height_map
  25306. * @param name defines the name of the mesh to create
  25307. * @param url sets the URL of the height map image resource
  25308. * @param width set the ground width size
  25309. * @param height set the ground height size
  25310. * @param subdivisions sets the number of subdivision per side
  25311. * @param minHeight is the minimum altitude on the ground
  25312. * @param maxHeight is the maximum altitude on the ground
  25313. * @param scene defines the hosting scene
  25314. * @param updatable defines if the mesh must be flagged as updatable
  25315. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25316. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25317. * @returns a new Mesh
  25318. */
  25319. 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;
  25320. /**
  25321. * Creates a tube mesh.
  25322. * The tube is a parametric shape.
  25323. * It has no predefined shape. Its final shape will depend on the input parameters.
  25324. * Please consider using the same method from the MeshBuilder class instead
  25325. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25326. * @param name defines the name of the mesh to create
  25327. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25328. * @param radius sets the tube radius size
  25329. * @param tessellation is the number of sides on the tubular surface
  25330. * @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
  25331. * @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
  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. * @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)
  25336. * @returns a new Mesh
  25337. */
  25338. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25339. (i: number, distance: number): number;
  25340. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25341. /**
  25342. * Creates a polyhedron mesh.
  25343. * Please consider using the same method from the MeshBuilder class instead.
  25344. * * 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
  25345. * * The parameter `size` (positive float, default 1) sets the polygon size
  25346. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25347. * * 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`
  25348. * * 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
  25349. * * 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)`)
  25350. * * 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
  25351. * * 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
  25352. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25353. * * If you create a double-sided mesh, you can choose what parts of 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
  25354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25355. * @param name defines the name of the mesh to create
  25356. * @param options defines the options used to create the mesh
  25357. * @param scene defines the hosting scene
  25358. * @returns a new Mesh
  25359. */
  25360. static CreatePolyhedron(name: string, options: {
  25361. type?: number;
  25362. size?: number;
  25363. sizeX?: number;
  25364. sizeY?: number;
  25365. sizeZ?: number;
  25366. custom?: any;
  25367. faceUV?: Vector4[];
  25368. faceColors?: Color4[];
  25369. updatable?: boolean;
  25370. sideOrientation?: number;
  25371. }, scene: Scene): Mesh;
  25372. /**
  25373. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25374. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25375. * * 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`)
  25376. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25377. * * 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
  25378. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25379. * * If you create a double-sided mesh, you can choose what parts of 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
  25380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25381. * @param name defines the name of the mesh
  25382. * @param options defines the options used to create the mesh
  25383. * @param scene defines the hosting scene
  25384. * @returns a new Mesh
  25385. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25386. */
  25387. static CreateIcoSphere(name: string, options: {
  25388. radius?: number;
  25389. flat?: boolean;
  25390. subdivisions?: number;
  25391. sideOrientation?: number;
  25392. updatable?: boolean;
  25393. }, scene: Scene): Mesh;
  25394. /**
  25395. * Creates a decal mesh.
  25396. * Please consider using the same method from the MeshBuilder class instead.
  25397. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25398. * @param name defines the name of the mesh
  25399. * @param sourceMesh defines the mesh receiving the decal
  25400. * @param position sets the position of the decal in world coordinates
  25401. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25402. * @param size sets the decal scaling
  25403. * @param angle sets the angle to rotate the decal
  25404. * @returns a new Mesh
  25405. */
  25406. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25407. /**
  25408. * Prepare internal position array for software CPU skinning
  25409. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25410. */
  25411. setPositionsForCPUSkinning(): Float32Array;
  25412. /**
  25413. * Prepare internal normal array for software CPU skinning
  25414. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25415. */
  25416. setNormalsForCPUSkinning(): Float32Array;
  25417. /**
  25418. * Updates the vertex buffer by applying transformation from the bones
  25419. * @param skeleton defines the skeleton to apply to current mesh
  25420. * @returns the current mesh
  25421. */
  25422. applySkeleton(skeleton: Skeleton): Mesh;
  25423. /**
  25424. * 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
  25425. * @param meshes defines the list of meshes to scan
  25426. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25427. */
  25428. static MinMax(meshes: AbstractMesh[]): {
  25429. min: Vector3;
  25430. max: Vector3;
  25431. };
  25432. /**
  25433. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25434. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25435. * @returns a vector3
  25436. */
  25437. static Center(meshesOrMinMaxVector: {
  25438. min: Vector3;
  25439. max: Vector3;
  25440. } | AbstractMesh[]): Vector3;
  25441. /**
  25442. * Merge the array of meshes into a single mesh for performance reasons.
  25443. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25444. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25445. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25446. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25447. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25448. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25449. * @returns a new mesh
  25450. */
  25451. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25452. /** @hidden */
  25453. addInstance(instance: InstancedMesh): void;
  25454. /** @hidden */
  25455. removeInstance(instance: InstancedMesh): void;
  25456. }
  25457. }
  25458. declare module "babylonjs/Cameras/camera" {
  25459. import { SmartArray } from "babylonjs/Misc/smartArray";
  25460. import { Observable } from "babylonjs/Misc/observable";
  25461. import { Nullable } from "babylonjs/types";
  25462. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25463. import { Scene } from "babylonjs/scene";
  25464. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25465. import { Node } from "babylonjs/node";
  25466. import { Mesh } from "babylonjs/Meshes/mesh";
  25467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25468. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25469. import { Viewport } from "babylonjs/Maths/math.viewport";
  25470. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25471. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25472. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25473. import { Ray } from "babylonjs/Culling/ray";
  25474. /**
  25475. * This is the base class of all the camera used in the application.
  25476. * @see http://doc.babylonjs.com/features/cameras
  25477. */
  25478. export class Camera extends Node {
  25479. /** @hidden */
  25480. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25481. /**
  25482. * This is the default projection mode used by the cameras.
  25483. * It helps recreating a feeling of perspective and better appreciate depth.
  25484. * This is the best way to simulate real life cameras.
  25485. */
  25486. static readonly PERSPECTIVE_CAMERA: number;
  25487. /**
  25488. * This helps creating camera with an orthographic mode.
  25489. * 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.
  25490. */
  25491. static readonly ORTHOGRAPHIC_CAMERA: number;
  25492. /**
  25493. * This is the default FOV mode for perspective cameras.
  25494. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25495. */
  25496. static readonly FOVMODE_VERTICAL_FIXED: number;
  25497. /**
  25498. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25499. */
  25500. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25501. /**
  25502. * This specifies ther is no need for a camera rig.
  25503. * Basically only one eye is rendered corresponding to the camera.
  25504. */
  25505. static readonly RIG_MODE_NONE: number;
  25506. /**
  25507. * Simulates a camera Rig with one blue eye and one red eye.
  25508. * This can be use with 3d blue and red glasses.
  25509. */
  25510. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25511. /**
  25512. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25513. */
  25514. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25515. /**
  25516. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25517. */
  25518. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25519. /**
  25520. * Defines that both eyes of the camera will be rendered over under each other.
  25521. */
  25522. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25523. /**
  25524. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25525. */
  25526. static readonly RIG_MODE_VR: number;
  25527. /**
  25528. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25529. */
  25530. static readonly RIG_MODE_WEBVR: number;
  25531. /**
  25532. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25533. */
  25534. static readonly RIG_MODE_CUSTOM: number;
  25535. /**
  25536. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25537. */
  25538. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25539. /**
  25540. * Define the input manager associated with the camera.
  25541. */
  25542. inputs: CameraInputsManager<Camera>;
  25543. /** @hidden */
  25544. _position: Vector3;
  25545. /**
  25546. * Define the current local position of the camera in the scene
  25547. */
  25548. position: Vector3;
  25549. /**
  25550. * The vector the camera should consider as up.
  25551. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25552. */
  25553. upVector: Vector3;
  25554. /**
  25555. * Define the current limit on the left side for an orthographic camera
  25556. * In scene unit
  25557. */
  25558. orthoLeft: Nullable<number>;
  25559. /**
  25560. * Define the current limit on the right side for an orthographic camera
  25561. * In scene unit
  25562. */
  25563. orthoRight: Nullable<number>;
  25564. /**
  25565. * Define the current limit on the bottom side for an orthographic camera
  25566. * In scene unit
  25567. */
  25568. orthoBottom: Nullable<number>;
  25569. /**
  25570. * Define the current limit on the top side for an orthographic camera
  25571. * In scene unit
  25572. */
  25573. orthoTop: Nullable<number>;
  25574. /**
  25575. * Field Of View is set in Radians. (default is 0.8)
  25576. */
  25577. fov: number;
  25578. /**
  25579. * Define the minimum distance the camera can see from.
  25580. * This is important to note that the depth buffer are not infinite and the closer it starts
  25581. * the more your scene might encounter depth fighting issue.
  25582. */
  25583. minZ: number;
  25584. /**
  25585. * Define the maximum distance the camera can see to.
  25586. * This is important to note that the depth buffer are not infinite and the further it end
  25587. * the more your scene might encounter depth fighting issue.
  25588. */
  25589. maxZ: number;
  25590. /**
  25591. * Define the default inertia of the camera.
  25592. * This helps giving a smooth feeling to the camera movement.
  25593. */
  25594. inertia: number;
  25595. /**
  25596. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25597. */
  25598. mode: number;
  25599. /**
  25600. * Define wether the camera is intermediate.
  25601. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25602. */
  25603. isIntermediate: boolean;
  25604. /**
  25605. * Define the viewport of the camera.
  25606. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25607. */
  25608. viewport: Viewport;
  25609. /**
  25610. * Restricts the camera to viewing objects with the same layerMask.
  25611. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25612. */
  25613. layerMask: number;
  25614. /**
  25615. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25616. */
  25617. fovMode: number;
  25618. /**
  25619. * Rig mode of the camera.
  25620. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25621. * This is normally controlled byt the camera themselves as internal use.
  25622. */
  25623. cameraRigMode: number;
  25624. /**
  25625. * Defines the distance between both "eyes" in case of a RIG
  25626. */
  25627. interaxialDistance: number;
  25628. /**
  25629. * Defines if stereoscopic rendering is done side by side or over under.
  25630. */
  25631. isStereoscopicSideBySide: boolean;
  25632. /**
  25633. * 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
  25634. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25635. * else in the scene. (Eg. security camera)
  25636. *
  25637. * 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)
  25638. */
  25639. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25640. /**
  25641. * When set, the camera will render to this render target instead of the default canvas
  25642. *
  25643. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25644. */
  25645. outputRenderTarget: Nullable<RenderTargetTexture>;
  25646. /**
  25647. * Observable triggered when the camera view matrix has changed.
  25648. */
  25649. onViewMatrixChangedObservable: Observable<Camera>;
  25650. /**
  25651. * Observable triggered when the camera Projection matrix has changed.
  25652. */
  25653. onProjectionMatrixChangedObservable: Observable<Camera>;
  25654. /**
  25655. * Observable triggered when the inputs have been processed.
  25656. */
  25657. onAfterCheckInputsObservable: Observable<Camera>;
  25658. /**
  25659. * Observable triggered when reset has been called and applied to the camera.
  25660. */
  25661. onRestoreStateObservable: Observable<Camera>;
  25662. /** @hidden */
  25663. _cameraRigParams: any;
  25664. /** @hidden */
  25665. _rigCameras: Camera[];
  25666. /** @hidden */
  25667. _rigPostProcess: Nullable<PostProcess>;
  25668. protected _webvrViewMatrix: Matrix;
  25669. /** @hidden */
  25670. _skipRendering: boolean;
  25671. /** @hidden */
  25672. _projectionMatrix: Matrix;
  25673. /** @hidden */
  25674. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25675. /** @hidden */
  25676. _activeMeshes: SmartArray<AbstractMesh>;
  25677. protected _globalPosition: Vector3;
  25678. /** @hidden */
  25679. _computedViewMatrix: Matrix;
  25680. private _doNotComputeProjectionMatrix;
  25681. private _transformMatrix;
  25682. private _frustumPlanes;
  25683. private _refreshFrustumPlanes;
  25684. private _storedFov;
  25685. private _stateStored;
  25686. /**
  25687. * Instantiates a new camera object.
  25688. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25689. * @see http://doc.babylonjs.com/features/cameras
  25690. * @param name Defines the name of the camera in the scene
  25691. * @param position Defines the position of the camera
  25692. * @param scene Defines the scene the camera belongs too
  25693. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25694. */
  25695. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25696. /**
  25697. * Store current camera state (fov, position, etc..)
  25698. * @returns the camera
  25699. */
  25700. storeState(): Camera;
  25701. /**
  25702. * Restores the camera state values if it has been stored. You must call storeState() first
  25703. */
  25704. protected _restoreStateValues(): boolean;
  25705. /**
  25706. * Restored camera state. You must call storeState() first.
  25707. * @returns true if restored and false otherwise
  25708. */
  25709. restoreState(): boolean;
  25710. /**
  25711. * Gets the class name of the camera.
  25712. * @returns the class name
  25713. */
  25714. getClassName(): string;
  25715. /** @hidden */
  25716. readonly _isCamera: boolean;
  25717. /**
  25718. * Gets a string representation of the camera useful for debug purpose.
  25719. * @param fullDetails Defines that a more verboe level of logging is required
  25720. * @returns the string representation
  25721. */
  25722. toString(fullDetails?: boolean): string;
  25723. /**
  25724. * Gets the current world space position of the camera.
  25725. */
  25726. readonly globalPosition: Vector3;
  25727. /**
  25728. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25729. * @returns the active meshe list
  25730. */
  25731. getActiveMeshes(): SmartArray<AbstractMesh>;
  25732. /**
  25733. * Check wether a mesh is part of the current active mesh list of the camera
  25734. * @param mesh Defines the mesh to check
  25735. * @returns true if active, false otherwise
  25736. */
  25737. isActiveMesh(mesh: Mesh): boolean;
  25738. /**
  25739. * Is this camera ready to be used/rendered
  25740. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25741. * @return true if the camera is ready
  25742. */
  25743. isReady(completeCheck?: boolean): boolean;
  25744. /** @hidden */
  25745. _initCache(): void;
  25746. /** @hidden */
  25747. _updateCache(ignoreParentClass?: boolean): void;
  25748. /** @hidden */
  25749. _isSynchronized(): boolean;
  25750. /** @hidden */
  25751. _isSynchronizedViewMatrix(): boolean;
  25752. /** @hidden */
  25753. _isSynchronizedProjectionMatrix(): boolean;
  25754. /**
  25755. * Attach the input controls to a specific dom element to get the input from.
  25756. * @param element Defines the element the controls should be listened from
  25757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25758. */
  25759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25760. /**
  25761. * Detach the current controls from the specified dom element.
  25762. * @param element Defines the element to stop listening the inputs from
  25763. */
  25764. detachControl(element: HTMLElement): void;
  25765. /**
  25766. * Update the camera state according to the different inputs gathered during the frame.
  25767. */
  25768. update(): void;
  25769. /** @hidden */
  25770. _checkInputs(): void;
  25771. /** @hidden */
  25772. readonly rigCameras: Camera[];
  25773. /**
  25774. * Gets the post process used by the rig cameras
  25775. */
  25776. readonly rigPostProcess: Nullable<PostProcess>;
  25777. /**
  25778. * Internal, gets the first post proces.
  25779. * @returns the first post process to be run on this camera.
  25780. */
  25781. _getFirstPostProcess(): Nullable<PostProcess>;
  25782. private _cascadePostProcessesToRigCams;
  25783. /**
  25784. * Attach a post process to the camera.
  25785. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25786. * @param postProcess The post process to attach to the camera
  25787. * @param insertAt The position of the post process in case several of them are in use in the scene
  25788. * @returns the position the post process has been inserted at
  25789. */
  25790. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25791. /**
  25792. * Detach a post process to the camera.
  25793. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25794. * @param postProcess The post process to detach from the camera
  25795. */
  25796. detachPostProcess(postProcess: PostProcess): void;
  25797. /**
  25798. * Gets the current world matrix of the camera
  25799. */
  25800. getWorldMatrix(): Matrix;
  25801. /** @hidden */
  25802. _getViewMatrix(): Matrix;
  25803. /**
  25804. * Gets the current view matrix of the camera.
  25805. * @param force forces the camera to recompute the matrix without looking at the cached state
  25806. * @returns the view matrix
  25807. */
  25808. getViewMatrix(force?: boolean): Matrix;
  25809. /**
  25810. * Freeze the projection matrix.
  25811. * It will prevent the cache check of the camera projection compute and can speed up perf
  25812. * if no parameter of the camera are meant to change
  25813. * @param projection Defines manually a projection if necessary
  25814. */
  25815. freezeProjectionMatrix(projection?: Matrix): void;
  25816. /**
  25817. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25818. */
  25819. unfreezeProjectionMatrix(): void;
  25820. /**
  25821. * Gets the current projection matrix of the camera.
  25822. * @param force forces the camera to recompute the matrix without looking at the cached state
  25823. * @returns the projection matrix
  25824. */
  25825. getProjectionMatrix(force?: boolean): Matrix;
  25826. /**
  25827. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25828. * @returns a Matrix
  25829. */
  25830. getTransformationMatrix(): Matrix;
  25831. private _updateFrustumPlanes;
  25832. /**
  25833. * Checks if a cullable object (mesh...) is in the camera frustum
  25834. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25835. * @param target The object to check
  25836. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25837. * @returns true if the object is in frustum otherwise false
  25838. */
  25839. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25840. /**
  25841. * Checks if a cullable object (mesh...) is in the camera frustum
  25842. * Unlike isInFrustum this cheks the full bounding box
  25843. * @param target The object to check
  25844. * @returns true if the object is in frustum otherwise false
  25845. */
  25846. isCompletelyInFrustum(target: ICullable): boolean;
  25847. /**
  25848. * Gets a ray in the forward direction from the camera.
  25849. * @param length Defines the length of the ray to create
  25850. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25851. * @param origin Defines the start point of the ray which defaults to the camera position
  25852. * @returns the forward ray
  25853. */
  25854. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25855. /**
  25856. * Releases resources associated with this node.
  25857. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25858. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25859. */
  25860. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25861. /** @hidden */
  25862. _isLeftCamera: boolean;
  25863. /**
  25864. * Gets the left camera of a rig setup in case of Rigged Camera
  25865. */
  25866. readonly isLeftCamera: boolean;
  25867. /** @hidden */
  25868. _isRightCamera: boolean;
  25869. /**
  25870. * Gets the right camera of a rig setup in case of Rigged Camera
  25871. */
  25872. readonly isRightCamera: boolean;
  25873. /**
  25874. * Gets the left camera of a rig setup in case of Rigged Camera
  25875. */
  25876. readonly leftCamera: Nullable<FreeCamera>;
  25877. /**
  25878. * Gets the right camera of a rig setup in case of Rigged Camera
  25879. */
  25880. readonly rightCamera: Nullable<FreeCamera>;
  25881. /**
  25882. * Gets the left camera target of a rig setup in case of Rigged Camera
  25883. * @returns the target position
  25884. */
  25885. getLeftTarget(): Nullable<Vector3>;
  25886. /**
  25887. * Gets the right camera target of a rig setup in case of Rigged Camera
  25888. * @returns the target position
  25889. */
  25890. getRightTarget(): Nullable<Vector3>;
  25891. /**
  25892. * @hidden
  25893. */
  25894. setCameraRigMode(mode: number, rigParams: any): void;
  25895. /** @hidden */
  25896. static _setStereoscopicRigMode(camera: Camera): void;
  25897. /** @hidden */
  25898. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25899. /** @hidden */
  25900. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25901. /** @hidden */
  25902. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25903. /** @hidden */
  25904. _getVRProjectionMatrix(): Matrix;
  25905. protected _updateCameraRotationMatrix(): void;
  25906. protected _updateWebVRCameraRotationMatrix(): void;
  25907. /**
  25908. * This function MUST be overwritten by the different WebVR cameras available.
  25909. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25910. * @hidden
  25911. */
  25912. _getWebVRProjectionMatrix(): Matrix;
  25913. /**
  25914. * This function MUST be overwritten by the different WebVR cameras available.
  25915. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25916. * @hidden
  25917. */
  25918. _getWebVRViewMatrix(): Matrix;
  25919. /** @hidden */
  25920. setCameraRigParameter(name: string, value: any): void;
  25921. /**
  25922. * needs to be overridden by children so sub has required properties to be copied
  25923. * @hidden
  25924. */
  25925. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25926. /**
  25927. * May need to be overridden by children
  25928. * @hidden
  25929. */
  25930. _updateRigCameras(): void;
  25931. /** @hidden */
  25932. _setupInputs(): void;
  25933. /**
  25934. * Serialiaze the camera setup to a json represention
  25935. * @returns the JSON representation
  25936. */
  25937. serialize(): any;
  25938. /**
  25939. * Clones the current camera.
  25940. * @param name The cloned camera name
  25941. * @returns the cloned camera
  25942. */
  25943. clone(name: string): Camera;
  25944. /**
  25945. * Gets the direction of the camera relative to a given local axis.
  25946. * @param localAxis Defines the reference axis to provide a relative direction.
  25947. * @return the direction
  25948. */
  25949. getDirection(localAxis: Vector3): Vector3;
  25950. /**
  25951. * Returns the current camera absolute rotation
  25952. */
  25953. readonly absoluteRotation: Quaternion;
  25954. /**
  25955. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25956. * @param localAxis Defines the reference axis to provide a relative direction.
  25957. * @param result Defines the vector to store the result in
  25958. */
  25959. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25960. /**
  25961. * Gets a camera constructor for a given camera type
  25962. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25963. * @param name The name of the camera the result will be able to instantiate
  25964. * @param scene The scene the result will construct the camera in
  25965. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25966. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25967. * @returns a factory method to construc the camera
  25968. */
  25969. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25970. /**
  25971. * Compute the world matrix of the camera.
  25972. * @returns the camera world matrix
  25973. */
  25974. computeWorldMatrix(): Matrix;
  25975. /**
  25976. * Parse a JSON and creates the camera from the parsed information
  25977. * @param parsedCamera The JSON to parse
  25978. * @param scene The scene to instantiate the camera in
  25979. * @returns the newly constructed camera
  25980. */
  25981. static Parse(parsedCamera: any, scene: Scene): Camera;
  25982. }
  25983. }
  25984. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25985. import { Nullable } from "babylonjs/types";
  25986. import { Scene } from "babylonjs/scene";
  25987. import { Vector4 } from "babylonjs/Maths/math.vector";
  25988. import { Mesh } from "babylonjs/Meshes/mesh";
  25989. /**
  25990. * Class containing static functions to help procedurally build meshes
  25991. */
  25992. export class DiscBuilder {
  25993. /**
  25994. * Creates a plane polygonal mesh. By default, this is a disc
  25995. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25996. * * 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
  25997. * * 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
  25998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26001. * @param name defines the name of the mesh
  26002. * @param options defines the options used to create the mesh
  26003. * @param scene defines the hosting scene
  26004. * @returns the plane polygonal mesh
  26005. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26006. */
  26007. static CreateDisc(name: string, options: {
  26008. radius?: number;
  26009. tessellation?: number;
  26010. arc?: number;
  26011. updatable?: boolean;
  26012. sideOrientation?: number;
  26013. frontUVs?: Vector4;
  26014. backUVs?: Vector4;
  26015. }, scene?: Nullable<Scene>): Mesh;
  26016. }
  26017. }
  26018. declare module "babylonjs/Particles/solidParticleSystem" {
  26019. import { Vector3 } from "babylonjs/Maths/math.vector";
  26020. import { Mesh } from "babylonjs/Meshes/mesh";
  26021. import { Scene, IDisposable } from "babylonjs/scene";
  26022. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26023. /**
  26024. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26025. *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.
  26026. * The SPS is also a particle system. It provides some methods to manage the particles.
  26027. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26028. *
  26029. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26030. */
  26031. export class SolidParticleSystem implements IDisposable {
  26032. /**
  26033. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26034. * Example : var p = SPS.particles[i];
  26035. */
  26036. particles: SolidParticle[];
  26037. /**
  26038. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26039. */
  26040. nbParticles: number;
  26041. /**
  26042. * If the particles must ever face the camera (default false). Useful for planar particles.
  26043. */
  26044. billboard: boolean;
  26045. /**
  26046. * Recompute normals when adding a shape
  26047. */
  26048. recomputeNormals: boolean;
  26049. /**
  26050. * This a counter ofr your own usage. It's not set by any SPS functions.
  26051. */
  26052. counter: number;
  26053. /**
  26054. * The SPS name. This name is also given to the underlying mesh.
  26055. */
  26056. name: string;
  26057. /**
  26058. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26059. */
  26060. mesh: Mesh;
  26061. /**
  26062. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26063. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26064. */
  26065. vars: any;
  26066. /**
  26067. * This array is populated when the SPS is set as 'pickable'.
  26068. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26069. * Each element of this array is an object `{idx: int, faceId: int}`.
  26070. * `idx` is the picked particle index in the `SPS.particles` array
  26071. * `faceId` is the picked face index counted within this particle.
  26072. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26073. */
  26074. pickedParticles: {
  26075. idx: number;
  26076. faceId: number;
  26077. }[];
  26078. /**
  26079. * This array is populated when `enableDepthSort` is set to true.
  26080. * Each element of this array is an instance of the class DepthSortedParticle.
  26081. */
  26082. depthSortedParticles: DepthSortedParticle[];
  26083. /**
  26084. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26085. * @hidden
  26086. */
  26087. _bSphereOnly: boolean;
  26088. /**
  26089. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26090. * @hidden
  26091. */
  26092. _bSphereRadiusFactor: number;
  26093. private _scene;
  26094. private _positions;
  26095. private _indices;
  26096. private _normals;
  26097. private _colors;
  26098. private _uvs;
  26099. private _indices32;
  26100. private _positions32;
  26101. private _normals32;
  26102. private _fixedNormal32;
  26103. private _colors32;
  26104. private _uvs32;
  26105. private _index;
  26106. private _updatable;
  26107. private _pickable;
  26108. private _isVisibilityBoxLocked;
  26109. private _alwaysVisible;
  26110. private _depthSort;
  26111. private _expandable;
  26112. private _shapeCounter;
  26113. private _copy;
  26114. private _color;
  26115. private _computeParticleColor;
  26116. private _computeParticleTexture;
  26117. private _computeParticleRotation;
  26118. private _computeParticleVertex;
  26119. private _computeBoundingBox;
  26120. private _depthSortParticles;
  26121. private _camera;
  26122. private _mustUnrotateFixedNormals;
  26123. private _particlesIntersect;
  26124. private _needs32Bits;
  26125. private _isNotBuilt;
  26126. /**
  26127. * Creates a SPS (Solid Particle System) object.
  26128. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26129. * @param scene (Scene) is the scene in which the SPS is added.
  26130. * @param options defines the options of the sps e.g.
  26131. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26132. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26133. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26134. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26135. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26136. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26137. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26138. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26139. */
  26140. constructor(name: string, scene: Scene, options?: {
  26141. updatable?: boolean;
  26142. isPickable?: boolean;
  26143. enableDepthSort?: boolean;
  26144. particleIntersection?: boolean;
  26145. boundingSphereOnly?: boolean;
  26146. bSphereRadiusFactor?: number;
  26147. expandable?: boolean;
  26148. });
  26149. /**
  26150. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26151. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26152. * @returns the created mesh
  26153. */
  26154. buildMesh(): Mesh;
  26155. /**
  26156. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26157. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26158. * Thus the particles generated from `digest()` have their property `position` set yet.
  26159. * @param mesh ( Mesh ) is the mesh to be digested
  26160. * @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
  26161. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26162. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26163. * @returns the current SPS
  26164. */
  26165. digest(mesh: Mesh, options?: {
  26166. facetNb?: number;
  26167. number?: number;
  26168. delta?: number;
  26169. }): SolidParticleSystem;
  26170. private _unrotateFixedNormals;
  26171. private _resetCopy;
  26172. private _meshBuilder;
  26173. private _posToShape;
  26174. private _uvsToShapeUV;
  26175. private _addParticle;
  26176. /**
  26177. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26178. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26179. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26180. * @param nb (positive integer) the number of particles to be created from this model
  26181. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26182. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26183. * @returns the number of shapes in the system
  26184. */
  26185. addShape(mesh: Mesh, nb: number, options?: {
  26186. positionFunction?: any;
  26187. vertexFunction?: any;
  26188. }): number;
  26189. private _rebuildParticle;
  26190. /**
  26191. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26192. * @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.
  26193. * @returns the SPS.
  26194. */
  26195. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26196. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26197. * Returns an array with the removed particles.
  26198. * 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.
  26199. * The SPS can't be empty so at least one particle needs to remain in place.
  26200. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26201. * @param start index of the first particle to remove
  26202. * @param end index of the last particle to remove (included)
  26203. * @returns an array populated with the removed particles
  26204. */
  26205. removeParticles(start: number, end: number): SolidParticle[];
  26206. /**
  26207. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26208. * This method calls `updateParticle()` for each particle of the SPS.
  26209. * For an animated SPS, it is usually called within the render loop.
  26210. * 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.
  26211. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26212. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26213. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26214. * @returns the SPS.
  26215. */
  26216. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26217. /**
  26218. * Disposes the SPS.
  26219. */
  26220. dispose(): void;
  26221. /**
  26222. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26223. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26224. * @returns the SPS.
  26225. */
  26226. refreshVisibleSize(): SolidParticleSystem;
  26227. /**
  26228. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26229. * @param size the size (float) of the visibility box
  26230. * note : this doesn't lock the SPS mesh bounding box.
  26231. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26232. */
  26233. setVisibilityBox(size: number): void;
  26234. /**
  26235. * Gets whether the SPS as always visible or not
  26236. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26237. */
  26238. /**
  26239. * Sets the SPS as always visible or not
  26240. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26241. */
  26242. isAlwaysVisible: boolean;
  26243. /**
  26244. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26245. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26246. */
  26247. /**
  26248. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26249. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26250. */
  26251. isVisibilityBoxLocked: boolean;
  26252. /**
  26253. * Tells to `setParticles()` to compute the particle rotations or not.
  26254. * Default value : true. The SPS is faster when it's set to false.
  26255. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26256. */
  26257. /**
  26258. * Gets if `setParticles()` computes the particle rotations or not.
  26259. * Default value : true. The SPS is faster when it's set to false.
  26260. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26261. */
  26262. computeParticleRotation: boolean;
  26263. /**
  26264. * Tells to `setParticles()` to compute the particle colors or not.
  26265. * Default value : true. The SPS is faster when it's set to false.
  26266. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26267. */
  26268. /**
  26269. * Gets if `setParticles()` computes the particle colors or not.
  26270. * Default value : true. The SPS is faster when it's set to false.
  26271. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26272. */
  26273. computeParticleColor: boolean;
  26274. /**
  26275. * Gets if `setParticles()` computes the particle textures or not.
  26276. * Default value : true. The SPS is faster when it's set to false.
  26277. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26278. */
  26279. computeParticleTexture: boolean;
  26280. /**
  26281. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26282. * Default value : false. The SPS is faster when it's set to false.
  26283. * Note : the particle custom vertex positions aren't stored values.
  26284. */
  26285. /**
  26286. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26287. * Default value : false. The SPS is faster when it's set to false.
  26288. * Note : the particle custom vertex positions aren't stored values.
  26289. */
  26290. computeParticleVertex: boolean;
  26291. /**
  26292. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26293. */
  26294. /**
  26295. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26296. */
  26297. computeBoundingBox: boolean;
  26298. /**
  26299. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26300. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26301. * Default : `true`
  26302. */
  26303. /**
  26304. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26305. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26306. * Default : `true`
  26307. */
  26308. depthSortParticles: boolean;
  26309. /**
  26310. * Gets if the SPS is created as expandable at construction time.
  26311. * Default : `false`
  26312. */
  26313. readonly expandable: boolean;
  26314. /**
  26315. * This function does nothing. It may be overwritten to set all the particle first values.
  26316. * The SPS doesn't call this function, you may have to call it by your own.
  26317. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26318. */
  26319. initParticles(): void;
  26320. /**
  26321. * This function does nothing. It may be overwritten to recycle a particle.
  26322. * The SPS doesn't call this function, you may have to call it by your own.
  26323. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26324. * @param particle The particle to recycle
  26325. * @returns the recycled particle
  26326. */
  26327. recycleParticle(particle: SolidParticle): SolidParticle;
  26328. /**
  26329. * Updates a particle : this function should be overwritten by the user.
  26330. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26331. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26332. * @example : just set a particle position or velocity and recycle conditions
  26333. * @param particle The particle to update
  26334. * @returns the updated particle
  26335. */
  26336. updateParticle(particle: SolidParticle): SolidParticle;
  26337. /**
  26338. * Updates a vertex of a particle : it can be overwritten by the user.
  26339. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26340. * @param particle the current particle
  26341. * @param vertex the current index of the current particle
  26342. * @param pt the index of the current vertex in the particle shape
  26343. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26344. * @example : just set a vertex particle position
  26345. * @returns the updated vertex
  26346. */
  26347. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26348. /**
  26349. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26350. * This does nothing and may be overwritten by the user.
  26351. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26352. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26353. * @param update the boolean update value actually passed to setParticles()
  26354. */
  26355. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26356. /**
  26357. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26358. * This will be passed three parameters.
  26359. * This does nothing and may be overwritten by the user.
  26360. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26361. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26362. * @param update the boolean update value actually passed to setParticles()
  26363. */
  26364. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26365. }
  26366. }
  26367. declare module "babylonjs/Particles/solidParticle" {
  26368. import { Nullable } from "babylonjs/types";
  26369. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26370. import { Color4 } from "babylonjs/Maths/math.color";
  26371. import { Mesh } from "babylonjs/Meshes/mesh";
  26372. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26373. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26374. import { Plane } from "babylonjs/Maths/math.plane";
  26375. /**
  26376. * Represents one particle of a solid particle system.
  26377. */
  26378. export class SolidParticle {
  26379. /**
  26380. * particle global index
  26381. */
  26382. idx: number;
  26383. /**
  26384. * The color of the particle
  26385. */
  26386. color: Nullable<Color4>;
  26387. /**
  26388. * The world space position of the particle.
  26389. */
  26390. position: Vector3;
  26391. /**
  26392. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26393. */
  26394. rotation: Vector3;
  26395. /**
  26396. * The world space rotation quaternion of the particle.
  26397. */
  26398. rotationQuaternion: Nullable<Quaternion>;
  26399. /**
  26400. * The scaling of the particle.
  26401. */
  26402. scaling: Vector3;
  26403. /**
  26404. * The uvs of the particle.
  26405. */
  26406. uvs: Vector4;
  26407. /**
  26408. * The current speed of the particle.
  26409. */
  26410. velocity: Vector3;
  26411. /**
  26412. * The pivot point in the particle local space.
  26413. */
  26414. pivot: Vector3;
  26415. /**
  26416. * Must the particle be translated from its pivot point in its local space ?
  26417. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26418. * Default : false
  26419. */
  26420. translateFromPivot: boolean;
  26421. /**
  26422. * Is the particle active or not ?
  26423. */
  26424. alive: boolean;
  26425. /**
  26426. * Is the particle visible or not ?
  26427. */
  26428. isVisible: boolean;
  26429. /**
  26430. * Index of this particle in the global "positions" array (Internal use)
  26431. * @hidden
  26432. */
  26433. _pos: number;
  26434. /**
  26435. * @hidden Index of this particle in the global "indices" array (Internal use)
  26436. */
  26437. _ind: number;
  26438. /**
  26439. * @hidden ModelShape of this particle (Internal use)
  26440. */
  26441. _model: ModelShape;
  26442. /**
  26443. * ModelShape id of this particle
  26444. */
  26445. shapeId: number;
  26446. /**
  26447. * Index of the particle in its shape id
  26448. */
  26449. idxInShape: number;
  26450. /**
  26451. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26452. */
  26453. _modelBoundingInfo: BoundingInfo;
  26454. /**
  26455. * @hidden Particle BoundingInfo object (Internal use)
  26456. */
  26457. _boundingInfo: BoundingInfo;
  26458. /**
  26459. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26460. */
  26461. _sps: SolidParticleSystem;
  26462. /**
  26463. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26464. */
  26465. _stillInvisible: boolean;
  26466. /**
  26467. * @hidden Last computed particle rotation matrix
  26468. */
  26469. _rotationMatrix: number[];
  26470. /**
  26471. * Parent particle Id, if any.
  26472. * Default null.
  26473. */
  26474. parentId: Nullable<number>;
  26475. /**
  26476. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26477. * The possible values are :
  26478. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26479. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26480. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26481. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26482. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26483. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26484. * */
  26485. cullingStrategy: number;
  26486. /**
  26487. * @hidden Internal global position in the SPS.
  26488. */
  26489. _globalPosition: Vector3;
  26490. /**
  26491. * Creates a Solid Particle object.
  26492. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26493. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26494. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26495. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26496. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26497. * @param shapeId (integer) is the model shape identifier in the SPS.
  26498. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26499. * @param sps defines the sps it is associated to
  26500. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26501. */
  26502. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26503. /**
  26504. * Legacy support, changed scale to scaling
  26505. */
  26506. /**
  26507. * Legacy support, changed scale to scaling
  26508. */
  26509. scale: Vector3;
  26510. /**
  26511. * Legacy support, changed quaternion to rotationQuaternion
  26512. */
  26513. /**
  26514. * Legacy support, changed quaternion to rotationQuaternion
  26515. */
  26516. quaternion: Nullable<Quaternion>;
  26517. /**
  26518. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26519. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26520. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26521. * @returns true if it intersects
  26522. */
  26523. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26524. /**
  26525. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26526. * A particle is in the frustum if its bounding box intersects the frustum
  26527. * @param frustumPlanes defines the frustum to test
  26528. * @returns true if the particle is in the frustum planes
  26529. */
  26530. isInFrustum(frustumPlanes: Plane[]): boolean;
  26531. /**
  26532. * get the rotation matrix of the particle
  26533. * @hidden
  26534. */
  26535. getRotationMatrix(m: Matrix): void;
  26536. }
  26537. /**
  26538. * Represents the shape of the model used by one particle of a solid particle system.
  26539. * SPS internal tool, don't use it manually.
  26540. */
  26541. export class ModelShape {
  26542. /**
  26543. * The shape id
  26544. * @hidden
  26545. */
  26546. shapeID: number;
  26547. /**
  26548. * flat array of model positions (internal use)
  26549. * @hidden
  26550. */
  26551. _shape: Vector3[];
  26552. /**
  26553. * flat array of model UVs (internal use)
  26554. * @hidden
  26555. */
  26556. _shapeUV: number[];
  26557. /**
  26558. * color array of the model
  26559. * @hidden
  26560. */
  26561. _shapeColors: number[];
  26562. /**
  26563. * indices array of the model
  26564. * @hidden
  26565. */
  26566. _indices: number[];
  26567. /**
  26568. * normals array of the model
  26569. * @hidden
  26570. */
  26571. _normals: number[];
  26572. /**
  26573. * length of the shape in the model indices array (internal use)
  26574. * @hidden
  26575. */
  26576. _indicesLength: number;
  26577. /**
  26578. * Custom position function (internal use)
  26579. * @hidden
  26580. */
  26581. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26582. /**
  26583. * Custom vertex function (internal use)
  26584. * @hidden
  26585. */
  26586. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26587. /**
  26588. * 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.
  26589. * SPS internal tool, don't use it manually.
  26590. * @hidden
  26591. */
  26592. 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>);
  26593. }
  26594. /**
  26595. * Represents a Depth Sorted Particle in the solid particle system.
  26596. */
  26597. export class DepthSortedParticle {
  26598. /**
  26599. * Index of the particle in the "indices" array
  26600. */
  26601. ind: number;
  26602. /**
  26603. * Length of the particle shape in the "indices" array
  26604. */
  26605. indicesLength: number;
  26606. /**
  26607. * Squared distance from the particle to the camera
  26608. */
  26609. sqDistance: number;
  26610. }
  26611. }
  26612. declare module "babylonjs/Collisions/meshCollisionData" {
  26613. import { Collider } from "babylonjs/Collisions/collider";
  26614. import { Vector3 } from "babylonjs/Maths/math.vector";
  26615. import { Nullable } from "babylonjs/types";
  26616. import { Observer } from "babylonjs/Misc/observable";
  26617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26618. /**
  26619. * @hidden
  26620. */
  26621. export class _MeshCollisionData {
  26622. _checkCollisions: boolean;
  26623. _collisionMask: number;
  26624. _collisionGroup: number;
  26625. _collider: Nullable<Collider>;
  26626. _oldPositionForCollisions: Vector3;
  26627. _diffPositionForCollisions: Vector3;
  26628. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26629. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26630. }
  26631. }
  26632. declare module "babylonjs/Meshes/abstractMesh" {
  26633. import { Observable } from "babylonjs/Misc/observable";
  26634. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26635. import { Camera } from "babylonjs/Cameras/camera";
  26636. import { Scene, IDisposable } from "babylonjs/scene";
  26637. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26638. import { Node } from "babylonjs/node";
  26639. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26640. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26641. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26642. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26643. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26644. import { Material } from "babylonjs/Materials/material";
  26645. import { Light } from "babylonjs/Lights/light";
  26646. import { Skeleton } from "babylonjs/Bones/skeleton";
  26647. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26648. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26649. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26650. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26651. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26652. import { Plane } from "babylonjs/Maths/math.plane";
  26653. import { Ray } from "babylonjs/Culling/ray";
  26654. import { Collider } from "babylonjs/Collisions/collider";
  26655. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26656. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26657. /** @hidden */
  26658. class _FacetDataStorage {
  26659. facetPositions: Vector3[];
  26660. facetNormals: Vector3[];
  26661. facetPartitioning: number[][];
  26662. facetNb: number;
  26663. partitioningSubdivisions: number;
  26664. partitioningBBoxRatio: number;
  26665. facetDataEnabled: boolean;
  26666. facetParameters: any;
  26667. bbSize: Vector3;
  26668. subDiv: {
  26669. max: number;
  26670. X: number;
  26671. Y: number;
  26672. Z: number;
  26673. };
  26674. facetDepthSort: boolean;
  26675. facetDepthSortEnabled: boolean;
  26676. depthSortedIndices: IndicesArray;
  26677. depthSortedFacets: {
  26678. ind: number;
  26679. sqDistance: number;
  26680. }[];
  26681. facetDepthSortFunction: (f1: {
  26682. ind: number;
  26683. sqDistance: number;
  26684. }, f2: {
  26685. ind: number;
  26686. sqDistance: number;
  26687. }) => number;
  26688. facetDepthSortFrom: Vector3;
  26689. facetDepthSortOrigin: Vector3;
  26690. invertedMatrix: Matrix;
  26691. }
  26692. /**
  26693. * @hidden
  26694. **/
  26695. class _InternalAbstractMeshDataInfo {
  26696. _hasVertexAlpha: boolean;
  26697. _useVertexColors: boolean;
  26698. _numBoneInfluencers: number;
  26699. _applyFog: boolean;
  26700. _receiveShadows: boolean;
  26701. _facetData: _FacetDataStorage;
  26702. _visibility: number;
  26703. _skeleton: Nullable<Skeleton>;
  26704. _layerMask: number;
  26705. _computeBonesUsingShaders: boolean;
  26706. _isActive: boolean;
  26707. _onlyForInstances: boolean;
  26708. _isActiveIntermediate: boolean;
  26709. _onlyForInstancesIntermediate: boolean;
  26710. _actAsRegularMesh: boolean;
  26711. }
  26712. /**
  26713. * Class used to store all common mesh properties
  26714. */
  26715. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26716. /** No occlusion */
  26717. static OCCLUSION_TYPE_NONE: number;
  26718. /** Occlusion set to optimisitic */
  26719. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26720. /** Occlusion set to strict */
  26721. static OCCLUSION_TYPE_STRICT: number;
  26722. /** Use an accurante occlusion algorithm */
  26723. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26724. /** Use a conservative occlusion algorithm */
  26725. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26726. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26727. * Test order :
  26728. * Is the bounding sphere outside the frustum ?
  26729. * If not, are the bounding box vertices outside the frustum ?
  26730. * It not, then the cullable object is in the frustum.
  26731. */
  26732. static readonly CULLINGSTRATEGY_STANDARD: number;
  26733. /** Culling strategy : Bounding Sphere Only.
  26734. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26735. * It's also less accurate than the standard because some not visible objects can still be selected.
  26736. * Test : is the bounding sphere outside the frustum ?
  26737. * If not, then the cullable object is in the frustum.
  26738. */
  26739. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26740. /** Culling strategy : Optimistic Inclusion.
  26741. * This in an inclusion test first, then the standard exclusion test.
  26742. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26743. * 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.
  26744. * Anyway, it's as accurate as the standard strategy.
  26745. * Test :
  26746. * Is the cullable object bounding sphere center in the frustum ?
  26747. * If not, apply the default culling strategy.
  26748. */
  26749. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26750. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26751. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26752. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26753. * 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.
  26754. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26755. * Test :
  26756. * Is the cullable object bounding sphere center in the frustum ?
  26757. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26758. */
  26759. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26760. /**
  26761. * No billboard
  26762. */
  26763. static readonly BILLBOARDMODE_NONE: number;
  26764. /** Billboard on X axis */
  26765. static readonly BILLBOARDMODE_X: number;
  26766. /** Billboard on Y axis */
  26767. static readonly BILLBOARDMODE_Y: number;
  26768. /** Billboard on Z axis */
  26769. static readonly BILLBOARDMODE_Z: number;
  26770. /** Billboard on all axes */
  26771. static readonly BILLBOARDMODE_ALL: number;
  26772. /** Billboard on using position instead of orientation */
  26773. static readonly BILLBOARDMODE_USE_POSITION: number;
  26774. /** @hidden */
  26775. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26776. /**
  26777. * The culling strategy to use to check whether the mesh must be rendered or not.
  26778. * This value can be changed at any time and will be used on the next render mesh selection.
  26779. * The possible values are :
  26780. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26781. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26782. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26783. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26784. * Please read each static variable documentation to get details about the culling process.
  26785. * */
  26786. cullingStrategy: number;
  26787. /**
  26788. * Gets the number of facets in the mesh
  26789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26790. */
  26791. readonly facetNb: number;
  26792. /**
  26793. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26795. */
  26796. partitioningSubdivisions: number;
  26797. /**
  26798. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26799. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26801. */
  26802. partitioningBBoxRatio: number;
  26803. /**
  26804. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26805. * Works only for updatable meshes.
  26806. * Doesn't work with multi-materials
  26807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26808. */
  26809. mustDepthSortFacets: boolean;
  26810. /**
  26811. * The location (Vector3) where the facet depth sort must be computed from.
  26812. * By default, the active camera position.
  26813. * Used only when facet depth sort is enabled
  26814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26815. */
  26816. facetDepthSortFrom: Vector3;
  26817. /**
  26818. * gets a boolean indicating if facetData is enabled
  26819. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26820. */
  26821. readonly isFacetDataEnabled: boolean;
  26822. /** @hidden */
  26823. _updateNonUniformScalingState(value: boolean): boolean;
  26824. /**
  26825. * An event triggered when this mesh collides with another one
  26826. */
  26827. onCollideObservable: Observable<AbstractMesh>;
  26828. /** Set a function to call when this mesh collides with another one */
  26829. onCollide: () => void;
  26830. /**
  26831. * An event triggered when the collision's position changes
  26832. */
  26833. onCollisionPositionChangeObservable: Observable<Vector3>;
  26834. /** Set a function to call when the collision's position changes */
  26835. onCollisionPositionChange: () => void;
  26836. /**
  26837. * An event triggered when material is changed
  26838. */
  26839. onMaterialChangedObservable: Observable<AbstractMesh>;
  26840. /**
  26841. * Gets or sets the orientation for POV movement & rotation
  26842. */
  26843. definedFacingForward: boolean;
  26844. /** @hidden */
  26845. _occlusionQuery: Nullable<WebGLQuery>;
  26846. /** @hidden */
  26847. _renderingGroup: Nullable<RenderingGroup>;
  26848. /**
  26849. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26850. */
  26851. /**
  26852. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26853. */
  26854. visibility: number;
  26855. /** Gets or sets the alpha index used to sort transparent meshes
  26856. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26857. */
  26858. alphaIndex: number;
  26859. /**
  26860. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26861. */
  26862. isVisible: boolean;
  26863. /**
  26864. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26865. */
  26866. isPickable: boolean;
  26867. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26868. showSubMeshesBoundingBox: boolean;
  26869. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26870. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26871. */
  26872. isBlocker: boolean;
  26873. /**
  26874. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26875. */
  26876. enablePointerMoveEvents: boolean;
  26877. /**
  26878. * Specifies the rendering group id for this mesh (0 by default)
  26879. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26880. */
  26881. renderingGroupId: number;
  26882. private _material;
  26883. /** Gets or sets current material */
  26884. material: Nullable<Material>;
  26885. /**
  26886. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26887. * @see http://doc.babylonjs.com/babylon101/shadows
  26888. */
  26889. receiveShadows: boolean;
  26890. /** Defines color to use when rendering outline */
  26891. outlineColor: Color3;
  26892. /** Define width to use when rendering outline */
  26893. outlineWidth: number;
  26894. /** Defines color to use when rendering overlay */
  26895. overlayColor: Color3;
  26896. /** Defines alpha to use when rendering overlay */
  26897. overlayAlpha: number;
  26898. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26899. hasVertexAlpha: boolean;
  26900. /** 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) */
  26901. useVertexColors: boolean;
  26902. /**
  26903. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26904. */
  26905. computeBonesUsingShaders: boolean;
  26906. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26907. numBoneInfluencers: number;
  26908. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26909. applyFog: boolean;
  26910. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26911. useOctreeForRenderingSelection: boolean;
  26912. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26913. useOctreeForPicking: boolean;
  26914. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26915. useOctreeForCollisions: boolean;
  26916. /**
  26917. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26918. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26919. */
  26920. layerMask: number;
  26921. /**
  26922. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26923. */
  26924. alwaysSelectAsActiveMesh: boolean;
  26925. /**
  26926. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26927. */
  26928. doNotSyncBoundingInfo: boolean;
  26929. /**
  26930. * Gets or sets the current action manager
  26931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26932. */
  26933. actionManager: Nullable<AbstractActionManager>;
  26934. private _meshCollisionData;
  26935. /**
  26936. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26937. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26938. */
  26939. ellipsoid: Vector3;
  26940. /**
  26941. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26942. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26943. */
  26944. ellipsoidOffset: Vector3;
  26945. /**
  26946. * Gets or sets a collision mask used to mask collisions (default is -1).
  26947. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26948. */
  26949. collisionMask: number;
  26950. /**
  26951. * Gets or sets the current collision group mask (-1 by default).
  26952. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26953. */
  26954. collisionGroup: number;
  26955. /**
  26956. * Defines edge width used when edgesRenderer is enabled
  26957. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26958. */
  26959. edgesWidth: number;
  26960. /**
  26961. * Defines edge color used when edgesRenderer is enabled
  26962. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26963. */
  26964. edgesColor: Color4;
  26965. /** @hidden */
  26966. _edgesRenderer: Nullable<IEdgesRenderer>;
  26967. /** @hidden */
  26968. _masterMesh: Nullable<AbstractMesh>;
  26969. /** @hidden */
  26970. _boundingInfo: Nullable<BoundingInfo>;
  26971. /** @hidden */
  26972. _renderId: number;
  26973. /**
  26974. * Gets or sets the list of subMeshes
  26975. * @see http://doc.babylonjs.com/how_to/multi_materials
  26976. */
  26977. subMeshes: SubMesh[];
  26978. /** @hidden */
  26979. _intersectionsInProgress: AbstractMesh[];
  26980. /** @hidden */
  26981. _unIndexed: boolean;
  26982. /** @hidden */
  26983. _lightSources: Light[];
  26984. /** Gets the list of lights affecting that mesh */
  26985. readonly lightSources: Light[];
  26986. /** @hidden */
  26987. readonly _positions: Nullable<Vector3[]>;
  26988. /** @hidden */
  26989. _waitingData: {
  26990. lods: Nullable<any>;
  26991. actions: Nullable<any>;
  26992. freezeWorldMatrix: Nullable<boolean>;
  26993. };
  26994. /** @hidden */
  26995. _bonesTransformMatrices: Nullable<Float32Array>;
  26996. /** @hidden */
  26997. _transformMatrixTexture: Nullable<RawTexture>;
  26998. /**
  26999. * Gets or sets a skeleton to apply skining transformations
  27000. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27001. */
  27002. skeleton: Nullable<Skeleton>;
  27003. /**
  27004. * An event triggered when the mesh is rebuilt.
  27005. */
  27006. onRebuildObservable: Observable<AbstractMesh>;
  27007. /**
  27008. * Creates a new AbstractMesh
  27009. * @param name defines the name of the mesh
  27010. * @param scene defines the hosting scene
  27011. */
  27012. constructor(name: string, scene?: Nullable<Scene>);
  27013. /**
  27014. * Returns the string "AbstractMesh"
  27015. * @returns "AbstractMesh"
  27016. */
  27017. getClassName(): string;
  27018. /**
  27019. * Gets a string representation of the current mesh
  27020. * @param fullDetails defines a boolean indicating if full details must be included
  27021. * @returns a string representation of the current mesh
  27022. */
  27023. toString(fullDetails?: boolean): string;
  27024. /**
  27025. * @hidden
  27026. */
  27027. protected _getEffectiveParent(): Nullable<Node>;
  27028. /** @hidden */
  27029. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27030. /** @hidden */
  27031. _rebuild(): void;
  27032. /** @hidden */
  27033. _resyncLightSources(): void;
  27034. /** @hidden */
  27035. _resyncLighSource(light: Light): void;
  27036. /** @hidden */
  27037. _unBindEffect(): void;
  27038. /** @hidden */
  27039. _removeLightSource(light: Light, dispose: boolean): void;
  27040. private _markSubMeshesAsDirty;
  27041. /** @hidden */
  27042. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27043. /** @hidden */
  27044. _markSubMeshesAsAttributesDirty(): void;
  27045. /** @hidden */
  27046. _markSubMeshesAsMiscDirty(): void;
  27047. /**
  27048. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27049. */
  27050. scaling: Vector3;
  27051. /**
  27052. * Returns true if the mesh is blocked. Implemented by child classes
  27053. */
  27054. readonly isBlocked: boolean;
  27055. /**
  27056. * Returns the mesh itself by default. Implemented by child classes
  27057. * @param camera defines the camera to use to pick the right LOD level
  27058. * @returns the currentAbstractMesh
  27059. */
  27060. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27061. /**
  27062. * Returns 0 by default. Implemented by child classes
  27063. * @returns an integer
  27064. */
  27065. getTotalVertices(): number;
  27066. /**
  27067. * Returns a positive integer : the total number of indices in this mesh geometry.
  27068. * @returns the numner of indices or zero if the mesh has no geometry.
  27069. */
  27070. getTotalIndices(): number;
  27071. /**
  27072. * Returns null by default. Implemented by child classes
  27073. * @returns null
  27074. */
  27075. getIndices(): Nullable<IndicesArray>;
  27076. /**
  27077. * Returns the array of the requested vertex data kind. Implemented by child classes
  27078. * @param kind defines the vertex data kind to use
  27079. * @returns null
  27080. */
  27081. getVerticesData(kind: string): Nullable<FloatArray>;
  27082. /**
  27083. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27084. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27085. * Note that a new underlying VertexBuffer object is created each call.
  27086. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27087. * @param kind defines vertex data kind:
  27088. * * VertexBuffer.PositionKind
  27089. * * VertexBuffer.UVKind
  27090. * * VertexBuffer.UV2Kind
  27091. * * VertexBuffer.UV3Kind
  27092. * * VertexBuffer.UV4Kind
  27093. * * VertexBuffer.UV5Kind
  27094. * * VertexBuffer.UV6Kind
  27095. * * VertexBuffer.ColorKind
  27096. * * VertexBuffer.MatricesIndicesKind
  27097. * * VertexBuffer.MatricesIndicesExtraKind
  27098. * * VertexBuffer.MatricesWeightsKind
  27099. * * VertexBuffer.MatricesWeightsExtraKind
  27100. * @param data defines the data source
  27101. * @param updatable defines if the data must be flagged as updatable (or static)
  27102. * @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
  27103. * @returns the current mesh
  27104. */
  27105. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27106. /**
  27107. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27108. * If the mesh has no geometry, it is simply returned as it is.
  27109. * @param kind defines vertex data kind:
  27110. * * VertexBuffer.PositionKind
  27111. * * VertexBuffer.UVKind
  27112. * * VertexBuffer.UV2Kind
  27113. * * VertexBuffer.UV3Kind
  27114. * * VertexBuffer.UV4Kind
  27115. * * VertexBuffer.UV5Kind
  27116. * * VertexBuffer.UV6Kind
  27117. * * VertexBuffer.ColorKind
  27118. * * VertexBuffer.MatricesIndicesKind
  27119. * * VertexBuffer.MatricesIndicesExtraKind
  27120. * * VertexBuffer.MatricesWeightsKind
  27121. * * VertexBuffer.MatricesWeightsExtraKind
  27122. * @param data defines the data source
  27123. * @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
  27124. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27125. * @returns the current mesh
  27126. */
  27127. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27128. /**
  27129. * Sets the mesh indices,
  27130. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27131. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27132. * @param totalVertices Defines the total number of vertices
  27133. * @returns the current mesh
  27134. */
  27135. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27136. /**
  27137. * Gets a boolean indicating if specific vertex data is present
  27138. * @param kind defines the vertex data kind to use
  27139. * @returns true is data kind is present
  27140. */
  27141. isVerticesDataPresent(kind: string): boolean;
  27142. /**
  27143. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27144. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27145. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27146. * @returns a BoundingInfo
  27147. */
  27148. getBoundingInfo(): BoundingInfo;
  27149. /**
  27150. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27151. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27152. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27153. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27154. * @returns the current mesh
  27155. */
  27156. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27157. /**
  27158. * Overwrite the current bounding info
  27159. * @param boundingInfo defines the new bounding info
  27160. * @returns the current mesh
  27161. */
  27162. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27163. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27164. readonly useBones: boolean;
  27165. /** @hidden */
  27166. _preActivate(): void;
  27167. /** @hidden */
  27168. _preActivateForIntermediateRendering(renderId: number): void;
  27169. /** @hidden */
  27170. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27171. /** @hidden */
  27172. _postActivate(): void;
  27173. /** @hidden */
  27174. _freeze(): void;
  27175. /** @hidden */
  27176. _unFreeze(): void;
  27177. /**
  27178. * Gets the current world matrix
  27179. * @returns a Matrix
  27180. */
  27181. getWorldMatrix(): Matrix;
  27182. /** @hidden */
  27183. _getWorldMatrixDeterminant(): number;
  27184. /**
  27185. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27186. */
  27187. readonly isAnInstance: boolean;
  27188. /**
  27189. * Gets a boolean indicating if this mesh has instances
  27190. */
  27191. readonly hasInstances: boolean;
  27192. /**
  27193. * Perform relative position change from the point of view of behind the front of the mesh.
  27194. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27195. * Supports definition of mesh facing forward or backward
  27196. * @param amountRight defines the distance on the right axis
  27197. * @param amountUp defines the distance on the up axis
  27198. * @param amountForward defines the distance on the forward axis
  27199. * @returns the current mesh
  27200. */
  27201. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27202. /**
  27203. * Calculate relative position change from the point of view of behind the front of the mesh.
  27204. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27205. * Supports definition of mesh facing forward or backward
  27206. * @param amountRight defines the distance on the right axis
  27207. * @param amountUp defines the distance on the up axis
  27208. * @param amountForward defines the distance on the forward axis
  27209. * @returns the new displacement vector
  27210. */
  27211. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27212. /**
  27213. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27214. * Supports definition of mesh facing forward or backward
  27215. * @param flipBack defines the flip
  27216. * @param twirlClockwise defines the twirl
  27217. * @param tiltRight defines the tilt
  27218. * @returns the current mesh
  27219. */
  27220. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27221. /**
  27222. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27223. * Supports definition of mesh facing forward or backward.
  27224. * @param flipBack defines the flip
  27225. * @param twirlClockwise defines the twirl
  27226. * @param tiltRight defines the tilt
  27227. * @returns the new rotation vector
  27228. */
  27229. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27230. /**
  27231. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27232. * This means the mesh underlying bounding box and sphere are recomputed.
  27233. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27234. * @returns the current mesh
  27235. */
  27236. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27237. /** @hidden */
  27238. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27239. /** @hidden */
  27240. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27241. /** @hidden */
  27242. _updateBoundingInfo(): AbstractMesh;
  27243. /** @hidden */
  27244. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27245. /** @hidden */
  27246. protected _afterComputeWorldMatrix(): void;
  27247. /** @hidden */
  27248. readonly _effectiveMesh: AbstractMesh;
  27249. /**
  27250. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27251. * A mesh is in the frustum if its bounding box intersects the frustum
  27252. * @param frustumPlanes defines the frustum to test
  27253. * @returns true if the mesh is in the frustum planes
  27254. */
  27255. isInFrustum(frustumPlanes: Plane[]): boolean;
  27256. /**
  27257. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27258. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27259. * @param frustumPlanes defines the frustum to test
  27260. * @returns true if the mesh is completely in the frustum planes
  27261. */
  27262. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27263. /**
  27264. * True if the mesh intersects another mesh or a SolidParticle object
  27265. * @param mesh defines a target mesh or SolidParticle to test
  27266. * @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)
  27267. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27268. * @returns true if there is an intersection
  27269. */
  27270. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27271. /**
  27272. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27273. * @param point defines the point to test
  27274. * @returns true if there is an intersection
  27275. */
  27276. intersectsPoint(point: Vector3): boolean;
  27277. /**
  27278. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27279. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27280. */
  27281. checkCollisions: boolean;
  27282. /**
  27283. * Gets Collider object used to compute collisions (not physics)
  27284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27285. */
  27286. readonly collider: Nullable<Collider>;
  27287. /**
  27288. * Move the mesh using collision engine
  27289. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27290. * @param displacement defines the requested displacement vector
  27291. * @returns the current mesh
  27292. */
  27293. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27294. private _onCollisionPositionChange;
  27295. /** @hidden */
  27296. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27297. /** @hidden */
  27298. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27299. /** @hidden */
  27300. _checkCollision(collider: Collider): AbstractMesh;
  27301. /** @hidden */
  27302. _generatePointsArray(): boolean;
  27303. /**
  27304. * Checks if the passed Ray intersects with the mesh
  27305. * @param ray defines the ray to use
  27306. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27307. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27308. * @returns the picking info
  27309. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27310. */
  27311. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27312. /**
  27313. * Clones the current mesh
  27314. * @param name defines the mesh name
  27315. * @param newParent defines the new mesh parent
  27316. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27317. * @returns the new mesh
  27318. */
  27319. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27320. /**
  27321. * Disposes all the submeshes of the current meshnp
  27322. * @returns the current mesh
  27323. */
  27324. releaseSubMeshes(): AbstractMesh;
  27325. /**
  27326. * Releases resources associated with this abstract mesh.
  27327. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27328. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27329. */
  27330. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27331. /**
  27332. * Adds the passed mesh as a child to the current mesh
  27333. * @param mesh defines the child mesh
  27334. * @returns the current mesh
  27335. */
  27336. addChild(mesh: AbstractMesh): AbstractMesh;
  27337. /**
  27338. * Removes the passed mesh from the current mesh children list
  27339. * @param mesh defines the child mesh
  27340. * @returns the current mesh
  27341. */
  27342. removeChild(mesh: AbstractMesh): AbstractMesh;
  27343. /** @hidden */
  27344. private _initFacetData;
  27345. /**
  27346. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27347. * This method can be called within the render loop.
  27348. * 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
  27349. * @returns the current mesh
  27350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27351. */
  27352. updateFacetData(): AbstractMesh;
  27353. /**
  27354. * Returns the facetLocalNormals array.
  27355. * The normals are expressed in the mesh local spac
  27356. * @returns an array of Vector3
  27357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27358. */
  27359. getFacetLocalNormals(): Vector3[];
  27360. /**
  27361. * Returns the facetLocalPositions array.
  27362. * The facet positions are expressed in the mesh local space
  27363. * @returns an array of Vector3
  27364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27365. */
  27366. getFacetLocalPositions(): Vector3[];
  27367. /**
  27368. * Returns the facetLocalPartioning array
  27369. * @returns an array of array of numbers
  27370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27371. */
  27372. getFacetLocalPartitioning(): number[][];
  27373. /**
  27374. * Returns the i-th facet position in the world system.
  27375. * This method allocates a new Vector3 per call
  27376. * @param i defines the facet index
  27377. * @returns a new Vector3
  27378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27379. */
  27380. getFacetPosition(i: number): Vector3;
  27381. /**
  27382. * Sets the reference Vector3 with the i-th facet position in the world system
  27383. * @param i defines the facet index
  27384. * @param ref defines the target vector
  27385. * @returns the current mesh
  27386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27387. */
  27388. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27389. /**
  27390. * Returns the i-th facet normal in the world system.
  27391. * This method allocates a new Vector3 per call
  27392. * @param i defines the facet index
  27393. * @returns a new Vector3
  27394. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27395. */
  27396. getFacetNormal(i: number): Vector3;
  27397. /**
  27398. * Sets the reference Vector3 with the i-th facet normal in the world system
  27399. * @param i defines the facet index
  27400. * @param ref defines the target vector
  27401. * @returns the current mesh
  27402. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27403. */
  27404. getFacetNormalToRef(i: number, ref: Vector3): this;
  27405. /**
  27406. * 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)
  27407. * @param x defines x coordinate
  27408. * @param y defines y coordinate
  27409. * @param z defines z coordinate
  27410. * @returns the array of facet indexes
  27411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27412. */
  27413. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27414. /**
  27415. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27416. * @param projected sets as the (x,y,z) world projection on the facet
  27417. * @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
  27418. * @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
  27419. * @param x defines x coordinate
  27420. * @param y defines y coordinate
  27421. * @param z defines z coordinate
  27422. * @returns the face index if found (or null instead)
  27423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27424. */
  27425. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27426. /**
  27427. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27428. * @param projected sets as the (x,y,z) local projection on the facet
  27429. * @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
  27430. * @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
  27431. * @param x defines x coordinate
  27432. * @param y defines y coordinate
  27433. * @param z defines z coordinate
  27434. * @returns the face index if found (or null instead)
  27435. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27436. */
  27437. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27438. /**
  27439. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27440. * @returns the parameters
  27441. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27442. */
  27443. getFacetDataParameters(): any;
  27444. /**
  27445. * Disables the feature FacetData and frees the related memory
  27446. * @returns the current mesh
  27447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27448. */
  27449. disableFacetData(): AbstractMesh;
  27450. /**
  27451. * Updates the AbstractMesh indices array
  27452. * @param indices defines the data source
  27453. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27454. * @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)
  27455. * @returns the current mesh
  27456. */
  27457. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27458. /**
  27459. * Creates new normals data for the mesh
  27460. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27461. * @returns the current mesh
  27462. */
  27463. createNormals(updatable: boolean): AbstractMesh;
  27464. /**
  27465. * Align the mesh with a normal
  27466. * @param normal defines the normal to use
  27467. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27468. * @returns the current mesh
  27469. */
  27470. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27471. /** @hidden */
  27472. _checkOcclusionQuery(): boolean;
  27473. /**
  27474. * Disables the mesh edge rendering mode
  27475. * @returns the currentAbstractMesh
  27476. */
  27477. disableEdgesRendering(): AbstractMesh;
  27478. /**
  27479. * Enables the edge rendering mode on the mesh.
  27480. * This mode makes the mesh edges visible
  27481. * @param epsilon defines the maximal distance between two angles to detect a face
  27482. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27483. * @returns the currentAbstractMesh
  27484. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27485. */
  27486. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27487. }
  27488. }
  27489. declare module "babylonjs/Actions/actionEvent" {
  27490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27491. import { Nullable } from "babylonjs/types";
  27492. import { Sprite } from "babylonjs/Sprites/sprite";
  27493. import { Scene } from "babylonjs/scene";
  27494. import { Vector2 } from "babylonjs/Maths/math.vector";
  27495. /**
  27496. * Interface used to define ActionEvent
  27497. */
  27498. export interface IActionEvent {
  27499. /** The mesh or sprite that triggered the action */
  27500. source: any;
  27501. /** The X mouse cursor position at the time of the event */
  27502. pointerX: number;
  27503. /** The Y mouse cursor position at the time of the event */
  27504. pointerY: number;
  27505. /** The mesh that is currently pointed at (can be null) */
  27506. meshUnderPointer: Nullable<AbstractMesh>;
  27507. /** the original (browser) event that triggered the ActionEvent */
  27508. sourceEvent?: any;
  27509. /** additional data for the event */
  27510. additionalData?: any;
  27511. }
  27512. /**
  27513. * ActionEvent is the event being sent when an action is triggered.
  27514. */
  27515. export class ActionEvent implements IActionEvent {
  27516. /** The mesh or sprite that triggered the action */
  27517. source: any;
  27518. /** The X mouse cursor position at the time of the event */
  27519. pointerX: number;
  27520. /** The Y mouse cursor position at the time of the event */
  27521. pointerY: number;
  27522. /** The mesh that is currently pointed at (can be null) */
  27523. meshUnderPointer: Nullable<AbstractMesh>;
  27524. /** the original (browser) event that triggered the ActionEvent */
  27525. sourceEvent?: any;
  27526. /** additional data for the event */
  27527. additionalData?: any;
  27528. /**
  27529. * Creates a new ActionEvent
  27530. * @param source The mesh or sprite that triggered the action
  27531. * @param pointerX The X mouse cursor position at the time of the event
  27532. * @param pointerY The Y mouse cursor position at the time of the event
  27533. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27534. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27535. * @param additionalData additional data for the event
  27536. */
  27537. constructor(
  27538. /** The mesh or sprite that triggered the action */
  27539. source: any,
  27540. /** The X mouse cursor position at the time of the event */
  27541. pointerX: number,
  27542. /** The Y mouse cursor position at the time of the event */
  27543. pointerY: number,
  27544. /** The mesh that is currently pointed at (can be null) */
  27545. meshUnderPointer: Nullable<AbstractMesh>,
  27546. /** the original (browser) event that triggered the ActionEvent */
  27547. sourceEvent?: any,
  27548. /** additional data for the event */
  27549. additionalData?: any);
  27550. /**
  27551. * Helper function to auto-create an ActionEvent from a source mesh.
  27552. * @param source The source mesh that triggered the event
  27553. * @param evt The original (browser) event
  27554. * @param additionalData additional data for the event
  27555. * @returns the new ActionEvent
  27556. */
  27557. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27558. /**
  27559. * Helper function to auto-create an ActionEvent from a source sprite
  27560. * @param source The source sprite that triggered the event
  27561. * @param scene Scene associated with the sprite
  27562. * @param evt The original (browser) event
  27563. * @param additionalData additional data for the event
  27564. * @returns the new ActionEvent
  27565. */
  27566. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27567. /**
  27568. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27569. * @param scene the scene where the event occurred
  27570. * @param evt The original (browser) event
  27571. * @returns the new ActionEvent
  27572. */
  27573. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27574. /**
  27575. * Helper function to auto-create an ActionEvent from a primitive
  27576. * @param prim defines the target primitive
  27577. * @param pointerPos defines the pointer position
  27578. * @param evt The original (browser) event
  27579. * @param additionalData additional data for the event
  27580. * @returns the new ActionEvent
  27581. */
  27582. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27583. }
  27584. }
  27585. declare module "babylonjs/Actions/abstractActionManager" {
  27586. import { IDisposable } from "babylonjs/scene";
  27587. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27588. import { IAction } from "babylonjs/Actions/action";
  27589. import { Nullable } from "babylonjs/types";
  27590. /**
  27591. * Abstract class used to decouple action Manager from scene and meshes.
  27592. * Do not instantiate.
  27593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27594. */
  27595. export abstract class AbstractActionManager implements IDisposable {
  27596. /** Gets the list of active triggers */
  27597. static Triggers: {
  27598. [key: string]: number;
  27599. };
  27600. /** Gets the cursor to use when hovering items */
  27601. hoverCursor: string;
  27602. /** Gets the list of actions */
  27603. actions: IAction[];
  27604. /**
  27605. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27606. */
  27607. isRecursive: boolean;
  27608. /**
  27609. * Releases all associated resources
  27610. */
  27611. abstract dispose(): void;
  27612. /**
  27613. * Does this action manager has pointer triggers
  27614. */
  27615. abstract readonly hasPointerTriggers: boolean;
  27616. /**
  27617. * Does this action manager has pick triggers
  27618. */
  27619. abstract readonly hasPickTriggers: boolean;
  27620. /**
  27621. * Process a specific trigger
  27622. * @param trigger defines the trigger to process
  27623. * @param evt defines the event details to be processed
  27624. */
  27625. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27626. /**
  27627. * Does this action manager handles actions of any of the given triggers
  27628. * @param triggers defines the triggers to be tested
  27629. * @return a boolean indicating whether one (or more) of the triggers is handled
  27630. */
  27631. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27632. /**
  27633. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27634. * speed.
  27635. * @param triggerA defines the trigger to be tested
  27636. * @param triggerB defines the trigger to be tested
  27637. * @return a boolean indicating whether one (or more) of the triggers is handled
  27638. */
  27639. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27640. /**
  27641. * Does this action manager handles actions of a given trigger
  27642. * @param trigger defines the trigger to be tested
  27643. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27644. * @return whether the trigger is handled
  27645. */
  27646. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27647. /**
  27648. * Serialize this manager to a JSON object
  27649. * @param name defines the property name to store this manager
  27650. * @returns a JSON representation of this manager
  27651. */
  27652. abstract serialize(name: string): any;
  27653. /**
  27654. * Registers an action to this action manager
  27655. * @param action defines the action to be registered
  27656. * @return the action amended (prepared) after registration
  27657. */
  27658. abstract registerAction(action: IAction): Nullable<IAction>;
  27659. /**
  27660. * Unregisters an action to this action manager
  27661. * @param action defines the action to be unregistered
  27662. * @return a boolean indicating whether the action has been unregistered
  27663. */
  27664. abstract unregisterAction(action: IAction): Boolean;
  27665. /**
  27666. * Does exist one action manager with at least one trigger
  27667. **/
  27668. static readonly HasTriggers: boolean;
  27669. /**
  27670. * Does exist one action manager with at least one pick trigger
  27671. **/
  27672. static readonly HasPickTriggers: boolean;
  27673. /**
  27674. * Does exist one action manager that handles actions of a given trigger
  27675. * @param trigger defines the trigger to be tested
  27676. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27677. **/
  27678. static HasSpecificTrigger(trigger: number): boolean;
  27679. }
  27680. }
  27681. declare module "babylonjs/node" {
  27682. import { Scene } from "babylonjs/scene";
  27683. import { Nullable } from "babylonjs/types";
  27684. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27685. import { Engine } from "babylonjs/Engines/engine";
  27686. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27687. import { Observable } from "babylonjs/Misc/observable";
  27688. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27689. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27690. import { Animatable } from "babylonjs/Animations/animatable";
  27691. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27692. import { Animation } from "babylonjs/Animations/animation";
  27693. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27695. /**
  27696. * Defines how a node can be built from a string name.
  27697. */
  27698. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27699. /**
  27700. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27701. */
  27702. export class Node implements IBehaviorAware<Node> {
  27703. /** @hidden */
  27704. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27705. private static _NodeConstructors;
  27706. /**
  27707. * Add a new node constructor
  27708. * @param type defines the type name of the node to construct
  27709. * @param constructorFunc defines the constructor function
  27710. */
  27711. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27712. /**
  27713. * Returns a node constructor based on type name
  27714. * @param type defines the type name
  27715. * @param name defines the new node name
  27716. * @param scene defines the hosting scene
  27717. * @param options defines optional options to transmit to constructors
  27718. * @returns the new constructor or null
  27719. */
  27720. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27721. /**
  27722. * Gets or sets the name of the node
  27723. */
  27724. name: string;
  27725. /**
  27726. * Gets or sets the id of the node
  27727. */
  27728. id: string;
  27729. /**
  27730. * Gets or sets the unique id of the node
  27731. */
  27732. uniqueId: number;
  27733. /**
  27734. * Gets or sets a string used to store user defined state for the node
  27735. */
  27736. state: string;
  27737. /**
  27738. * Gets or sets an object used to store user defined information for the node
  27739. */
  27740. metadata: any;
  27741. /**
  27742. * For internal use only. Please do not use.
  27743. */
  27744. reservedDataStore: any;
  27745. /**
  27746. * List of inspectable custom properties (used by the Inspector)
  27747. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27748. */
  27749. inspectableCustomProperties: IInspectable[];
  27750. private _doNotSerialize;
  27751. /**
  27752. * Gets or sets a boolean used to define if the node must be serialized
  27753. */
  27754. doNotSerialize: boolean;
  27755. /** @hidden */
  27756. _isDisposed: boolean;
  27757. /**
  27758. * Gets a list of Animations associated with the node
  27759. */
  27760. animations: import("babylonjs/Animations/animation").Animation[];
  27761. protected _ranges: {
  27762. [name: string]: Nullable<AnimationRange>;
  27763. };
  27764. /**
  27765. * Callback raised when the node is ready to be used
  27766. */
  27767. onReady: Nullable<(node: Node) => void>;
  27768. private _isEnabled;
  27769. private _isParentEnabled;
  27770. private _isReady;
  27771. /** @hidden */
  27772. _currentRenderId: number;
  27773. private _parentUpdateId;
  27774. /** @hidden */
  27775. _childUpdateId: number;
  27776. /** @hidden */
  27777. _waitingParentId: Nullable<string>;
  27778. /** @hidden */
  27779. _scene: Scene;
  27780. /** @hidden */
  27781. _cache: any;
  27782. private _parentNode;
  27783. private _children;
  27784. /** @hidden */
  27785. _worldMatrix: Matrix;
  27786. /** @hidden */
  27787. _worldMatrixDeterminant: number;
  27788. /** @hidden */
  27789. _worldMatrixDeterminantIsDirty: boolean;
  27790. /** @hidden */
  27791. private _sceneRootNodesIndex;
  27792. /**
  27793. * Gets a boolean indicating if the node has been disposed
  27794. * @returns true if the node was disposed
  27795. */
  27796. isDisposed(): boolean;
  27797. /**
  27798. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27799. * @see https://doc.babylonjs.com/how_to/parenting
  27800. */
  27801. parent: Nullable<Node>;
  27802. private addToSceneRootNodes;
  27803. private removeFromSceneRootNodes;
  27804. private _animationPropertiesOverride;
  27805. /**
  27806. * Gets or sets the animation properties override
  27807. */
  27808. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27809. /**
  27810. * Gets a string idenfifying the name of the class
  27811. * @returns "Node" string
  27812. */
  27813. getClassName(): string;
  27814. /** @hidden */
  27815. readonly _isNode: boolean;
  27816. /**
  27817. * An event triggered when the mesh is disposed
  27818. */
  27819. onDisposeObservable: Observable<Node>;
  27820. private _onDisposeObserver;
  27821. /**
  27822. * Sets a callback that will be raised when the node will be disposed
  27823. */
  27824. onDispose: () => void;
  27825. /**
  27826. * Creates a new Node
  27827. * @param name the name and id to be given to this node
  27828. * @param scene the scene this node will be added to
  27829. * @param addToRootNodes the node will be added to scene.rootNodes
  27830. */
  27831. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27832. /**
  27833. * Gets the scene of the node
  27834. * @returns a scene
  27835. */
  27836. getScene(): Scene;
  27837. /**
  27838. * Gets the engine of the node
  27839. * @returns a Engine
  27840. */
  27841. getEngine(): Engine;
  27842. private _behaviors;
  27843. /**
  27844. * Attach a behavior to the node
  27845. * @see http://doc.babylonjs.com/features/behaviour
  27846. * @param behavior defines the behavior to attach
  27847. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27848. * @returns the current Node
  27849. */
  27850. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27851. /**
  27852. * Remove an attached behavior
  27853. * @see http://doc.babylonjs.com/features/behaviour
  27854. * @param behavior defines the behavior to attach
  27855. * @returns the current Node
  27856. */
  27857. removeBehavior(behavior: Behavior<Node>): Node;
  27858. /**
  27859. * Gets the list of attached behaviors
  27860. * @see http://doc.babylonjs.com/features/behaviour
  27861. */
  27862. readonly behaviors: Behavior<Node>[];
  27863. /**
  27864. * Gets an attached behavior by name
  27865. * @param name defines the name of the behavior to look for
  27866. * @see http://doc.babylonjs.com/features/behaviour
  27867. * @returns null if behavior was not found else the requested behavior
  27868. */
  27869. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27870. /**
  27871. * Returns the latest update of the World matrix
  27872. * @returns a Matrix
  27873. */
  27874. getWorldMatrix(): Matrix;
  27875. /** @hidden */
  27876. _getWorldMatrixDeterminant(): number;
  27877. /**
  27878. * Returns directly the latest state of the mesh World matrix.
  27879. * A Matrix is returned.
  27880. */
  27881. readonly worldMatrixFromCache: Matrix;
  27882. /** @hidden */
  27883. _initCache(): void;
  27884. /** @hidden */
  27885. updateCache(force?: boolean): void;
  27886. /** @hidden */
  27887. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27888. /** @hidden */
  27889. _updateCache(ignoreParentClass?: boolean): void;
  27890. /** @hidden */
  27891. _isSynchronized(): boolean;
  27892. /** @hidden */
  27893. _markSyncedWithParent(): void;
  27894. /** @hidden */
  27895. isSynchronizedWithParent(): boolean;
  27896. /** @hidden */
  27897. isSynchronized(): boolean;
  27898. /**
  27899. * Is this node ready to be used/rendered
  27900. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27901. * @return true if the node is ready
  27902. */
  27903. isReady(completeCheck?: boolean): boolean;
  27904. /**
  27905. * Is this node enabled?
  27906. * 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
  27907. * @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
  27908. * @return whether this node (and its parent) is enabled
  27909. */
  27910. isEnabled(checkAncestors?: boolean): boolean;
  27911. /** @hidden */
  27912. protected _syncParentEnabledState(): void;
  27913. /**
  27914. * Set the enabled state of this node
  27915. * @param value defines the new enabled state
  27916. */
  27917. setEnabled(value: boolean): void;
  27918. /**
  27919. * Is this node a descendant of the given node?
  27920. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27921. * @param ancestor defines the parent node to inspect
  27922. * @returns a boolean indicating if this node is a descendant of the given node
  27923. */
  27924. isDescendantOf(ancestor: Node): boolean;
  27925. /** @hidden */
  27926. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27927. /**
  27928. * Will return all nodes that have this node as ascendant
  27929. * @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
  27930. * @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
  27931. * @return all children nodes of all types
  27932. */
  27933. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27934. /**
  27935. * Get all child-meshes of this node
  27936. * @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)
  27937. * @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
  27938. * @returns an array of AbstractMesh
  27939. */
  27940. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27941. /**
  27942. * Get all direct children of this node
  27943. * @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
  27944. * @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)
  27945. * @returns an array of Node
  27946. */
  27947. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27948. /** @hidden */
  27949. _setReady(state: boolean): void;
  27950. /**
  27951. * Get an animation by name
  27952. * @param name defines the name of the animation to look for
  27953. * @returns null if not found else the requested animation
  27954. */
  27955. getAnimationByName(name: string): Nullable<Animation>;
  27956. /**
  27957. * Creates an animation range for this node
  27958. * @param name defines the name of the range
  27959. * @param from defines the starting key
  27960. * @param to defines the end key
  27961. */
  27962. createAnimationRange(name: string, from: number, to: number): void;
  27963. /**
  27964. * Delete a specific animation range
  27965. * @param name defines the name of the range to delete
  27966. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27967. */
  27968. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27969. /**
  27970. * Get an animation range by name
  27971. * @param name defines the name of the animation range to look for
  27972. * @returns null if not found else the requested animation range
  27973. */
  27974. getAnimationRange(name: string): Nullable<AnimationRange>;
  27975. /**
  27976. * Gets the list of all animation ranges defined on this node
  27977. * @returns an array
  27978. */
  27979. getAnimationRanges(): Nullable<AnimationRange>[];
  27980. /**
  27981. * Will start the animation sequence
  27982. * @param name defines the range frames for animation sequence
  27983. * @param loop defines if the animation should loop (false by default)
  27984. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27985. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27986. * @returns the object created for this animation. If range does not exist, it will return null
  27987. */
  27988. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27989. /**
  27990. * Serialize animation ranges into a JSON compatible object
  27991. * @returns serialization object
  27992. */
  27993. serializeAnimationRanges(): any;
  27994. /**
  27995. * Computes the world matrix of the node
  27996. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27997. * @returns the world matrix
  27998. */
  27999. computeWorldMatrix(force?: boolean): Matrix;
  28000. /**
  28001. * Releases resources associated with this node.
  28002. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28003. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28004. */
  28005. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28006. /**
  28007. * Parse animation range data from a serialization object and store them into a given node
  28008. * @param node defines where to store the animation ranges
  28009. * @param parsedNode defines the serialization object to read data from
  28010. * @param scene defines the hosting scene
  28011. */
  28012. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28013. /**
  28014. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28015. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28016. * @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
  28017. * @returns the new bounding vectors
  28018. */
  28019. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28020. min: Vector3;
  28021. max: Vector3;
  28022. };
  28023. }
  28024. }
  28025. declare module "babylonjs/Animations/animation" {
  28026. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28027. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28028. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28029. import { Nullable } from "babylonjs/types";
  28030. import { Scene } from "babylonjs/scene";
  28031. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28032. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28033. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28034. import { Node } from "babylonjs/node";
  28035. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28036. import { Size } from "babylonjs/Maths/math.size";
  28037. import { Animatable } from "babylonjs/Animations/animatable";
  28038. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28039. /**
  28040. * @hidden
  28041. */
  28042. export class _IAnimationState {
  28043. key: number;
  28044. repeatCount: number;
  28045. workValue?: any;
  28046. loopMode?: number;
  28047. offsetValue?: any;
  28048. highLimitValue?: any;
  28049. }
  28050. /**
  28051. * Class used to store any kind of animation
  28052. */
  28053. export class Animation {
  28054. /**Name of the animation */
  28055. name: string;
  28056. /**Property to animate */
  28057. targetProperty: string;
  28058. /**The frames per second of the animation */
  28059. framePerSecond: number;
  28060. /**The data type of the animation */
  28061. dataType: number;
  28062. /**The loop mode of the animation */
  28063. loopMode?: number | undefined;
  28064. /**Specifies if blending should be enabled */
  28065. enableBlending?: boolean | undefined;
  28066. /**
  28067. * Use matrix interpolation instead of using direct key value when animating matrices
  28068. */
  28069. static AllowMatricesInterpolation: boolean;
  28070. /**
  28071. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28072. */
  28073. static AllowMatrixDecomposeForInterpolation: boolean;
  28074. /**
  28075. * Stores the key frames of the animation
  28076. */
  28077. private _keys;
  28078. /**
  28079. * Stores the easing function of the animation
  28080. */
  28081. private _easingFunction;
  28082. /**
  28083. * @hidden Internal use only
  28084. */
  28085. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28086. /**
  28087. * The set of event that will be linked to this animation
  28088. */
  28089. private _events;
  28090. /**
  28091. * Stores an array of target property paths
  28092. */
  28093. targetPropertyPath: string[];
  28094. /**
  28095. * Stores the blending speed of the animation
  28096. */
  28097. blendingSpeed: number;
  28098. /**
  28099. * Stores the animation ranges for the animation
  28100. */
  28101. private _ranges;
  28102. /**
  28103. * @hidden Internal use
  28104. */
  28105. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28106. /**
  28107. * Sets up an animation
  28108. * @param property The property to animate
  28109. * @param animationType The animation type to apply
  28110. * @param framePerSecond The frames per second of the animation
  28111. * @param easingFunction The easing function used in the animation
  28112. * @returns The created animation
  28113. */
  28114. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28115. /**
  28116. * Create and start an animation on a node
  28117. * @param name defines the name of the global animation that will be run on all nodes
  28118. * @param node defines the root node where the animation will take place
  28119. * @param targetProperty defines property to animate
  28120. * @param framePerSecond defines the number of frame per second yo use
  28121. * @param totalFrame defines the number of frames in total
  28122. * @param from defines the initial value
  28123. * @param to defines the final value
  28124. * @param loopMode defines which loop mode you want to use (off by default)
  28125. * @param easingFunction defines the easing function to use (linear by default)
  28126. * @param onAnimationEnd defines the callback to call when animation end
  28127. * @returns the animatable created for this animation
  28128. */
  28129. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28130. /**
  28131. * Create and start an animation on a node and its descendants
  28132. * @param name defines the name of the global animation that will be run on all nodes
  28133. * @param node defines the root node where the animation will take place
  28134. * @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
  28135. * @param targetProperty defines property to animate
  28136. * @param framePerSecond defines the number of frame per second to use
  28137. * @param totalFrame defines the number of frames in total
  28138. * @param from defines the initial value
  28139. * @param to defines the final value
  28140. * @param loopMode defines which loop mode you want to use (off by default)
  28141. * @param easingFunction defines the easing function to use (linear by default)
  28142. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28143. * @returns the list of animatables created for all nodes
  28144. * @example https://www.babylonjs-playground.com/#MH0VLI
  28145. */
  28146. 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[]>;
  28147. /**
  28148. * Creates a new animation, merges it with the existing animations and starts it
  28149. * @param name Name of the animation
  28150. * @param node Node which contains the scene that begins the animations
  28151. * @param targetProperty Specifies which property to animate
  28152. * @param framePerSecond The frames per second of the animation
  28153. * @param totalFrame The total number of frames
  28154. * @param from The frame at the beginning of the animation
  28155. * @param to The frame at the end of the animation
  28156. * @param loopMode Specifies the loop mode of the animation
  28157. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28158. * @param onAnimationEnd Callback to run once the animation is complete
  28159. * @returns Nullable animation
  28160. */
  28161. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28162. /**
  28163. * Transition property of an host to the target Value
  28164. * @param property The property to transition
  28165. * @param targetValue The target Value of the property
  28166. * @param host The object where the property to animate belongs
  28167. * @param scene Scene used to run the animation
  28168. * @param frameRate Framerate (in frame/s) to use
  28169. * @param transition The transition type we want to use
  28170. * @param duration The duration of the animation, in milliseconds
  28171. * @param onAnimationEnd Callback trigger at the end of the animation
  28172. * @returns Nullable animation
  28173. */
  28174. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28175. /**
  28176. * Return the array of runtime animations currently using this animation
  28177. */
  28178. readonly runtimeAnimations: RuntimeAnimation[];
  28179. /**
  28180. * Specifies if any of the runtime animations are currently running
  28181. */
  28182. readonly hasRunningRuntimeAnimations: boolean;
  28183. /**
  28184. * Initializes the animation
  28185. * @param name Name of the animation
  28186. * @param targetProperty Property to animate
  28187. * @param framePerSecond The frames per second of the animation
  28188. * @param dataType The data type of the animation
  28189. * @param loopMode The loop mode of the animation
  28190. * @param enableBlending Specifies if blending should be enabled
  28191. */
  28192. constructor(
  28193. /**Name of the animation */
  28194. name: string,
  28195. /**Property to animate */
  28196. targetProperty: string,
  28197. /**The frames per second of the animation */
  28198. framePerSecond: number,
  28199. /**The data type of the animation */
  28200. dataType: number,
  28201. /**The loop mode of the animation */
  28202. loopMode?: number | undefined,
  28203. /**Specifies if blending should be enabled */
  28204. enableBlending?: boolean | undefined);
  28205. /**
  28206. * Converts the animation to a string
  28207. * @param fullDetails support for multiple levels of logging within scene loading
  28208. * @returns String form of the animation
  28209. */
  28210. toString(fullDetails?: boolean): string;
  28211. /**
  28212. * Add an event to this animation
  28213. * @param event Event to add
  28214. */
  28215. addEvent(event: AnimationEvent): void;
  28216. /**
  28217. * Remove all events found at the given frame
  28218. * @param frame The frame to remove events from
  28219. */
  28220. removeEvents(frame: number): void;
  28221. /**
  28222. * Retrieves all the events from the animation
  28223. * @returns Events from the animation
  28224. */
  28225. getEvents(): AnimationEvent[];
  28226. /**
  28227. * Creates an animation range
  28228. * @param name Name of the animation range
  28229. * @param from Starting frame of the animation range
  28230. * @param to Ending frame of the animation
  28231. */
  28232. createRange(name: string, from: number, to: number): void;
  28233. /**
  28234. * Deletes an animation range by name
  28235. * @param name Name of the animation range to delete
  28236. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28237. */
  28238. deleteRange(name: string, deleteFrames?: boolean): void;
  28239. /**
  28240. * Gets the animation range by name, or null if not defined
  28241. * @param name Name of the animation range
  28242. * @returns Nullable animation range
  28243. */
  28244. getRange(name: string): Nullable<AnimationRange>;
  28245. /**
  28246. * Gets the key frames from the animation
  28247. * @returns The key frames of the animation
  28248. */
  28249. getKeys(): Array<IAnimationKey>;
  28250. /**
  28251. * Gets the highest frame rate of the animation
  28252. * @returns Highest frame rate of the animation
  28253. */
  28254. getHighestFrame(): number;
  28255. /**
  28256. * Gets the easing function of the animation
  28257. * @returns Easing function of the animation
  28258. */
  28259. getEasingFunction(): IEasingFunction;
  28260. /**
  28261. * Sets the easing function of the animation
  28262. * @param easingFunction A custom mathematical formula for animation
  28263. */
  28264. setEasingFunction(easingFunction: EasingFunction): void;
  28265. /**
  28266. * Interpolates a scalar linearly
  28267. * @param startValue Start value of the animation curve
  28268. * @param endValue End value of the animation curve
  28269. * @param gradient Scalar amount to interpolate
  28270. * @returns Interpolated scalar value
  28271. */
  28272. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28273. /**
  28274. * Interpolates a scalar cubically
  28275. * @param startValue Start value of the animation curve
  28276. * @param outTangent End tangent of the animation
  28277. * @param endValue End value of the animation curve
  28278. * @param inTangent Start tangent of the animation curve
  28279. * @param gradient Scalar amount to interpolate
  28280. * @returns Interpolated scalar value
  28281. */
  28282. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28283. /**
  28284. * Interpolates a quaternion using a spherical linear interpolation
  28285. * @param startValue Start value of the animation curve
  28286. * @param endValue End value of the animation curve
  28287. * @param gradient Scalar amount to interpolate
  28288. * @returns Interpolated quaternion value
  28289. */
  28290. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28291. /**
  28292. * Interpolates a quaternion cubically
  28293. * @param startValue Start value of the animation curve
  28294. * @param outTangent End tangent of the animation curve
  28295. * @param endValue End value of the animation curve
  28296. * @param inTangent Start tangent of the animation curve
  28297. * @param gradient Scalar amount to interpolate
  28298. * @returns Interpolated quaternion value
  28299. */
  28300. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28301. /**
  28302. * Interpolates a Vector3 linearl
  28303. * @param startValue Start value of the animation curve
  28304. * @param endValue End value of the animation curve
  28305. * @param gradient Scalar amount to interpolate
  28306. * @returns Interpolated scalar value
  28307. */
  28308. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28309. /**
  28310. * Interpolates a Vector3 cubically
  28311. * @param startValue Start value of the animation curve
  28312. * @param outTangent End tangent of the animation
  28313. * @param endValue End value of the animation curve
  28314. * @param inTangent Start tangent of the animation curve
  28315. * @param gradient Scalar amount to interpolate
  28316. * @returns InterpolatedVector3 value
  28317. */
  28318. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28319. /**
  28320. * Interpolates a Vector2 linearly
  28321. * @param startValue Start value of the animation curve
  28322. * @param endValue End value of the animation curve
  28323. * @param gradient Scalar amount to interpolate
  28324. * @returns Interpolated Vector2 value
  28325. */
  28326. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28327. /**
  28328. * Interpolates a Vector2 cubically
  28329. * @param startValue Start value of the animation curve
  28330. * @param outTangent End tangent of the animation
  28331. * @param endValue End value of the animation curve
  28332. * @param inTangent Start tangent of the animation curve
  28333. * @param gradient Scalar amount to interpolate
  28334. * @returns Interpolated Vector2 value
  28335. */
  28336. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28337. /**
  28338. * Interpolates a size linearly
  28339. * @param startValue Start value of the animation curve
  28340. * @param endValue End value of the animation curve
  28341. * @param gradient Scalar amount to interpolate
  28342. * @returns Interpolated Size value
  28343. */
  28344. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28345. /**
  28346. * Interpolates a Color3 linearly
  28347. * @param startValue Start value of the animation curve
  28348. * @param endValue End value of the animation curve
  28349. * @param gradient Scalar amount to interpolate
  28350. * @returns Interpolated Color3 value
  28351. */
  28352. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28353. /**
  28354. * Interpolates a Color4 linearly
  28355. * @param startValue Start value of the animation curve
  28356. * @param endValue End value of the animation curve
  28357. * @param gradient Scalar amount to interpolate
  28358. * @returns Interpolated Color3 value
  28359. */
  28360. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28361. /**
  28362. * @hidden Internal use only
  28363. */
  28364. _getKeyValue(value: any): any;
  28365. /**
  28366. * @hidden Internal use only
  28367. */
  28368. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28369. /**
  28370. * Defines the function to use to interpolate matrices
  28371. * @param startValue defines the start matrix
  28372. * @param endValue defines the end matrix
  28373. * @param gradient defines the gradient between both matrices
  28374. * @param result defines an optional target matrix where to store the interpolation
  28375. * @returns the interpolated matrix
  28376. */
  28377. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28378. /**
  28379. * Makes a copy of the animation
  28380. * @returns Cloned animation
  28381. */
  28382. clone(): Animation;
  28383. /**
  28384. * Sets the key frames of the animation
  28385. * @param values The animation key frames to set
  28386. */
  28387. setKeys(values: Array<IAnimationKey>): void;
  28388. /**
  28389. * Serializes the animation to an object
  28390. * @returns Serialized object
  28391. */
  28392. serialize(): any;
  28393. /**
  28394. * Float animation type
  28395. */
  28396. static readonly ANIMATIONTYPE_FLOAT: number;
  28397. /**
  28398. * Vector3 animation type
  28399. */
  28400. static readonly ANIMATIONTYPE_VECTOR3: number;
  28401. /**
  28402. * Quaternion animation type
  28403. */
  28404. static readonly ANIMATIONTYPE_QUATERNION: number;
  28405. /**
  28406. * Matrix animation type
  28407. */
  28408. static readonly ANIMATIONTYPE_MATRIX: number;
  28409. /**
  28410. * Color3 animation type
  28411. */
  28412. static readonly ANIMATIONTYPE_COLOR3: number;
  28413. /**
  28414. * Color3 animation type
  28415. */
  28416. static readonly ANIMATIONTYPE_COLOR4: number;
  28417. /**
  28418. * Vector2 animation type
  28419. */
  28420. static readonly ANIMATIONTYPE_VECTOR2: number;
  28421. /**
  28422. * Size animation type
  28423. */
  28424. static readonly ANIMATIONTYPE_SIZE: number;
  28425. /**
  28426. * Relative Loop Mode
  28427. */
  28428. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28429. /**
  28430. * Cycle Loop Mode
  28431. */
  28432. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28433. /**
  28434. * Constant Loop Mode
  28435. */
  28436. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28437. /** @hidden */
  28438. static _UniversalLerp(left: any, right: any, amount: number): any;
  28439. /**
  28440. * Parses an animation object and creates an animation
  28441. * @param parsedAnimation Parsed animation object
  28442. * @returns Animation object
  28443. */
  28444. static Parse(parsedAnimation: any): Animation;
  28445. /**
  28446. * Appends the serialized animations from the source animations
  28447. * @param source Source containing the animations
  28448. * @param destination Target to store the animations
  28449. */
  28450. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28451. }
  28452. }
  28453. declare module "babylonjs/Animations/animatable.interface" {
  28454. import { Nullable } from "babylonjs/types";
  28455. import { Animation } from "babylonjs/Animations/animation";
  28456. /**
  28457. * Interface containing an array of animations
  28458. */
  28459. export interface IAnimatable {
  28460. /**
  28461. * Array of animations
  28462. */
  28463. animations: Nullable<Array<Animation>>;
  28464. }
  28465. }
  28466. declare module "babylonjs/Materials/fresnelParameters" {
  28467. import { Color3 } from "babylonjs/Maths/math.color";
  28468. /**
  28469. * This represents all the required information to add a fresnel effect on a material:
  28470. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28471. */
  28472. export class FresnelParameters {
  28473. private _isEnabled;
  28474. /**
  28475. * Define if the fresnel effect is enable or not.
  28476. */
  28477. isEnabled: boolean;
  28478. /**
  28479. * Define the color used on edges (grazing angle)
  28480. */
  28481. leftColor: Color3;
  28482. /**
  28483. * Define the color used on center
  28484. */
  28485. rightColor: Color3;
  28486. /**
  28487. * Define bias applied to computed fresnel term
  28488. */
  28489. bias: number;
  28490. /**
  28491. * Defined the power exponent applied to fresnel term
  28492. */
  28493. power: number;
  28494. /**
  28495. * Clones the current fresnel and its valuues
  28496. * @returns a clone fresnel configuration
  28497. */
  28498. clone(): FresnelParameters;
  28499. /**
  28500. * Serializes the current fresnel parameters to a JSON representation.
  28501. * @return the JSON serialization
  28502. */
  28503. serialize(): any;
  28504. /**
  28505. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28506. * @param parsedFresnelParameters Define the JSON representation
  28507. * @returns the parsed parameters
  28508. */
  28509. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28510. }
  28511. }
  28512. declare module "babylonjs/Misc/decorators" {
  28513. import { Nullable } from "babylonjs/types";
  28514. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28515. import { Scene } from "babylonjs/scene";
  28516. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28517. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28518. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28519. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28520. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28521. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28522. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28523. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28524. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28525. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28526. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28527. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28528. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28529. /**
  28530. * Decorator used to define property that can be serialized as reference to a camera
  28531. * @param sourceName defines the name of the property to decorate
  28532. */
  28533. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28534. /**
  28535. * Class used to help serialization objects
  28536. */
  28537. export class SerializationHelper {
  28538. /** @hidden */
  28539. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28540. /** @hidden */
  28541. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28542. /** @hidden */
  28543. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28544. /** @hidden */
  28545. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28546. /**
  28547. * Appends the serialized animations from the source animations
  28548. * @param source Source containing the animations
  28549. * @param destination Target to store the animations
  28550. */
  28551. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28552. /**
  28553. * Static function used to serialized a specific entity
  28554. * @param entity defines the entity to serialize
  28555. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28556. * @returns a JSON compatible object representing the serialization of the entity
  28557. */
  28558. static Serialize<T>(entity: T, serializationObject?: any): any;
  28559. /**
  28560. * Creates a new entity from a serialization data object
  28561. * @param creationFunction defines a function used to instanciated the new entity
  28562. * @param source defines the source serialization data
  28563. * @param scene defines the hosting scene
  28564. * @param rootUrl defines the root url for resources
  28565. * @returns a new entity
  28566. */
  28567. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28568. /**
  28569. * Clones an object
  28570. * @param creationFunction defines the function used to instanciate the new object
  28571. * @param source defines the source object
  28572. * @returns the cloned object
  28573. */
  28574. static Clone<T>(creationFunction: () => T, source: T): T;
  28575. /**
  28576. * Instanciates a new object based on a source one (some data will be shared between both object)
  28577. * @param creationFunction defines the function used to instanciate the new object
  28578. * @param source defines the source object
  28579. * @returns the new object
  28580. */
  28581. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28582. }
  28583. }
  28584. declare module "babylonjs/Misc/guid" {
  28585. /**
  28586. * Class used to manipulate GUIDs
  28587. */
  28588. export class GUID {
  28589. /**
  28590. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28591. * Be aware Math.random() could cause collisions, but:
  28592. * "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"
  28593. * @returns a pseudo random id
  28594. */
  28595. static RandomId(): string;
  28596. }
  28597. }
  28598. declare module "babylonjs/Materials/Textures/baseTexture" {
  28599. import { Observable } from "babylonjs/Misc/observable";
  28600. import { Nullable } from "babylonjs/types";
  28601. import { Scene } from "babylonjs/scene";
  28602. import { Matrix } from "babylonjs/Maths/math.vector";
  28603. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28604. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28605. import { ISize } from "babylonjs/Maths/math.size";
  28606. /**
  28607. * Base class of all the textures in babylon.
  28608. * It groups all the common properties the materials, post process, lights... might need
  28609. * in order to make a correct use of the texture.
  28610. */
  28611. export class BaseTexture implements IAnimatable {
  28612. /**
  28613. * Default anisotropic filtering level for the application.
  28614. * It is set to 4 as a good tradeoff between perf and quality.
  28615. */
  28616. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28617. /**
  28618. * Gets or sets the unique id of the texture
  28619. */
  28620. uniqueId: number;
  28621. /**
  28622. * Define the name of the texture.
  28623. */
  28624. name: string;
  28625. /**
  28626. * Gets or sets an object used to store user defined information.
  28627. */
  28628. metadata: any;
  28629. /**
  28630. * For internal use only. Please do not use.
  28631. */
  28632. reservedDataStore: any;
  28633. private _hasAlpha;
  28634. /**
  28635. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28636. */
  28637. hasAlpha: boolean;
  28638. /**
  28639. * Defines if the alpha value should be determined via the rgb values.
  28640. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28641. */
  28642. getAlphaFromRGB: boolean;
  28643. /**
  28644. * Intensity or strength of the texture.
  28645. * It is commonly used by materials to fine tune the intensity of the texture
  28646. */
  28647. level: number;
  28648. /**
  28649. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28650. * This is part of the texture as textures usually maps to one uv set.
  28651. */
  28652. coordinatesIndex: number;
  28653. private _coordinatesMode;
  28654. /**
  28655. * How a texture is mapped.
  28656. *
  28657. * | Value | Type | Description |
  28658. * | ----- | ----------------------------------- | ----------- |
  28659. * | 0 | EXPLICIT_MODE | |
  28660. * | 1 | SPHERICAL_MODE | |
  28661. * | 2 | PLANAR_MODE | |
  28662. * | 3 | CUBIC_MODE | |
  28663. * | 4 | PROJECTION_MODE | |
  28664. * | 5 | SKYBOX_MODE | |
  28665. * | 6 | INVCUBIC_MODE | |
  28666. * | 7 | EQUIRECTANGULAR_MODE | |
  28667. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28668. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28669. */
  28670. coordinatesMode: number;
  28671. /**
  28672. * | Value | Type | Description |
  28673. * | ----- | ------------------ | ----------- |
  28674. * | 0 | CLAMP_ADDRESSMODE | |
  28675. * | 1 | WRAP_ADDRESSMODE | |
  28676. * | 2 | MIRROR_ADDRESSMODE | |
  28677. */
  28678. wrapU: number;
  28679. /**
  28680. * | Value | Type | Description |
  28681. * | ----- | ------------------ | ----------- |
  28682. * | 0 | CLAMP_ADDRESSMODE | |
  28683. * | 1 | WRAP_ADDRESSMODE | |
  28684. * | 2 | MIRROR_ADDRESSMODE | |
  28685. */
  28686. wrapV: number;
  28687. /**
  28688. * | Value | Type | Description |
  28689. * | ----- | ------------------ | ----------- |
  28690. * | 0 | CLAMP_ADDRESSMODE | |
  28691. * | 1 | WRAP_ADDRESSMODE | |
  28692. * | 2 | MIRROR_ADDRESSMODE | |
  28693. */
  28694. wrapR: number;
  28695. /**
  28696. * With compliant hardware and browser (supporting anisotropic filtering)
  28697. * this defines the level of anisotropic filtering in the texture.
  28698. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28699. */
  28700. anisotropicFilteringLevel: number;
  28701. /**
  28702. * Define if the texture is a cube texture or if false a 2d texture.
  28703. */
  28704. isCube: boolean;
  28705. /**
  28706. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28707. */
  28708. is3D: boolean;
  28709. /**
  28710. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28711. * HDR texture are usually stored in linear space.
  28712. * This only impacts the PBR and Background materials
  28713. */
  28714. gammaSpace: boolean;
  28715. /**
  28716. * Gets or sets whether or not the texture contains RGBD data.
  28717. */
  28718. isRGBD: boolean;
  28719. /**
  28720. * Is Z inverted in the texture (useful in a cube texture).
  28721. */
  28722. invertZ: boolean;
  28723. /**
  28724. * Are mip maps generated for this texture or not.
  28725. */
  28726. readonly noMipmap: boolean;
  28727. /**
  28728. * @hidden
  28729. */
  28730. lodLevelInAlpha: boolean;
  28731. /**
  28732. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28733. */
  28734. lodGenerationOffset: number;
  28735. /**
  28736. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28737. */
  28738. lodGenerationScale: number;
  28739. /**
  28740. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28741. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28742. * average roughness values.
  28743. */
  28744. linearSpecularLOD: boolean;
  28745. /**
  28746. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28747. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28748. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28749. */
  28750. irradianceTexture: Nullable<BaseTexture>;
  28751. /**
  28752. * Define if the texture is a render target.
  28753. */
  28754. isRenderTarget: boolean;
  28755. /**
  28756. * Define the unique id of the texture in the scene.
  28757. */
  28758. readonly uid: string;
  28759. /**
  28760. * Return a string representation of the texture.
  28761. * @returns the texture as a string
  28762. */
  28763. toString(): string;
  28764. /**
  28765. * Get the class name of the texture.
  28766. * @returns "BaseTexture"
  28767. */
  28768. getClassName(): string;
  28769. /**
  28770. * Define the list of animation attached to the texture.
  28771. */
  28772. animations: import("babylonjs/Animations/animation").Animation[];
  28773. /**
  28774. * An event triggered when the texture is disposed.
  28775. */
  28776. onDisposeObservable: Observable<BaseTexture>;
  28777. private _onDisposeObserver;
  28778. /**
  28779. * Callback triggered when the texture has been disposed.
  28780. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28781. */
  28782. onDispose: () => void;
  28783. /**
  28784. * Define the current state of the loading sequence when in delayed load mode.
  28785. */
  28786. delayLoadState: number;
  28787. private _scene;
  28788. /** @hidden */
  28789. _texture: Nullable<InternalTexture>;
  28790. private _uid;
  28791. /**
  28792. * Define if the texture is preventinga material to render or not.
  28793. * If not and the texture is not ready, the engine will use a default black texture instead.
  28794. */
  28795. readonly isBlocking: boolean;
  28796. /**
  28797. * Instantiates a new BaseTexture.
  28798. * Base class of all the textures in babylon.
  28799. * It groups all the common properties the materials, post process, lights... might need
  28800. * in order to make a correct use of the texture.
  28801. * @param scene Define the scene the texture blongs to
  28802. */
  28803. constructor(scene: Nullable<Scene>);
  28804. /**
  28805. * Get the scene the texture belongs to.
  28806. * @returns the scene or null if undefined
  28807. */
  28808. getScene(): Nullable<Scene>;
  28809. /**
  28810. * Get the texture transform matrix used to offset tile the texture for istance.
  28811. * @returns the transformation matrix
  28812. */
  28813. getTextureMatrix(): Matrix;
  28814. /**
  28815. * Get the texture reflection matrix used to rotate/transform the reflection.
  28816. * @returns the reflection matrix
  28817. */
  28818. getReflectionTextureMatrix(): Matrix;
  28819. /**
  28820. * Get the underlying lower level texture from Babylon.
  28821. * @returns the insternal texture
  28822. */
  28823. getInternalTexture(): Nullable<InternalTexture>;
  28824. /**
  28825. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28826. * @returns true if ready or not blocking
  28827. */
  28828. isReadyOrNotBlocking(): boolean;
  28829. /**
  28830. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28831. * @returns true if fully ready
  28832. */
  28833. isReady(): boolean;
  28834. private _cachedSize;
  28835. /**
  28836. * Get the size of the texture.
  28837. * @returns the texture size.
  28838. */
  28839. getSize(): ISize;
  28840. /**
  28841. * Get the base size of the texture.
  28842. * It can be different from the size if the texture has been resized for POT for instance
  28843. * @returns the base size
  28844. */
  28845. getBaseSize(): ISize;
  28846. /**
  28847. * Update the sampling mode of the texture.
  28848. * Default is Trilinear mode.
  28849. *
  28850. * | Value | Type | Description |
  28851. * | ----- | ------------------ | ----------- |
  28852. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28853. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28854. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28855. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28856. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28857. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28858. * | 7 | NEAREST_LINEAR | |
  28859. * | 8 | NEAREST_NEAREST | |
  28860. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28861. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28862. * | 11 | LINEAR_LINEAR | |
  28863. * | 12 | LINEAR_NEAREST | |
  28864. *
  28865. * > _mag_: magnification filter (close to the viewer)
  28866. * > _min_: minification filter (far from the viewer)
  28867. * > _mip_: filter used between mip map levels
  28868. *@param samplingMode Define the new sampling mode of the texture
  28869. */
  28870. updateSamplingMode(samplingMode: number): void;
  28871. /**
  28872. * Scales the texture if is `canRescale()`
  28873. * @param ratio the resize factor we want to use to rescale
  28874. */
  28875. scale(ratio: number): void;
  28876. /**
  28877. * Get if the texture can rescale.
  28878. */
  28879. readonly canRescale: boolean;
  28880. /** @hidden */
  28881. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28882. /** @hidden */
  28883. _rebuild(): void;
  28884. /**
  28885. * Triggers the load sequence in delayed load mode.
  28886. */
  28887. delayLoad(): void;
  28888. /**
  28889. * Clones the texture.
  28890. * @returns the cloned texture
  28891. */
  28892. clone(): Nullable<BaseTexture>;
  28893. /**
  28894. * Get the texture underlying type (INT, FLOAT...)
  28895. */
  28896. readonly textureType: number;
  28897. /**
  28898. * Get the texture underlying format (RGB, RGBA...)
  28899. */
  28900. readonly textureFormat: number;
  28901. /**
  28902. * Indicates that textures need to be re-calculated for all materials
  28903. */
  28904. protected _markAllSubMeshesAsTexturesDirty(): void;
  28905. /**
  28906. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28907. * This will returns an RGBA array buffer containing either in values (0-255) or
  28908. * float values (0-1) depending of the underlying buffer type.
  28909. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28910. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28911. * @param buffer defines a user defined buffer to fill with data (can be null)
  28912. * @returns The Array buffer containing the pixels data.
  28913. */
  28914. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28915. /**
  28916. * Release and destroy the underlying lower level texture aka internalTexture.
  28917. */
  28918. releaseInternalTexture(): void;
  28919. /** @hidden */
  28920. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28921. /** @hidden */
  28922. readonly _lodTextureMid: Nullable<BaseTexture>;
  28923. /** @hidden */
  28924. readonly _lodTextureLow: Nullable<BaseTexture>;
  28925. /**
  28926. * Dispose the texture and release its associated resources.
  28927. */
  28928. dispose(): void;
  28929. /**
  28930. * Serialize the texture into a JSON representation that can be parsed later on.
  28931. * @returns the JSON representation of the texture
  28932. */
  28933. serialize(): any;
  28934. /**
  28935. * Helper function to be called back once a list of texture contains only ready textures.
  28936. * @param textures Define the list of textures to wait for
  28937. * @param callback Define the callback triggered once the entire list will be ready
  28938. */
  28939. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28940. }
  28941. }
  28942. declare module "babylonjs/Materials/effect" {
  28943. import { Observable } from "babylonjs/Misc/observable";
  28944. import { Nullable } from "babylonjs/types";
  28945. import { IDisposable } from "babylonjs/scene";
  28946. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28947. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28948. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28949. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28950. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28951. import { Engine } from "babylonjs/Engines/engine";
  28952. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28954. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28955. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28956. /**
  28957. * Options to be used when creating an effect.
  28958. */
  28959. export interface IEffectCreationOptions {
  28960. /**
  28961. * Atrributes that will be used in the shader.
  28962. */
  28963. attributes: string[];
  28964. /**
  28965. * Uniform varible names that will be set in the shader.
  28966. */
  28967. uniformsNames: string[];
  28968. /**
  28969. * Uniform buffer varible names that will be set in the shader.
  28970. */
  28971. uniformBuffersNames: string[];
  28972. /**
  28973. * Sampler texture variable names that will be set in the shader.
  28974. */
  28975. samplers: string[];
  28976. /**
  28977. * Define statements that will be set in the shader.
  28978. */
  28979. defines: any;
  28980. /**
  28981. * Possible fallbacks for this effect to improve performance when needed.
  28982. */
  28983. fallbacks: Nullable<IEffectFallbacks>;
  28984. /**
  28985. * Callback that will be called when the shader is compiled.
  28986. */
  28987. onCompiled: Nullable<(effect: Effect) => void>;
  28988. /**
  28989. * Callback that will be called if an error occurs during shader compilation.
  28990. */
  28991. onError: Nullable<(effect: Effect, errors: string) => void>;
  28992. /**
  28993. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28994. */
  28995. indexParameters?: any;
  28996. /**
  28997. * Max number of lights that can be used in the shader.
  28998. */
  28999. maxSimultaneousLights?: number;
  29000. /**
  29001. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29002. */
  29003. transformFeedbackVaryings?: Nullable<string[]>;
  29004. }
  29005. /**
  29006. * Effect containing vertex and fragment shader that can be executed on an object.
  29007. */
  29008. export class Effect implements IDisposable {
  29009. /**
  29010. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29011. */
  29012. static ShadersRepository: string;
  29013. /**
  29014. * Name of the effect.
  29015. */
  29016. name: any;
  29017. /**
  29018. * String container all the define statements that should be set on the shader.
  29019. */
  29020. defines: string;
  29021. /**
  29022. * Callback that will be called when the shader is compiled.
  29023. */
  29024. onCompiled: Nullable<(effect: Effect) => void>;
  29025. /**
  29026. * Callback that will be called if an error occurs during shader compilation.
  29027. */
  29028. onError: Nullable<(effect: Effect, errors: string) => void>;
  29029. /**
  29030. * Callback that will be called when effect is bound.
  29031. */
  29032. onBind: Nullable<(effect: Effect) => void>;
  29033. /**
  29034. * Unique ID of the effect.
  29035. */
  29036. uniqueId: number;
  29037. /**
  29038. * Observable that will be called when the shader is compiled.
  29039. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29040. */
  29041. onCompileObservable: Observable<Effect>;
  29042. /**
  29043. * Observable that will be called if an error occurs during shader compilation.
  29044. */
  29045. onErrorObservable: Observable<Effect>;
  29046. /** @hidden */
  29047. _onBindObservable: Nullable<Observable<Effect>>;
  29048. /**
  29049. * Observable that will be called when effect is bound.
  29050. */
  29051. readonly onBindObservable: Observable<Effect>;
  29052. /** @hidden */
  29053. _bonesComputationForcedToCPU: boolean;
  29054. private static _uniqueIdSeed;
  29055. private _engine;
  29056. private _uniformBuffersNames;
  29057. private _uniformsNames;
  29058. private _samplerList;
  29059. private _samplers;
  29060. private _isReady;
  29061. private _compilationError;
  29062. private _allFallbacksProcessed;
  29063. private _attributesNames;
  29064. private _attributes;
  29065. private _uniforms;
  29066. /**
  29067. * Key for the effect.
  29068. * @hidden
  29069. */
  29070. _key: string;
  29071. private _indexParameters;
  29072. private _fallbacks;
  29073. private _vertexSourceCode;
  29074. private _fragmentSourceCode;
  29075. private _vertexSourceCodeOverride;
  29076. private _fragmentSourceCodeOverride;
  29077. private _transformFeedbackVaryings;
  29078. /**
  29079. * Compiled shader to webGL program.
  29080. * @hidden
  29081. */
  29082. _pipelineContext: Nullable<IPipelineContext>;
  29083. private _valueCache;
  29084. private static _baseCache;
  29085. /**
  29086. * Instantiates an effect.
  29087. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29088. * @param baseName Name of the effect.
  29089. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29090. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29091. * @param samplers List of sampler variables that will be passed to the shader.
  29092. * @param engine Engine to be used to render the effect
  29093. * @param defines Define statements to be added to the shader.
  29094. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29095. * @param onCompiled Callback that will be called when the shader is compiled.
  29096. * @param onError Callback that will be called if an error occurs during shader compilation.
  29097. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29098. */
  29099. 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);
  29100. private _useFinalCode;
  29101. /**
  29102. * Unique key for this effect
  29103. */
  29104. readonly key: string;
  29105. /**
  29106. * If the effect has been compiled and prepared.
  29107. * @returns if the effect is compiled and prepared.
  29108. */
  29109. isReady(): boolean;
  29110. private _isReadyInternal;
  29111. /**
  29112. * The engine the effect was initialized with.
  29113. * @returns the engine.
  29114. */
  29115. getEngine(): Engine;
  29116. /**
  29117. * The pipeline context for this effect
  29118. * @returns the associated pipeline context
  29119. */
  29120. getPipelineContext(): Nullable<IPipelineContext>;
  29121. /**
  29122. * The set of names of attribute variables for the shader.
  29123. * @returns An array of attribute names.
  29124. */
  29125. getAttributesNames(): string[];
  29126. /**
  29127. * Returns the attribute at the given index.
  29128. * @param index The index of the attribute.
  29129. * @returns The location of the attribute.
  29130. */
  29131. getAttributeLocation(index: number): number;
  29132. /**
  29133. * Returns the attribute based on the name of the variable.
  29134. * @param name of the attribute to look up.
  29135. * @returns the attribute location.
  29136. */
  29137. getAttributeLocationByName(name: string): number;
  29138. /**
  29139. * The number of attributes.
  29140. * @returns the numnber of attributes.
  29141. */
  29142. getAttributesCount(): number;
  29143. /**
  29144. * Gets the index of a uniform variable.
  29145. * @param uniformName of the uniform to look up.
  29146. * @returns the index.
  29147. */
  29148. getUniformIndex(uniformName: string): number;
  29149. /**
  29150. * Returns the attribute based on the name of the variable.
  29151. * @param uniformName of the uniform to look up.
  29152. * @returns the location of the uniform.
  29153. */
  29154. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29155. /**
  29156. * Returns an array of sampler variable names
  29157. * @returns The array of sampler variable neames.
  29158. */
  29159. getSamplers(): string[];
  29160. /**
  29161. * The error from the last compilation.
  29162. * @returns the error string.
  29163. */
  29164. getCompilationError(): string;
  29165. /**
  29166. * Gets a boolean indicating that all fallbacks were used during compilation
  29167. * @returns true if all fallbacks were used
  29168. */
  29169. allFallbacksProcessed(): boolean;
  29170. /**
  29171. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29172. * @param func The callback to be used.
  29173. */
  29174. executeWhenCompiled(func: (effect: Effect) => void): void;
  29175. private _checkIsReady;
  29176. private _loadShader;
  29177. /**
  29178. * Recompiles the webGL program
  29179. * @param vertexSourceCode The source code for the vertex shader.
  29180. * @param fragmentSourceCode The source code for the fragment shader.
  29181. * @param onCompiled Callback called when completed.
  29182. * @param onError Callback called on error.
  29183. * @hidden
  29184. */
  29185. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29186. /**
  29187. * Prepares the effect
  29188. * @hidden
  29189. */
  29190. _prepareEffect(): void;
  29191. private _processCompilationErrors;
  29192. /**
  29193. * Checks if the effect is supported. (Must be called after compilation)
  29194. */
  29195. readonly isSupported: boolean;
  29196. /**
  29197. * Binds a texture to the engine to be used as output of the shader.
  29198. * @param channel Name of the output variable.
  29199. * @param texture Texture to bind.
  29200. * @hidden
  29201. */
  29202. _bindTexture(channel: string, texture: InternalTexture): void;
  29203. /**
  29204. * Sets a texture on the engine to be used in the shader.
  29205. * @param channel Name of the sampler variable.
  29206. * @param texture Texture to set.
  29207. */
  29208. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29209. /**
  29210. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29211. * @param channel Name of the sampler variable.
  29212. * @param texture Texture to set.
  29213. */
  29214. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29215. /**
  29216. * Sets an array of textures on the engine to be used in the shader.
  29217. * @param channel Name of the variable.
  29218. * @param textures Textures to set.
  29219. */
  29220. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29221. /**
  29222. * 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)
  29223. * @param channel Name of the sampler variable.
  29224. * @param postProcess Post process to get the input texture from.
  29225. */
  29226. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29227. /**
  29228. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29229. * 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)
  29230. * @param channel Name of the sampler variable.
  29231. * @param postProcess Post process to get the output texture from.
  29232. */
  29233. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29234. /** @hidden */
  29235. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29236. /** @hidden */
  29237. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29238. /** @hidden */
  29239. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29240. /** @hidden */
  29241. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29242. /**
  29243. * Binds a buffer to a uniform.
  29244. * @param buffer Buffer to bind.
  29245. * @param name Name of the uniform variable to bind to.
  29246. */
  29247. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29248. /**
  29249. * Binds block to a uniform.
  29250. * @param blockName Name of the block to bind.
  29251. * @param index Index to bind.
  29252. */
  29253. bindUniformBlock(blockName: string, index: number): void;
  29254. /**
  29255. * Sets an interger value on a uniform variable.
  29256. * @param uniformName Name of the variable.
  29257. * @param value Value to be set.
  29258. * @returns this effect.
  29259. */
  29260. setInt(uniformName: string, value: number): Effect;
  29261. /**
  29262. * Sets an int array on a uniform variable.
  29263. * @param uniformName Name of the variable.
  29264. * @param array array to be set.
  29265. * @returns this effect.
  29266. */
  29267. setIntArray(uniformName: string, array: Int32Array): Effect;
  29268. /**
  29269. * 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)
  29270. * @param uniformName Name of the variable.
  29271. * @param array array to be set.
  29272. * @returns this effect.
  29273. */
  29274. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29275. /**
  29276. * 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)
  29277. * @param uniformName Name of the variable.
  29278. * @param array array to be set.
  29279. * @returns this effect.
  29280. */
  29281. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29282. /**
  29283. * 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)
  29284. * @param uniformName Name of the variable.
  29285. * @param array array to be set.
  29286. * @returns this effect.
  29287. */
  29288. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29289. /**
  29290. * Sets an float array on a uniform variable.
  29291. * @param uniformName Name of the variable.
  29292. * @param array array to be set.
  29293. * @returns this effect.
  29294. */
  29295. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29296. /**
  29297. * 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)
  29298. * @param uniformName Name of the variable.
  29299. * @param array array to be set.
  29300. * @returns this effect.
  29301. */
  29302. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29303. /**
  29304. * 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)
  29305. * @param uniformName Name of the variable.
  29306. * @param array array to be set.
  29307. * @returns this effect.
  29308. */
  29309. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29310. /**
  29311. * 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)
  29312. * @param uniformName Name of the variable.
  29313. * @param array array to be set.
  29314. * @returns this effect.
  29315. */
  29316. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29317. /**
  29318. * Sets an array on a uniform variable.
  29319. * @param uniformName Name of the variable.
  29320. * @param array array to be set.
  29321. * @returns this effect.
  29322. */
  29323. setArray(uniformName: string, array: number[]): Effect;
  29324. /**
  29325. * 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)
  29326. * @param uniformName Name of the variable.
  29327. * @param array array to be set.
  29328. * @returns this effect.
  29329. */
  29330. setArray2(uniformName: string, array: number[]): Effect;
  29331. /**
  29332. * 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)
  29333. * @param uniformName Name of the variable.
  29334. * @param array array to be set.
  29335. * @returns this effect.
  29336. */
  29337. setArray3(uniformName: string, array: number[]): Effect;
  29338. /**
  29339. * 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)
  29340. * @param uniformName Name of the variable.
  29341. * @param array array to be set.
  29342. * @returns this effect.
  29343. */
  29344. setArray4(uniformName: string, array: number[]): Effect;
  29345. /**
  29346. * Sets matrices on a uniform variable.
  29347. * @param uniformName Name of the variable.
  29348. * @param matrices matrices to be set.
  29349. * @returns this effect.
  29350. */
  29351. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29352. /**
  29353. * Sets matrix on a uniform variable.
  29354. * @param uniformName Name of the variable.
  29355. * @param matrix matrix to be set.
  29356. * @returns this effect.
  29357. */
  29358. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29359. /**
  29360. * 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)
  29361. * @param uniformName Name of the variable.
  29362. * @param matrix matrix to be set.
  29363. * @returns this effect.
  29364. */
  29365. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29366. /**
  29367. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29368. * @param uniformName Name of the variable.
  29369. * @param matrix matrix to be set.
  29370. * @returns this effect.
  29371. */
  29372. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29373. /**
  29374. * Sets a float on a uniform variable.
  29375. * @param uniformName Name of the variable.
  29376. * @param value value to be set.
  29377. * @returns this effect.
  29378. */
  29379. setFloat(uniformName: string, value: number): Effect;
  29380. /**
  29381. * Sets a boolean on a uniform variable.
  29382. * @param uniformName Name of the variable.
  29383. * @param bool value to be set.
  29384. * @returns this effect.
  29385. */
  29386. setBool(uniformName: string, bool: boolean): Effect;
  29387. /**
  29388. * Sets a Vector2 on a uniform variable.
  29389. * @param uniformName Name of the variable.
  29390. * @param vector2 vector2 to be set.
  29391. * @returns this effect.
  29392. */
  29393. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29394. /**
  29395. * Sets a float2 on a uniform variable.
  29396. * @param uniformName Name of the variable.
  29397. * @param x First float in float2.
  29398. * @param y Second float in float2.
  29399. * @returns this effect.
  29400. */
  29401. setFloat2(uniformName: string, x: number, y: number): Effect;
  29402. /**
  29403. * Sets a Vector3 on a uniform variable.
  29404. * @param uniformName Name of the variable.
  29405. * @param vector3 Value to be set.
  29406. * @returns this effect.
  29407. */
  29408. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29409. /**
  29410. * Sets a float3 on a uniform variable.
  29411. * @param uniformName Name of the variable.
  29412. * @param x First float in float3.
  29413. * @param y Second float in float3.
  29414. * @param z Third float in float3.
  29415. * @returns this effect.
  29416. */
  29417. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29418. /**
  29419. * Sets a Vector4 on a uniform variable.
  29420. * @param uniformName Name of the variable.
  29421. * @param vector4 Value to be set.
  29422. * @returns this effect.
  29423. */
  29424. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29425. /**
  29426. * Sets a float4 on a uniform variable.
  29427. * @param uniformName Name of the variable.
  29428. * @param x First float in float4.
  29429. * @param y Second float in float4.
  29430. * @param z Third float in float4.
  29431. * @param w Fourth float in float4.
  29432. * @returns this effect.
  29433. */
  29434. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29435. /**
  29436. * Sets a Color3 on a uniform variable.
  29437. * @param uniformName Name of the variable.
  29438. * @param color3 Value to be set.
  29439. * @returns this effect.
  29440. */
  29441. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29442. /**
  29443. * Sets a Color4 on a uniform variable.
  29444. * @param uniformName Name of the variable.
  29445. * @param color3 Value to be set.
  29446. * @param alpha Alpha value to be set.
  29447. * @returns this effect.
  29448. */
  29449. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29450. /**
  29451. * Sets a Color4 on a uniform variable
  29452. * @param uniformName defines the name of the variable
  29453. * @param color4 defines the value to be set
  29454. * @returns this effect.
  29455. */
  29456. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29457. /** Release all associated resources */
  29458. dispose(): void;
  29459. /**
  29460. * This function will add a new shader to the shader store
  29461. * @param name the name of the shader
  29462. * @param pixelShader optional pixel shader content
  29463. * @param vertexShader optional vertex shader content
  29464. */
  29465. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29466. /**
  29467. * Store of each shader (The can be looked up using effect.key)
  29468. */
  29469. static ShadersStore: {
  29470. [key: string]: string;
  29471. };
  29472. /**
  29473. * Store of each included file for a shader (The can be looked up using effect.key)
  29474. */
  29475. static IncludesShadersStore: {
  29476. [key: string]: string;
  29477. };
  29478. /**
  29479. * Resets the cache of effects.
  29480. */
  29481. static ResetCache(): void;
  29482. }
  29483. }
  29484. declare module "babylonjs/Engines/engineCapabilities" {
  29485. /**
  29486. * Interface used to describe the capabilities of the engine relatively to the current browser
  29487. */
  29488. export interface EngineCapabilities {
  29489. /** Maximum textures units per fragment shader */
  29490. maxTexturesImageUnits: number;
  29491. /** Maximum texture units per vertex shader */
  29492. maxVertexTextureImageUnits: number;
  29493. /** Maximum textures units in the entire pipeline */
  29494. maxCombinedTexturesImageUnits: number;
  29495. /** Maximum texture size */
  29496. maxTextureSize: number;
  29497. /** Maximum cube texture size */
  29498. maxCubemapTextureSize: number;
  29499. /** Maximum render texture size */
  29500. maxRenderTextureSize: number;
  29501. /** Maximum number of vertex attributes */
  29502. maxVertexAttribs: number;
  29503. /** Maximum number of varyings */
  29504. maxVaryingVectors: number;
  29505. /** Maximum number of uniforms per vertex shader */
  29506. maxVertexUniformVectors: number;
  29507. /** Maximum number of uniforms per fragment shader */
  29508. maxFragmentUniformVectors: number;
  29509. /** Defines if standard derivates (dx/dy) are supported */
  29510. standardDerivatives: boolean;
  29511. /** Defines if s3tc texture compression is supported */
  29512. s3tc?: WEBGL_compressed_texture_s3tc;
  29513. /** Defines if pvrtc texture compression is supported */
  29514. pvrtc: any;
  29515. /** Defines if etc1 texture compression is supported */
  29516. etc1: any;
  29517. /** Defines if etc2 texture compression is supported */
  29518. etc2: any;
  29519. /** Defines if astc texture compression is supported */
  29520. astc: any;
  29521. /** Defines if float textures are supported */
  29522. textureFloat: boolean;
  29523. /** Defines if vertex array objects are supported */
  29524. vertexArrayObject: boolean;
  29525. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29526. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29527. /** Gets the maximum level of anisotropy supported */
  29528. maxAnisotropy: number;
  29529. /** Defines if instancing is supported */
  29530. instancedArrays: boolean;
  29531. /** Defines if 32 bits indices are supported */
  29532. uintIndices: boolean;
  29533. /** Defines if high precision shaders are supported */
  29534. highPrecisionShaderSupported: boolean;
  29535. /** Defines if depth reading in the fragment shader is supported */
  29536. fragmentDepthSupported: boolean;
  29537. /** Defines if float texture linear filtering is supported*/
  29538. textureFloatLinearFiltering: boolean;
  29539. /** Defines if rendering to float textures is supported */
  29540. textureFloatRender: boolean;
  29541. /** Defines if half float textures are supported*/
  29542. textureHalfFloat: boolean;
  29543. /** Defines if half float texture linear filtering is supported*/
  29544. textureHalfFloatLinearFiltering: boolean;
  29545. /** Defines if rendering to half float textures is supported */
  29546. textureHalfFloatRender: boolean;
  29547. /** Defines if textureLOD shader command is supported */
  29548. textureLOD: boolean;
  29549. /** Defines if draw buffers extension is supported */
  29550. drawBuffersExtension: boolean;
  29551. /** Defines if depth textures are supported */
  29552. depthTextureExtension: boolean;
  29553. /** Defines if float color buffer are supported */
  29554. colorBufferFloat: boolean;
  29555. /** Gets disjoint timer query extension (null if not supported) */
  29556. timerQuery?: EXT_disjoint_timer_query;
  29557. /** Defines if timestamp can be used with timer query */
  29558. canUseTimestampForTimerQuery: boolean;
  29559. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29560. multiview?: any;
  29561. /** Function used to let the system compiles shaders in background */
  29562. parallelShaderCompile?: {
  29563. COMPLETION_STATUS_KHR: number;
  29564. };
  29565. /** Max number of texture samples for MSAA */
  29566. maxMSAASamples: number;
  29567. /** Defines if the blend min max extension is supported */
  29568. blendMinMax: boolean;
  29569. }
  29570. }
  29571. declare module "babylonjs/States/depthCullingState" {
  29572. import { Nullable } from "babylonjs/types";
  29573. /**
  29574. * @hidden
  29575. **/
  29576. export class DepthCullingState {
  29577. private _isDepthTestDirty;
  29578. private _isDepthMaskDirty;
  29579. private _isDepthFuncDirty;
  29580. private _isCullFaceDirty;
  29581. private _isCullDirty;
  29582. private _isZOffsetDirty;
  29583. private _isFrontFaceDirty;
  29584. private _depthTest;
  29585. private _depthMask;
  29586. private _depthFunc;
  29587. private _cull;
  29588. private _cullFace;
  29589. private _zOffset;
  29590. private _frontFace;
  29591. /**
  29592. * Initializes the state.
  29593. */
  29594. constructor();
  29595. readonly isDirty: boolean;
  29596. zOffset: number;
  29597. cullFace: Nullable<number>;
  29598. cull: Nullable<boolean>;
  29599. depthFunc: Nullable<number>;
  29600. depthMask: boolean;
  29601. depthTest: boolean;
  29602. frontFace: Nullable<number>;
  29603. reset(): void;
  29604. apply(gl: WebGLRenderingContext): void;
  29605. }
  29606. }
  29607. declare module "babylonjs/States/stencilState" {
  29608. /**
  29609. * @hidden
  29610. **/
  29611. export class StencilState {
  29612. /** 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 */
  29613. static readonly ALWAYS: number;
  29614. /** Passed to stencilOperation to specify that stencil value must be kept */
  29615. static readonly KEEP: number;
  29616. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29617. static readonly REPLACE: number;
  29618. private _isStencilTestDirty;
  29619. private _isStencilMaskDirty;
  29620. private _isStencilFuncDirty;
  29621. private _isStencilOpDirty;
  29622. private _stencilTest;
  29623. private _stencilMask;
  29624. private _stencilFunc;
  29625. private _stencilFuncRef;
  29626. private _stencilFuncMask;
  29627. private _stencilOpStencilFail;
  29628. private _stencilOpDepthFail;
  29629. private _stencilOpStencilDepthPass;
  29630. readonly isDirty: boolean;
  29631. stencilFunc: number;
  29632. stencilFuncRef: number;
  29633. stencilFuncMask: number;
  29634. stencilOpStencilFail: number;
  29635. stencilOpDepthFail: number;
  29636. stencilOpStencilDepthPass: number;
  29637. stencilMask: number;
  29638. stencilTest: boolean;
  29639. constructor();
  29640. reset(): void;
  29641. apply(gl: WebGLRenderingContext): void;
  29642. }
  29643. }
  29644. declare module "babylonjs/States/alphaCullingState" {
  29645. /**
  29646. * @hidden
  29647. **/
  29648. export class AlphaState {
  29649. private _isAlphaBlendDirty;
  29650. private _isBlendFunctionParametersDirty;
  29651. private _isBlendEquationParametersDirty;
  29652. private _isBlendConstantsDirty;
  29653. private _alphaBlend;
  29654. private _blendFunctionParameters;
  29655. private _blendEquationParameters;
  29656. private _blendConstants;
  29657. /**
  29658. * Initializes the state.
  29659. */
  29660. constructor();
  29661. readonly isDirty: boolean;
  29662. alphaBlend: boolean;
  29663. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29664. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29665. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29666. reset(): void;
  29667. apply(gl: WebGLRenderingContext): void;
  29668. }
  29669. }
  29670. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29671. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29672. /** @hidden */
  29673. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29674. attributeProcessor(attribute: string): string;
  29675. varyingProcessor(varying: string, isFragment: boolean): string;
  29676. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29677. }
  29678. }
  29679. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29680. /**
  29681. * Interface for attribute information associated with buffer instanciation
  29682. */
  29683. export interface InstancingAttributeInfo {
  29684. /**
  29685. * Index/offset of the attribute in the vertex shader
  29686. */
  29687. index: number;
  29688. /**
  29689. * size of the attribute, 1, 2, 3 or 4
  29690. */
  29691. attributeSize: number;
  29692. /**
  29693. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29694. * default is FLOAT
  29695. */
  29696. attributeType: number;
  29697. /**
  29698. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29699. */
  29700. normalized: boolean;
  29701. /**
  29702. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29703. */
  29704. offset: number;
  29705. /**
  29706. * Name of the GLSL attribute, for debugging purpose only
  29707. */
  29708. attributeName: string;
  29709. }
  29710. }
  29711. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29712. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29713. import { Nullable } from "babylonjs/types";
  29714. module "babylonjs/Engines/thinEngine" {
  29715. interface ThinEngine {
  29716. /**
  29717. * Update a video texture
  29718. * @param texture defines the texture to update
  29719. * @param video defines the video element to use
  29720. * @param invertY defines if data must be stored with Y axis inverted
  29721. */
  29722. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29723. }
  29724. }
  29725. }
  29726. declare module "babylonjs/Materials/Textures/videoTexture" {
  29727. import { Observable } from "babylonjs/Misc/observable";
  29728. import { Nullable } from "babylonjs/types";
  29729. import { Scene } from "babylonjs/scene";
  29730. import { Texture } from "babylonjs/Materials/Textures/texture";
  29731. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29732. /**
  29733. * Settings for finer control over video usage
  29734. */
  29735. export interface VideoTextureSettings {
  29736. /**
  29737. * Applies `autoplay` to video, if specified
  29738. */
  29739. autoPlay?: boolean;
  29740. /**
  29741. * Applies `loop` to video, if specified
  29742. */
  29743. loop?: boolean;
  29744. /**
  29745. * Automatically updates internal texture from video at every frame in the render loop
  29746. */
  29747. autoUpdateTexture: boolean;
  29748. /**
  29749. * Image src displayed during the video loading or until the user interacts with the video.
  29750. */
  29751. poster?: string;
  29752. }
  29753. /**
  29754. * If you want to display a video in your scene, this is the special texture for that.
  29755. * This special texture works similar to other textures, with the exception of a few parameters.
  29756. * @see https://doc.babylonjs.com/how_to/video_texture
  29757. */
  29758. export class VideoTexture extends Texture {
  29759. /**
  29760. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29761. */
  29762. readonly autoUpdateTexture: boolean;
  29763. /**
  29764. * The video instance used by the texture internally
  29765. */
  29766. readonly video: HTMLVideoElement;
  29767. private _onUserActionRequestedObservable;
  29768. /**
  29769. * Event triggerd when a dom action is required by the user to play the video.
  29770. * This happens due to recent changes in browser policies preventing video to auto start.
  29771. */
  29772. readonly onUserActionRequestedObservable: Observable<Texture>;
  29773. private _generateMipMaps;
  29774. private _engine;
  29775. private _stillImageCaptured;
  29776. private _displayingPosterTexture;
  29777. private _settings;
  29778. private _createInternalTextureOnEvent;
  29779. private _frameId;
  29780. /**
  29781. * Creates a video texture.
  29782. * If you want to display a video in your scene, this is the special texture for that.
  29783. * This special texture works similar to other textures, with the exception of a few parameters.
  29784. * @see https://doc.babylonjs.com/how_to/video_texture
  29785. * @param name optional name, will detect from video source, if not defined
  29786. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29787. * @param scene is obviously the current scene.
  29788. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29789. * @param invertY is false by default but can be used to invert video on Y axis
  29790. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29791. * @param settings allows finer control over video usage
  29792. */
  29793. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29794. private _getName;
  29795. private _getVideo;
  29796. private _createInternalTexture;
  29797. private reset;
  29798. /**
  29799. * @hidden Internal method to initiate `update`.
  29800. */
  29801. _rebuild(): void;
  29802. /**
  29803. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29804. */
  29805. update(): void;
  29806. /**
  29807. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29808. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29809. */
  29810. updateTexture(isVisible: boolean): void;
  29811. protected _updateInternalTexture: () => void;
  29812. /**
  29813. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29814. * @param url New url.
  29815. */
  29816. updateURL(url: string): void;
  29817. /**
  29818. * Dispose the texture and release its associated resources.
  29819. */
  29820. dispose(): void;
  29821. /**
  29822. * Creates a video texture straight from a stream.
  29823. * @param scene Define the scene the texture should be created in
  29824. * @param stream Define the stream the texture should be created from
  29825. * @returns The created video texture as a promise
  29826. */
  29827. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29828. /**
  29829. * Creates a video texture straight from your WebCam video feed.
  29830. * @param scene Define the scene the texture should be created in
  29831. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29832. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29833. * @returns The created video texture as a promise
  29834. */
  29835. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29836. minWidth: number;
  29837. maxWidth: number;
  29838. minHeight: number;
  29839. maxHeight: number;
  29840. deviceId: string;
  29841. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29842. /**
  29843. * Creates a video texture straight from your WebCam video feed.
  29844. * @param scene Define the scene the texture should be created in
  29845. * @param onReady Define a callback to triggered once the texture will be ready
  29846. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29847. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29848. */
  29849. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29850. minWidth: number;
  29851. maxWidth: number;
  29852. minHeight: number;
  29853. maxHeight: number;
  29854. deviceId: string;
  29855. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29856. }
  29857. }
  29858. declare module "babylonjs/Engines/thinEngine" {
  29859. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29860. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29861. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29862. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29863. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29864. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29865. import { Observable } from "babylonjs/Misc/observable";
  29866. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29867. import { StencilState } from "babylonjs/States/stencilState";
  29868. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29869. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29870. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29871. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29872. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29873. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29874. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29875. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29876. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29878. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29879. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29880. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29881. /**
  29882. * Defines the interface used by objects working like Scene
  29883. * @hidden
  29884. */
  29885. interface ISceneLike {
  29886. _addPendingData(data: any): void;
  29887. _removePendingData(data: any): void;
  29888. offlineProvider: IOfflineProvider;
  29889. }
  29890. /** Interface defining initialization parameters for Engine class */
  29891. export interface EngineOptions extends WebGLContextAttributes {
  29892. /**
  29893. * Defines if the engine should no exceed a specified device ratio
  29894. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29895. */
  29896. limitDeviceRatio?: number;
  29897. /**
  29898. * Defines if webvr should be enabled automatically
  29899. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29900. */
  29901. autoEnableWebVR?: boolean;
  29902. /**
  29903. * Defines if webgl2 should be turned off even if supported
  29904. * @see http://doc.babylonjs.com/features/webgl2
  29905. */
  29906. disableWebGL2Support?: boolean;
  29907. /**
  29908. * Defines if webaudio should be initialized as well
  29909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29910. */
  29911. audioEngine?: boolean;
  29912. /**
  29913. * Defines if animations should run using a deterministic lock step
  29914. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29915. */
  29916. deterministicLockstep?: boolean;
  29917. /** Defines the maximum steps to use with deterministic lock step mode */
  29918. lockstepMaxSteps?: number;
  29919. /**
  29920. * Defines that engine should ignore context lost events
  29921. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29922. */
  29923. doNotHandleContextLost?: boolean;
  29924. /**
  29925. * Defines that engine should ignore modifying touch action attribute and style
  29926. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29927. */
  29928. doNotHandleTouchAction?: boolean;
  29929. /**
  29930. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29931. */
  29932. useHighPrecisionFloats?: boolean;
  29933. }
  29934. /**
  29935. * The base engine class (root of all engines)
  29936. */
  29937. export class ThinEngine {
  29938. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29939. static ExceptionList: ({
  29940. key: string;
  29941. capture: string;
  29942. captureConstraint: number;
  29943. targets: string[];
  29944. } | {
  29945. key: string;
  29946. capture: null;
  29947. captureConstraint: null;
  29948. targets: string[];
  29949. })[];
  29950. /** @hidden */
  29951. static _TextureLoaders: IInternalTextureLoader[];
  29952. /**
  29953. * Returns the current npm package of the sdk
  29954. */
  29955. static readonly NpmPackage: string;
  29956. /**
  29957. * Returns the current version of the framework
  29958. */
  29959. static readonly Version: string;
  29960. /**
  29961. * Returns a string describing the current engine
  29962. */
  29963. readonly description: string;
  29964. /**
  29965. * Gets or sets the epsilon value used by collision engine
  29966. */
  29967. static CollisionsEpsilon: number;
  29968. /**
  29969. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29970. */
  29971. static ShadersRepository: string;
  29972. /** @hidden */
  29973. _shaderProcessor: IShaderProcessor;
  29974. /**
  29975. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29976. */
  29977. forcePOTTextures: boolean;
  29978. /**
  29979. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29980. */
  29981. isFullscreen: boolean;
  29982. /**
  29983. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29984. */
  29985. cullBackFaces: boolean;
  29986. /**
  29987. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29988. */
  29989. renderEvenInBackground: boolean;
  29990. /**
  29991. * Gets or sets a boolean indicating that cache can be kept between frames
  29992. */
  29993. preventCacheWipeBetweenFrames: boolean;
  29994. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29995. validateShaderPrograms: boolean;
  29996. /**
  29997. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29998. */
  29999. disableUniformBuffers: boolean;
  30000. /** @hidden */
  30001. _uniformBuffers: UniformBuffer[];
  30002. /**
  30003. * Gets a boolean indicating that the engine supports uniform buffers
  30004. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30005. */
  30006. readonly supportsUniformBuffers: boolean;
  30007. /** @hidden */
  30008. _gl: WebGLRenderingContext;
  30009. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30010. protected _windowIsBackground: boolean;
  30011. protected _webGLVersion: number;
  30012. protected _highPrecisionShadersAllowed: boolean;
  30013. /** @hidden */
  30014. readonly _shouldUseHighPrecisionShader: boolean;
  30015. /**
  30016. * Gets a boolean indicating that only power of 2 textures are supported
  30017. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30018. */
  30019. readonly needPOTTextures: boolean;
  30020. /** @hidden */
  30021. _badOS: boolean;
  30022. /** @hidden */
  30023. _badDesktopOS: boolean;
  30024. private _hardwareScalingLevel;
  30025. /** @hidden */
  30026. _caps: EngineCapabilities;
  30027. private _isStencilEnable;
  30028. protected _colorWrite: boolean;
  30029. private _glVersion;
  30030. private _glRenderer;
  30031. private _glVendor;
  30032. /** @hidden */
  30033. _videoTextureSupported: boolean;
  30034. protected _renderingQueueLaunched: boolean;
  30035. protected _activeRenderLoops: (() => void)[];
  30036. /**
  30037. * Observable signaled when a context lost event is raised
  30038. */
  30039. onContextLostObservable: Observable<ThinEngine>;
  30040. /**
  30041. * Observable signaled when a context restored event is raised
  30042. */
  30043. onContextRestoredObservable: Observable<ThinEngine>;
  30044. private _onContextLost;
  30045. private _onContextRestored;
  30046. protected _contextWasLost: boolean;
  30047. /** @hidden */
  30048. _doNotHandleContextLost: boolean;
  30049. /**
  30050. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30052. */
  30053. doNotHandleContextLost: boolean;
  30054. /**
  30055. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30056. */
  30057. disableVertexArrayObjects: boolean;
  30058. /** @hidden */
  30059. protected _depthCullingState: DepthCullingState;
  30060. /** @hidden */
  30061. protected _stencilState: StencilState;
  30062. /** @hidden */
  30063. protected _alphaState: AlphaState;
  30064. /** @hidden */
  30065. _internalTexturesCache: InternalTexture[];
  30066. /** @hidden */
  30067. protected _activeChannel: number;
  30068. private _currentTextureChannel;
  30069. /** @hidden */
  30070. protected _boundTexturesCache: {
  30071. [key: string]: Nullable<InternalTexture>;
  30072. };
  30073. /** @hidden */
  30074. protected _currentEffect: Nullable<Effect>;
  30075. /** @hidden */
  30076. protected _currentProgram: Nullable<WebGLProgram>;
  30077. private _compiledEffects;
  30078. private _vertexAttribArraysEnabled;
  30079. /** @hidden */
  30080. protected _cachedViewport: Nullable<IViewportLike>;
  30081. private _cachedVertexArrayObject;
  30082. /** @hidden */
  30083. protected _cachedVertexBuffers: any;
  30084. /** @hidden */
  30085. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30086. /** @hidden */
  30087. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30088. /** @hidden */
  30089. _currentRenderTarget: Nullable<InternalTexture>;
  30090. private _uintIndicesCurrentlySet;
  30091. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30092. /** @hidden */
  30093. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30094. private _currentBufferPointers;
  30095. private _currentInstanceLocations;
  30096. private _currentInstanceBuffers;
  30097. private _textureUnits;
  30098. /** @hidden */
  30099. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30100. /** @hidden */
  30101. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30102. /** @hidden */
  30103. _bindedRenderFunction: any;
  30104. private _vaoRecordInProgress;
  30105. private _mustWipeVertexAttributes;
  30106. private _emptyTexture;
  30107. private _emptyCubeTexture;
  30108. private _emptyTexture3D;
  30109. /** @hidden */
  30110. _frameHandler: number;
  30111. private _nextFreeTextureSlots;
  30112. private _maxSimultaneousTextures;
  30113. private _activeRequests;
  30114. protected _texturesSupported: string[];
  30115. /** @hidden */
  30116. _textureFormatInUse: Nullable<string>;
  30117. protected readonly _supportsHardwareTextureRescaling: boolean;
  30118. /**
  30119. * Gets the list of texture formats supported
  30120. */
  30121. readonly texturesSupported: Array<string>;
  30122. /**
  30123. * Gets the list of texture formats in use
  30124. */
  30125. readonly textureFormatInUse: Nullable<string>;
  30126. /**
  30127. * Gets the current viewport
  30128. */
  30129. readonly currentViewport: Nullable<IViewportLike>;
  30130. /**
  30131. * Gets the default empty texture
  30132. */
  30133. readonly emptyTexture: InternalTexture;
  30134. /**
  30135. * Gets the default empty 3D texture
  30136. */
  30137. readonly emptyTexture3D: InternalTexture;
  30138. /**
  30139. * Gets the default empty cube texture
  30140. */
  30141. readonly emptyCubeTexture: InternalTexture;
  30142. /**
  30143. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30144. */
  30145. readonly premultipliedAlpha: boolean;
  30146. /**
  30147. * Observable event triggered before each texture is initialized
  30148. */
  30149. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30150. /**
  30151. * Creates a new engine
  30152. * @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
  30153. * @param antialias defines enable antialiasing (default: false)
  30154. * @param options defines further options to be sent to the getContext() function
  30155. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30156. */
  30157. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30158. private _rebuildInternalTextures;
  30159. private _rebuildEffects;
  30160. /**
  30161. * Gets a boolean indicating if all created effects are ready
  30162. * @returns true if all effects are ready
  30163. */
  30164. areAllEffectsReady(): boolean;
  30165. protected _rebuildBuffers(): void;
  30166. private _initGLContext;
  30167. /**
  30168. * Gets version of the current webGL context
  30169. */
  30170. readonly webGLVersion: number;
  30171. /**
  30172. * Gets a string idenfifying the name of the class
  30173. * @returns "Engine" string
  30174. */
  30175. getClassName(): string;
  30176. /**
  30177. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30178. */
  30179. readonly isStencilEnable: boolean;
  30180. /** @hidden */
  30181. _prepareWorkingCanvas(): void;
  30182. /**
  30183. * Reset the texture cache to empty state
  30184. */
  30185. resetTextureCache(): void;
  30186. /**
  30187. * Gets an object containing information about the current webGL context
  30188. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30189. */
  30190. getGlInfo(): {
  30191. vendor: string;
  30192. renderer: string;
  30193. version: string;
  30194. };
  30195. /**
  30196. * Defines the hardware scaling level.
  30197. * By default the hardware scaling level is computed from the window device ratio.
  30198. * 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.
  30199. * @param level defines the level to use
  30200. */
  30201. setHardwareScalingLevel(level: number): void;
  30202. /**
  30203. * Gets the current hardware scaling level.
  30204. * By default the hardware scaling level is computed from the window device ratio.
  30205. * 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.
  30206. * @returns a number indicating the current hardware scaling level
  30207. */
  30208. getHardwareScalingLevel(): number;
  30209. /**
  30210. * Gets the list of loaded textures
  30211. * @returns an array containing all loaded textures
  30212. */
  30213. getLoadedTexturesCache(): InternalTexture[];
  30214. /**
  30215. * Gets the object containing all engine capabilities
  30216. * @returns the EngineCapabilities object
  30217. */
  30218. getCaps(): EngineCapabilities;
  30219. /**
  30220. * stop executing a render loop function and remove it from the execution array
  30221. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30222. */
  30223. stopRenderLoop(renderFunction?: () => void): void;
  30224. /** @hidden */
  30225. _renderLoop(): void;
  30226. /**
  30227. * Gets the HTML canvas attached with the current webGL context
  30228. * @returns a HTML canvas
  30229. */
  30230. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30231. /**
  30232. * Gets host window
  30233. * @returns the host window object
  30234. */
  30235. getHostWindow(): Nullable<Window>;
  30236. /**
  30237. * Gets the current render width
  30238. * @param useScreen defines if screen size must be used (or the current render target if any)
  30239. * @returns a number defining the current render width
  30240. */
  30241. getRenderWidth(useScreen?: boolean): number;
  30242. /**
  30243. * Gets the current render height
  30244. * @param useScreen defines if screen size must be used (or the current render target if any)
  30245. * @returns a number defining the current render height
  30246. */
  30247. getRenderHeight(useScreen?: boolean): number;
  30248. /**
  30249. * Can be used to override the current requestAnimationFrame requester.
  30250. * @hidden
  30251. */
  30252. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30253. /**
  30254. * Register and execute a render loop. The engine can have more than one render function
  30255. * @param renderFunction defines the function to continuously execute
  30256. */
  30257. runRenderLoop(renderFunction: () => void): void;
  30258. /**
  30259. * Clear the current render buffer or the current render target (if any is set up)
  30260. * @param color defines the color to use
  30261. * @param backBuffer defines if the back buffer must be cleared
  30262. * @param depth defines if the depth buffer must be cleared
  30263. * @param stencil defines if the stencil buffer must be cleared
  30264. */
  30265. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30266. private _viewportCached;
  30267. /** @hidden */
  30268. _viewport(x: number, y: number, width: number, height: number): void;
  30269. /**
  30270. * Set the WebGL's viewport
  30271. * @param viewport defines the viewport element to be used
  30272. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30273. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30274. */
  30275. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30276. /**
  30277. * Begin a new frame
  30278. */
  30279. beginFrame(): void;
  30280. /**
  30281. * Enf the current frame
  30282. */
  30283. endFrame(): void;
  30284. /**
  30285. * Resize the view according to the canvas' size
  30286. */
  30287. resize(): void;
  30288. /**
  30289. * Force a specific size of the canvas
  30290. * @param width defines the new canvas' width
  30291. * @param height defines the new canvas' height
  30292. */
  30293. setSize(width: number, height: number): void;
  30294. /**
  30295. * Binds the frame buffer to the specified texture.
  30296. * @param texture The texture to render to or null for the default canvas
  30297. * @param faceIndex The face of the texture to render to in case of cube texture
  30298. * @param requiredWidth The width of the target to render to
  30299. * @param requiredHeight The height of the target to render to
  30300. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30301. * @param depthStencilTexture The depth stencil texture to use to render
  30302. * @param lodLevel defines le lod level to bind to the frame buffer
  30303. */
  30304. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30305. /** @hidden */
  30306. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30307. /**
  30308. * Unbind the current render target texture from the webGL context
  30309. * @param texture defines the render target texture to unbind
  30310. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30311. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30312. */
  30313. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30314. /**
  30315. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30316. */
  30317. flushFramebuffer(): void;
  30318. /**
  30319. * Unbind the current render target and bind the default framebuffer
  30320. */
  30321. restoreDefaultFramebuffer(): void;
  30322. /** @hidden */
  30323. protected _resetVertexBufferBinding(): void;
  30324. /**
  30325. * Creates a vertex buffer
  30326. * @param data the data for the vertex buffer
  30327. * @returns the new WebGL static buffer
  30328. */
  30329. createVertexBuffer(data: DataArray): DataBuffer;
  30330. private _createVertexBuffer;
  30331. /**
  30332. * Creates a dynamic vertex buffer
  30333. * @param data the data for the dynamic vertex buffer
  30334. * @returns the new WebGL dynamic buffer
  30335. */
  30336. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30337. protected _resetIndexBufferBinding(): void;
  30338. /**
  30339. * Creates a new index buffer
  30340. * @param indices defines the content of the index buffer
  30341. * @param updatable defines if the index buffer must be updatable
  30342. * @returns a new webGL buffer
  30343. */
  30344. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30345. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30346. /**
  30347. * Bind a webGL buffer to the webGL context
  30348. * @param buffer defines the buffer to bind
  30349. */
  30350. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30351. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30352. private bindBuffer;
  30353. /**
  30354. * update the bound buffer with the given data
  30355. * @param data defines the data to update
  30356. */
  30357. updateArrayBuffer(data: Float32Array): void;
  30358. private _vertexAttribPointer;
  30359. private _bindIndexBufferWithCache;
  30360. private _bindVertexBuffersAttributes;
  30361. /**
  30362. * Records a vertex array object
  30363. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30364. * @param vertexBuffers defines the list of vertex buffers to store
  30365. * @param indexBuffer defines the index buffer to store
  30366. * @param effect defines the effect to store
  30367. * @returns the new vertex array object
  30368. */
  30369. recordVertexArrayObject(vertexBuffers: {
  30370. [key: string]: VertexBuffer;
  30371. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30372. /**
  30373. * Bind a specific vertex array object
  30374. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30375. * @param vertexArrayObject defines the vertex array object to bind
  30376. * @param indexBuffer defines the index buffer to bind
  30377. */
  30378. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30379. /**
  30380. * Bind webGl buffers directly to the webGL context
  30381. * @param vertexBuffer defines the vertex buffer to bind
  30382. * @param indexBuffer defines the index buffer to bind
  30383. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30384. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30385. * @param effect defines the effect associated with the vertex buffer
  30386. */
  30387. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30388. private _unbindVertexArrayObject;
  30389. /**
  30390. * Bind a list of vertex buffers to the webGL context
  30391. * @param vertexBuffers defines the list of vertex buffers to bind
  30392. * @param indexBuffer defines the index buffer to bind
  30393. * @param effect defines the effect associated with the vertex buffers
  30394. */
  30395. bindBuffers(vertexBuffers: {
  30396. [key: string]: Nullable<VertexBuffer>;
  30397. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30398. /**
  30399. * Unbind all instance attributes
  30400. */
  30401. unbindInstanceAttributes(): void;
  30402. /**
  30403. * Release and free the memory of a vertex array object
  30404. * @param vao defines the vertex array object to delete
  30405. */
  30406. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30407. /** @hidden */
  30408. _releaseBuffer(buffer: DataBuffer): boolean;
  30409. protected _deleteBuffer(buffer: DataBuffer): void;
  30410. /**
  30411. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30412. * @param instancesBuffer defines the webGL buffer to update and bind
  30413. * @param data defines the data to store in the buffer
  30414. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30415. */
  30416. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30417. /**
  30418. * Apply all cached states (depth, culling, stencil and alpha)
  30419. */
  30420. applyStates(): void;
  30421. /**
  30422. * Send a draw order
  30423. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30424. * @param indexStart defines the starting index
  30425. * @param indexCount defines the number of index to draw
  30426. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30427. */
  30428. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30429. /**
  30430. * Draw a list of points
  30431. * @param verticesStart defines the index of first vertex to draw
  30432. * @param verticesCount defines the count of vertices to draw
  30433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30434. */
  30435. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30436. /**
  30437. * Draw a list of unindexed primitives
  30438. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30439. * @param verticesStart defines the index of first vertex to draw
  30440. * @param verticesCount defines the count of vertices to draw
  30441. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30442. */
  30443. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30444. /**
  30445. * Draw a list of indexed primitives
  30446. * @param fillMode defines the primitive to use
  30447. * @param indexStart defines the starting index
  30448. * @param indexCount defines the number of index to draw
  30449. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30450. */
  30451. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30452. /**
  30453. * Draw a list of unindexed primitives
  30454. * @param fillMode defines the primitive to use
  30455. * @param verticesStart defines the index of first vertex to draw
  30456. * @param verticesCount defines the count of vertices to draw
  30457. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30458. */
  30459. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30460. private _drawMode;
  30461. /** @hidden */
  30462. protected _reportDrawCall(): void;
  30463. /** @hidden */
  30464. _releaseEffect(effect: Effect): void;
  30465. /** @hidden */
  30466. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30467. /**
  30468. * Create a new effect (used to store vertex/fragment shaders)
  30469. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30470. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30471. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30472. * @param samplers defines an array of string used to represent textures
  30473. * @param defines defines the string containing the defines to use to compile the shaders
  30474. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30475. * @param onCompiled defines a function to call when the effect creation is successful
  30476. * @param onError defines a function to call when the effect creation has failed
  30477. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30478. * @returns the new Effect
  30479. */
  30480. 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;
  30481. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30482. private _compileShader;
  30483. private _compileRawShader;
  30484. /**
  30485. * Directly creates a webGL program
  30486. * @param pipelineContext defines the pipeline context to attach to
  30487. * @param vertexCode defines the vertex shader code to use
  30488. * @param fragmentCode defines the fragment shader code to use
  30489. * @param context defines the webGL context to use (if not set, the current one will be used)
  30490. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30491. * @returns the new webGL program
  30492. */
  30493. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30494. /**
  30495. * Creates a webGL program
  30496. * @param pipelineContext defines the pipeline context to attach to
  30497. * @param vertexCode defines the vertex shader code to use
  30498. * @param fragmentCode defines the fragment shader code to use
  30499. * @param defines defines the string containing the defines to use to compile the shaders
  30500. * @param context defines the webGL context to use (if not set, the current one will be used)
  30501. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30502. * @returns the new webGL program
  30503. */
  30504. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30505. /**
  30506. * Creates a new pipeline context
  30507. * @returns the new pipeline
  30508. */
  30509. createPipelineContext(): IPipelineContext;
  30510. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30511. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30512. /** @hidden */
  30513. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30514. /** @hidden */
  30515. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30516. /** @hidden */
  30517. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30518. /**
  30519. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30520. * @param pipelineContext defines the pipeline context to use
  30521. * @param uniformsNames defines the list of uniform names
  30522. * @returns an array of webGL uniform locations
  30523. */
  30524. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30525. /**
  30526. * Gets the lsit of active attributes for a given webGL program
  30527. * @param pipelineContext defines the pipeline context to use
  30528. * @param attributesNames defines the list of attribute names to get
  30529. * @returns an array of indices indicating the offset of each attribute
  30530. */
  30531. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30532. /**
  30533. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30534. * @param effect defines the effect to activate
  30535. */
  30536. enableEffect(effect: Nullable<Effect>): void;
  30537. /**
  30538. * Set the value of an uniform to a number (int)
  30539. * @param uniform defines the webGL uniform location where to store the value
  30540. * @param value defines the int number to store
  30541. */
  30542. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30543. /**
  30544. * Set the value of an uniform to an array of int32
  30545. * @param uniform defines the webGL uniform location where to store the value
  30546. * @param array defines the array of int32 to store
  30547. */
  30548. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30549. /**
  30550. * Set the value of an uniform to an array of int32 (stored as vec2)
  30551. * @param uniform defines the webGL uniform location where to store the value
  30552. * @param array defines the array of int32 to store
  30553. */
  30554. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30555. /**
  30556. * Set the value of an uniform to an array of int32 (stored as vec3)
  30557. * @param uniform defines the webGL uniform location where to store the value
  30558. * @param array defines the array of int32 to store
  30559. */
  30560. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30561. /**
  30562. * Set the value of an uniform to an array of int32 (stored as vec4)
  30563. * @param uniform defines the webGL uniform location where to store the value
  30564. * @param array defines the array of int32 to store
  30565. */
  30566. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30567. /**
  30568. * Set the value of an uniform to an array of number
  30569. * @param uniform defines the webGL uniform location where to store the value
  30570. * @param array defines the array of number to store
  30571. */
  30572. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30573. /**
  30574. * Set the value of an uniform to an array of number (stored as vec2)
  30575. * @param uniform defines the webGL uniform location where to store the value
  30576. * @param array defines the array of number to store
  30577. */
  30578. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30579. /**
  30580. * Set the value of an uniform to an array of number (stored as vec3)
  30581. * @param uniform defines the webGL uniform location where to store the value
  30582. * @param array defines the array of number to store
  30583. */
  30584. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30585. /**
  30586. * Set the value of an uniform to an array of number (stored as vec4)
  30587. * @param uniform defines the webGL uniform location where to store the value
  30588. * @param array defines the array of number to store
  30589. */
  30590. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30591. /**
  30592. * Set the value of an uniform to an array of float32 (stored as matrices)
  30593. * @param uniform defines the webGL uniform location where to store the value
  30594. * @param matrices defines the array of float32 to store
  30595. */
  30596. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30597. /**
  30598. * Set the value of an uniform to a matrix (3x3)
  30599. * @param uniform defines the webGL uniform location where to store the value
  30600. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30601. */
  30602. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30603. /**
  30604. * Set the value of an uniform to a matrix (2x2)
  30605. * @param uniform defines the webGL uniform location where to store the value
  30606. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30607. */
  30608. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30609. /**
  30610. * Set the value of an uniform to a number (float)
  30611. * @param uniform defines the webGL uniform location where to store the value
  30612. * @param value defines the float number to store
  30613. */
  30614. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30615. /**
  30616. * Set the value of an uniform to a vec2
  30617. * @param uniform defines the webGL uniform location where to store the value
  30618. * @param x defines the 1st component of the value
  30619. * @param y defines the 2nd component of the value
  30620. */
  30621. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30622. /**
  30623. * Set the value of an uniform to a vec3
  30624. * @param uniform defines the webGL uniform location where to store the value
  30625. * @param x defines the 1st component of the value
  30626. * @param y defines the 2nd component of the value
  30627. * @param z defines the 3rd component of the value
  30628. */
  30629. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30630. /**
  30631. * Set the value of an uniform to a vec4
  30632. * @param uniform defines the webGL uniform location where to store the value
  30633. * @param x defines the 1st component of the value
  30634. * @param y defines the 2nd component of the value
  30635. * @param z defines the 3rd component of the value
  30636. * @param w defines the 4th component of the value
  30637. */
  30638. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30639. /**
  30640. * Gets the depth culling state manager
  30641. */
  30642. readonly depthCullingState: DepthCullingState;
  30643. /**
  30644. * Gets the alpha state manager
  30645. */
  30646. readonly alphaState: AlphaState;
  30647. /**
  30648. * Gets the stencil state manager
  30649. */
  30650. readonly stencilState: StencilState;
  30651. /**
  30652. * Clears the list of texture accessible through engine.
  30653. * This can help preventing texture load conflict due to name collision.
  30654. */
  30655. clearInternalTexturesCache(): void;
  30656. /**
  30657. * Force the entire cache to be cleared
  30658. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30659. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30660. */
  30661. wipeCaches(bruteForce?: boolean): void;
  30662. /** @hidden */
  30663. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30664. min: number;
  30665. mag: number;
  30666. };
  30667. /** @hidden */
  30668. _createTexture(): WebGLTexture;
  30669. /**
  30670. * Usually called from Texture.ts.
  30671. * Passed information to create a WebGLTexture
  30672. * @param urlArg defines a value which contains one of the following:
  30673. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30674. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30675. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30676. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30677. * @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)
  30678. * @param scene needed for loading to the correct scene
  30679. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30680. * @param onLoad optional callback to be called upon successful completion
  30681. * @param onError optional callback to be called upon failure
  30682. * @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
  30683. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30684. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30685. * @param forcedExtension defines the extension to use to pick the right loader
  30686. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30687. * @param mimeType defines an optional mime type
  30688. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30689. */
  30690. 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;
  30691. /**
  30692. * @hidden
  30693. */
  30694. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30695. /**
  30696. * Creates a raw texture
  30697. * @param data defines the data to store in the texture
  30698. * @param width defines the width of the texture
  30699. * @param height defines the height of the texture
  30700. * @param format defines the format of the data
  30701. * @param generateMipMaps defines if the engine should generate the mip levels
  30702. * @param invertY defines if data must be stored with Y axis inverted
  30703. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30704. * @param compression defines the compression used (null by default)
  30705. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30706. * @returns the raw texture inside an InternalTexture
  30707. */
  30708. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30709. /**
  30710. * Creates a new raw cube texture
  30711. * @param data defines the array of data to use to create each face
  30712. * @param size defines the size of the textures
  30713. * @param format defines the format of the data
  30714. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30715. * @param generateMipMaps defines if the engine should generate the mip levels
  30716. * @param invertY defines if data must be stored with Y axis inverted
  30717. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30718. * @param compression defines the compression used (null by default)
  30719. * @returns the cube texture as an InternalTexture
  30720. */
  30721. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30722. /**
  30723. * Creates a new raw 3D texture
  30724. * @param data defines the data used to create the texture
  30725. * @param width defines the width of the texture
  30726. * @param height defines the height of the texture
  30727. * @param depth defines the depth of the texture
  30728. * @param format defines the format of the texture
  30729. * @param generateMipMaps defines if the engine must generate mip levels
  30730. * @param invertY defines if data must be stored with Y axis inverted
  30731. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30732. * @param compression defines the compressed used (can be null)
  30733. * @param textureType defines the compressed used (can be null)
  30734. * @returns a new raw 3D texture (stored in an InternalTexture)
  30735. */
  30736. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30737. private _unpackFlipYCached;
  30738. /**
  30739. * In case you are sharing the context with other applications, it might
  30740. * be interested to not cache the unpack flip y state to ensure a consistent
  30741. * value would be set.
  30742. */
  30743. enableUnpackFlipYCached: boolean;
  30744. /** @hidden */
  30745. _unpackFlipY(value: boolean): void;
  30746. /** @hidden */
  30747. _getUnpackAlignement(): number;
  30748. /**
  30749. * Update the sampling mode of a given texture
  30750. * @param samplingMode defines the required sampling mode
  30751. * @param texture defines the texture to update
  30752. */
  30753. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30754. /** @hidden */
  30755. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30756. width: number;
  30757. height: number;
  30758. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30759. /** @hidden */
  30760. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30761. /** @hidden */
  30762. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30763. /** @hidden */
  30764. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30765. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30766. private _prepareWebGLTexture;
  30767. /** @hidden */
  30768. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30769. /** @hidden */
  30770. _releaseFramebufferObjects(texture: InternalTexture): void;
  30771. /** @hidden */
  30772. _releaseTexture(texture: InternalTexture): void;
  30773. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30774. protected _setProgram(program: WebGLProgram): void;
  30775. protected _boundUniforms: {
  30776. [key: number]: WebGLUniformLocation;
  30777. };
  30778. /**
  30779. * Binds an effect to the webGL context
  30780. * @param effect defines the effect to bind
  30781. */
  30782. bindSamplers(effect: Effect): void;
  30783. private _activateCurrentTexture;
  30784. /** @hidden */
  30785. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30786. /** @hidden */
  30787. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30788. /**
  30789. * Unbind all textures from the webGL context
  30790. */
  30791. unbindAllTextures(): void;
  30792. /**
  30793. * Sets a texture to the according uniform.
  30794. * @param channel The texture channel
  30795. * @param uniform The uniform to set
  30796. * @param texture The texture to apply
  30797. */
  30798. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30799. private _bindSamplerUniformToChannel;
  30800. private _getTextureWrapMode;
  30801. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30802. /**
  30803. * Sets an array of texture to the webGL context
  30804. * @param channel defines the channel where the texture array must be set
  30805. * @param uniform defines the associated uniform location
  30806. * @param textures defines the array of textures to bind
  30807. */
  30808. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30809. /** @hidden */
  30810. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30811. private _setTextureParameterFloat;
  30812. private _setTextureParameterInteger;
  30813. /**
  30814. * Unbind all vertex attributes from the webGL context
  30815. */
  30816. unbindAllAttributes(): void;
  30817. /**
  30818. * 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
  30819. */
  30820. releaseEffects(): void;
  30821. /**
  30822. * Dispose and release all associated resources
  30823. */
  30824. dispose(): void;
  30825. /**
  30826. * Attach a new callback raised when context lost event is fired
  30827. * @param callback defines the callback to call
  30828. */
  30829. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30830. /**
  30831. * Attach a new callback raised when context restored event is fired
  30832. * @param callback defines the callback to call
  30833. */
  30834. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30835. /**
  30836. * Get the current error code of the webGL context
  30837. * @returns the error code
  30838. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30839. */
  30840. getError(): number;
  30841. private _canRenderToFloatFramebuffer;
  30842. private _canRenderToHalfFloatFramebuffer;
  30843. private _canRenderToFramebuffer;
  30844. /** @hidden */
  30845. _getWebGLTextureType(type: number): number;
  30846. /** @hidden */
  30847. _getInternalFormat(format: number): number;
  30848. /** @hidden */
  30849. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30850. /** @hidden */
  30851. _getRGBAMultiSampleBufferFormat(type: number): number;
  30852. /** @hidden */
  30853. _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;
  30854. /**
  30855. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30856. * @returns true if the engine can be created
  30857. * @ignorenaming
  30858. */
  30859. static isSupported(): boolean;
  30860. /**
  30861. * Find the next highest power of two.
  30862. * @param x Number to start search from.
  30863. * @return Next highest power of two.
  30864. */
  30865. static CeilingPOT(x: number): number;
  30866. /**
  30867. * Find the next lowest power of two.
  30868. * @param x Number to start search from.
  30869. * @return Next lowest power of two.
  30870. */
  30871. static FloorPOT(x: number): number;
  30872. /**
  30873. * Find the nearest power of two.
  30874. * @param x Number to start search from.
  30875. * @return Next nearest power of two.
  30876. */
  30877. static NearestPOT(x: number): number;
  30878. /**
  30879. * Get the closest exponent of two
  30880. * @param value defines the value to approximate
  30881. * @param max defines the maximum value to return
  30882. * @param mode defines how to define the closest value
  30883. * @returns closest exponent of two of the given value
  30884. */
  30885. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30886. /**
  30887. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30888. * @param func - the function to be called
  30889. * @param requester - the object that will request the next frame. Falls back to window.
  30890. * @returns frame number
  30891. */
  30892. static QueueNewFrame(func: () => void, requester?: any): number;
  30893. }
  30894. }
  30895. declare module "babylonjs/Maths/sphericalPolynomial" {
  30896. import { Vector3 } from "babylonjs/Maths/math.vector";
  30897. import { Color3 } from "babylonjs/Maths/math.color";
  30898. /**
  30899. * Class representing spherical harmonics coefficients to the 3rd degree
  30900. */
  30901. export class SphericalHarmonics {
  30902. /**
  30903. * Defines whether or not the harmonics have been prescaled for rendering.
  30904. */
  30905. preScaled: boolean;
  30906. /**
  30907. * The l0,0 coefficients of the spherical harmonics
  30908. */
  30909. l00: Vector3;
  30910. /**
  30911. * The l1,-1 coefficients of the spherical harmonics
  30912. */
  30913. l1_1: Vector3;
  30914. /**
  30915. * The l1,0 coefficients of the spherical harmonics
  30916. */
  30917. l10: Vector3;
  30918. /**
  30919. * The l1,1 coefficients of the spherical harmonics
  30920. */
  30921. l11: Vector3;
  30922. /**
  30923. * The l2,-2 coefficients of the spherical harmonics
  30924. */
  30925. l2_2: Vector3;
  30926. /**
  30927. * The l2,-1 coefficients of the spherical harmonics
  30928. */
  30929. l2_1: Vector3;
  30930. /**
  30931. * The l2,0 coefficients of the spherical harmonics
  30932. */
  30933. l20: Vector3;
  30934. /**
  30935. * The l2,1 coefficients of the spherical harmonics
  30936. */
  30937. l21: Vector3;
  30938. /**
  30939. * The l2,2 coefficients of the spherical harmonics
  30940. */
  30941. l22: Vector3;
  30942. /**
  30943. * Adds a light to the spherical harmonics
  30944. * @param direction the direction of the light
  30945. * @param color the color of the light
  30946. * @param deltaSolidAngle the delta solid angle of the light
  30947. */
  30948. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30949. /**
  30950. * Scales the spherical harmonics by the given amount
  30951. * @param scale the amount to scale
  30952. */
  30953. scaleInPlace(scale: number): void;
  30954. /**
  30955. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30956. *
  30957. * ```
  30958. * E_lm = A_l * L_lm
  30959. * ```
  30960. *
  30961. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30962. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30963. * the scaling factors are given in equation 9.
  30964. */
  30965. convertIncidentRadianceToIrradiance(): void;
  30966. /**
  30967. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30968. *
  30969. * ```
  30970. * L = (1/pi) * E * rho
  30971. * ```
  30972. *
  30973. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30974. */
  30975. convertIrradianceToLambertianRadiance(): void;
  30976. /**
  30977. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30978. * required operations at run time.
  30979. *
  30980. * This is simply done by scaling back the SH with Ylm constants parameter.
  30981. * The trigonometric part being applied by the shader at run time.
  30982. */
  30983. preScaleForRendering(): void;
  30984. /**
  30985. * Constructs a spherical harmonics from an array.
  30986. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30987. * @returns the spherical harmonics
  30988. */
  30989. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30990. /**
  30991. * Gets the spherical harmonics from polynomial
  30992. * @param polynomial the spherical polynomial
  30993. * @returns the spherical harmonics
  30994. */
  30995. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30996. }
  30997. /**
  30998. * Class representing spherical polynomial coefficients to the 3rd degree
  30999. */
  31000. export class SphericalPolynomial {
  31001. private _harmonics;
  31002. /**
  31003. * The spherical harmonics used to create the polynomials.
  31004. */
  31005. readonly preScaledHarmonics: SphericalHarmonics;
  31006. /**
  31007. * The x coefficients of the spherical polynomial
  31008. */
  31009. x: Vector3;
  31010. /**
  31011. * The y coefficients of the spherical polynomial
  31012. */
  31013. y: Vector3;
  31014. /**
  31015. * The z coefficients of the spherical polynomial
  31016. */
  31017. z: Vector3;
  31018. /**
  31019. * The xx coefficients of the spherical polynomial
  31020. */
  31021. xx: Vector3;
  31022. /**
  31023. * The yy coefficients of the spherical polynomial
  31024. */
  31025. yy: Vector3;
  31026. /**
  31027. * The zz coefficients of the spherical polynomial
  31028. */
  31029. zz: Vector3;
  31030. /**
  31031. * The xy coefficients of the spherical polynomial
  31032. */
  31033. xy: Vector3;
  31034. /**
  31035. * The yz coefficients of the spherical polynomial
  31036. */
  31037. yz: Vector3;
  31038. /**
  31039. * The zx coefficients of the spherical polynomial
  31040. */
  31041. zx: Vector3;
  31042. /**
  31043. * Adds an ambient color to the spherical polynomial
  31044. * @param color the color to add
  31045. */
  31046. addAmbient(color: Color3): void;
  31047. /**
  31048. * Scales the spherical polynomial by the given amount
  31049. * @param scale the amount to scale
  31050. */
  31051. scaleInPlace(scale: number): void;
  31052. /**
  31053. * Gets the spherical polynomial from harmonics
  31054. * @param harmonics the spherical harmonics
  31055. * @returns the spherical polynomial
  31056. */
  31057. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31058. /**
  31059. * Constructs a spherical polynomial from an array.
  31060. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31061. * @returns the spherical polynomial
  31062. */
  31063. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31064. }
  31065. }
  31066. declare module "babylonjs/Materials/Textures/internalTexture" {
  31067. import { Observable } from "babylonjs/Misc/observable";
  31068. import { Nullable, int } from "babylonjs/types";
  31069. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31070. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31071. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31072. /**
  31073. * Defines the source of the internal texture
  31074. */
  31075. export enum InternalTextureSource {
  31076. /**
  31077. * The source of the texture data is unknown
  31078. */
  31079. Unknown = 0,
  31080. /**
  31081. * Texture data comes from an URL
  31082. */
  31083. Url = 1,
  31084. /**
  31085. * Texture data is only used for temporary storage
  31086. */
  31087. Temp = 2,
  31088. /**
  31089. * Texture data comes from raw data (ArrayBuffer)
  31090. */
  31091. Raw = 3,
  31092. /**
  31093. * Texture content is dynamic (video or dynamic texture)
  31094. */
  31095. Dynamic = 4,
  31096. /**
  31097. * Texture content is generated by rendering to it
  31098. */
  31099. RenderTarget = 5,
  31100. /**
  31101. * Texture content is part of a multi render target process
  31102. */
  31103. MultiRenderTarget = 6,
  31104. /**
  31105. * Texture data comes from a cube data file
  31106. */
  31107. Cube = 7,
  31108. /**
  31109. * Texture data comes from a raw cube data
  31110. */
  31111. CubeRaw = 8,
  31112. /**
  31113. * Texture data come from a prefiltered cube data file
  31114. */
  31115. CubePrefiltered = 9,
  31116. /**
  31117. * Texture content is raw 3D data
  31118. */
  31119. Raw3D = 10,
  31120. /**
  31121. * Texture content is a depth texture
  31122. */
  31123. Depth = 11,
  31124. /**
  31125. * Texture data comes from a raw cube data encoded with RGBD
  31126. */
  31127. CubeRawRGBD = 12
  31128. }
  31129. /**
  31130. * Class used to store data associated with WebGL texture data for the engine
  31131. * This class should not be used directly
  31132. */
  31133. export class InternalTexture {
  31134. /** @hidden */
  31135. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31136. /**
  31137. * Defines if the texture is ready
  31138. */
  31139. isReady: boolean;
  31140. /**
  31141. * Defines if the texture is a cube texture
  31142. */
  31143. isCube: boolean;
  31144. /**
  31145. * Defines if the texture contains 3D data
  31146. */
  31147. is3D: boolean;
  31148. /**
  31149. * Defines if the texture contains multiview data
  31150. */
  31151. isMultiview: boolean;
  31152. /**
  31153. * Gets the URL used to load this texture
  31154. */
  31155. url: string;
  31156. /**
  31157. * Gets the sampling mode of the texture
  31158. */
  31159. samplingMode: number;
  31160. /**
  31161. * Gets a boolean indicating if the texture needs mipmaps generation
  31162. */
  31163. generateMipMaps: boolean;
  31164. /**
  31165. * Gets the number of samples used by the texture (WebGL2+ only)
  31166. */
  31167. samples: number;
  31168. /**
  31169. * Gets the type of the texture (int, float...)
  31170. */
  31171. type: number;
  31172. /**
  31173. * Gets the format of the texture (RGB, RGBA...)
  31174. */
  31175. format: number;
  31176. /**
  31177. * Observable called when the texture is loaded
  31178. */
  31179. onLoadedObservable: Observable<InternalTexture>;
  31180. /**
  31181. * Gets the width of the texture
  31182. */
  31183. width: number;
  31184. /**
  31185. * Gets the height of the texture
  31186. */
  31187. height: number;
  31188. /**
  31189. * Gets the depth of the texture
  31190. */
  31191. depth: number;
  31192. /**
  31193. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31194. */
  31195. baseWidth: number;
  31196. /**
  31197. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31198. */
  31199. baseHeight: number;
  31200. /**
  31201. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31202. */
  31203. baseDepth: number;
  31204. /**
  31205. * Gets a boolean indicating if the texture is inverted on Y axis
  31206. */
  31207. invertY: boolean;
  31208. /** @hidden */
  31209. _invertVScale: boolean;
  31210. /** @hidden */
  31211. _associatedChannel: number;
  31212. /** @hidden */
  31213. _source: InternalTextureSource;
  31214. /** @hidden */
  31215. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31216. /** @hidden */
  31217. _bufferView: Nullable<ArrayBufferView>;
  31218. /** @hidden */
  31219. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31220. /** @hidden */
  31221. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31222. /** @hidden */
  31223. _size: number;
  31224. /** @hidden */
  31225. _extension: string;
  31226. /** @hidden */
  31227. _files: Nullable<string[]>;
  31228. /** @hidden */
  31229. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31230. /** @hidden */
  31231. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31232. /** @hidden */
  31233. _framebuffer: Nullable<WebGLFramebuffer>;
  31234. /** @hidden */
  31235. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31236. /** @hidden */
  31237. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31238. /** @hidden */
  31239. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31240. /** @hidden */
  31241. _attachments: Nullable<number[]>;
  31242. /** @hidden */
  31243. _cachedCoordinatesMode: Nullable<number>;
  31244. /** @hidden */
  31245. _cachedWrapU: Nullable<number>;
  31246. /** @hidden */
  31247. _cachedWrapV: Nullable<number>;
  31248. /** @hidden */
  31249. _cachedWrapR: Nullable<number>;
  31250. /** @hidden */
  31251. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31252. /** @hidden */
  31253. _isDisabled: boolean;
  31254. /** @hidden */
  31255. _compression: Nullable<string>;
  31256. /** @hidden */
  31257. _generateStencilBuffer: boolean;
  31258. /** @hidden */
  31259. _generateDepthBuffer: boolean;
  31260. /** @hidden */
  31261. _comparisonFunction: number;
  31262. /** @hidden */
  31263. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31264. /** @hidden */
  31265. _lodGenerationScale: number;
  31266. /** @hidden */
  31267. _lodGenerationOffset: number;
  31268. /** @hidden */
  31269. _colorTextureArray: Nullable<WebGLTexture>;
  31270. /** @hidden */
  31271. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31272. /** @hidden */
  31273. _lodTextureHigh: Nullable<BaseTexture>;
  31274. /** @hidden */
  31275. _lodTextureMid: Nullable<BaseTexture>;
  31276. /** @hidden */
  31277. _lodTextureLow: Nullable<BaseTexture>;
  31278. /** @hidden */
  31279. _isRGBD: boolean;
  31280. /** @hidden */
  31281. _linearSpecularLOD: boolean;
  31282. /** @hidden */
  31283. _irradianceTexture: Nullable<BaseTexture>;
  31284. /** @hidden */
  31285. _webGLTexture: Nullable<WebGLTexture>;
  31286. /** @hidden */
  31287. _references: number;
  31288. private _engine;
  31289. /**
  31290. * Gets the Engine the texture belongs to.
  31291. * @returns The babylon engine
  31292. */
  31293. getEngine(): ThinEngine;
  31294. /**
  31295. * Gets the data source type of the texture
  31296. */
  31297. readonly source: InternalTextureSource;
  31298. /**
  31299. * Creates a new InternalTexture
  31300. * @param engine defines the engine to use
  31301. * @param source defines the type of data that will be used
  31302. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31303. */
  31304. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31305. /**
  31306. * Increments the number of references (ie. the number of Texture that point to it)
  31307. */
  31308. incrementReferences(): void;
  31309. /**
  31310. * Change the size of the texture (not the size of the content)
  31311. * @param width defines the new width
  31312. * @param height defines the new height
  31313. * @param depth defines the new depth (1 by default)
  31314. */
  31315. updateSize(width: int, height: int, depth?: int): void;
  31316. /** @hidden */
  31317. _rebuild(): void;
  31318. /** @hidden */
  31319. _swapAndDie(target: InternalTexture): void;
  31320. /**
  31321. * Dispose the current allocated resources
  31322. */
  31323. dispose(): void;
  31324. }
  31325. }
  31326. declare module "babylonjs/Audio/analyser" {
  31327. import { Scene } from "babylonjs/scene";
  31328. /**
  31329. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31330. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31331. */
  31332. export class Analyser {
  31333. /**
  31334. * Gets or sets the smoothing
  31335. * @ignorenaming
  31336. */
  31337. SMOOTHING: number;
  31338. /**
  31339. * Gets or sets the FFT table size
  31340. * @ignorenaming
  31341. */
  31342. FFT_SIZE: number;
  31343. /**
  31344. * Gets or sets the bar graph amplitude
  31345. * @ignorenaming
  31346. */
  31347. BARGRAPHAMPLITUDE: number;
  31348. /**
  31349. * Gets or sets the position of the debug canvas
  31350. * @ignorenaming
  31351. */
  31352. DEBUGCANVASPOS: {
  31353. x: number;
  31354. y: number;
  31355. };
  31356. /**
  31357. * Gets or sets the debug canvas size
  31358. * @ignorenaming
  31359. */
  31360. DEBUGCANVASSIZE: {
  31361. width: number;
  31362. height: number;
  31363. };
  31364. private _byteFreqs;
  31365. private _byteTime;
  31366. private _floatFreqs;
  31367. private _webAudioAnalyser;
  31368. private _debugCanvas;
  31369. private _debugCanvasContext;
  31370. private _scene;
  31371. private _registerFunc;
  31372. private _audioEngine;
  31373. /**
  31374. * Creates a new analyser
  31375. * @param scene defines hosting scene
  31376. */
  31377. constructor(scene: Scene);
  31378. /**
  31379. * Get the number of data values you will have to play with for the visualization
  31380. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31381. * @returns a number
  31382. */
  31383. getFrequencyBinCount(): number;
  31384. /**
  31385. * Gets the current frequency data as a byte array
  31386. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31387. * @returns a Uint8Array
  31388. */
  31389. getByteFrequencyData(): Uint8Array;
  31390. /**
  31391. * Gets the current waveform as a byte array
  31392. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31393. * @returns a Uint8Array
  31394. */
  31395. getByteTimeDomainData(): Uint8Array;
  31396. /**
  31397. * Gets the current frequency data as a float array
  31398. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31399. * @returns a Float32Array
  31400. */
  31401. getFloatFrequencyData(): Float32Array;
  31402. /**
  31403. * Renders the debug canvas
  31404. */
  31405. drawDebugCanvas(): void;
  31406. /**
  31407. * Stops rendering the debug canvas and removes it
  31408. */
  31409. stopDebugCanvas(): void;
  31410. /**
  31411. * Connects two audio nodes
  31412. * @param inputAudioNode defines first node to connect
  31413. * @param outputAudioNode defines second node to connect
  31414. */
  31415. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31416. /**
  31417. * Releases all associated resources
  31418. */
  31419. dispose(): void;
  31420. }
  31421. }
  31422. declare module "babylonjs/Audio/audioEngine" {
  31423. import { IDisposable } from "babylonjs/scene";
  31424. import { Analyser } from "babylonjs/Audio/analyser";
  31425. import { Nullable } from "babylonjs/types";
  31426. import { Observable } from "babylonjs/Misc/observable";
  31427. /**
  31428. * This represents an audio engine and it is responsible
  31429. * to play, synchronize and analyse sounds throughout the application.
  31430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31431. */
  31432. export interface IAudioEngine extends IDisposable {
  31433. /**
  31434. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31435. */
  31436. readonly canUseWebAudio: boolean;
  31437. /**
  31438. * Gets the current AudioContext if available.
  31439. */
  31440. readonly audioContext: Nullable<AudioContext>;
  31441. /**
  31442. * The master gain node defines the global audio volume of your audio engine.
  31443. */
  31444. readonly masterGain: GainNode;
  31445. /**
  31446. * Gets whether or not mp3 are supported by your browser.
  31447. */
  31448. readonly isMP3supported: boolean;
  31449. /**
  31450. * Gets whether or not ogg are supported by your browser.
  31451. */
  31452. readonly isOGGsupported: boolean;
  31453. /**
  31454. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31455. * @ignoreNaming
  31456. */
  31457. WarnedWebAudioUnsupported: boolean;
  31458. /**
  31459. * Defines if the audio engine relies on a custom unlocked button.
  31460. * In this case, the embedded button will not be displayed.
  31461. */
  31462. useCustomUnlockedButton: boolean;
  31463. /**
  31464. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31465. */
  31466. readonly unlocked: boolean;
  31467. /**
  31468. * Event raised when audio has been unlocked on the browser.
  31469. */
  31470. onAudioUnlockedObservable: Observable<AudioEngine>;
  31471. /**
  31472. * Event raised when audio has been locked on the browser.
  31473. */
  31474. onAudioLockedObservable: Observable<AudioEngine>;
  31475. /**
  31476. * Flags the audio engine in Locked state.
  31477. * This happens due to new browser policies preventing audio to autoplay.
  31478. */
  31479. lock(): void;
  31480. /**
  31481. * Unlocks the audio engine once a user action has been done on the dom.
  31482. * This is helpful to resume play once browser policies have been satisfied.
  31483. */
  31484. unlock(): void;
  31485. }
  31486. /**
  31487. * This represents the default audio engine used in babylon.
  31488. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31490. */
  31491. export class AudioEngine implements IAudioEngine {
  31492. private _audioContext;
  31493. private _audioContextInitialized;
  31494. private _muteButton;
  31495. private _hostElement;
  31496. /**
  31497. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31498. */
  31499. canUseWebAudio: boolean;
  31500. /**
  31501. * The master gain node defines the global audio volume of your audio engine.
  31502. */
  31503. masterGain: GainNode;
  31504. /**
  31505. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31506. * @ignoreNaming
  31507. */
  31508. WarnedWebAudioUnsupported: boolean;
  31509. /**
  31510. * Gets whether or not mp3 are supported by your browser.
  31511. */
  31512. isMP3supported: boolean;
  31513. /**
  31514. * Gets whether or not ogg are supported by your browser.
  31515. */
  31516. isOGGsupported: boolean;
  31517. /**
  31518. * Gets whether audio has been unlocked on the device.
  31519. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31520. * a user interaction has happened.
  31521. */
  31522. unlocked: boolean;
  31523. /**
  31524. * Defines if the audio engine relies on a custom unlocked button.
  31525. * In this case, the embedded button will not be displayed.
  31526. */
  31527. useCustomUnlockedButton: boolean;
  31528. /**
  31529. * Event raised when audio has been unlocked on the browser.
  31530. */
  31531. onAudioUnlockedObservable: Observable<AudioEngine>;
  31532. /**
  31533. * Event raised when audio has been locked on the browser.
  31534. */
  31535. onAudioLockedObservable: Observable<AudioEngine>;
  31536. /**
  31537. * Gets the current AudioContext if available.
  31538. */
  31539. readonly audioContext: Nullable<AudioContext>;
  31540. private _connectedAnalyser;
  31541. /**
  31542. * Instantiates a new audio engine.
  31543. *
  31544. * There should be only one per page as some browsers restrict the number
  31545. * of audio contexts you can create.
  31546. * @param hostElement defines the host element where to display the mute icon if necessary
  31547. */
  31548. constructor(hostElement?: Nullable<HTMLElement>);
  31549. /**
  31550. * Flags the audio engine in Locked state.
  31551. * This happens due to new browser policies preventing audio to autoplay.
  31552. */
  31553. lock(): void;
  31554. /**
  31555. * Unlocks the audio engine once a user action has been done on the dom.
  31556. * This is helpful to resume play once browser policies have been satisfied.
  31557. */
  31558. unlock(): void;
  31559. private _resumeAudioContext;
  31560. private _initializeAudioContext;
  31561. private _tryToRun;
  31562. private _triggerRunningState;
  31563. private _triggerSuspendedState;
  31564. private _displayMuteButton;
  31565. private _moveButtonToTopLeft;
  31566. private _onResize;
  31567. private _hideMuteButton;
  31568. /**
  31569. * Destroy and release the resources associated with the audio ccontext.
  31570. */
  31571. dispose(): void;
  31572. /**
  31573. * Gets the global volume sets on the master gain.
  31574. * @returns the global volume if set or -1 otherwise
  31575. */
  31576. getGlobalVolume(): number;
  31577. /**
  31578. * Sets the global volume of your experience (sets on the master gain).
  31579. * @param newVolume Defines the new global volume of the application
  31580. */
  31581. setGlobalVolume(newVolume: number): void;
  31582. /**
  31583. * Connect the audio engine to an audio analyser allowing some amazing
  31584. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31586. * @param analyser The analyser to connect to the engine
  31587. */
  31588. connectToAnalyser(analyser: Analyser): void;
  31589. }
  31590. }
  31591. declare module "babylonjs/Loading/loadingScreen" {
  31592. /**
  31593. * Interface used to present a loading screen while loading a scene
  31594. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31595. */
  31596. export interface ILoadingScreen {
  31597. /**
  31598. * Function called to display the loading screen
  31599. */
  31600. displayLoadingUI: () => void;
  31601. /**
  31602. * Function called to hide the loading screen
  31603. */
  31604. hideLoadingUI: () => void;
  31605. /**
  31606. * Gets or sets the color to use for the background
  31607. */
  31608. loadingUIBackgroundColor: string;
  31609. /**
  31610. * Gets or sets the text to display while loading
  31611. */
  31612. loadingUIText: string;
  31613. }
  31614. /**
  31615. * Class used for the default loading screen
  31616. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31617. */
  31618. export class DefaultLoadingScreen implements ILoadingScreen {
  31619. private _renderingCanvas;
  31620. private _loadingText;
  31621. private _loadingDivBackgroundColor;
  31622. private _loadingDiv;
  31623. private _loadingTextDiv;
  31624. /** Gets or sets the logo url to use for the default loading screen */
  31625. static DefaultLogoUrl: string;
  31626. /** Gets or sets the spinner url to use for the default loading screen */
  31627. static DefaultSpinnerUrl: string;
  31628. /**
  31629. * Creates a new default loading screen
  31630. * @param _renderingCanvas defines the canvas used to render the scene
  31631. * @param _loadingText defines the default text to display
  31632. * @param _loadingDivBackgroundColor defines the default background color
  31633. */
  31634. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31635. /**
  31636. * Function called to display the loading screen
  31637. */
  31638. displayLoadingUI(): void;
  31639. /**
  31640. * Function called to hide the loading screen
  31641. */
  31642. hideLoadingUI(): void;
  31643. /**
  31644. * Gets or sets the text to display while loading
  31645. */
  31646. loadingUIText: string;
  31647. /**
  31648. * Gets or sets the color to use for the background
  31649. */
  31650. loadingUIBackgroundColor: string;
  31651. private _resizeLoadingUI;
  31652. }
  31653. }
  31654. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31655. /**
  31656. * Interface for any object that can request an animation frame
  31657. */
  31658. export interface ICustomAnimationFrameRequester {
  31659. /**
  31660. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31661. */
  31662. renderFunction?: Function;
  31663. /**
  31664. * Called to request the next frame to render to
  31665. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31666. */
  31667. requestAnimationFrame: Function;
  31668. /**
  31669. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31670. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31671. */
  31672. requestID?: number;
  31673. }
  31674. }
  31675. declare module "babylonjs/Misc/performanceMonitor" {
  31676. /**
  31677. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31678. */
  31679. export class PerformanceMonitor {
  31680. private _enabled;
  31681. private _rollingFrameTime;
  31682. private _lastFrameTimeMs;
  31683. /**
  31684. * constructor
  31685. * @param frameSampleSize The number of samples required to saturate the sliding window
  31686. */
  31687. constructor(frameSampleSize?: number);
  31688. /**
  31689. * Samples current frame
  31690. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31691. */
  31692. sampleFrame(timeMs?: number): void;
  31693. /**
  31694. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31695. */
  31696. readonly averageFrameTime: number;
  31697. /**
  31698. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31699. */
  31700. readonly averageFrameTimeVariance: number;
  31701. /**
  31702. * Returns the frame time of the most recent frame
  31703. */
  31704. readonly instantaneousFrameTime: number;
  31705. /**
  31706. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31707. */
  31708. readonly averageFPS: number;
  31709. /**
  31710. * Returns the average framerate in frames per second using the most recent frame time
  31711. */
  31712. readonly instantaneousFPS: number;
  31713. /**
  31714. * Returns true if enough samples have been taken to completely fill the sliding window
  31715. */
  31716. readonly isSaturated: boolean;
  31717. /**
  31718. * Enables contributions to the sliding window sample set
  31719. */
  31720. enable(): void;
  31721. /**
  31722. * Disables contributions to the sliding window sample set
  31723. * Samples will not be interpolated over the disabled period
  31724. */
  31725. disable(): void;
  31726. /**
  31727. * Returns true if sampling is enabled
  31728. */
  31729. readonly isEnabled: boolean;
  31730. /**
  31731. * Resets performance monitor
  31732. */
  31733. reset(): void;
  31734. }
  31735. /**
  31736. * RollingAverage
  31737. *
  31738. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31739. */
  31740. export class RollingAverage {
  31741. /**
  31742. * Current average
  31743. */
  31744. average: number;
  31745. /**
  31746. * Current variance
  31747. */
  31748. variance: number;
  31749. protected _samples: Array<number>;
  31750. protected _sampleCount: number;
  31751. protected _pos: number;
  31752. protected _m2: number;
  31753. /**
  31754. * constructor
  31755. * @param length The number of samples required to saturate the sliding window
  31756. */
  31757. constructor(length: number);
  31758. /**
  31759. * Adds a sample to the sample set
  31760. * @param v The sample value
  31761. */
  31762. add(v: number): void;
  31763. /**
  31764. * Returns previously added values or null if outside of history or outside the sliding window domain
  31765. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31766. * @return Value previously recorded with add() or null if outside of range
  31767. */
  31768. history(i: number): number;
  31769. /**
  31770. * Returns true if enough samples have been taken to completely fill the sliding window
  31771. * @return true if sample-set saturated
  31772. */
  31773. isSaturated(): boolean;
  31774. /**
  31775. * Resets the rolling average (equivalent to 0 samples taken so far)
  31776. */
  31777. reset(): void;
  31778. /**
  31779. * Wraps a value around the sample range boundaries
  31780. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31781. * @return Wrapped position in sample range
  31782. */
  31783. protected _wrapPosition(i: number): number;
  31784. }
  31785. }
  31786. declare module "babylonjs/Misc/perfCounter" {
  31787. /**
  31788. * This class is used to track a performance counter which is number based.
  31789. * The user has access to many properties which give statistics of different nature.
  31790. *
  31791. * The implementer can track two kinds of Performance Counter: time and count.
  31792. * 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.
  31793. * 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.
  31794. */
  31795. export class PerfCounter {
  31796. /**
  31797. * Gets or sets a global boolean to turn on and off all the counters
  31798. */
  31799. static Enabled: boolean;
  31800. /**
  31801. * Returns the smallest value ever
  31802. */
  31803. readonly min: number;
  31804. /**
  31805. * Returns the biggest value ever
  31806. */
  31807. readonly max: number;
  31808. /**
  31809. * Returns the average value since the performance counter is running
  31810. */
  31811. readonly average: number;
  31812. /**
  31813. * Returns the average value of the last second the counter was monitored
  31814. */
  31815. readonly lastSecAverage: number;
  31816. /**
  31817. * Returns the current value
  31818. */
  31819. readonly current: number;
  31820. /**
  31821. * Gets the accumulated total
  31822. */
  31823. readonly total: number;
  31824. /**
  31825. * Gets the total value count
  31826. */
  31827. readonly count: number;
  31828. /**
  31829. * Creates a new counter
  31830. */
  31831. constructor();
  31832. /**
  31833. * Call this method to start monitoring a new frame.
  31834. * 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.
  31835. */
  31836. fetchNewFrame(): void;
  31837. /**
  31838. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31839. * @param newCount the count value to add to the monitored count
  31840. * @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.
  31841. */
  31842. addCount(newCount: number, fetchResult: boolean): void;
  31843. /**
  31844. * Start monitoring this performance counter
  31845. */
  31846. beginMonitoring(): void;
  31847. /**
  31848. * Compute the time lapsed since the previous beginMonitoring() call.
  31849. * @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
  31850. */
  31851. endMonitoring(newFrame?: boolean): void;
  31852. private _fetchResult;
  31853. private _startMonitoringTime;
  31854. private _min;
  31855. private _max;
  31856. private _average;
  31857. private _current;
  31858. private _totalValueCount;
  31859. private _totalAccumulated;
  31860. private _lastSecAverage;
  31861. private _lastSecAccumulated;
  31862. private _lastSecTime;
  31863. private _lastSecValueCount;
  31864. }
  31865. }
  31866. declare module "babylonjs/Engines/engine" {
  31867. import { Observable } from "babylonjs/Misc/observable";
  31868. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  31869. import { Scene } from "babylonjs/scene";
  31870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31871. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31872. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31873. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31874. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31875. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31876. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31877. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31878. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31880. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31881. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31882. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31883. import { Material } from "babylonjs/Materials/material";
  31884. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31885. /**
  31886. * Defines the interface used by display changed events
  31887. */
  31888. export interface IDisplayChangedEventArgs {
  31889. /** Gets the vrDisplay object (if any) */
  31890. vrDisplay: Nullable<any>;
  31891. /** Gets a boolean indicating if webVR is supported */
  31892. vrSupported: boolean;
  31893. }
  31894. /**
  31895. * Defines the interface used by objects containing a viewport (like a camera)
  31896. */
  31897. interface IViewportOwnerLike {
  31898. /**
  31899. * Gets or sets the viewport
  31900. */
  31901. viewport: IViewportLike;
  31902. }
  31903. /**
  31904. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31905. */
  31906. export class Engine extends ThinEngine {
  31907. /** Defines that alpha blending is disabled */
  31908. static readonly ALPHA_DISABLE: number;
  31909. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31910. static readonly ALPHA_ADD: number;
  31911. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31912. static readonly ALPHA_COMBINE: number;
  31913. /** Defines that alpha blending to DEST - SRC * DEST */
  31914. static readonly ALPHA_SUBTRACT: number;
  31915. /** Defines that alpha blending to SRC * DEST */
  31916. static readonly ALPHA_MULTIPLY: number;
  31917. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31918. static readonly ALPHA_MAXIMIZED: number;
  31919. /** Defines that alpha blending to SRC + DEST */
  31920. static readonly ALPHA_ONEONE: number;
  31921. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31922. static readonly ALPHA_PREMULTIPLIED: number;
  31923. /**
  31924. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31925. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31926. */
  31927. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31928. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31929. static readonly ALPHA_INTERPOLATE: number;
  31930. /**
  31931. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31932. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31933. */
  31934. static readonly ALPHA_SCREENMODE: number;
  31935. /** Defines that the ressource is not delayed*/
  31936. static readonly DELAYLOADSTATE_NONE: number;
  31937. /** Defines that the ressource was successfully delay loaded */
  31938. static readonly DELAYLOADSTATE_LOADED: number;
  31939. /** Defines that the ressource is currently delay loading */
  31940. static readonly DELAYLOADSTATE_LOADING: number;
  31941. /** Defines that the ressource is delayed and has not started loading */
  31942. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31943. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31944. static readonly NEVER: number;
  31945. /** 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 */
  31946. static readonly ALWAYS: number;
  31947. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31948. static readonly LESS: number;
  31949. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31950. static readonly EQUAL: number;
  31951. /** 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 */
  31952. static readonly LEQUAL: number;
  31953. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31954. static readonly GREATER: number;
  31955. /** 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 */
  31956. static readonly GEQUAL: number;
  31957. /** 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 */
  31958. static readonly NOTEQUAL: number;
  31959. /** Passed to stencilOperation to specify that stencil value must be kept */
  31960. static readonly KEEP: number;
  31961. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31962. static readonly REPLACE: number;
  31963. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31964. static readonly INCR: number;
  31965. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31966. static readonly DECR: number;
  31967. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31968. static readonly INVERT: number;
  31969. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31970. static readonly INCR_WRAP: number;
  31971. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31972. static readonly DECR_WRAP: number;
  31973. /** Texture is not repeating outside of 0..1 UVs */
  31974. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31975. /** Texture is repeating outside of 0..1 UVs */
  31976. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31977. /** Texture is repeating and mirrored */
  31978. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31979. /** ALPHA */
  31980. static readonly TEXTUREFORMAT_ALPHA: number;
  31981. /** LUMINANCE */
  31982. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31983. /** LUMINANCE_ALPHA */
  31984. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31985. /** RGB */
  31986. static readonly TEXTUREFORMAT_RGB: number;
  31987. /** RGBA */
  31988. static readonly TEXTUREFORMAT_RGBA: number;
  31989. /** RED */
  31990. static readonly TEXTUREFORMAT_RED: number;
  31991. /** RED (2nd reference) */
  31992. static readonly TEXTUREFORMAT_R: number;
  31993. /** RG */
  31994. static readonly TEXTUREFORMAT_RG: number;
  31995. /** RED_INTEGER */
  31996. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31997. /** RED_INTEGER (2nd reference) */
  31998. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31999. /** RG_INTEGER */
  32000. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32001. /** RGB_INTEGER */
  32002. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32003. /** RGBA_INTEGER */
  32004. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32005. /** UNSIGNED_BYTE */
  32006. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32007. /** UNSIGNED_BYTE (2nd reference) */
  32008. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32009. /** FLOAT */
  32010. static readonly TEXTURETYPE_FLOAT: number;
  32011. /** HALF_FLOAT */
  32012. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32013. /** BYTE */
  32014. static readonly TEXTURETYPE_BYTE: number;
  32015. /** SHORT */
  32016. static readonly TEXTURETYPE_SHORT: number;
  32017. /** UNSIGNED_SHORT */
  32018. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32019. /** INT */
  32020. static readonly TEXTURETYPE_INT: number;
  32021. /** UNSIGNED_INT */
  32022. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32023. /** UNSIGNED_SHORT_4_4_4_4 */
  32024. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32025. /** UNSIGNED_SHORT_5_5_5_1 */
  32026. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32027. /** UNSIGNED_SHORT_5_6_5 */
  32028. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32029. /** UNSIGNED_INT_2_10_10_10_REV */
  32030. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32031. /** UNSIGNED_INT_24_8 */
  32032. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32033. /** UNSIGNED_INT_10F_11F_11F_REV */
  32034. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32035. /** UNSIGNED_INT_5_9_9_9_REV */
  32036. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32037. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32038. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32039. /** nearest is mag = nearest and min = nearest and mip = linear */
  32040. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32041. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32042. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32043. /** Trilinear is mag = linear and min = linear and mip = linear */
  32044. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32045. /** nearest is mag = nearest and min = nearest and mip = linear */
  32046. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32047. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32048. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32049. /** Trilinear is mag = linear and min = linear and mip = linear */
  32050. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32051. /** mag = nearest and min = nearest and mip = nearest */
  32052. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32053. /** mag = nearest and min = linear and mip = nearest */
  32054. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32055. /** mag = nearest and min = linear and mip = linear */
  32056. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32057. /** mag = nearest and min = linear and mip = none */
  32058. static readonly TEXTURE_NEAREST_LINEAR: number;
  32059. /** mag = nearest and min = nearest and mip = none */
  32060. static readonly TEXTURE_NEAREST_NEAREST: number;
  32061. /** mag = linear and min = nearest and mip = nearest */
  32062. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32063. /** mag = linear and min = nearest and mip = linear */
  32064. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32065. /** mag = linear and min = linear and mip = none */
  32066. static readonly TEXTURE_LINEAR_LINEAR: number;
  32067. /** mag = linear and min = nearest and mip = none */
  32068. static readonly TEXTURE_LINEAR_NEAREST: number;
  32069. /** Explicit coordinates mode */
  32070. static readonly TEXTURE_EXPLICIT_MODE: number;
  32071. /** Spherical coordinates mode */
  32072. static readonly TEXTURE_SPHERICAL_MODE: number;
  32073. /** Planar coordinates mode */
  32074. static readonly TEXTURE_PLANAR_MODE: number;
  32075. /** Cubic coordinates mode */
  32076. static readonly TEXTURE_CUBIC_MODE: number;
  32077. /** Projection coordinates mode */
  32078. static readonly TEXTURE_PROJECTION_MODE: number;
  32079. /** Skybox coordinates mode */
  32080. static readonly TEXTURE_SKYBOX_MODE: number;
  32081. /** Inverse Cubic coordinates mode */
  32082. static readonly TEXTURE_INVCUBIC_MODE: number;
  32083. /** Equirectangular coordinates mode */
  32084. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32085. /** Equirectangular Fixed coordinates mode */
  32086. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32087. /** Equirectangular Fixed Mirrored coordinates mode */
  32088. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32089. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32090. static readonly SCALEMODE_FLOOR: number;
  32091. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32092. static readonly SCALEMODE_NEAREST: number;
  32093. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32094. static readonly SCALEMODE_CEILING: number;
  32095. /**
  32096. * Returns the current npm package of the sdk
  32097. */
  32098. static readonly NpmPackage: string;
  32099. /**
  32100. * Returns the current version of the framework
  32101. */
  32102. static readonly Version: string;
  32103. /** Gets the list of created engines */
  32104. static readonly Instances: Engine[];
  32105. /**
  32106. * Gets the latest created engine
  32107. */
  32108. static readonly LastCreatedEngine: Nullable<Engine>;
  32109. /**
  32110. * Gets the latest created scene
  32111. */
  32112. static readonly LastCreatedScene: Nullable<Scene>;
  32113. /**
  32114. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32115. * @param flag defines which part of the materials must be marked as dirty
  32116. * @param predicate defines a predicate used to filter which materials should be affected
  32117. */
  32118. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32119. /**
  32120. * Method called to create the default loading screen.
  32121. * This can be overriden in your own app.
  32122. * @param canvas The rendering canvas element
  32123. * @returns The loading screen
  32124. */
  32125. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32126. /**
  32127. * Method called to create the default rescale post process on each engine.
  32128. */
  32129. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32130. /**
  32131. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32132. **/
  32133. enableOfflineSupport: boolean;
  32134. /**
  32135. * 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)
  32136. **/
  32137. disableManifestCheck: boolean;
  32138. /**
  32139. * Gets the list of created scenes
  32140. */
  32141. scenes: Scene[];
  32142. /**
  32143. * Event raised when a new scene is created
  32144. */
  32145. onNewSceneAddedObservable: Observable<Scene>;
  32146. /**
  32147. * Gets the list of created postprocesses
  32148. */
  32149. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32150. /**
  32151. * Gets a boolean indicating if the pointer is currently locked
  32152. */
  32153. isPointerLock: boolean;
  32154. /**
  32155. * Observable event triggered each time the rendering canvas is resized
  32156. */
  32157. onResizeObservable: Observable<Engine>;
  32158. /**
  32159. * Observable event triggered each time the canvas loses focus
  32160. */
  32161. onCanvasBlurObservable: Observable<Engine>;
  32162. /**
  32163. * Observable event triggered each time the canvas gains focus
  32164. */
  32165. onCanvasFocusObservable: Observable<Engine>;
  32166. /**
  32167. * Observable event triggered each time the canvas receives pointerout event
  32168. */
  32169. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32170. /**
  32171. * Observable raised when the engine begins a new frame
  32172. */
  32173. onBeginFrameObservable: Observable<Engine>;
  32174. /**
  32175. * If set, will be used to request the next animation frame for the render loop
  32176. */
  32177. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32178. /**
  32179. * Observable raised when the engine ends the current frame
  32180. */
  32181. onEndFrameObservable: Observable<Engine>;
  32182. /**
  32183. * Observable raised when the engine is about to compile a shader
  32184. */
  32185. onBeforeShaderCompilationObservable: Observable<Engine>;
  32186. /**
  32187. * Observable raised when the engine has jsut compiled a shader
  32188. */
  32189. onAfterShaderCompilationObservable: Observable<Engine>;
  32190. /**
  32191. * Gets the audio engine
  32192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32193. * @ignorenaming
  32194. */
  32195. static audioEngine: IAudioEngine;
  32196. /**
  32197. * Default AudioEngine factory responsible of creating the Audio Engine.
  32198. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32199. */
  32200. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32201. /**
  32202. * Default offline support factory responsible of creating a tool used to store data locally.
  32203. * By default, this will create a Database object if the workload has been embedded.
  32204. */
  32205. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32206. private _loadingScreen;
  32207. private _pointerLockRequested;
  32208. private _dummyFramebuffer;
  32209. private _rescalePostProcess;
  32210. /** @hidden */
  32211. protected _alphaMode: number;
  32212. /** @hidden */
  32213. protected _alphaEquation: number;
  32214. private _deterministicLockstep;
  32215. private _lockstepMaxSteps;
  32216. protected readonly _supportsHardwareTextureRescaling: boolean;
  32217. private _fps;
  32218. private _deltaTime;
  32219. /** @hidden */
  32220. _drawCalls: PerfCounter;
  32221. /**
  32222. * Turn this value on if you want to pause FPS computation when in background
  32223. */
  32224. disablePerformanceMonitorInBackground: boolean;
  32225. private _performanceMonitor;
  32226. /**
  32227. * Gets the performance monitor attached to this engine
  32228. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32229. */
  32230. readonly performanceMonitor: PerformanceMonitor;
  32231. private _onFocus;
  32232. private _onBlur;
  32233. private _onCanvasPointerOut;
  32234. private _onCanvasBlur;
  32235. private _onCanvasFocus;
  32236. private _onFullscreenChange;
  32237. private _onPointerLockChange;
  32238. /**
  32239. * Creates a new engine
  32240. * @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
  32241. * @param antialias defines enable antialiasing (default: false)
  32242. * @param options defines further options to be sent to the getContext() function
  32243. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32244. */
  32245. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32246. /**
  32247. * Gets current aspect ratio
  32248. * @param viewportOwner defines the camera to use to get the aspect ratio
  32249. * @param useScreen defines if screen size must be used (or the current render target if any)
  32250. * @returns a number defining the aspect ratio
  32251. */
  32252. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32253. /**
  32254. * Gets current screen aspect ratio
  32255. * @returns a number defining the aspect ratio
  32256. */
  32257. getScreenAspectRatio(): number;
  32258. /**
  32259. * Gets host document
  32260. * @returns the host document object
  32261. */
  32262. getHostDocument(): Document;
  32263. /**
  32264. * Gets the client rect of the HTML canvas attached with the current webGL context
  32265. * @returns a client rectanglee
  32266. */
  32267. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32268. /**
  32269. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32270. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32271. * @returns true if engine is in deterministic lock step mode
  32272. */
  32273. isDeterministicLockStep(): boolean;
  32274. /**
  32275. * Gets the max steps when engine is running in deterministic lock step
  32276. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32277. * @returns the max steps
  32278. */
  32279. getLockstepMaxSteps(): number;
  32280. /**
  32281. * Force the mipmap generation for the given render target texture
  32282. * @param texture defines the render target texture to use
  32283. */
  32284. generateMipMapsForCubemap(texture: InternalTexture): void;
  32285. /** States */
  32286. /**
  32287. * Set various states to the webGL context
  32288. * @param culling defines backface culling state
  32289. * @param zOffset defines the value to apply to zOffset (0 by default)
  32290. * @param force defines if states must be applied even if cache is up to date
  32291. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32292. */
  32293. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32294. /**
  32295. * Set the z offset to apply to current rendering
  32296. * @param value defines the offset to apply
  32297. */
  32298. setZOffset(value: number): void;
  32299. /**
  32300. * Gets the current value of the zOffset
  32301. * @returns the current zOffset state
  32302. */
  32303. getZOffset(): number;
  32304. /**
  32305. * Enable or disable depth buffering
  32306. * @param enable defines the state to set
  32307. */
  32308. setDepthBuffer(enable: boolean): void;
  32309. /**
  32310. * Gets a boolean indicating if depth writing is enabled
  32311. * @returns the current depth writing state
  32312. */
  32313. getDepthWrite(): boolean;
  32314. /**
  32315. * Enable or disable depth writing
  32316. * @param enable defines the state to set
  32317. */
  32318. setDepthWrite(enable: boolean): void;
  32319. /**
  32320. * Enable or disable color writing
  32321. * @param enable defines the state to set
  32322. */
  32323. setColorWrite(enable: boolean): void;
  32324. /**
  32325. * Gets a boolean indicating if color writing is enabled
  32326. * @returns the current color writing state
  32327. */
  32328. getColorWrite(): boolean;
  32329. /**
  32330. * Sets alpha constants used by some alpha blending modes
  32331. * @param r defines the red component
  32332. * @param g defines the green component
  32333. * @param b defines the blue component
  32334. * @param a defines the alpha component
  32335. */
  32336. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32337. /**
  32338. * Sets the current alpha mode
  32339. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32340. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32341. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32342. */
  32343. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32344. /**
  32345. * Gets the current alpha mode
  32346. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32347. * @returns the current alpha mode
  32348. */
  32349. getAlphaMode(): number;
  32350. /**
  32351. * Sets the current alpha equation
  32352. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32353. */
  32354. setAlphaEquation(equation: number): void;
  32355. /**
  32356. * Gets the current alpha equation.
  32357. * @returns the current alpha equation
  32358. */
  32359. getAlphaEquation(): number;
  32360. /**
  32361. * Gets a boolean indicating if stencil buffer is enabled
  32362. * @returns the current stencil buffer state
  32363. */
  32364. getStencilBuffer(): boolean;
  32365. /**
  32366. * Enable or disable the stencil buffer
  32367. * @param enable defines if the stencil buffer must be enabled or disabled
  32368. */
  32369. setStencilBuffer(enable: boolean): void;
  32370. /**
  32371. * Gets the current stencil mask
  32372. * @returns a number defining the new stencil mask to use
  32373. */
  32374. getStencilMask(): number;
  32375. /**
  32376. * Sets the current stencil mask
  32377. * @param mask defines the new stencil mask to use
  32378. */
  32379. setStencilMask(mask: number): void;
  32380. /**
  32381. * Gets the current stencil function
  32382. * @returns a number defining the stencil function to use
  32383. */
  32384. getStencilFunction(): number;
  32385. /**
  32386. * Gets the current stencil reference value
  32387. * @returns a number defining the stencil reference value to use
  32388. */
  32389. getStencilFunctionReference(): number;
  32390. /**
  32391. * Gets the current stencil mask
  32392. * @returns a number defining the stencil mask to use
  32393. */
  32394. getStencilFunctionMask(): number;
  32395. /**
  32396. * Sets the current stencil function
  32397. * @param stencilFunc defines the new stencil function to use
  32398. */
  32399. setStencilFunction(stencilFunc: number): void;
  32400. /**
  32401. * Sets the current stencil reference
  32402. * @param reference defines the new stencil reference to use
  32403. */
  32404. setStencilFunctionReference(reference: number): void;
  32405. /**
  32406. * Sets the current stencil mask
  32407. * @param mask defines the new stencil mask to use
  32408. */
  32409. setStencilFunctionMask(mask: number): void;
  32410. /**
  32411. * Gets the current stencil operation when stencil fails
  32412. * @returns a number defining stencil operation to use when stencil fails
  32413. */
  32414. getStencilOperationFail(): number;
  32415. /**
  32416. * Gets the current stencil operation when depth fails
  32417. * @returns a number defining stencil operation to use when depth fails
  32418. */
  32419. getStencilOperationDepthFail(): number;
  32420. /**
  32421. * Gets the current stencil operation when stencil passes
  32422. * @returns a number defining stencil operation to use when stencil passes
  32423. */
  32424. getStencilOperationPass(): number;
  32425. /**
  32426. * Sets the stencil operation to use when stencil fails
  32427. * @param operation defines the stencil operation to use when stencil fails
  32428. */
  32429. setStencilOperationFail(operation: number): void;
  32430. /**
  32431. * Sets the stencil operation to use when depth fails
  32432. * @param operation defines the stencil operation to use when depth fails
  32433. */
  32434. setStencilOperationDepthFail(operation: number): void;
  32435. /**
  32436. * Sets the stencil operation to use when stencil passes
  32437. * @param operation defines the stencil operation to use when stencil passes
  32438. */
  32439. setStencilOperationPass(operation: number): void;
  32440. /**
  32441. * Sets a boolean indicating if the dithering state is enabled or disabled
  32442. * @param value defines the dithering state
  32443. */
  32444. setDitheringState(value: boolean): void;
  32445. /**
  32446. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32447. * @param value defines the rasterizer state
  32448. */
  32449. setRasterizerState(value: boolean): void;
  32450. /**
  32451. * Gets the current depth function
  32452. * @returns a number defining the depth function
  32453. */
  32454. getDepthFunction(): Nullable<number>;
  32455. /**
  32456. * Sets the current depth function
  32457. * @param depthFunc defines the function to use
  32458. */
  32459. setDepthFunction(depthFunc: number): void;
  32460. /**
  32461. * Sets the current depth function to GREATER
  32462. */
  32463. setDepthFunctionToGreater(): void;
  32464. /**
  32465. * Sets the current depth function to GEQUAL
  32466. */
  32467. setDepthFunctionToGreaterOrEqual(): void;
  32468. /**
  32469. * Sets the current depth function to LESS
  32470. */
  32471. setDepthFunctionToLess(): void;
  32472. /**
  32473. * Sets the current depth function to LEQUAL
  32474. */
  32475. setDepthFunctionToLessOrEqual(): void;
  32476. private _cachedStencilBuffer;
  32477. private _cachedStencilFunction;
  32478. private _cachedStencilMask;
  32479. private _cachedStencilOperationPass;
  32480. private _cachedStencilOperationFail;
  32481. private _cachedStencilOperationDepthFail;
  32482. private _cachedStencilReference;
  32483. /**
  32484. * Caches the the state of the stencil buffer
  32485. */
  32486. cacheStencilState(): void;
  32487. /**
  32488. * Restores the state of the stencil buffer
  32489. */
  32490. restoreStencilState(): void;
  32491. /**
  32492. * Directly set the WebGL Viewport
  32493. * @param x defines the x coordinate of the viewport (in screen space)
  32494. * @param y defines the y coordinate of the viewport (in screen space)
  32495. * @param width defines the width of the viewport (in screen space)
  32496. * @param height defines the height of the viewport (in screen space)
  32497. * @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
  32498. */
  32499. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32500. /**
  32501. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32502. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32503. * @param y defines the y-coordinate of the corner of the clear rectangle
  32504. * @param width defines the width of the clear rectangle
  32505. * @param height defines the height of the clear rectangle
  32506. * @param clearColor defines the clear color
  32507. */
  32508. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32509. /**
  32510. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32511. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32512. * @param y defines the y-coordinate of the corner of the clear rectangle
  32513. * @param width defines the width of the clear rectangle
  32514. * @param height defines the height of the clear rectangle
  32515. */
  32516. enableScissor(x: number, y: number, width: number, height: number): void;
  32517. /**
  32518. * Disable previously set scissor test rectangle
  32519. */
  32520. disableScissor(): void;
  32521. protected _reportDrawCall(): void;
  32522. /**
  32523. * Initializes a webVR display and starts listening to display change events
  32524. * The onVRDisplayChangedObservable will be notified upon these changes
  32525. * @returns The onVRDisplayChangedObservable
  32526. */
  32527. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32528. /** @hidden */
  32529. _prepareVRComponent(): void;
  32530. /** @hidden */
  32531. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32532. /** @hidden */
  32533. _submitVRFrame(): void;
  32534. /**
  32535. * Call this function to leave webVR mode
  32536. * Will do nothing if webVR is not supported or if there is no webVR device
  32537. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32538. */
  32539. disableVR(): void;
  32540. /**
  32541. * Gets a boolean indicating that the system is in VR mode and is presenting
  32542. * @returns true if VR mode is engaged
  32543. */
  32544. isVRPresenting(): boolean;
  32545. /** @hidden */
  32546. _requestVRFrame(): void;
  32547. /** @hidden */
  32548. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32549. /**
  32550. * Gets the source code of the vertex shader associated with a specific webGL program
  32551. * @param program defines the program to use
  32552. * @returns a string containing the source code of the vertex shader associated with the program
  32553. */
  32554. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32555. /**
  32556. * Gets the source code of the fragment shader associated with a specific webGL program
  32557. * @param program defines the program to use
  32558. * @returns a string containing the source code of the fragment shader associated with the program
  32559. */
  32560. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32561. /**
  32562. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32563. * @param x defines the x coordinate of the rectangle where pixels must be read
  32564. * @param y defines the y coordinate of the rectangle where pixels must be read
  32565. * @param width defines the width of the rectangle where pixels must be read
  32566. * @param height defines the height of the rectangle where pixels must be read
  32567. * @returns a Uint8Array containing RGBA colors
  32568. */
  32569. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32570. /**
  32571. * Sets a depth stencil texture from a render target to the according uniform.
  32572. * @param channel The texture channel
  32573. * @param uniform The uniform to set
  32574. * @param texture The render target texture containing the depth stencil texture to apply
  32575. */
  32576. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32577. /**
  32578. * Sets a texture to the webGL context from a postprocess
  32579. * @param channel defines the channel to use
  32580. * @param postProcess defines the source postprocess
  32581. */
  32582. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32583. /**
  32584. * Binds the output of the passed in post process to the texture channel specified
  32585. * @param channel The channel the texture should be bound to
  32586. * @param postProcess The post process which's output should be bound
  32587. */
  32588. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32589. /** @hidden */
  32590. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32591. protected _rebuildBuffers(): void;
  32592. _renderLoop(): void;
  32593. /**
  32594. * Toggle full screen mode
  32595. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32596. */
  32597. switchFullscreen(requestPointerLock: boolean): void;
  32598. /**
  32599. * Enters full screen mode
  32600. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32601. */
  32602. enterFullscreen(requestPointerLock: boolean): void;
  32603. /**
  32604. * Exits full screen mode
  32605. */
  32606. exitFullscreen(): void;
  32607. /**
  32608. * Enters Pointerlock mode
  32609. */
  32610. enterPointerlock(): void;
  32611. /**
  32612. * Exits Pointerlock mode
  32613. */
  32614. exitPointerlock(): void;
  32615. /**
  32616. * Begin a new frame
  32617. */
  32618. beginFrame(): void;
  32619. /**
  32620. * Enf the current frame
  32621. */
  32622. endFrame(): void;
  32623. resize(): void;
  32624. /**
  32625. * Set the compressed texture format to use, based on the formats you have, and the formats
  32626. * supported by the hardware / browser.
  32627. *
  32628. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32629. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32630. * to API arguments needed to compressed textures. This puts the burden on the container
  32631. * generator to house the arcane code for determining these for current & future formats.
  32632. *
  32633. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32634. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32635. *
  32636. * Note: The result of this call is not taken into account when a texture is base64.
  32637. *
  32638. * @param formatsAvailable defines the list of those format families you have created
  32639. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32640. *
  32641. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32642. * @returns The extension selected.
  32643. */
  32644. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32645. /**
  32646. * Force a specific size of the canvas
  32647. * @param width defines the new canvas' width
  32648. * @param height defines the new canvas' height
  32649. */
  32650. setSize(width: number, height: number): void;
  32651. /**
  32652. * Updates a dynamic vertex buffer.
  32653. * @param vertexBuffer the vertex buffer to update
  32654. * @param data the data used to update the vertex buffer
  32655. * @param byteOffset the byte offset of the data
  32656. * @param byteLength the byte length of the data
  32657. */
  32658. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32659. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32660. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32661. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32662. _releaseTexture(texture: InternalTexture): void;
  32663. /**
  32664. * @hidden
  32665. * Rescales a texture
  32666. * @param source input texutre
  32667. * @param destination destination texture
  32668. * @param scene scene to use to render the resize
  32669. * @param internalFormat format to use when resizing
  32670. * @param onComplete callback to be called when resize has completed
  32671. */
  32672. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32673. /**
  32674. * Gets the current framerate
  32675. * @returns a number representing the framerate
  32676. */
  32677. getFps(): number;
  32678. /**
  32679. * Gets the time spent between current and previous frame
  32680. * @returns a number representing the delta time in ms
  32681. */
  32682. getDeltaTime(): number;
  32683. private _measureFps;
  32684. /** @hidden */
  32685. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32686. /**
  32687. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32688. * @param renderTarget The render target to set the frame buffer for
  32689. */
  32690. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32691. /**
  32692. * Update a dynamic index buffer
  32693. * @param indexBuffer defines the target index buffer
  32694. * @param indices defines the data to update
  32695. * @param offset defines the offset in the target index buffer where update should start
  32696. */
  32697. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32698. /**
  32699. * Updates the sample count of a render target texture
  32700. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32701. * @param texture defines the texture to update
  32702. * @param samples defines the sample count to set
  32703. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32704. */
  32705. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32706. /**
  32707. * Updates a depth texture Comparison Mode and Function.
  32708. * If the comparison Function is equal to 0, the mode will be set to none.
  32709. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32710. * @param texture The texture to set the comparison function for
  32711. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32712. */
  32713. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32714. /**
  32715. * Creates a webGL buffer to use with instanciation
  32716. * @param capacity defines the size of the buffer
  32717. * @returns the webGL buffer
  32718. */
  32719. createInstancesBuffer(capacity: number): DataBuffer;
  32720. /**
  32721. * Delete a webGL buffer used with instanciation
  32722. * @param buffer defines the webGL buffer to delete
  32723. */
  32724. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32725. /** @hidden */
  32726. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32727. dispose(): void;
  32728. private _disableTouchAction;
  32729. /**
  32730. * Display the loading screen
  32731. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32732. */
  32733. displayLoadingUI(): void;
  32734. /**
  32735. * Hide the loading screen
  32736. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32737. */
  32738. hideLoadingUI(): void;
  32739. /**
  32740. * Gets the current loading screen object
  32741. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32742. */
  32743. /**
  32744. * Sets the current loading screen object
  32745. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32746. */
  32747. loadingScreen: ILoadingScreen;
  32748. /**
  32749. * Sets the current loading screen text
  32750. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32751. */
  32752. loadingUIText: string;
  32753. /**
  32754. * Sets the current loading screen background color
  32755. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32756. */
  32757. loadingUIBackgroundColor: string;
  32758. /** Pointerlock and fullscreen */
  32759. /**
  32760. * Ask the browser to promote the current element to pointerlock mode
  32761. * @param element defines the DOM element to promote
  32762. */
  32763. static _RequestPointerlock(element: HTMLElement): void;
  32764. /**
  32765. * Asks the browser to exit pointerlock mode
  32766. */
  32767. static _ExitPointerlock(): void;
  32768. /**
  32769. * Ask the browser to promote the current element to fullscreen rendering mode
  32770. * @param element defines the DOM element to promote
  32771. */
  32772. static _RequestFullscreen(element: HTMLElement): void;
  32773. /**
  32774. * Asks the browser to exit fullscreen mode
  32775. */
  32776. static _ExitFullscreen(): void;
  32777. }
  32778. }
  32779. declare module "babylonjs/Engines/engineStore" {
  32780. import { Nullable } from "babylonjs/types";
  32781. import { Engine } from "babylonjs/Engines/engine";
  32782. import { Scene } from "babylonjs/scene";
  32783. /**
  32784. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32785. * during the life time of the application.
  32786. */
  32787. export class EngineStore {
  32788. /** Gets the list of created engines */
  32789. static Instances: import("babylonjs/Engines/engine").Engine[];
  32790. /** @hidden */
  32791. static _LastCreatedScene: Nullable<Scene>;
  32792. /**
  32793. * Gets the latest created engine
  32794. */
  32795. static readonly LastCreatedEngine: Nullable<Engine>;
  32796. /**
  32797. * Gets the latest created scene
  32798. */
  32799. static readonly LastCreatedScene: Nullable<Scene>;
  32800. /**
  32801. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32802. * @ignorenaming
  32803. */
  32804. static UseFallbackTexture: boolean;
  32805. /**
  32806. * Texture content used if a texture cannot loaded
  32807. * @ignorenaming
  32808. */
  32809. static FallbackTexture: string;
  32810. }
  32811. }
  32812. declare module "babylonjs/Misc/promise" {
  32813. /**
  32814. * Helper class that provides a small promise polyfill
  32815. */
  32816. export class PromisePolyfill {
  32817. /**
  32818. * Static function used to check if the polyfill is required
  32819. * If this is the case then the function will inject the polyfill to window.Promise
  32820. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32821. */
  32822. static Apply(force?: boolean): void;
  32823. }
  32824. }
  32825. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32826. /**
  32827. * Interface for screenshot methods with describe argument called `size` as object with options
  32828. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32829. */
  32830. export interface IScreenshotSize {
  32831. /**
  32832. * number in pixels for canvas height
  32833. */
  32834. height?: number;
  32835. /**
  32836. * multiplier allowing render at a higher or lower resolution
  32837. * If value is defined then height and width will be ignored and taken from camera
  32838. */
  32839. precision?: number;
  32840. /**
  32841. * number in pixels for canvas width
  32842. */
  32843. width?: number;
  32844. }
  32845. }
  32846. declare module "babylonjs/Misc/tools" {
  32847. import { Nullable, float } from "babylonjs/types";
  32848. import { DomManagement } from "babylonjs/Misc/domManagement";
  32849. import { WebRequest } from "babylonjs/Misc/webRequest";
  32850. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32851. import { ReadFileError } from "babylonjs/Misc/fileTools";
  32852. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32853. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32854. import { Camera } from "babylonjs/Cameras/camera";
  32855. import { Engine } from "babylonjs/Engines/engine";
  32856. interface IColor4Like {
  32857. r: float;
  32858. g: float;
  32859. b: float;
  32860. a: float;
  32861. }
  32862. /**
  32863. * Class containing a set of static utilities functions
  32864. */
  32865. export class Tools {
  32866. /**
  32867. * Gets or sets the base URL to use to load assets
  32868. */
  32869. static BaseUrl: string;
  32870. /**
  32871. * Enable/Disable Custom HTTP Request Headers globally.
  32872. * default = false
  32873. * @see CustomRequestHeaders
  32874. */
  32875. static UseCustomRequestHeaders: boolean;
  32876. /**
  32877. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32878. * i.e. when loading files, where the server/service expects an Authorization header
  32879. */
  32880. static CustomRequestHeaders: {
  32881. [key: string]: string;
  32882. };
  32883. /**
  32884. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32885. */
  32886. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32887. /**
  32888. * Default behaviour for cors in the application.
  32889. * It can be a string if the expected behavior is identical in the entire app.
  32890. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32891. */
  32892. static CorsBehavior: string | ((url: string | string[]) => string);
  32893. /**
  32894. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32895. * @ignorenaming
  32896. */
  32897. static UseFallbackTexture: boolean;
  32898. /**
  32899. * Use this object to register external classes like custom textures or material
  32900. * to allow the laoders to instantiate them
  32901. */
  32902. static RegisteredExternalClasses: {
  32903. [key: string]: Object;
  32904. };
  32905. /**
  32906. * Texture content used if a texture cannot loaded
  32907. * @ignorenaming
  32908. */
  32909. static fallbackTexture: string;
  32910. /**
  32911. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32912. * @param u defines the coordinate on X axis
  32913. * @param v defines the coordinate on Y axis
  32914. * @param width defines the width of the source data
  32915. * @param height defines the height of the source data
  32916. * @param pixels defines the source byte array
  32917. * @param color defines the output color
  32918. */
  32919. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32920. /**
  32921. * Interpolates between a and b via alpha
  32922. * @param a The lower value (returned when alpha = 0)
  32923. * @param b The upper value (returned when alpha = 1)
  32924. * @param alpha The interpolation-factor
  32925. * @return The mixed value
  32926. */
  32927. static Mix(a: number, b: number, alpha: number): number;
  32928. /**
  32929. * Tries to instantiate a new object from a given class name
  32930. * @param className defines the class name to instantiate
  32931. * @returns the new object or null if the system was not able to do the instantiation
  32932. */
  32933. static Instantiate(className: string): any;
  32934. /**
  32935. * Provides a slice function that will work even on IE
  32936. * @param data defines the array to slice
  32937. * @param start defines the start of the data (optional)
  32938. * @param end defines the end of the data (optional)
  32939. * @returns the new sliced array
  32940. */
  32941. static Slice<T>(data: T, start?: number, end?: number): T;
  32942. /**
  32943. * Polyfill for setImmediate
  32944. * @param action defines the action to execute after the current execution block
  32945. */
  32946. static SetImmediate(action: () => void): void;
  32947. /**
  32948. * Function indicating if a number is an exponent of 2
  32949. * @param value defines the value to test
  32950. * @returns true if the value is an exponent of 2
  32951. */
  32952. static IsExponentOfTwo(value: number): boolean;
  32953. private static _tmpFloatArray;
  32954. /**
  32955. * Returns the nearest 32-bit single precision float representation of a Number
  32956. * @param value A Number. If the parameter is of a different type, it will get converted
  32957. * to a number or to NaN if it cannot be converted
  32958. * @returns number
  32959. */
  32960. static FloatRound(value: number): number;
  32961. /**
  32962. * Extracts the filename from a path
  32963. * @param path defines the path to use
  32964. * @returns the filename
  32965. */
  32966. static GetFilename(path: string): string;
  32967. /**
  32968. * Extracts the "folder" part of a path (everything before the filename).
  32969. * @param uri The URI to extract the info from
  32970. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32971. * @returns The "folder" part of the path
  32972. */
  32973. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32974. /**
  32975. * Extracts text content from a DOM element hierarchy
  32976. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32977. */
  32978. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32979. /**
  32980. * Convert an angle in radians to degrees
  32981. * @param angle defines the angle to convert
  32982. * @returns the angle in degrees
  32983. */
  32984. static ToDegrees(angle: number): number;
  32985. /**
  32986. * Convert an angle in degrees to radians
  32987. * @param angle defines the angle to convert
  32988. * @returns the angle in radians
  32989. */
  32990. static ToRadians(angle: number): number;
  32991. /**
  32992. * Returns an array if obj is not an array
  32993. * @param obj defines the object to evaluate as an array
  32994. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32995. * @returns either obj directly if obj is an array or a new array containing obj
  32996. */
  32997. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32998. /**
  32999. * Gets the pointer prefix to use
  33000. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33001. */
  33002. static GetPointerPrefix(): string;
  33003. /**
  33004. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33005. * @param url define the url we are trying
  33006. * @param element define the dom element where to configure the cors policy
  33007. */
  33008. static SetCorsBehavior(url: string | string[], element: {
  33009. crossOrigin: string | null;
  33010. }): void;
  33011. /**
  33012. * Removes unwanted characters from an url
  33013. * @param url defines the url to clean
  33014. * @returns the cleaned url
  33015. */
  33016. static CleanUrl(url: string): string;
  33017. /**
  33018. * Gets or sets a function used to pre-process url before using them to load assets
  33019. */
  33020. static PreprocessUrl: (url: string) => string;
  33021. /**
  33022. * Loads an image as an HTMLImageElement.
  33023. * @param input url string, ArrayBuffer, or Blob to load
  33024. * @param onLoad callback called when the image successfully loads
  33025. * @param onError callback called when the image fails to load
  33026. * @param offlineProvider offline provider for caching
  33027. * @param mimeType optional mime type
  33028. * @returns the HTMLImageElement of the loaded image
  33029. */
  33030. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33031. /**
  33032. * Loads a file from a url
  33033. * @param url url string, ArrayBuffer, or Blob to load
  33034. * @param onSuccess callback called when the file successfully loads
  33035. * @param onProgress callback called while file is loading (if the server supports this mode)
  33036. * @param offlineProvider defines the offline provider for caching
  33037. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33038. * @param onError callback called when the file fails to load
  33039. * @returns a file request object
  33040. */
  33041. 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;
  33042. /**
  33043. * Loads a file from a url
  33044. * @param url the file url to load
  33045. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33046. */
  33047. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33048. /**
  33049. * Load a script (identified by an url). When the url returns, the
  33050. * content of this file is added into a new script element, attached to the DOM (body element)
  33051. * @param scriptUrl defines the url of the script to laod
  33052. * @param onSuccess defines the callback called when the script is loaded
  33053. * @param onError defines the callback to call if an error occurs
  33054. * @param scriptId defines the id of the script element
  33055. */
  33056. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33057. /**
  33058. * Load an asynchronous script (identified by an url). When the url returns, the
  33059. * content of this file is added into a new script element, attached to the DOM (body element)
  33060. * @param scriptUrl defines the url of the script to laod
  33061. * @param scriptId defines the id of the script element
  33062. * @returns a promise request object
  33063. */
  33064. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33065. /**
  33066. * Loads a file from a blob
  33067. * @param fileToLoad defines the blob to use
  33068. * @param callback defines the callback to call when data is loaded
  33069. * @param progressCallback defines the callback to call during loading process
  33070. * @returns a file request object
  33071. */
  33072. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33073. /**
  33074. * Reads a file from a File object
  33075. * @param file defines the file to load
  33076. * @param onSuccess defines the callback to call when data is loaded
  33077. * @param onProgress defines the callback to call during loading process
  33078. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33079. * @param onError defines the callback to call when an error occurs
  33080. * @returns a file request object
  33081. */
  33082. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33083. /**
  33084. * Creates a data url from a given string content
  33085. * @param content defines the content to convert
  33086. * @returns the new data url link
  33087. */
  33088. static FileAsURL(content: string): string;
  33089. /**
  33090. * Format the given number to a specific decimal format
  33091. * @param value defines the number to format
  33092. * @param decimals defines the number of decimals to use
  33093. * @returns the formatted string
  33094. */
  33095. static Format(value: number, decimals?: number): string;
  33096. /**
  33097. * Tries to copy an object by duplicating every property
  33098. * @param source defines the source object
  33099. * @param destination defines the target object
  33100. * @param doNotCopyList defines a list of properties to avoid
  33101. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33102. */
  33103. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33104. /**
  33105. * Gets a boolean indicating if the given object has no own property
  33106. * @param obj defines the object to test
  33107. * @returns true if object has no own property
  33108. */
  33109. static IsEmpty(obj: any): boolean;
  33110. /**
  33111. * Function used to register events at window level
  33112. * @param windowElement defines the Window object to use
  33113. * @param events defines the events to register
  33114. */
  33115. static RegisterTopRootEvents(windowElement: Window, events: {
  33116. name: string;
  33117. handler: Nullable<(e: FocusEvent) => any>;
  33118. }[]): void;
  33119. /**
  33120. * Function used to unregister events from window level
  33121. * @param windowElement defines the Window object to use
  33122. * @param events defines the events to unregister
  33123. */
  33124. static UnregisterTopRootEvents(windowElement: Window, events: {
  33125. name: string;
  33126. handler: Nullable<(e: FocusEvent) => any>;
  33127. }[]): void;
  33128. /**
  33129. * @ignore
  33130. */
  33131. static _ScreenshotCanvas: HTMLCanvasElement;
  33132. /**
  33133. * Dumps the current bound framebuffer
  33134. * @param width defines the rendering width
  33135. * @param height defines the rendering height
  33136. * @param engine defines the hosting engine
  33137. * @param successCallback defines the callback triggered once the data are available
  33138. * @param mimeType defines the mime type of the result
  33139. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33140. */
  33141. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33142. /**
  33143. * Converts the canvas data to blob.
  33144. * This acts as a polyfill for browsers not supporting the to blob function.
  33145. * @param canvas Defines the canvas to extract the data from
  33146. * @param successCallback Defines the callback triggered once the data are available
  33147. * @param mimeType Defines the mime type of the result
  33148. */
  33149. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33150. /**
  33151. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33152. * @param successCallback defines the callback triggered once the data are available
  33153. * @param mimeType defines the mime type of the result
  33154. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33155. */
  33156. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33157. /**
  33158. * Downloads a blob in the browser
  33159. * @param blob defines the blob to download
  33160. * @param fileName defines the name of the downloaded file
  33161. */
  33162. static Download(blob: Blob, fileName: string): void;
  33163. /**
  33164. * Captures a screenshot of the current rendering
  33165. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33166. * @param engine defines the rendering engine
  33167. * @param camera defines the source camera
  33168. * @param size This parameter can be set to a single number or to an object with the
  33169. * following (optional) properties: precision, width, height. If a single number is passed,
  33170. * it will be used for both width and height. If an object is passed, the screenshot size
  33171. * will be derived from the parameters. The precision property is a multiplier allowing
  33172. * rendering at a higher or lower resolution
  33173. * @param successCallback defines the callback receives a single parameter which contains the
  33174. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33175. * src parameter of an <img> to display it
  33176. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33177. * Check your browser for supported MIME types
  33178. */
  33179. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33180. /**
  33181. * Captures a screenshot of the current rendering
  33182. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33183. * @param engine defines the rendering engine
  33184. * @param camera defines the source camera
  33185. * @param size This parameter can be set to a single number or to an object with the
  33186. * following (optional) properties: precision, width, height. If a single number is passed,
  33187. * it will be used for both width and height. If an object is passed, the screenshot size
  33188. * will be derived from the parameters. The precision property is a multiplier allowing
  33189. * rendering at a higher or lower resolution
  33190. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33191. * Check your browser for supported MIME types
  33192. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33193. * to the src parameter of an <img> to display it
  33194. */
  33195. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33196. /**
  33197. * Generates an image screenshot from the specified camera.
  33198. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33199. * @param engine The engine to use for rendering
  33200. * @param camera The camera to use for rendering
  33201. * @param size This parameter can be set to a single number or to an object with the
  33202. * following (optional) properties: precision, width, height. If a single number is passed,
  33203. * it will be used for both width and height. If an object is passed, the screenshot size
  33204. * will be derived from the parameters. The precision property is a multiplier allowing
  33205. * rendering at a higher or lower resolution
  33206. * @param successCallback The callback receives a single parameter which contains the
  33207. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33208. * src parameter of an <img> to display it
  33209. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33210. * Check your browser for supported MIME types
  33211. * @param samples Texture samples (default: 1)
  33212. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33213. * @param fileName A name for for the downloaded file.
  33214. */
  33215. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33216. /**
  33217. * Generates an image screenshot from the specified camera.
  33218. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33219. * @param engine The engine to use for rendering
  33220. * @param camera The camera to use for rendering
  33221. * @param size This parameter can be set to a single number or to an object with the
  33222. * following (optional) properties: precision, width, height. If a single number is passed,
  33223. * it will be used for both width and height. If an object is passed, the screenshot size
  33224. * will be derived from the parameters. The precision property is a multiplier allowing
  33225. * rendering at a higher or lower resolution
  33226. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33227. * Check your browser for supported MIME types
  33228. * @param samples Texture samples (default: 1)
  33229. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33230. * @param fileName A name for for the downloaded file.
  33231. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33232. * to the src parameter of an <img> to display it
  33233. */
  33234. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33235. /**
  33236. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33237. * Be aware Math.random() could cause collisions, but:
  33238. * "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"
  33239. * @returns a pseudo random id
  33240. */
  33241. static RandomId(): string;
  33242. /**
  33243. * Test if the given uri is a base64 string
  33244. * @param uri The uri to test
  33245. * @return True if the uri is a base64 string or false otherwise
  33246. */
  33247. static IsBase64(uri: string): boolean;
  33248. /**
  33249. * Decode the given base64 uri.
  33250. * @param uri The uri to decode
  33251. * @return The decoded base64 data.
  33252. */
  33253. static DecodeBase64(uri: string): ArrayBuffer;
  33254. /**
  33255. * Gets the absolute url.
  33256. * @param url the input url
  33257. * @return the absolute url
  33258. */
  33259. static GetAbsoluteUrl(url: string): string;
  33260. /**
  33261. * No log
  33262. */
  33263. static readonly NoneLogLevel: number;
  33264. /**
  33265. * Only message logs
  33266. */
  33267. static readonly MessageLogLevel: number;
  33268. /**
  33269. * Only warning logs
  33270. */
  33271. static readonly WarningLogLevel: number;
  33272. /**
  33273. * Only error logs
  33274. */
  33275. static readonly ErrorLogLevel: number;
  33276. /**
  33277. * All logs
  33278. */
  33279. static readonly AllLogLevel: number;
  33280. /**
  33281. * Gets a value indicating the number of loading errors
  33282. * @ignorenaming
  33283. */
  33284. static readonly errorsCount: number;
  33285. /**
  33286. * Callback called when a new log is added
  33287. */
  33288. static OnNewCacheEntry: (entry: string) => void;
  33289. /**
  33290. * Log a message to the console
  33291. * @param message defines the message to log
  33292. */
  33293. static Log(message: string): void;
  33294. /**
  33295. * Write a warning message to the console
  33296. * @param message defines the message to log
  33297. */
  33298. static Warn(message: string): void;
  33299. /**
  33300. * Write an error message to the console
  33301. * @param message defines the message to log
  33302. */
  33303. static Error(message: string): void;
  33304. /**
  33305. * Gets current log cache (list of logs)
  33306. */
  33307. static readonly LogCache: string;
  33308. /**
  33309. * Clears the log cache
  33310. */
  33311. static ClearLogCache(): void;
  33312. /**
  33313. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33314. */
  33315. static LogLevels: number;
  33316. /**
  33317. * Checks if the window object exists
  33318. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33319. */
  33320. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33321. /**
  33322. * No performance log
  33323. */
  33324. static readonly PerformanceNoneLogLevel: number;
  33325. /**
  33326. * Use user marks to log performance
  33327. */
  33328. static readonly PerformanceUserMarkLogLevel: number;
  33329. /**
  33330. * Log performance to the console
  33331. */
  33332. static readonly PerformanceConsoleLogLevel: number;
  33333. private static _performance;
  33334. /**
  33335. * Sets the current performance log level
  33336. */
  33337. static PerformanceLogLevel: number;
  33338. private static _StartPerformanceCounterDisabled;
  33339. private static _EndPerformanceCounterDisabled;
  33340. private static _StartUserMark;
  33341. private static _EndUserMark;
  33342. private static _StartPerformanceConsole;
  33343. private static _EndPerformanceConsole;
  33344. /**
  33345. * Starts a performance counter
  33346. */
  33347. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33348. /**
  33349. * Ends a specific performance coutner
  33350. */
  33351. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33352. /**
  33353. * Gets either window.performance.now() if supported or Date.now() else
  33354. */
  33355. static readonly Now: number;
  33356. /**
  33357. * This method will return the name of the class used to create the instance of the given object.
  33358. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33359. * @param object the object to get the class name from
  33360. * @param isType defines if the object is actually a type
  33361. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33362. */
  33363. static GetClassName(object: any, isType?: boolean): string;
  33364. /**
  33365. * Gets the first element of an array satisfying a given predicate
  33366. * @param array defines the array to browse
  33367. * @param predicate defines the predicate to use
  33368. * @returns null if not found or the element
  33369. */
  33370. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33371. /**
  33372. * This method will return the name of the full name of the class, including its owning module (if any).
  33373. * 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).
  33374. * @param object the object to get the class name from
  33375. * @param isType defines if the object is actually a type
  33376. * @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.
  33377. * @ignorenaming
  33378. */
  33379. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33380. /**
  33381. * Returns a promise that resolves after the given amount of time.
  33382. * @param delay Number of milliseconds to delay
  33383. * @returns Promise that resolves after the given amount of time
  33384. */
  33385. static DelayAsync(delay: number): Promise<void>;
  33386. }
  33387. /**
  33388. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33389. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33390. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33391. * @param name The name of the class, case should be preserved
  33392. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33393. */
  33394. export function className(name: string, module?: string): (target: Object) => void;
  33395. /**
  33396. * An implementation of a loop for asynchronous functions.
  33397. */
  33398. export class AsyncLoop {
  33399. /**
  33400. * Defines the number of iterations for the loop
  33401. */
  33402. iterations: number;
  33403. /**
  33404. * Defines the current index of the loop.
  33405. */
  33406. index: number;
  33407. private _done;
  33408. private _fn;
  33409. private _successCallback;
  33410. /**
  33411. * Constructor.
  33412. * @param iterations the number of iterations.
  33413. * @param func the function to run each iteration
  33414. * @param successCallback the callback that will be called upon succesful execution
  33415. * @param offset starting offset.
  33416. */
  33417. constructor(
  33418. /**
  33419. * Defines the number of iterations for the loop
  33420. */
  33421. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33422. /**
  33423. * Execute the next iteration. Must be called after the last iteration was finished.
  33424. */
  33425. executeNext(): void;
  33426. /**
  33427. * Break the loop and run the success callback.
  33428. */
  33429. breakLoop(): void;
  33430. /**
  33431. * Create and run an async loop.
  33432. * @param iterations the number of iterations.
  33433. * @param fn the function to run each iteration
  33434. * @param successCallback the callback that will be called upon succesful execution
  33435. * @param offset starting offset.
  33436. * @returns the created async loop object
  33437. */
  33438. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33439. /**
  33440. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33441. * @param iterations total number of iterations
  33442. * @param syncedIterations number of synchronous iterations in each async iteration.
  33443. * @param fn the function to call each iteration.
  33444. * @param callback a success call back that will be called when iterating stops.
  33445. * @param breakFunction a break condition (optional)
  33446. * @param timeout timeout settings for the setTimeout function. default - 0.
  33447. * @returns the created async loop object
  33448. */
  33449. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33450. }
  33451. }
  33452. declare module "babylonjs/Misc/stringDictionary" {
  33453. import { Nullable } from "babylonjs/types";
  33454. /**
  33455. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33456. * The underlying implementation relies on an associative array to ensure the best performances.
  33457. * The value can be anything including 'null' but except 'undefined'
  33458. */
  33459. export class StringDictionary<T> {
  33460. /**
  33461. * This will clear this dictionary and copy the content from the 'source' one.
  33462. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33463. * @param source the dictionary to take the content from and copy to this dictionary
  33464. */
  33465. copyFrom(source: StringDictionary<T>): void;
  33466. /**
  33467. * Get a value based from its key
  33468. * @param key the given key to get the matching value from
  33469. * @return the value if found, otherwise undefined is returned
  33470. */
  33471. get(key: string): T | undefined;
  33472. /**
  33473. * Get a value from its key or add it if it doesn't exist.
  33474. * This method will ensure you that a given key/data will be present in the dictionary.
  33475. * @param key the given key to get the matching value from
  33476. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33477. * The factory will only be invoked if there's no data for the given key.
  33478. * @return the value corresponding to the key.
  33479. */
  33480. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33481. /**
  33482. * Get a value from its key if present in the dictionary otherwise add it
  33483. * @param key the key to get the value from
  33484. * @param val if there's no such key/value pair in the dictionary add it with this value
  33485. * @return the value corresponding to the key
  33486. */
  33487. getOrAdd(key: string, val: T): T;
  33488. /**
  33489. * Check if there's a given key in the dictionary
  33490. * @param key the key to check for
  33491. * @return true if the key is present, false otherwise
  33492. */
  33493. contains(key: string): boolean;
  33494. /**
  33495. * Add a new key and its corresponding value
  33496. * @param key the key to add
  33497. * @param value the value corresponding to the key
  33498. * @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
  33499. */
  33500. add(key: string, value: T): boolean;
  33501. /**
  33502. * Update a specific value associated to a key
  33503. * @param key defines the key to use
  33504. * @param value defines the value to store
  33505. * @returns true if the value was updated (or false if the key was not found)
  33506. */
  33507. set(key: string, value: T): boolean;
  33508. /**
  33509. * Get the element of the given key and remove it from the dictionary
  33510. * @param key defines the key to search
  33511. * @returns the value associated with the key or null if not found
  33512. */
  33513. getAndRemove(key: string): Nullable<T>;
  33514. /**
  33515. * Remove a key/value from the dictionary.
  33516. * @param key the key to remove
  33517. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33518. */
  33519. remove(key: string): boolean;
  33520. /**
  33521. * Clear the whole content of the dictionary
  33522. */
  33523. clear(): void;
  33524. /**
  33525. * Gets the current count
  33526. */
  33527. readonly count: number;
  33528. /**
  33529. * Execute a callback on each key/val of the dictionary.
  33530. * Note that you can remove any element in this dictionary in the callback implementation
  33531. * @param callback the callback to execute on a given key/value pair
  33532. */
  33533. forEach(callback: (key: string, val: T) => void): void;
  33534. /**
  33535. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33536. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33537. * Note that you can remove any element in this dictionary in the callback implementation
  33538. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33539. * @returns the first item
  33540. */
  33541. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33542. private _count;
  33543. private _data;
  33544. }
  33545. }
  33546. declare module "babylonjs/Collisions/collisionCoordinator" {
  33547. import { Nullable } from "babylonjs/types";
  33548. import { Scene } from "babylonjs/scene";
  33549. import { Vector3 } from "babylonjs/Maths/math.vector";
  33550. import { Collider } from "babylonjs/Collisions/collider";
  33551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33552. /** @hidden */
  33553. export interface ICollisionCoordinator {
  33554. createCollider(): Collider;
  33555. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33556. init(scene: Scene): void;
  33557. }
  33558. /** @hidden */
  33559. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33560. private _scene;
  33561. private _scaledPosition;
  33562. private _scaledVelocity;
  33563. private _finalPosition;
  33564. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33565. createCollider(): Collider;
  33566. init(scene: Scene): void;
  33567. private _collideWithWorld;
  33568. }
  33569. }
  33570. declare module "babylonjs/Inputs/scene.inputManager" {
  33571. import { Nullable } from "babylonjs/types";
  33572. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33573. import { Vector2 } from "babylonjs/Maths/math.vector";
  33574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33575. import { Scene } from "babylonjs/scene";
  33576. /**
  33577. * Class used to manage all inputs for the scene.
  33578. */
  33579. export class InputManager {
  33580. /** The distance in pixel that you have to move to prevent some events */
  33581. static DragMovementThreshold: number;
  33582. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33583. static LongPressDelay: number;
  33584. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33585. static DoubleClickDelay: number;
  33586. /** If you need to check double click without raising a single click at first click, enable this flag */
  33587. static ExclusiveDoubleClickMode: boolean;
  33588. private _wheelEventName;
  33589. private _onPointerMove;
  33590. private _onPointerDown;
  33591. private _onPointerUp;
  33592. private _initClickEvent;
  33593. private _initActionManager;
  33594. private _delayedSimpleClick;
  33595. private _delayedSimpleClickTimeout;
  33596. private _previousDelayedSimpleClickTimeout;
  33597. private _meshPickProceed;
  33598. private _previousButtonPressed;
  33599. private _currentPickResult;
  33600. private _previousPickResult;
  33601. private _totalPointersPressed;
  33602. private _doubleClickOccured;
  33603. private _pointerOverMesh;
  33604. private _pickedDownMesh;
  33605. private _pickedUpMesh;
  33606. private _pointerX;
  33607. private _pointerY;
  33608. private _unTranslatedPointerX;
  33609. private _unTranslatedPointerY;
  33610. private _startingPointerPosition;
  33611. private _previousStartingPointerPosition;
  33612. private _startingPointerTime;
  33613. private _previousStartingPointerTime;
  33614. private _pointerCaptures;
  33615. private _onKeyDown;
  33616. private _onKeyUp;
  33617. private _onCanvasFocusObserver;
  33618. private _onCanvasBlurObserver;
  33619. private _scene;
  33620. /**
  33621. * Creates a new InputManager
  33622. * @param scene defines the hosting scene
  33623. */
  33624. constructor(scene: Scene);
  33625. /**
  33626. * Gets the mesh that is currently under the pointer
  33627. */
  33628. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33629. /**
  33630. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33631. */
  33632. readonly unTranslatedPointer: Vector2;
  33633. /**
  33634. * Gets or sets the current on-screen X position of the pointer
  33635. */
  33636. pointerX: number;
  33637. /**
  33638. * Gets or sets the current on-screen Y position of the pointer
  33639. */
  33640. pointerY: number;
  33641. private _updatePointerPosition;
  33642. private _processPointerMove;
  33643. private _setRayOnPointerInfo;
  33644. private _checkPrePointerObservable;
  33645. /**
  33646. * Use this method to simulate a pointer move on a mesh
  33647. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33648. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33649. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33650. */
  33651. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33652. /**
  33653. * Use this method to simulate a pointer down on a mesh
  33654. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33655. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33656. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33657. */
  33658. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33659. private _processPointerDown;
  33660. /** @hidden */
  33661. _isPointerSwiping(): boolean;
  33662. /**
  33663. * Use this method to simulate a pointer up on a mesh
  33664. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33665. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33666. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33667. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33668. */
  33669. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33670. private _processPointerUp;
  33671. /**
  33672. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33673. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33674. * @returns true if the pointer was captured
  33675. */
  33676. isPointerCaptured(pointerId?: number): boolean;
  33677. /**
  33678. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33679. * @param attachUp defines if you want to attach events to pointerup
  33680. * @param attachDown defines if you want to attach events to pointerdown
  33681. * @param attachMove defines if you want to attach events to pointermove
  33682. */
  33683. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33684. /**
  33685. * Detaches all event handlers
  33686. */
  33687. detachControl(): void;
  33688. /**
  33689. * Force the value of meshUnderPointer
  33690. * @param mesh defines the mesh to use
  33691. */
  33692. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33693. /**
  33694. * Gets the mesh under the pointer
  33695. * @returns a Mesh or null if no mesh is under the pointer
  33696. */
  33697. getPointerOverMesh(): Nullable<AbstractMesh>;
  33698. }
  33699. }
  33700. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33701. /**
  33702. * Helper class used to generate session unique ID
  33703. */
  33704. export class UniqueIdGenerator {
  33705. private static _UniqueIdCounter;
  33706. /**
  33707. * Gets an unique (relatively to the current scene) Id
  33708. */
  33709. static readonly UniqueId: number;
  33710. }
  33711. }
  33712. declare module "babylonjs/Animations/animationGroup" {
  33713. import { Animatable } from "babylonjs/Animations/animatable";
  33714. import { Animation } from "babylonjs/Animations/animation";
  33715. import { Scene, IDisposable } from "babylonjs/scene";
  33716. import { Observable } from "babylonjs/Misc/observable";
  33717. import { Nullable } from "babylonjs/types";
  33718. import "babylonjs/Animations/animatable";
  33719. /**
  33720. * This class defines the direct association between an animation and a target
  33721. */
  33722. export class TargetedAnimation {
  33723. /**
  33724. * Animation to perform
  33725. */
  33726. animation: Animation;
  33727. /**
  33728. * Target to animate
  33729. */
  33730. target: any;
  33731. /**
  33732. * Serialize the object
  33733. * @returns the JSON object representing the current entity
  33734. */
  33735. serialize(): any;
  33736. }
  33737. /**
  33738. * Use this class to create coordinated animations on multiple targets
  33739. */
  33740. export class AnimationGroup implements IDisposable {
  33741. /** The name of the animation group */
  33742. name: string;
  33743. private _scene;
  33744. private _targetedAnimations;
  33745. private _animatables;
  33746. private _from;
  33747. private _to;
  33748. private _isStarted;
  33749. private _isPaused;
  33750. private _speedRatio;
  33751. private _loopAnimation;
  33752. /**
  33753. * Gets or sets the unique id of the node
  33754. */
  33755. uniqueId: number;
  33756. /**
  33757. * This observable will notify when one animation have ended
  33758. */
  33759. onAnimationEndObservable: Observable<TargetedAnimation>;
  33760. /**
  33761. * Observer raised when one animation loops
  33762. */
  33763. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33764. /**
  33765. * This observable will notify when all animations have ended.
  33766. */
  33767. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33768. /**
  33769. * This observable will notify when all animations have paused.
  33770. */
  33771. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33772. /**
  33773. * This observable will notify when all animations are playing.
  33774. */
  33775. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33776. /**
  33777. * Gets the first frame
  33778. */
  33779. readonly from: number;
  33780. /**
  33781. * Gets the last frame
  33782. */
  33783. readonly to: number;
  33784. /**
  33785. * Define if the animations are started
  33786. */
  33787. readonly isStarted: boolean;
  33788. /**
  33789. * Gets a value indicating that the current group is playing
  33790. */
  33791. readonly isPlaying: boolean;
  33792. /**
  33793. * Gets or sets the speed ratio to use for all animations
  33794. */
  33795. /**
  33796. * Gets or sets the speed ratio to use for all animations
  33797. */
  33798. speedRatio: number;
  33799. /**
  33800. * Gets or sets if all animations should loop or not
  33801. */
  33802. loopAnimation: boolean;
  33803. /**
  33804. * Gets the targeted animations for this animation group
  33805. */
  33806. readonly targetedAnimations: Array<TargetedAnimation>;
  33807. /**
  33808. * returning the list of animatables controlled by this animation group.
  33809. */
  33810. readonly animatables: Array<Animatable>;
  33811. /**
  33812. * Instantiates a new Animation Group.
  33813. * This helps managing several animations at once.
  33814. * @see http://doc.babylonjs.com/how_to/group
  33815. * @param name Defines the name of the group
  33816. * @param scene Defines the scene the group belongs to
  33817. */
  33818. constructor(
  33819. /** The name of the animation group */
  33820. name: string, scene?: Nullable<Scene>);
  33821. /**
  33822. * Add an animation (with its target) in the group
  33823. * @param animation defines the animation we want to add
  33824. * @param target defines the target of the animation
  33825. * @returns the TargetedAnimation object
  33826. */
  33827. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33828. /**
  33829. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33830. * It can add constant keys at begin or end
  33831. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33832. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33833. * @returns the animation group
  33834. */
  33835. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33836. /**
  33837. * Start all animations on given targets
  33838. * @param loop defines if animations must loop
  33839. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33840. * @param from defines the from key (optional)
  33841. * @param to defines the to key (optional)
  33842. * @returns the current animation group
  33843. */
  33844. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33845. /**
  33846. * Pause all animations
  33847. * @returns the animation group
  33848. */
  33849. pause(): AnimationGroup;
  33850. /**
  33851. * Play all animations to initial state
  33852. * This function will start() the animations if they were not started or will restart() them if they were paused
  33853. * @param loop defines if animations must loop
  33854. * @returns the animation group
  33855. */
  33856. play(loop?: boolean): AnimationGroup;
  33857. /**
  33858. * Reset all animations to initial state
  33859. * @returns the animation group
  33860. */
  33861. reset(): AnimationGroup;
  33862. /**
  33863. * Restart animations from key 0
  33864. * @returns the animation group
  33865. */
  33866. restart(): AnimationGroup;
  33867. /**
  33868. * Stop all animations
  33869. * @returns the animation group
  33870. */
  33871. stop(): AnimationGroup;
  33872. /**
  33873. * Set animation weight for all animatables
  33874. * @param weight defines the weight to use
  33875. * @return the animationGroup
  33876. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33877. */
  33878. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33879. /**
  33880. * Synchronize and normalize all animatables with a source animatable
  33881. * @param root defines the root animatable to synchronize with
  33882. * @return the animationGroup
  33883. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33884. */
  33885. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33886. /**
  33887. * Goes to a specific frame in this animation group
  33888. * @param frame the frame number to go to
  33889. * @return the animationGroup
  33890. */
  33891. goToFrame(frame: number): AnimationGroup;
  33892. /**
  33893. * Dispose all associated resources
  33894. */
  33895. dispose(): void;
  33896. private _checkAnimationGroupEnded;
  33897. /**
  33898. * Clone the current animation group and returns a copy
  33899. * @param newName defines the name of the new group
  33900. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33901. * @returns the new aniamtion group
  33902. */
  33903. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33904. /**
  33905. * Serializes the animationGroup to an object
  33906. * @returns Serialized object
  33907. */
  33908. serialize(): any;
  33909. /**
  33910. * Returns a new AnimationGroup object parsed from the source provided.
  33911. * @param parsedAnimationGroup defines the source
  33912. * @param scene defines the scene that will receive the animationGroup
  33913. * @returns a new AnimationGroup
  33914. */
  33915. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33916. /**
  33917. * Returns the string "AnimationGroup"
  33918. * @returns "AnimationGroup"
  33919. */
  33920. getClassName(): string;
  33921. /**
  33922. * Creates a detailled string about the object
  33923. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33924. * @returns a string representing the object
  33925. */
  33926. toString(fullDetails?: boolean): string;
  33927. }
  33928. }
  33929. declare module "babylonjs/scene" {
  33930. import { Nullable } from "babylonjs/types";
  33931. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33932. import { Observable } from "babylonjs/Misc/observable";
  33933. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33934. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33935. import { Geometry } from "babylonjs/Meshes/geometry";
  33936. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33937. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33939. import { Mesh } from "babylonjs/Meshes/mesh";
  33940. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33941. import { Bone } from "babylonjs/Bones/bone";
  33942. import { Skeleton } from "babylonjs/Bones/skeleton";
  33943. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33944. import { Camera } from "babylonjs/Cameras/camera";
  33945. import { AbstractScene } from "babylonjs/abstractScene";
  33946. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33947. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33948. import { Material } from "babylonjs/Materials/material";
  33949. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33950. import { Effect } from "babylonjs/Materials/effect";
  33951. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33952. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33953. import { Light } from "babylonjs/Lights/light";
  33954. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33955. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33956. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33957. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33958. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33959. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33960. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33961. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33962. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33963. import { Engine } from "babylonjs/Engines/engine";
  33964. import { Node } from "babylonjs/node";
  33965. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33966. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33967. import { WebRequest } from "babylonjs/Misc/webRequest";
  33968. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33969. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33970. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33971. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33972. import { Plane } from "babylonjs/Maths/math.plane";
  33973. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  33974. import { Ray } from "babylonjs/Culling/ray";
  33975. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33976. import { Animation } from "babylonjs/Animations/animation";
  33977. import { Animatable } from "babylonjs/Animations/animatable";
  33978. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33979. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33980. import { Collider } from "babylonjs/Collisions/collider";
  33981. /**
  33982. * Define an interface for all classes that will hold resources
  33983. */
  33984. export interface IDisposable {
  33985. /**
  33986. * Releases all held resources
  33987. */
  33988. dispose(): void;
  33989. }
  33990. /** Interface defining initialization parameters for Scene class */
  33991. export interface SceneOptions {
  33992. /**
  33993. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33994. * It will improve performance when the number of geometries becomes important.
  33995. */
  33996. useGeometryUniqueIdsMap?: boolean;
  33997. /**
  33998. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33999. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34000. */
  34001. useMaterialMeshMap?: boolean;
  34002. /**
  34003. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34004. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34005. */
  34006. useClonedMeshhMap?: boolean;
  34007. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34008. virtual?: boolean;
  34009. }
  34010. /**
  34011. * Represents a scene to be rendered by the engine.
  34012. * @see http://doc.babylonjs.com/features/scene
  34013. */
  34014. export class Scene extends AbstractScene implements IAnimatable {
  34015. /** The fog is deactivated */
  34016. static readonly FOGMODE_NONE: number;
  34017. /** The fog density is following an exponential function */
  34018. static readonly FOGMODE_EXP: number;
  34019. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34020. static readonly FOGMODE_EXP2: number;
  34021. /** The fog density is following a linear function. */
  34022. static readonly FOGMODE_LINEAR: number;
  34023. /**
  34024. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34025. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34026. */
  34027. static MinDeltaTime: number;
  34028. /**
  34029. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34030. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34031. */
  34032. static MaxDeltaTime: number;
  34033. /**
  34034. * Factory used to create the default material.
  34035. * @param name The name of the material to create
  34036. * @param scene The scene to create the material for
  34037. * @returns The default material
  34038. */
  34039. static DefaultMaterialFactory(scene: Scene): Material;
  34040. /**
  34041. * Factory used to create the a collision coordinator.
  34042. * @returns The collision coordinator
  34043. */
  34044. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34045. /** @hidden */
  34046. _inputManager: InputManager;
  34047. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34048. cameraToUseForPointers: Nullable<Camera>;
  34049. /** @hidden */
  34050. readonly _isScene: boolean;
  34051. /**
  34052. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34053. */
  34054. autoClear: boolean;
  34055. /**
  34056. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34057. */
  34058. autoClearDepthAndStencil: boolean;
  34059. /**
  34060. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34061. */
  34062. clearColor: Color4;
  34063. /**
  34064. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34065. */
  34066. ambientColor: Color3;
  34067. /**
  34068. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34069. * It should only be one of the following (if not the default embedded one):
  34070. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34071. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34072. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34073. * The material properties need to be setup according to the type of texture in use.
  34074. */
  34075. environmentBRDFTexture: BaseTexture;
  34076. /** @hidden */
  34077. protected _environmentTexture: Nullable<BaseTexture>;
  34078. /**
  34079. * Texture used in all pbr material as the reflection texture.
  34080. * As in the majority of the scene they are the same (exception for multi room and so on),
  34081. * this is easier to reference from here than from all the materials.
  34082. */
  34083. /**
  34084. * Texture used in all pbr material as the reflection texture.
  34085. * As in the majority of the scene they are the same (exception for multi room and so on),
  34086. * this is easier to set here than in all the materials.
  34087. */
  34088. environmentTexture: Nullable<BaseTexture>;
  34089. /** @hidden */
  34090. protected _environmentIntensity: number;
  34091. /**
  34092. * Intensity of the environment in all pbr material.
  34093. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34094. * As in the majority of the scene they are the same (exception for multi room and so on),
  34095. * this is easier to reference from here than from all the materials.
  34096. */
  34097. /**
  34098. * Intensity of the environment in all pbr material.
  34099. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34100. * As in the majority of the scene they are the same (exception for multi room and so on),
  34101. * this is easier to set here than in all the materials.
  34102. */
  34103. environmentIntensity: number;
  34104. /** @hidden */
  34105. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34106. /**
  34107. * Default image processing configuration used either in the rendering
  34108. * Forward main pass or through the imageProcessingPostProcess if present.
  34109. * As in the majority of the scene they are the same (exception for multi camera),
  34110. * this is easier to reference from here than from all the materials and post process.
  34111. *
  34112. * No setter as we it is a shared configuration, you can set the values instead.
  34113. */
  34114. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34115. private _forceWireframe;
  34116. /**
  34117. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34118. */
  34119. forceWireframe: boolean;
  34120. private _forcePointsCloud;
  34121. /**
  34122. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34123. */
  34124. forcePointsCloud: boolean;
  34125. /**
  34126. * Gets or sets the active clipplane 1
  34127. */
  34128. clipPlane: Nullable<Plane>;
  34129. /**
  34130. * Gets or sets the active clipplane 2
  34131. */
  34132. clipPlane2: Nullable<Plane>;
  34133. /**
  34134. * Gets or sets the active clipplane 3
  34135. */
  34136. clipPlane3: Nullable<Plane>;
  34137. /**
  34138. * Gets or sets the active clipplane 4
  34139. */
  34140. clipPlane4: Nullable<Plane>;
  34141. /**
  34142. * Gets or sets a boolean indicating if animations are enabled
  34143. */
  34144. animationsEnabled: boolean;
  34145. private _animationPropertiesOverride;
  34146. /**
  34147. * Gets or sets the animation properties override
  34148. */
  34149. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34150. /**
  34151. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34152. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34153. */
  34154. useConstantAnimationDeltaTime: boolean;
  34155. /**
  34156. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34157. * Please note that it requires to run a ray cast through the scene on every frame
  34158. */
  34159. constantlyUpdateMeshUnderPointer: boolean;
  34160. /**
  34161. * Defines the HTML cursor to use when hovering over interactive elements
  34162. */
  34163. hoverCursor: string;
  34164. /**
  34165. * Defines the HTML default cursor to use (empty by default)
  34166. */
  34167. defaultCursor: string;
  34168. /**
  34169. * Defines wether cursors are handled by the scene.
  34170. */
  34171. doNotHandleCursors: boolean;
  34172. /**
  34173. * This is used to call preventDefault() on pointer down
  34174. * in order to block unwanted artifacts like system double clicks
  34175. */
  34176. preventDefaultOnPointerDown: boolean;
  34177. /**
  34178. * This is used to call preventDefault() on pointer up
  34179. * in order to block unwanted artifacts like system double clicks
  34180. */
  34181. preventDefaultOnPointerUp: boolean;
  34182. /**
  34183. * Gets or sets user defined metadata
  34184. */
  34185. metadata: any;
  34186. /**
  34187. * For internal use only. Please do not use.
  34188. */
  34189. reservedDataStore: any;
  34190. /**
  34191. * Gets the name of the plugin used to load this scene (null by default)
  34192. */
  34193. loadingPluginName: string;
  34194. /**
  34195. * Use this array to add regular expressions used to disable offline support for specific urls
  34196. */
  34197. disableOfflineSupportExceptionRules: RegExp[];
  34198. /**
  34199. * An event triggered when the scene is disposed.
  34200. */
  34201. onDisposeObservable: Observable<Scene>;
  34202. private _onDisposeObserver;
  34203. /** Sets a function to be executed when this scene is disposed. */
  34204. onDispose: () => void;
  34205. /**
  34206. * An event triggered before rendering the scene (right after animations and physics)
  34207. */
  34208. onBeforeRenderObservable: Observable<Scene>;
  34209. private _onBeforeRenderObserver;
  34210. /** Sets a function to be executed before rendering this scene */
  34211. beforeRender: Nullable<() => void>;
  34212. /**
  34213. * An event triggered after rendering the scene
  34214. */
  34215. onAfterRenderObservable: Observable<Scene>;
  34216. /**
  34217. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34218. */
  34219. onAfterRenderCameraObservable: Observable<Camera>;
  34220. private _onAfterRenderObserver;
  34221. /** Sets a function to be executed after rendering this scene */
  34222. afterRender: Nullable<() => void>;
  34223. /**
  34224. * An event triggered before animating the scene
  34225. */
  34226. onBeforeAnimationsObservable: Observable<Scene>;
  34227. /**
  34228. * An event triggered after animations processing
  34229. */
  34230. onAfterAnimationsObservable: Observable<Scene>;
  34231. /**
  34232. * An event triggered before draw calls are ready to be sent
  34233. */
  34234. onBeforeDrawPhaseObservable: Observable<Scene>;
  34235. /**
  34236. * An event triggered after draw calls have been sent
  34237. */
  34238. onAfterDrawPhaseObservable: Observable<Scene>;
  34239. /**
  34240. * An event triggered when the scene is ready
  34241. */
  34242. onReadyObservable: Observable<Scene>;
  34243. /**
  34244. * An event triggered before rendering a camera
  34245. */
  34246. onBeforeCameraRenderObservable: Observable<Camera>;
  34247. private _onBeforeCameraRenderObserver;
  34248. /** Sets a function to be executed before rendering a camera*/
  34249. beforeCameraRender: () => void;
  34250. /**
  34251. * An event triggered after rendering a camera
  34252. */
  34253. onAfterCameraRenderObservable: Observable<Camera>;
  34254. private _onAfterCameraRenderObserver;
  34255. /** Sets a function to be executed after rendering a camera*/
  34256. afterCameraRender: () => void;
  34257. /**
  34258. * An event triggered when active meshes evaluation is about to start
  34259. */
  34260. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34261. /**
  34262. * An event triggered when active meshes evaluation is done
  34263. */
  34264. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34265. /**
  34266. * An event triggered when particles rendering is about to start
  34267. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34268. */
  34269. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34270. /**
  34271. * An event triggered when particles rendering is done
  34272. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34273. */
  34274. onAfterParticlesRenderingObservable: Observable<Scene>;
  34275. /**
  34276. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34277. */
  34278. onDataLoadedObservable: Observable<Scene>;
  34279. /**
  34280. * An event triggered when a camera is created
  34281. */
  34282. onNewCameraAddedObservable: Observable<Camera>;
  34283. /**
  34284. * An event triggered when a camera is removed
  34285. */
  34286. onCameraRemovedObservable: Observable<Camera>;
  34287. /**
  34288. * An event triggered when a light is created
  34289. */
  34290. onNewLightAddedObservable: Observable<Light>;
  34291. /**
  34292. * An event triggered when a light is removed
  34293. */
  34294. onLightRemovedObservable: Observable<Light>;
  34295. /**
  34296. * An event triggered when a geometry is created
  34297. */
  34298. onNewGeometryAddedObservable: Observable<Geometry>;
  34299. /**
  34300. * An event triggered when a geometry is removed
  34301. */
  34302. onGeometryRemovedObservable: Observable<Geometry>;
  34303. /**
  34304. * An event triggered when a transform node is created
  34305. */
  34306. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34307. /**
  34308. * An event triggered when a transform node is removed
  34309. */
  34310. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34311. /**
  34312. * An event triggered when a mesh is created
  34313. */
  34314. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34315. /**
  34316. * An event triggered when a mesh is removed
  34317. */
  34318. onMeshRemovedObservable: Observable<AbstractMesh>;
  34319. /**
  34320. * An event triggered when a skeleton is created
  34321. */
  34322. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34323. /**
  34324. * An event triggered when a skeleton is removed
  34325. */
  34326. onSkeletonRemovedObservable: Observable<Skeleton>;
  34327. /**
  34328. * An event triggered when a material is created
  34329. */
  34330. onNewMaterialAddedObservable: Observable<Material>;
  34331. /**
  34332. * An event triggered when a material is removed
  34333. */
  34334. onMaterialRemovedObservable: Observable<Material>;
  34335. /**
  34336. * An event triggered when a texture is created
  34337. */
  34338. onNewTextureAddedObservable: Observable<BaseTexture>;
  34339. /**
  34340. * An event triggered when a texture is removed
  34341. */
  34342. onTextureRemovedObservable: Observable<BaseTexture>;
  34343. /**
  34344. * An event triggered when render targets are about to be rendered
  34345. * Can happen multiple times per frame.
  34346. */
  34347. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34348. /**
  34349. * An event triggered when render targets were rendered.
  34350. * Can happen multiple times per frame.
  34351. */
  34352. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34353. /**
  34354. * An event triggered before calculating deterministic simulation step
  34355. */
  34356. onBeforeStepObservable: Observable<Scene>;
  34357. /**
  34358. * An event triggered after calculating deterministic simulation step
  34359. */
  34360. onAfterStepObservable: Observable<Scene>;
  34361. /**
  34362. * An event triggered when the activeCamera property is updated
  34363. */
  34364. onActiveCameraChanged: Observable<Scene>;
  34365. /**
  34366. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34367. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34368. * 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)
  34369. */
  34370. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34371. /**
  34372. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34373. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34374. * 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)
  34375. */
  34376. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34377. /**
  34378. * This Observable will when a mesh has been imported into the scene.
  34379. */
  34380. onMeshImportedObservable: Observable<AbstractMesh>;
  34381. /**
  34382. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34383. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34384. */
  34385. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34386. /** @hidden */
  34387. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34388. /**
  34389. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34390. */
  34391. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34392. /**
  34393. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34394. */
  34395. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34396. /**
  34397. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34398. */
  34399. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34400. /** Callback called when a pointer move is detected */
  34401. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34402. /** Callback called when a pointer down is detected */
  34403. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34404. /** Callback called when a pointer up is detected */
  34405. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34406. /** Callback called when a pointer pick is detected */
  34407. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34408. /**
  34409. * 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).
  34410. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34411. */
  34412. onPrePointerObservable: Observable<PointerInfoPre>;
  34413. /**
  34414. * Observable event triggered each time an input event is received from the rendering canvas
  34415. */
  34416. onPointerObservable: Observable<PointerInfo>;
  34417. /**
  34418. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34419. */
  34420. readonly unTranslatedPointer: Vector2;
  34421. /**
  34422. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34423. */
  34424. static DragMovementThreshold: number;
  34425. /**
  34426. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34427. */
  34428. static LongPressDelay: number;
  34429. /**
  34430. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34431. */
  34432. static DoubleClickDelay: number;
  34433. /** If you need to check double click without raising a single click at first click, enable this flag */
  34434. static ExclusiveDoubleClickMode: boolean;
  34435. /** @hidden */
  34436. _mirroredCameraPosition: Nullable<Vector3>;
  34437. /**
  34438. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34439. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34440. */
  34441. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34442. /**
  34443. * Observable event triggered each time an keyboard event is received from the hosting window
  34444. */
  34445. onKeyboardObservable: Observable<KeyboardInfo>;
  34446. private _useRightHandedSystem;
  34447. /**
  34448. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34449. */
  34450. useRightHandedSystem: boolean;
  34451. private _timeAccumulator;
  34452. private _currentStepId;
  34453. private _currentInternalStep;
  34454. /**
  34455. * Sets the step Id used by deterministic lock step
  34456. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34457. * @param newStepId defines the step Id
  34458. */
  34459. setStepId(newStepId: number): void;
  34460. /**
  34461. * Gets the step Id used by deterministic lock step
  34462. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34463. * @returns the step Id
  34464. */
  34465. getStepId(): number;
  34466. /**
  34467. * Gets the internal step used by deterministic lock step
  34468. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34469. * @returns the internal step
  34470. */
  34471. getInternalStep(): number;
  34472. private _fogEnabled;
  34473. /**
  34474. * Gets or sets a boolean indicating if fog is enabled on this scene
  34475. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34476. * (Default is true)
  34477. */
  34478. fogEnabled: boolean;
  34479. private _fogMode;
  34480. /**
  34481. * Gets or sets the fog mode to use
  34482. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34483. * | mode | value |
  34484. * | --- | --- |
  34485. * | FOGMODE_NONE | 0 |
  34486. * | FOGMODE_EXP | 1 |
  34487. * | FOGMODE_EXP2 | 2 |
  34488. * | FOGMODE_LINEAR | 3 |
  34489. */
  34490. fogMode: number;
  34491. /**
  34492. * Gets or sets the fog color to use
  34493. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34494. * (Default is Color3(0.2, 0.2, 0.3))
  34495. */
  34496. fogColor: Color3;
  34497. /**
  34498. * Gets or sets the fog density to use
  34499. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34500. * (Default is 0.1)
  34501. */
  34502. fogDensity: number;
  34503. /**
  34504. * Gets or sets the fog start distance to use
  34505. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34506. * (Default is 0)
  34507. */
  34508. fogStart: number;
  34509. /**
  34510. * Gets or sets the fog end distance to use
  34511. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34512. * (Default is 1000)
  34513. */
  34514. fogEnd: number;
  34515. private _shadowsEnabled;
  34516. /**
  34517. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34518. */
  34519. shadowsEnabled: boolean;
  34520. private _lightsEnabled;
  34521. /**
  34522. * Gets or sets a boolean indicating if lights are enabled on this scene
  34523. */
  34524. lightsEnabled: boolean;
  34525. /** All of the active cameras added to this scene. */
  34526. activeCameras: Camera[];
  34527. /** @hidden */
  34528. _activeCamera: Nullable<Camera>;
  34529. /** Gets or sets the current active camera */
  34530. activeCamera: Nullable<Camera>;
  34531. private _defaultMaterial;
  34532. /** The default material used on meshes when no material is affected */
  34533. /** The default material used on meshes when no material is affected */
  34534. defaultMaterial: Material;
  34535. private _texturesEnabled;
  34536. /**
  34537. * Gets or sets a boolean indicating if textures are enabled on this scene
  34538. */
  34539. texturesEnabled: boolean;
  34540. /**
  34541. * Gets or sets a boolean indicating if particles are enabled on this scene
  34542. */
  34543. particlesEnabled: boolean;
  34544. /**
  34545. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34546. */
  34547. spritesEnabled: boolean;
  34548. private _skeletonsEnabled;
  34549. /**
  34550. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34551. */
  34552. skeletonsEnabled: boolean;
  34553. /**
  34554. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34555. */
  34556. lensFlaresEnabled: boolean;
  34557. /**
  34558. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34559. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34560. */
  34561. collisionsEnabled: boolean;
  34562. private _collisionCoordinator;
  34563. /** @hidden */
  34564. readonly collisionCoordinator: ICollisionCoordinator;
  34565. /**
  34566. * Defines the gravity applied to this scene (used only for collisions)
  34567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34568. */
  34569. gravity: Vector3;
  34570. /**
  34571. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34572. */
  34573. postProcessesEnabled: boolean;
  34574. /**
  34575. * The list of postprocesses added to the scene
  34576. */
  34577. postProcesses: PostProcess[];
  34578. /**
  34579. * Gets the current postprocess manager
  34580. */
  34581. postProcessManager: PostProcessManager;
  34582. /**
  34583. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34584. */
  34585. renderTargetsEnabled: boolean;
  34586. /**
  34587. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34588. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34589. */
  34590. dumpNextRenderTargets: boolean;
  34591. /**
  34592. * The list of user defined render targets added to the scene
  34593. */
  34594. customRenderTargets: RenderTargetTexture[];
  34595. /**
  34596. * Defines if texture loading must be delayed
  34597. * If true, textures will only be loaded when they need to be rendered
  34598. */
  34599. useDelayedTextureLoading: boolean;
  34600. /**
  34601. * Gets the list of meshes imported to the scene through SceneLoader
  34602. */
  34603. importedMeshesFiles: String[];
  34604. /**
  34605. * Gets or sets a boolean indicating if probes are enabled on this scene
  34606. */
  34607. probesEnabled: boolean;
  34608. /**
  34609. * Gets or sets the current offline provider to use to store scene data
  34610. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34611. */
  34612. offlineProvider: IOfflineProvider;
  34613. /**
  34614. * Gets or sets the action manager associated with the scene
  34615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34616. */
  34617. actionManager: AbstractActionManager;
  34618. private _meshesForIntersections;
  34619. /**
  34620. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34621. */
  34622. proceduralTexturesEnabled: boolean;
  34623. private _engine;
  34624. private _totalVertices;
  34625. /** @hidden */
  34626. _activeIndices: PerfCounter;
  34627. /** @hidden */
  34628. _activeParticles: PerfCounter;
  34629. /** @hidden */
  34630. _activeBones: PerfCounter;
  34631. private _animationRatio;
  34632. /** @hidden */
  34633. _animationTimeLast: number;
  34634. /** @hidden */
  34635. _animationTime: number;
  34636. /**
  34637. * Gets or sets a general scale for animation speed
  34638. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34639. */
  34640. animationTimeScale: number;
  34641. /** @hidden */
  34642. _cachedMaterial: Nullable<Material>;
  34643. /** @hidden */
  34644. _cachedEffect: Nullable<Effect>;
  34645. /** @hidden */
  34646. _cachedVisibility: Nullable<number>;
  34647. private _renderId;
  34648. private _frameId;
  34649. private _executeWhenReadyTimeoutId;
  34650. private _intermediateRendering;
  34651. private _viewUpdateFlag;
  34652. private _projectionUpdateFlag;
  34653. /** @hidden */
  34654. _toBeDisposed: Nullable<IDisposable>[];
  34655. private _activeRequests;
  34656. /** @hidden */
  34657. _pendingData: any[];
  34658. private _isDisposed;
  34659. /**
  34660. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34661. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34662. */
  34663. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34664. private _activeMeshes;
  34665. private _processedMaterials;
  34666. private _renderTargets;
  34667. /** @hidden */
  34668. _activeParticleSystems: SmartArray<IParticleSystem>;
  34669. private _activeSkeletons;
  34670. private _softwareSkinnedMeshes;
  34671. private _renderingManager;
  34672. /** @hidden */
  34673. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34674. private _transformMatrix;
  34675. private _sceneUbo;
  34676. /** @hidden */
  34677. _viewMatrix: Matrix;
  34678. private _projectionMatrix;
  34679. /** @hidden */
  34680. _forcedViewPosition: Nullable<Vector3>;
  34681. /** @hidden */
  34682. _frustumPlanes: Plane[];
  34683. /**
  34684. * Gets the list of frustum planes (built from the active camera)
  34685. */
  34686. readonly frustumPlanes: Plane[];
  34687. /**
  34688. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34689. * This is useful if there are more lights that the maximum simulteanous authorized
  34690. */
  34691. requireLightSorting: boolean;
  34692. /** @hidden */
  34693. readonly useMaterialMeshMap: boolean;
  34694. /** @hidden */
  34695. readonly useClonedMeshhMap: boolean;
  34696. private _externalData;
  34697. private _uid;
  34698. /**
  34699. * @hidden
  34700. * Backing store of defined scene components.
  34701. */
  34702. _components: ISceneComponent[];
  34703. /**
  34704. * @hidden
  34705. * Backing store of defined scene components.
  34706. */
  34707. _serializableComponents: ISceneSerializableComponent[];
  34708. /**
  34709. * List of components to register on the next registration step.
  34710. */
  34711. private _transientComponents;
  34712. /**
  34713. * Registers the transient components if needed.
  34714. */
  34715. private _registerTransientComponents;
  34716. /**
  34717. * @hidden
  34718. * Add a component to the scene.
  34719. * Note that the ccomponent could be registered on th next frame if this is called after
  34720. * the register component stage.
  34721. * @param component Defines the component to add to the scene
  34722. */
  34723. _addComponent(component: ISceneComponent): void;
  34724. /**
  34725. * @hidden
  34726. * Gets a component from the scene.
  34727. * @param name defines the name of the component to retrieve
  34728. * @returns the component or null if not present
  34729. */
  34730. _getComponent(name: string): Nullable<ISceneComponent>;
  34731. /**
  34732. * @hidden
  34733. * Defines the actions happening before camera updates.
  34734. */
  34735. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34736. /**
  34737. * @hidden
  34738. * Defines the actions happening before clear the canvas.
  34739. */
  34740. _beforeClearStage: Stage<SimpleStageAction>;
  34741. /**
  34742. * @hidden
  34743. * Defines the actions when collecting render targets for the frame.
  34744. */
  34745. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34746. /**
  34747. * @hidden
  34748. * Defines the actions happening for one camera in the frame.
  34749. */
  34750. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34751. /**
  34752. * @hidden
  34753. * Defines the actions happening during the per mesh ready checks.
  34754. */
  34755. _isReadyForMeshStage: Stage<MeshStageAction>;
  34756. /**
  34757. * @hidden
  34758. * Defines the actions happening before evaluate active mesh checks.
  34759. */
  34760. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34761. /**
  34762. * @hidden
  34763. * Defines the actions happening during the evaluate sub mesh checks.
  34764. */
  34765. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34766. /**
  34767. * @hidden
  34768. * Defines the actions happening during the active mesh stage.
  34769. */
  34770. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34771. /**
  34772. * @hidden
  34773. * Defines the actions happening during the per camera render target step.
  34774. */
  34775. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34776. /**
  34777. * @hidden
  34778. * Defines the actions happening just before the active camera is drawing.
  34779. */
  34780. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34781. /**
  34782. * @hidden
  34783. * Defines the actions happening just before a render target is drawing.
  34784. */
  34785. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34786. /**
  34787. * @hidden
  34788. * Defines the actions happening just before a rendering group is drawing.
  34789. */
  34790. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34791. /**
  34792. * @hidden
  34793. * Defines the actions happening just before a mesh is drawing.
  34794. */
  34795. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34796. /**
  34797. * @hidden
  34798. * Defines the actions happening just after a mesh has been drawn.
  34799. */
  34800. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34801. /**
  34802. * @hidden
  34803. * Defines the actions happening just after a rendering group has been drawn.
  34804. */
  34805. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34806. /**
  34807. * @hidden
  34808. * Defines the actions happening just after the active camera has been drawn.
  34809. */
  34810. _afterCameraDrawStage: Stage<CameraStageAction>;
  34811. /**
  34812. * @hidden
  34813. * Defines the actions happening just after a render target has been drawn.
  34814. */
  34815. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34816. /**
  34817. * @hidden
  34818. * Defines the actions happening just after rendering all cameras and computing intersections.
  34819. */
  34820. _afterRenderStage: Stage<SimpleStageAction>;
  34821. /**
  34822. * @hidden
  34823. * Defines the actions happening when a pointer move event happens.
  34824. */
  34825. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34826. /**
  34827. * @hidden
  34828. * Defines the actions happening when a pointer down event happens.
  34829. */
  34830. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34831. /**
  34832. * @hidden
  34833. * Defines the actions happening when a pointer up event happens.
  34834. */
  34835. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34836. /**
  34837. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34838. */
  34839. private geometriesByUniqueId;
  34840. /**
  34841. * Creates a new Scene
  34842. * @param engine defines the engine to use to render this scene
  34843. * @param options defines the scene options
  34844. */
  34845. constructor(engine: Engine, options?: SceneOptions);
  34846. /**
  34847. * Gets a string idenfifying the name of the class
  34848. * @returns "Scene" string
  34849. */
  34850. getClassName(): string;
  34851. private _defaultMeshCandidates;
  34852. /**
  34853. * @hidden
  34854. */
  34855. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34856. private _defaultSubMeshCandidates;
  34857. /**
  34858. * @hidden
  34859. */
  34860. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34861. /**
  34862. * Sets the default candidate providers for the scene.
  34863. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34864. * and getCollidingSubMeshCandidates to their default function
  34865. */
  34866. setDefaultCandidateProviders(): void;
  34867. /**
  34868. * Gets the mesh that is currently under the pointer
  34869. */
  34870. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34871. /**
  34872. * Gets or sets the current on-screen X position of the pointer
  34873. */
  34874. pointerX: number;
  34875. /**
  34876. * Gets or sets the current on-screen Y position of the pointer
  34877. */
  34878. pointerY: number;
  34879. /**
  34880. * Gets the cached material (ie. the latest rendered one)
  34881. * @returns the cached material
  34882. */
  34883. getCachedMaterial(): Nullable<Material>;
  34884. /**
  34885. * Gets the cached effect (ie. the latest rendered one)
  34886. * @returns the cached effect
  34887. */
  34888. getCachedEffect(): Nullable<Effect>;
  34889. /**
  34890. * Gets the cached visibility state (ie. the latest rendered one)
  34891. * @returns the cached visibility state
  34892. */
  34893. getCachedVisibility(): Nullable<number>;
  34894. /**
  34895. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34896. * @param material defines the current material
  34897. * @param effect defines the current effect
  34898. * @param visibility defines the current visibility state
  34899. * @returns true if one parameter is not cached
  34900. */
  34901. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34902. /**
  34903. * Gets the engine associated with the scene
  34904. * @returns an Engine
  34905. */
  34906. getEngine(): Engine;
  34907. /**
  34908. * Gets the total number of vertices rendered per frame
  34909. * @returns the total number of vertices rendered per frame
  34910. */
  34911. getTotalVertices(): number;
  34912. /**
  34913. * Gets the performance counter for total vertices
  34914. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34915. */
  34916. readonly totalVerticesPerfCounter: PerfCounter;
  34917. /**
  34918. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34919. * @returns the total number of active indices rendered per frame
  34920. */
  34921. getActiveIndices(): number;
  34922. /**
  34923. * Gets the performance counter for active indices
  34924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34925. */
  34926. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34927. /**
  34928. * Gets the total number of active particles rendered per frame
  34929. * @returns the total number of active particles rendered per frame
  34930. */
  34931. getActiveParticles(): number;
  34932. /**
  34933. * Gets the performance counter for active particles
  34934. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34935. */
  34936. readonly activeParticlesPerfCounter: PerfCounter;
  34937. /**
  34938. * Gets the total number of active bones rendered per frame
  34939. * @returns the total number of active bones rendered per frame
  34940. */
  34941. getActiveBones(): number;
  34942. /**
  34943. * Gets the performance counter for active bones
  34944. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34945. */
  34946. readonly activeBonesPerfCounter: PerfCounter;
  34947. /**
  34948. * Gets the array of active meshes
  34949. * @returns an array of AbstractMesh
  34950. */
  34951. getActiveMeshes(): SmartArray<AbstractMesh>;
  34952. /**
  34953. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34954. * @returns a number
  34955. */
  34956. getAnimationRatio(): number;
  34957. /**
  34958. * Gets an unique Id for the current render phase
  34959. * @returns a number
  34960. */
  34961. getRenderId(): number;
  34962. /**
  34963. * Gets an unique Id for the current frame
  34964. * @returns a number
  34965. */
  34966. getFrameId(): number;
  34967. /** Call this function if you want to manually increment the render Id*/
  34968. incrementRenderId(): void;
  34969. private _createUbo;
  34970. /**
  34971. * Use this method to simulate a pointer move on a mesh
  34972. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34973. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34974. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34975. * @returns the current scene
  34976. */
  34977. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34978. /**
  34979. * Use this method to simulate a pointer down on a mesh
  34980. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34981. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34982. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34983. * @returns the current scene
  34984. */
  34985. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34986. /**
  34987. * Use this method to simulate a pointer up on a mesh
  34988. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34989. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34990. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34991. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34992. * @returns the current scene
  34993. */
  34994. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34995. /**
  34996. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34997. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34998. * @returns true if the pointer was captured
  34999. */
  35000. isPointerCaptured(pointerId?: number): boolean;
  35001. /**
  35002. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35003. * @param attachUp defines if you want to attach events to pointerup
  35004. * @param attachDown defines if you want to attach events to pointerdown
  35005. * @param attachMove defines if you want to attach events to pointermove
  35006. */
  35007. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35008. /** Detaches all event handlers*/
  35009. detachControl(): void;
  35010. /**
  35011. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35012. * Delay loaded resources are not taking in account
  35013. * @return true if all required resources are ready
  35014. */
  35015. isReady(): boolean;
  35016. /** Resets all cached information relative to material (including effect and visibility) */
  35017. resetCachedMaterial(): void;
  35018. /**
  35019. * Registers a function to be called before every frame render
  35020. * @param func defines the function to register
  35021. */
  35022. registerBeforeRender(func: () => void): void;
  35023. /**
  35024. * Unregisters a function called before every frame render
  35025. * @param func defines the function to unregister
  35026. */
  35027. unregisterBeforeRender(func: () => void): void;
  35028. /**
  35029. * Registers a function to be called after every frame render
  35030. * @param func defines the function to register
  35031. */
  35032. registerAfterRender(func: () => void): void;
  35033. /**
  35034. * Unregisters a function called after every frame render
  35035. * @param func defines the function to unregister
  35036. */
  35037. unregisterAfterRender(func: () => void): void;
  35038. private _executeOnceBeforeRender;
  35039. /**
  35040. * The provided function will run before render once and will be disposed afterwards.
  35041. * A timeout delay can be provided so that the function will be executed in N ms.
  35042. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35043. * @param func The function to be executed.
  35044. * @param timeout optional delay in ms
  35045. */
  35046. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35047. /** @hidden */
  35048. _addPendingData(data: any): void;
  35049. /** @hidden */
  35050. _removePendingData(data: any): void;
  35051. /**
  35052. * Returns the number of items waiting to be loaded
  35053. * @returns the number of items waiting to be loaded
  35054. */
  35055. getWaitingItemsCount(): number;
  35056. /**
  35057. * Returns a boolean indicating if the scene is still loading data
  35058. */
  35059. readonly isLoading: boolean;
  35060. /**
  35061. * Registers a function to be executed when the scene is ready
  35062. * @param {Function} func - the function to be executed
  35063. */
  35064. executeWhenReady(func: () => void): void;
  35065. /**
  35066. * Returns a promise that resolves when the scene is ready
  35067. * @returns A promise that resolves when the scene is ready
  35068. */
  35069. whenReadyAsync(): Promise<void>;
  35070. /** @hidden */
  35071. _checkIsReady(): void;
  35072. /**
  35073. * Gets all animatable attached to the scene
  35074. */
  35075. readonly animatables: Animatable[];
  35076. /**
  35077. * Resets the last animation time frame.
  35078. * Useful to override when animations start running when loading a scene for the first time.
  35079. */
  35080. resetLastAnimationTimeFrame(): void;
  35081. /**
  35082. * Gets the current view matrix
  35083. * @returns a Matrix
  35084. */
  35085. getViewMatrix(): Matrix;
  35086. /**
  35087. * Gets the current projection matrix
  35088. * @returns a Matrix
  35089. */
  35090. getProjectionMatrix(): Matrix;
  35091. /**
  35092. * Gets the current transform matrix
  35093. * @returns a Matrix made of View * Projection
  35094. */
  35095. getTransformMatrix(): Matrix;
  35096. /**
  35097. * Sets the current transform matrix
  35098. * @param viewL defines the View matrix to use
  35099. * @param projectionL defines the Projection matrix to use
  35100. * @param viewR defines the right View matrix to use (if provided)
  35101. * @param projectionR defines the right Projection matrix to use (if provided)
  35102. */
  35103. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35104. /**
  35105. * Gets the uniform buffer used to store scene data
  35106. * @returns a UniformBuffer
  35107. */
  35108. getSceneUniformBuffer(): UniformBuffer;
  35109. /**
  35110. * Gets an unique (relatively to the current scene) Id
  35111. * @returns an unique number for the scene
  35112. */
  35113. getUniqueId(): number;
  35114. /**
  35115. * Add a mesh to the list of scene's meshes
  35116. * @param newMesh defines the mesh to add
  35117. * @param recursive if all child meshes should also be added to the scene
  35118. */
  35119. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35120. /**
  35121. * Remove a mesh for the list of scene's meshes
  35122. * @param toRemove defines the mesh to remove
  35123. * @param recursive if all child meshes should also be removed from the scene
  35124. * @returns the index where the mesh was in the mesh list
  35125. */
  35126. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35127. /**
  35128. * Add a transform node to the list of scene's transform nodes
  35129. * @param newTransformNode defines the transform node to add
  35130. */
  35131. addTransformNode(newTransformNode: TransformNode): void;
  35132. /**
  35133. * Remove a transform node for the list of scene's transform nodes
  35134. * @param toRemove defines the transform node to remove
  35135. * @returns the index where the transform node was in the transform node list
  35136. */
  35137. removeTransformNode(toRemove: TransformNode): number;
  35138. /**
  35139. * Remove a skeleton for the list of scene's skeletons
  35140. * @param toRemove defines the skeleton to remove
  35141. * @returns the index where the skeleton was in the skeleton list
  35142. */
  35143. removeSkeleton(toRemove: Skeleton): number;
  35144. /**
  35145. * Remove a morph target for the list of scene's morph targets
  35146. * @param toRemove defines the morph target to remove
  35147. * @returns the index where the morph target was in the morph target list
  35148. */
  35149. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35150. /**
  35151. * Remove a light for the list of scene's lights
  35152. * @param toRemove defines the light to remove
  35153. * @returns the index where the light was in the light list
  35154. */
  35155. removeLight(toRemove: Light): number;
  35156. /**
  35157. * Remove a camera for the list of scene's cameras
  35158. * @param toRemove defines the camera to remove
  35159. * @returns the index where the camera was in the camera list
  35160. */
  35161. removeCamera(toRemove: Camera): number;
  35162. /**
  35163. * Remove a particle system for the list of scene's particle systems
  35164. * @param toRemove defines the particle system to remove
  35165. * @returns the index where the particle system was in the particle system list
  35166. */
  35167. removeParticleSystem(toRemove: IParticleSystem): number;
  35168. /**
  35169. * Remove a animation for the list of scene's animations
  35170. * @param toRemove defines the animation to remove
  35171. * @returns the index where the animation was in the animation list
  35172. */
  35173. removeAnimation(toRemove: Animation): number;
  35174. /**
  35175. * Will stop the animation of the given target
  35176. * @param target - the target
  35177. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35178. * @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)
  35179. */
  35180. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35181. /**
  35182. * Removes the given animation group from this scene.
  35183. * @param toRemove The animation group to remove
  35184. * @returns The index of the removed animation group
  35185. */
  35186. removeAnimationGroup(toRemove: AnimationGroup): number;
  35187. /**
  35188. * Removes the given multi-material from this scene.
  35189. * @param toRemove The multi-material to remove
  35190. * @returns The index of the removed multi-material
  35191. */
  35192. removeMultiMaterial(toRemove: MultiMaterial): number;
  35193. /**
  35194. * Removes the given material from this scene.
  35195. * @param toRemove The material to remove
  35196. * @returns The index of the removed material
  35197. */
  35198. removeMaterial(toRemove: Material): number;
  35199. /**
  35200. * Removes the given action manager from this scene.
  35201. * @param toRemove The action manager to remove
  35202. * @returns The index of the removed action manager
  35203. */
  35204. removeActionManager(toRemove: AbstractActionManager): number;
  35205. /**
  35206. * Removes the given texture from this scene.
  35207. * @param toRemove The texture to remove
  35208. * @returns The index of the removed texture
  35209. */
  35210. removeTexture(toRemove: BaseTexture): number;
  35211. /**
  35212. * Adds the given light to this scene
  35213. * @param newLight The light to add
  35214. */
  35215. addLight(newLight: Light): void;
  35216. /**
  35217. * Sorts the list list based on light priorities
  35218. */
  35219. sortLightsByPriority(): void;
  35220. /**
  35221. * Adds the given camera to this scene
  35222. * @param newCamera The camera to add
  35223. */
  35224. addCamera(newCamera: Camera): void;
  35225. /**
  35226. * Adds the given skeleton to this scene
  35227. * @param newSkeleton The skeleton to add
  35228. */
  35229. addSkeleton(newSkeleton: Skeleton): void;
  35230. /**
  35231. * Adds the given particle system to this scene
  35232. * @param newParticleSystem The particle system to add
  35233. */
  35234. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35235. /**
  35236. * Adds the given animation to this scene
  35237. * @param newAnimation The animation to add
  35238. */
  35239. addAnimation(newAnimation: Animation): void;
  35240. /**
  35241. * Adds the given animation group to this scene.
  35242. * @param newAnimationGroup The animation group to add
  35243. */
  35244. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35245. /**
  35246. * Adds the given multi-material to this scene
  35247. * @param newMultiMaterial The multi-material to add
  35248. */
  35249. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35250. /**
  35251. * Adds the given material to this scene
  35252. * @param newMaterial The material to add
  35253. */
  35254. addMaterial(newMaterial: Material): void;
  35255. /**
  35256. * Adds the given morph target to this scene
  35257. * @param newMorphTargetManager The morph target to add
  35258. */
  35259. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35260. /**
  35261. * Adds the given geometry to this scene
  35262. * @param newGeometry The geometry to add
  35263. */
  35264. addGeometry(newGeometry: Geometry): void;
  35265. /**
  35266. * Adds the given action manager to this scene
  35267. * @param newActionManager The action manager to add
  35268. */
  35269. addActionManager(newActionManager: AbstractActionManager): void;
  35270. /**
  35271. * Adds the given texture to this scene.
  35272. * @param newTexture The texture to add
  35273. */
  35274. addTexture(newTexture: BaseTexture): void;
  35275. /**
  35276. * Switch active camera
  35277. * @param newCamera defines the new active camera
  35278. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35279. */
  35280. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35281. /**
  35282. * sets the active camera of the scene using its ID
  35283. * @param id defines the camera's ID
  35284. * @return the new active camera or null if none found.
  35285. */
  35286. setActiveCameraByID(id: string): Nullable<Camera>;
  35287. /**
  35288. * sets the active camera of the scene using its name
  35289. * @param name defines the camera's name
  35290. * @returns the new active camera or null if none found.
  35291. */
  35292. setActiveCameraByName(name: string): Nullable<Camera>;
  35293. /**
  35294. * get an animation group using its name
  35295. * @param name defines the material's name
  35296. * @return the animation group or null if none found.
  35297. */
  35298. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35299. /**
  35300. * Get a material using its unique id
  35301. * @param uniqueId defines the material's unique id
  35302. * @return the material or null if none found.
  35303. */
  35304. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35305. /**
  35306. * get a material using its id
  35307. * @param id defines the material's ID
  35308. * @return the material or null if none found.
  35309. */
  35310. getMaterialByID(id: string): Nullable<Material>;
  35311. /**
  35312. * Gets a the last added material using a given id
  35313. * @param id defines the material's ID
  35314. * @return the last material with the given id or null if none found.
  35315. */
  35316. getLastMaterialByID(id: string): Nullable<Material>;
  35317. /**
  35318. * Gets a material using its name
  35319. * @param name defines the material's name
  35320. * @return the material or null if none found.
  35321. */
  35322. getMaterialByName(name: string): Nullable<Material>;
  35323. /**
  35324. * Get a texture using its unique id
  35325. * @param uniqueId defines the texture's unique id
  35326. * @return the texture or null if none found.
  35327. */
  35328. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35329. /**
  35330. * Gets a camera using its id
  35331. * @param id defines the id to look for
  35332. * @returns the camera or null if not found
  35333. */
  35334. getCameraByID(id: string): Nullable<Camera>;
  35335. /**
  35336. * Gets a camera using its unique id
  35337. * @param uniqueId defines the unique id to look for
  35338. * @returns the camera or null if not found
  35339. */
  35340. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35341. /**
  35342. * Gets a camera using its name
  35343. * @param name defines the camera's name
  35344. * @return the camera or null if none found.
  35345. */
  35346. getCameraByName(name: string): Nullable<Camera>;
  35347. /**
  35348. * Gets a bone using its id
  35349. * @param id defines the bone's id
  35350. * @return the bone or null if not found
  35351. */
  35352. getBoneByID(id: string): Nullable<Bone>;
  35353. /**
  35354. * Gets a bone using its id
  35355. * @param name defines the bone's name
  35356. * @return the bone or null if not found
  35357. */
  35358. getBoneByName(name: string): Nullable<Bone>;
  35359. /**
  35360. * Gets a light node using its name
  35361. * @param name defines the the light's name
  35362. * @return the light or null if none found.
  35363. */
  35364. getLightByName(name: string): Nullable<Light>;
  35365. /**
  35366. * Gets a light node using its id
  35367. * @param id defines the light's id
  35368. * @return the light or null if none found.
  35369. */
  35370. getLightByID(id: string): Nullable<Light>;
  35371. /**
  35372. * Gets a light node using its scene-generated unique ID
  35373. * @param uniqueId defines the light's unique id
  35374. * @return the light or null if none found.
  35375. */
  35376. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35377. /**
  35378. * Gets a particle system by id
  35379. * @param id defines the particle system id
  35380. * @return the corresponding system or null if none found
  35381. */
  35382. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35383. /**
  35384. * Gets a geometry using its ID
  35385. * @param id defines the geometry's id
  35386. * @return the geometry or null if none found.
  35387. */
  35388. getGeometryByID(id: string): Nullable<Geometry>;
  35389. private _getGeometryByUniqueID;
  35390. /**
  35391. * Add a new geometry to this scene
  35392. * @param geometry defines the geometry to be added to the scene.
  35393. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35394. * @return a boolean defining if the geometry was added or not
  35395. */
  35396. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35397. /**
  35398. * Removes an existing geometry
  35399. * @param geometry defines the geometry to be removed from the scene
  35400. * @return a boolean defining if the geometry was removed or not
  35401. */
  35402. removeGeometry(geometry: Geometry): boolean;
  35403. /**
  35404. * Gets the list of geometries attached to the scene
  35405. * @returns an array of Geometry
  35406. */
  35407. getGeometries(): Geometry[];
  35408. /**
  35409. * Gets the first added mesh found of a given ID
  35410. * @param id defines the id to search for
  35411. * @return the mesh found or null if not found at all
  35412. */
  35413. getMeshByID(id: string): Nullable<AbstractMesh>;
  35414. /**
  35415. * Gets a list of meshes using their id
  35416. * @param id defines the id to search for
  35417. * @returns a list of meshes
  35418. */
  35419. getMeshesByID(id: string): Array<AbstractMesh>;
  35420. /**
  35421. * Gets the first added transform node found of a given ID
  35422. * @param id defines the id to search for
  35423. * @return the found transform node or null if not found at all.
  35424. */
  35425. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35426. /**
  35427. * Gets a transform node with its auto-generated unique id
  35428. * @param uniqueId efines the unique id to search for
  35429. * @return the found transform node or null if not found at all.
  35430. */
  35431. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35432. /**
  35433. * Gets a list of transform nodes using their id
  35434. * @param id defines the id to search for
  35435. * @returns a list of transform nodes
  35436. */
  35437. getTransformNodesByID(id: string): Array<TransformNode>;
  35438. /**
  35439. * Gets a mesh with its auto-generated unique id
  35440. * @param uniqueId defines the unique id to search for
  35441. * @return the found mesh or null if not found at all.
  35442. */
  35443. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35444. /**
  35445. * Gets a the last added mesh using a given id
  35446. * @param id defines the id to search for
  35447. * @return the found mesh or null if not found at all.
  35448. */
  35449. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35450. /**
  35451. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35452. * @param id defines the id to search for
  35453. * @return the found node or null if not found at all
  35454. */
  35455. getLastEntryByID(id: string): Nullable<Node>;
  35456. /**
  35457. * Gets a node (Mesh, Camera, Light) using a given id
  35458. * @param id defines the id to search for
  35459. * @return the found node or null if not found at all
  35460. */
  35461. getNodeByID(id: string): Nullable<Node>;
  35462. /**
  35463. * Gets a node (Mesh, Camera, Light) using a given name
  35464. * @param name defines the name to search for
  35465. * @return the found node or null if not found at all.
  35466. */
  35467. getNodeByName(name: string): Nullable<Node>;
  35468. /**
  35469. * Gets a mesh using a given name
  35470. * @param name defines the name to search for
  35471. * @return the found mesh or null if not found at all.
  35472. */
  35473. getMeshByName(name: string): Nullable<AbstractMesh>;
  35474. /**
  35475. * Gets a transform node using a given name
  35476. * @param name defines the name to search for
  35477. * @return the found transform node or null if not found at all.
  35478. */
  35479. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35480. /**
  35481. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35482. * @param id defines the id to search for
  35483. * @return the found skeleton or null if not found at all.
  35484. */
  35485. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35486. /**
  35487. * Gets a skeleton using a given auto generated unique id
  35488. * @param uniqueId defines the unique id to search for
  35489. * @return the found skeleton or null if not found at all.
  35490. */
  35491. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35492. /**
  35493. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35494. * @param id defines the id to search for
  35495. * @return the found skeleton or null if not found at all.
  35496. */
  35497. getSkeletonById(id: string): Nullable<Skeleton>;
  35498. /**
  35499. * Gets a skeleton using a given name
  35500. * @param name defines the name to search for
  35501. * @return the found skeleton or null if not found at all.
  35502. */
  35503. getSkeletonByName(name: string): Nullable<Skeleton>;
  35504. /**
  35505. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35506. * @param id defines the id to search for
  35507. * @return the found morph target manager or null if not found at all.
  35508. */
  35509. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35510. /**
  35511. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35512. * @param id defines the id to search for
  35513. * @return the found morph target or null if not found at all.
  35514. */
  35515. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35516. /**
  35517. * Gets a boolean indicating if the given mesh is active
  35518. * @param mesh defines the mesh to look for
  35519. * @returns true if the mesh is in the active list
  35520. */
  35521. isActiveMesh(mesh: AbstractMesh): boolean;
  35522. /**
  35523. * Return a unique id as a string which can serve as an identifier for the scene
  35524. */
  35525. readonly uid: string;
  35526. /**
  35527. * Add an externaly attached data from its key.
  35528. * This method call will fail and return false, if such key already exists.
  35529. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35530. * @param key the unique key that identifies the data
  35531. * @param data the data object to associate to the key for this Engine instance
  35532. * @return true if no such key were already present and the data was added successfully, false otherwise
  35533. */
  35534. addExternalData<T>(key: string, data: T): boolean;
  35535. /**
  35536. * Get an externaly attached data from its key
  35537. * @param key the unique key that identifies the data
  35538. * @return the associated data, if present (can be null), or undefined if not present
  35539. */
  35540. getExternalData<T>(key: string): Nullable<T>;
  35541. /**
  35542. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35543. * @param key the unique key that identifies the data
  35544. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35545. * @return the associated data, can be null if the factory returned null.
  35546. */
  35547. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35548. /**
  35549. * Remove an externaly attached data from the Engine instance
  35550. * @param key the unique key that identifies the data
  35551. * @return true if the data was successfully removed, false if it doesn't exist
  35552. */
  35553. removeExternalData(key: string): boolean;
  35554. private _evaluateSubMesh;
  35555. /**
  35556. * Clear the processed materials smart array preventing retention point in material dispose.
  35557. */
  35558. freeProcessedMaterials(): void;
  35559. private _preventFreeActiveMeshesAndRenderingGroups;
  35560. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35561. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35562. * when disposing several meshes in a row or a hierarchy of meshes.
  35563. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35564. */
  35565. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35566. /**
  35567. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35568. */
  35569. freeActiveMeshes(): void;
  35570. /**
  35571. * Clear the info related to rendering groups preventing retention points during dispose.
  35572. */
  35573. freeRenderingGroups(): void;
  35574. /** @hidden */
  35575. _isInIntermediateRendering(): boolean;
  35576. /**
  35577. * Lambda returning the list of potentially active meshes.
  35578. */
  35579. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35580. /**
  35581. * Lambda returning the list of potentially active sub meshes.
  35582. */
  35583. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35584. /**
  35585. * Lambda returning the list of potentially intersecting sub meshes.
  35586. */
  35587. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35588. /**
  35589. * Lambda returning the list of potentially colliding sub meshes.
  35590. */
  35591. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35592. private _activeMeshesFrozen;
  35593. /**
  35594. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35595. * @returns the current scene
  35596. */
  35597. freezeActiveMeshes(): Scene;
  35598. /**
  35599. * Use this function to restart evaluating active meshes on every frame
  35600. * @returns the current scene
  35601. */
  35602. unfreezeActiveMeshes(): Scene;
  35603. private _evaluateActiveMeshes;
  35604. private _activeMesh;
  35605. /**
  35606. * Update the transform matrix to update from the current active camera
  35607. * @param force defines a boolean used to force the update even if cache is up to date
  35608. */
  35609. updateTransformMatrix(force?: boolean): void;
  35610. private _bindFrameBuffer;
  35611. /** @hidden */
  35612. _allowPostProcessClearColor: boolean;
  35613. /** @hidden */
  35614. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35615. private _processSubCameras;
  35616. private _checkIntersections;
  35617. /** @hidden */
  35618. _advancePhysicsEngineStep(step: number): void;
  35619. /**
  35620. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35621. */
  35622. getDeterministicFrameTime: () => number;
  35623. /** @hidden */
  35624. _animate(): void;
  35625. /** Execute all animations (for a frame) */
  35626. animate(): void;
  35627. /**
  35628. * Render the scene
  35629. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35630. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35631. */
  35632. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35633. /**
  35634. * Freeze all materials
  35635. * A frozen material will not be updatable but should be faster to render
  35636. */
  35637. freezeMaterials(): void;
  35638. /**
  35639. * Unfreeze all materials
  35640. * A frozen material will not be updatable but should be faster to render
  35641. */
  35642. unfreezeMaterials(): void;
  35643. /**
  35644. * Releases all held ressources
  35645. */
  35646. dispose(): void;
  35647. /**
  35648. * Gets if the scene is already disposed
  35649. */
  35650. readonly isDisposed: boolean;
  35651. /**
  35652. * Call this function to reduce memory footprint of the scene.
  35653. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35654. */
  35655. clearCachedVertexData(): void;
  35656. /**
  35657. * This function will remove the local cached buffer data from texture.
  35658. * It will save memory but will prevent the texture from being rebuilt
  35659. */
  35660. cleanCachedTextureBuffer(): void;
  35661. /**
  35662. * Get the world extend vectors with an optional filter
  35663. *
  35664. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35665. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35666. */
  35667. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35668. min: Vector3;
  35669. max: Vector3;
  35670. };
  35671. /**
  35672. * Creates a ray that can be used to pick in the scene
  35673. * @param x defines the x coordinate of the origin (on-screen)
  35674. * @param y defines the y coordinate of the origin (on-screen)
  35675. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35676. * @param camera defines the camera to use for the picking
  35677. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35678. * @returns a Ray
  35679. */
  35680. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35681. /**
  35682. * Creates a ray that can be used to pick in the scene
  35683. * @param x defines the x coordinate of the origin (on-screen)
  35684. * @param y defines the y coordinate of the origin (on-screen)
  35685. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35686. * @param result defines the ray where to store the picking ray
  35687. * @param camera defines the camera to use for the picking
  35688. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35689. * @returns the current scene
  35690. */
  35691. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35692. /**
  35693. * Creates a ray that can be used to pick in the scene
  35694. * @param x defines the x coordinate of the origin (on-screen)
  35695. * @param y defines the y coordinate of the origin (on-screen)
  35696. * @param camera defines the camera to use for the picking
  35697. * @returns a Ray
  35698. */
  35699. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35700. /**
  35701. * Creates a ray that can be used to pick in the scene
  35702. * @param x defines the x coordinate of the origin (on-screen)
  35703. * @param y defines the y coordinate of the origin (on-screen)
  35704. * @param result defines the ray where to store the picking ray
  35705. * @param camera defines the camera to use for the picking
  35706. * @returns the current scene
  35707. */
  35708. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35709. /** Launch a ray to try to pick a mesh in the scene
  35710. * @param x position on screen
  35711. * @param y position on screen
  35712. * @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
  35713. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35714. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35715. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35716. * @returns a PickingInfo
  35717. */
  35718. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35719. /** Use the given ray to pick a mesh in the scene
  35720. * @param ray The ray to use to pick meshes
  35721. * @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
  35722. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35723. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35724. * @returns a PickingInfo
  35725. */
  35726. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35727. /**
  35728. * Launch a ray to try to pick a mesh in the scene
  35729. * @param x X position on screen
  35730. * @param y Y position on screen
  35731. * @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
  35732. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35733. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35734. * @returns an array of PickingInfo
  35735. */
  35736. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35737. /**
  35738. * Launch a ray to try to pick a mesh in the scene
  35739. * @param ray Ray to use
  35740. * @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
  35741. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35742. * @returns an array of PickingInfo
  35743. */
  35744. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35745. /**
  35746. * Force the value of meshUnderPointer
  35747. * @param mesh defines the mesh to use
  35748. */
  35749. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35750. /**
  35751. * Gets the mesh under the pointer
  35752. * @returns a Mesh or null if no mesh is under the pointer
  35753. */
  35754. getPointerOverMesh(): Nullable<AbstractMesh>;
  35755. /** @hidden */
  35756. _rebuildGeometries(): void;
  35757. /** @hidden */
  35758. _rebuildTextures(): void;
  35759. private _getByTags;
  35760. /**
  35761. * Get a list of meshes by tags
  35762. * @param tagsQuery defines the tags query to use
  35763. * @param forEach defines a predicate used to filter results
  35764. * @returns an array of Mesh
  35765. */
  35766. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35767. /**
  35768. * Get a list of cameras by tags
  35769. * @param tagsQuery defines the tags query to use
  35770. * @param forEach defines a predicate used to filter results
  35771. * @returns an array of Camera
  35772. */
  35773. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35774. /**
  35775. * Get a list of lights by tags
  35776. * @param tagsQuery defines the tags query to use
  35777. * @param forEach defines a predicate used to filter results
  35778. * @returns an array of Light
  35779. */
  35780. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35781. /**
  35782. * Get a list of materials by tags
  35783. * @param tagsQuery defines the tags query to use
  35784. * @param forEach defines a predicate used to filter results
  35785. * @returns an array of Material
  35786. */
  35787. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35788. /**
  35789. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35790. * This allowed control for front to back rendering or reversly depending of the special needs.
  35791. *
  35792. * @param renderingGroupId The rendering group id corresponding to its index
  35793. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35794. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35795. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35796. */
  35797. 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;
  35798. /**
  35799. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35800. *
  35801. * @param renderingGroupId The rendering group id corresponding to its index
  35802. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35803. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35804. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35805. */
  35806. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35807. /**
  35808. * Gets the current auto clear configuration for one rendering group of the rendering
  35809. * manager.
  35810. * @param index the rendering group index to get the information for
  35811. * @returns The auto clear setup for the requested rendering group
  35812. */
  35813. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35814. private _blockMaterialDirtyMechanism;
  35815. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35816. blockMaterialDirtyMechanism: boolean;
  35817. /**
  35818. * Will flag all materials as dirty to trigger new shader compilation
  35819. * @param flag defines the flag used to specify which material part must be marked as dirty
  35820. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35821. */
  35822. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35823. /** @hidden */
  35824. _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;
  35825. /** @hidden */
  35826. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35827. /** @hidden */
  35828. _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;
  35829. /** @hidden */
  35830. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  35831. /** @hidden */
  35832. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35833. /** @hidden */
  35834. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35835. }
  35836. }
  35837. declare module "babylonjs/assetContainer" {
  35838. import { AbstractScene } from "babylonjs/abstractScene";
  35839. import { Scene } from "babylonjs/scene";
  35840. import { Mesh } from "babylonjs/Meshes/mesh";
  35841. /**
  35842. * Set of assets to keep when moving a scene into an asset container.
  35843. */
  35844. export class KeepAssets extends AbstractScene {
  35845. }
  35846. /**
  35847. * Container with a set of assets that can be added or removed from a scene.
  35848. */
  35849. export class AssetContainer extends AbstractScene {
  35850. /**
  35851. * The scene the AssetContainer belongs to.
  35852. */
  35853. scene: Scene;
  35854. /**
  35855. * Instantiates an AssetContainer.
  35856. * @param scene The scene the AssetContainer belongs to.
  35857. */
  35858. constructor(scene: Scene);
  35859. /**
  35860. * Adds all the assets from the container to the scene.
  35861. */
  35862. addAllToScene(): void;
  35863. /**
  35864. * Removes all the assets in the container from the scene
  35865. */
  35866. removeAllFromScene(): void;
  35867. /**
  35868. * Disposes all the assets in the container
  35869. */
  35870. dispose(): void;
  35871. private _moveAssets;
  35872. /**
  35873. * Removes all the assets contained in the scene and adds them to the container.
  35874. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35875. */
  35876. moveAllFromScene(keepAssets?: KeepAssets): void;
  35877. /**
  35878. * 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.
  35879. * @returns the root mesh
  35880. */
  35881. createRootMesh(): Mesh;
  35882. }
  35883. }
  35884. declare module "babylonjs/abstractScene" {
  35885. import { Scene } from "babylonjs/scene";
  35886. import { Nullable } from "babylonjs/types";
  35887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35888. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35889. import { Geometry } from "babylonjs/Meshes/geometry";
  35890. import { Skeleton } from "babylonjs/Bones/skeleton";
  35891. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35892. import { AssetContainer } from "babylonjs/assetContainer";
  35893. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35894. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35896. import { Material } from "babylonjs/Materials/material";
  35897. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35898. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35899. import { Camera } from "babylonjs/Cameras/camera";
  35900. import { Light } from "babylonjs/Lights/light";
  35901. import { Node } from "babylonjs/node";
  35902. import { Animation } from "babylonjs/Animations/animation";
  35903. /**
  35904. * Defines how the parser contract is defined.
  35905. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35906. */
  35907. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35908. /**
  35909. * Defines how the individual parser contract is defined.
  35910. * These parser can parse an individual asset
  35911. */
  35912. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35913. /**
  35914. * Base class of the scene acting as a container for the different elements composing a scene.
  35915. * This class is dynamically extended by the different components of the scene increasing
  35916. * flexibility and reducing coupling
  35917. */
  35918. export abstract class AbstractScene {
  35919. /**
  35920. * Stores the list of available parsers in the application.
  35921. */
  35922. private static _BabylonFileParsers;
  35923. /**
  35924. * Stores the list of available individual parsers in the application.
  35925. */
  35926. private static _IndividualBabylonFileParsers;
  35927. /**
  35928. * Adds a parser in the list of available ones
  35929. * @param name Defines the name of the parser
  35930. * @param parser Defines the parser to add
  35931. */
  35932. static AddParser(name: string, parser: BabylonFileParser): void;
  35933. /**
  35934. * Gets a general parser from the list of avaialble ones
  35935. * @param name Defines the name of the parser
  35936. * @returns the requested parser or null
  35937. */
  35938. static GetParser(name: string): Nullable<BabylonFileParser>;
  35939. /**
  35940. * Adds n individual parser in the list of available ones
  35941. * @param name Defines the name of the parser
  35942. * @param parser Defines the parser to add
  35943. */
  35944. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35945. /**
  35946. * Gets an individual parser from the list of avaialble ones
  35947. * @param name Defines the name of the parser
  35948. * @returns the requested parser or null
  35949. */
  35950. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35951. /**
  35952. * Parser json data and populate both a scene and its associated container object
  35953. * @param jsonData Defines the data to parse
  35954. * @param scene Defines the scene to parse the data for
  35955. * @param container Defines the container attached to the parsing sequence
  35956. * @param rootUrl Defines the root url of the data
  35957. */
  35958. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35959. /**
  35960. * Gets the list of root nodes (ie. nodes with no parent)
  35961. */
  35962. rootNodes: Node[];
  35963. /** All of the cameras added to this scene
  35964. * @see http://doc.babylonjs.com/babylon101/cameras
  35965. */
  35966. cameras: Camera[];
  35967. /**
  35968. * All of the lights added to this scene
  35969. * @see http://doc.babylonjs.com/babylon101/lights
  35970. */
  35971. lights: Light[];
  35972. /**
  35973. * All of the (abstract) meshes added to this scene
  35974. */
  35975. meshes: AbstractMesh[];
  35976. /**
  35977. * The list of skeletons added to the scene
  35978. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35979. */
  35980. skeletons: Skeleton[];
  35981. /**
  35982. * All of the particle systems added to this scene
  35983. * @see http://doc.babylonjs.com/babylon101/particles
  35984. */
  35985. particleSystems: IParticleSystem[];
  35986. /**
  35987. * Gets a list of Animations associated with the scene
  35988. */
  35989. animations: Animation[];
  35990. /**
  35991. * All of the animation groups added to this scene
  35992. * @see http://doc.babylonjs.com/how_to/group
  35993. */
  35994. animationGroups: AnimationGroup[];
  35995. /**
  35996. * All of the multi-materials added to this scene
  35997. * @see http://doc.babylonjs.com/how_to/multi_materials
  35998. */
  35999. multiMaterials: MultiMaterial[];
  36000. /**
  36001. * All of the materials added to this scene
  36002. * In the context of a Scene, it is not supposed to be modified manually.
  36003. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  36004. * Note also that the order of the Material wihin the array is not significant and might change.
  36005. * @see http://doc.babylonjs.com/babylon101/materials
  36006. */
  36007. materials: Material[];
  36008. /**
  36009. * The list of morph target managers added to the scene
  36010. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36011. */
  36012. morphTargetManagers: MorphTargetManager[];
  36013. /**
  36014. * The list of geometries used in the scene.
  36015. */
  36016. geometries: Geometry[];
  36017. /**
  36018. * All of the tranform nodes added to this scene
  36019. * In the context of a Scene, it is not supposed to be modified manually.
  36020. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36021. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36022. * @see http://doc.babylonjs.com/how_to/transformnode
  36023. */
  36024. transformNodes: TransformNode[];
  36025. /**
  36026. * ActionManagers available on the scene.
  36027. */
  36028. actionManagers: AbstractActionManager[];
  36029. /**
  36030. * Textures to keep.
  36031. */
  36032. textures: BaseTexture[];
  36033. /**
  36034. * Environment texture for the scene
  36035. */
  36036. environmentTexture: Nullable<BaseTexture>;
  36037. }
  36038. }
  36039. declare module "babylonjs/Audio/sound" {
  36040. import { Observable } from "babylonjs/Misc/observable";
  36041. import { Vector3 } from "babylonjs/Maths/math.vector";
  36042. import { Nullable } from "babylonjs/types";
  36043. import { Scene } from "babylonjs/scene";
  36044. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36045. /**
  36046. * Interface used to define options for Sound class
  36047. */
  36048. export interface ISoundOptions {
  36049. /**
  36050. * Does the sound autoplay once loaded.
  36051. */
  36052. autoplay?: boolean;
  36053. /**
  36054. * Does the sound loop after it finishes playing once.
  36055. */
  36056. loop?: boolean;
  36057. /**
  36058. * Sound's volume
  36059. */
  36060. volume?: number;
  36061. /**
  36062. * Is it a spatial sound?
  36063. */
  36064. spatialSound?: boolean;
  36065. /**
  36066. * Maximum distance to hear that sound
  36067. */
  36068. maxDistance?: number;
  36069. /**
  36070. * Uses user defined attenuation function
  36071. */
  36072. useCustomAttenuation?: boolean;
  36073. /**
  36074. * Define the roll off factor of spatial sounds.
  36075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36076. */
  36077. rolloffFactor?: number;
  36078. /**
  36079. * Define the reference distance the sound should be heard perfectly.
  36080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36081. */
  36082. refDistance?: number;
  36083. /**
  36084. * Define the distance attenuation model the sound will follow.
  36085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36086. */
  36087. distanceModel?: string;
  36088. /**
  36089. * Defines the playback speed (1 by default)
  36090. */
  36091. playbackRate?: number;
  36092. /**
  36093. * Defines if the sound is from a streaming source
  36094. */
  36095. streaming?: boolean;
  36096. /**
  36097. * Defines an optional length (in seconds) inside the sound file
  36098. */
  36099. length?: number;
  36100. /**
  36101. * Defines an optional offset (in seconds) inside the sound file
  36102. */
  36103. offset?: number;
  36104. /**
  36105. * If true, URLs will not be required to state the audio file codec to use.
  36106. */
  36107. skipCodecCheck?: boolean;
  36108. }
  36109. /**
  36110. * Defines a sound that can be played in the application.
  36111. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36113. */
  36114. export class Sound {
  36115. /**
  36116. * The name of the sound in the scene.
  36117. */
  36118. name: string;
  36119. /**
  36120. * Does the sound autoplay once loaded.
  36121. */
  36122. autoplay: boolean;
  36123. /**
  36124. * Does the sound loop after it finishes playing once.
  36125. */
  36126. loop: boolean;
  36127. /**
  36128. * Does the sound use a custom attenuation curve to simulate the falloff
  36129. * happening when the source gets further away from the camera.
  36130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36131. */
  36132. useCustomAttenuation: boolean;
  36133. /**
  36134. * The sound track id this sound belongs to.
  36135. */
  36136. soundTrackId: number;
  36137. /**
  36138. * Is this sound currently played.
  36139. */
  36140. isPlaying: boolean;
  36141. /**
  36142. * Is this sound currently paused.
  36143. */
  36144. isPaused: boolean;
  36145. /**
  36146. * Does this sound enables spatial sound.
  36147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36148. */
  36149. spatialSound: boolean;
  36150. /**
  36151. * Define the reference distance the sound should be heard perfectly.
  36152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36153. */
  36154. refDistance: number;
  36155. /**
  36156. * Define the roll off factor of spatial sounds.
  36157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36158. */
  36159. rolloffFactor: number;
  36160. /**
  36161. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36163. */
  36164. maxDistance: number;
  36165. /**
  36166. * Define the distance attenuation model the sound will follow.
  36167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36168. */
  36169. distanceModel: string;
  36170. /**
  36171. * @hidden
  36172. * Back Compat
  36173. **/
  36174. onended: () => any;
  36175. /**
  36176. * Observable event when the current playing sound finishes.
  36177. */
  36178. onEndedObservable: Observable<Sound>;
  36179. private _panningModel;
  36180. private _playbackRate;
  36181. private _streaming;
  36182. private _startTime;
  36183. private _startOffset;
  36184. private _position;
  36185. /** @hidden */
  36186. _positionInEmitterSpace: boolean;
  36187. private _localDirection;
  36188. private _volume;
  36189. private _isReadyToPlay;
  36190. private _isDirectional;
  36191. private _readyToPlayCallback;
  36192. private _audioBuffer;
  36193. private _soundSource;
  36194. private _streamingSource;
  36195. private _soundPanner;
  36196. private _soundGain;
  36197. private _inputAudioNode;
  36198. private _outputAudioNode;
  36199. private _coneInnerAngle;
  36200. private _coneOuterAngle;
  36201. private _coneOuterGain;
  36202. private _scene;
  36203. private _connectedTransformNode;
  36204. private _customAttenuationFunction;
  36205. private _registerFunc;
  36206. private _isOutputConnected;
  36207. private _htmlAudioElement;
  36208. private _urlType;
  36209. private _length?;
  36210. private _offset?;
  36211. /** @hidden */
  36212. static _SceneComponentInitialization: (scene: Scene) => void;
  36213. /**
  36214. * Create a sound and attach it to a scene
  36215. * @param name Name of your sound
  36216. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36217. * @param scene defines the scene the sound belongs to
  36218. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36219. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36220. */
  36221. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36222. /**
  36223. * Release the sound and its associated resources
  36224. */
  36225. dispose(): void;
  36226. /**
  36227. * Gets if the sounds is ready to be played or not.
  36228. * @returns true if ready, otherwise false
  36229. */
  36230. isReady(): boolean;
  36231. private _soundLoaded;
  36232. /**
  36233. * Sets the data of the sound from an audiobuffer
  36234. * @param audioBuffer The audioBuffer containing the data
  36235. */
  36236. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36237. /**
  36238. * Updates the current sounds options such as maxdistance, loop...
  36239. * @param options A JSON object containing values named as the object properties
  36240. */
  36241. updateOptions(options: ISoundOptions): void;
  36242. private _createSpatialParameters;
  36243. private _updateSpatialParameters;
  36244. /**
  36245. * Switch the panning model to HRTF:
  36246. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36248. */
  36249. switchPanningModelToHRTF(): void;
  36250. /**
  36251. * Switch the panning model to Equal Power:
  36252. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36254. */
  36255. switchPanningModelToEqualPower(): void;
  36256. private _switchPanningModel;
  36257. /**
  36258. * Connect this sound to a sound track audio node like gain...
  36259. * @param soundTrackAudioNode the sound track audio node to connect to
  36260. */
  36261. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36262. /**
  36263. * Transform this sound into a directional source
  36264. * @param coneInnerAngle Size of the inner cone in degree
  36265. * @param coneOuterAngle Size of the outer cone in degree
  36266. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36267. */
  36268. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36269. /**
  36270. * Gets or sets the inner angle for the directional cone.
  36271. */
  36272. /**
  36273. * Gets or sets the inner angle for the directional cone.
  36274. */
  36275. directionalConeInnerAngle: number;
  36276. /**
  36277. * Gets or sets the outer angle for the directional cone.
  36278. */
  36279. /**
  36280. * Gets or sets the outer angle for the directional cone.
  36281. */
  36282. directionalConeOuterAngle: number;
  36283. /**
  36284. * Sets the position of the emitter if spatial sound is enabled
  36285. * @param newPosition Defines the new posisiton
  36286. */
  36287. setPosition(newPosition: Vector3): void;
  36288. /**
  36289. * Sets the local direction of the emitter if spatial sound is enabled
  36290. * @param newLocalDirection Defines the new local direction
  36291. */
  36292. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36293. private _updateDirection;
  36294. /** @hidden */
  36295. updateDistanceFromListener(): void;
  36296. /**
  36297. * Sets a new custom attenuation function for the sound.
  36298. * @param callback Defines the function used for the attenuation
  36299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36300. */
  36301. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36302. /**
  36303. * Play the sound
  36304. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36305. * @param offset (optional) Start the sound at a specific time in seconds
  36306. * @param length (optional) Sound duration (in seconds)
  36307. */
  36308. play(time?: number, offset?: number, length?: number): void;
  36309. private _onended;
  36310. /**
  36311. * Stop the sound
  36312. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36313. */
  36314. stop(time?: number): void;
  36315. /**
  36316. * Put the sound in pause
  36317. */
  36318. pause(): void;
  36319. /**
  36320. * Sets a dedicated volume for this sounds
  36321. * @param newVolume Define the new volume of the sound
  36322. * @param time Define time for gradual change to new volume
  36323. */
  36324. setVolume(newVolume: number, time?: number): void;
  36325. /**
  36326. * Set the sound play back rate
  36327. * @param newPlaybackRate Define the playback rate the sound should be played at
  36328. */
  36329. setPlaybackRate(newPlaybackRate: number): void;
  36330. /**
  36331. * Gets the volume of the sound.
  36332. * @returns the volume of the sound
  36333. */
  36334. getVolume(): number;
  36335. /**
  36336. * Attach the sound to a dedicated mesh
  36337. * @param transformNode The transform node to connect the sound with
  36338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36339. */
  36340. attachToMesh(transformNode: TransformNode): void;
  36341. /**
  36342. * Detach the sound from the previously attached mesh
  36343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36344. */
  36345. detachFromMesh(): void;
  36346. private _onRegisterAfterWorldMatrixUpdate;
  36347. /**
  36348. * Clone the current sound in the scene.
  36349. * @returns the new sound clone
  36350. */
  36351. clone(): Nullable<Sound>;
  36352. /**
  36353. * Gets the current underlying audio buffer containing the data
  36354. * @returns the audio buffer
  36355. */
  36356. getAudioBuffer(): Nullable<AudioBuffer>;
  36357. /**
  36358. * Serializes the Sound in a JSON representation
  36359. * @returns the JSON representation of the sound
  36360. */
  36361. serialize(): any;
  36362. /**
  36363. * Parse a JSON representation of a sound to innstantiate in a given scene
  36364. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36365. * @param scene Define the scene the new parsed sound should be created in
  36366. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36367. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36368. * @returns the newly parsed sound
  36369. */
  36370. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36371. }
  36372. }
  36373. declare module "babylonjs/Actions/directAudioActions" {
  36374. import { Action } from "babylonjs/Actions/action";
  36375. import { Condition } from "babylonjs/Actions/condition";
  36376. import { Sound } from "babylonjs/Audio/sound";
  36377. /**
  36378. * This defines an action helpful to play a defined sound on a triggered action.
  36379. */
  36380. export class PlaySoundAction extends Action {
  36381. private _sound;
  36382. /**
  36383. * Instantiate the action
  36384. * @param triggerOptions defines the trigger options
  36385. * @param sound defines the sound to play
  36386. * @param condition defines the trigger related conditions
  36387. */
  36388. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36389. /** @hidden */
  36390. _prepare(): void;
  36391. /**
  36392. * Execute the action and play the sound.
  36393. */
  36394. execute(): void;
  36395. /**
  36396. * Serializes the actions and its related information.
  36397. * @param parent defines the object to serialize in
  36398. * @returns the serialized object
  36399. */
  36400. serialize(parent: any): any;
  36401. }
  36402. /**
  36403. * This defines an action helpful to stop a defined sound on a triggered action.
  36404. */
  36405. export class StopSoundAction extends Action {
  36406. private _sound;
  36407. /**
  36408. * Instantiate the action
  36409. * @param triggerOptions defines the trigger options
  36410. * @param sound defines the sound to stop
  36411. * @param condition defines the trigger related conditions
  36412. */
  36413. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36414. /** @hidden */
  36415. _prepare(): void;
  36416. /**
  36417. * Execute the action and stop the sound.
  36418. */
  36419. execute(): void;
  36420. /**
  36421. * Serializes the actions and its related information.
  36422. * @param parent defines the object to serialize in
  36423. * @returns the serialized object
  36424. */
  36425. serialize(parent: any): any;
  36426. }
  36427. }
  36428. declare module "babylonjs/Actions/interpolateValueAction" {
  36429. import { Action } from "babylonjs/Actions/action";
  36430. import { Condition } from "babylonjs/Actions/condition";
  36431. import { Observable } from "babylonjs/Misc/observable";
  36432. /**
  36433. * This defines an action responsible to change the value of a property
  36434. * by interpolating between its current value and the newly set one once triggered.
  36435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36436. */
  36437. export class InterpolateValueAction extends Action {
  36438. /**
  36439. * Defines the path of the property where the value should be interpolated
  36440. */
  36441. propertyPath: string;
  36442. /**
  36443. * Defines the target value at the end of the interpolation.
  36444. */
  36445. value: any;
  36446. /**
  36447. * Defines the time it will take for the property to interpolate to the value.
  36448. */
  36449. duration: number;
  36450. /**
  36451. * Defines if the other scene animations should be stopped when the action has been triggered
  36452. */
  36453. stopOtherAnimations?: boolean;
  36454. /**
  36455. * Defines a callback raised once the interpolation animation has been done.
  36456. */
  36457. onInterpolationDone?: () => void;
  36458. /**
  36459. * Observable triggered once the interpolation animation has been done.
  36460. */
  36461. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36462. private _target;
  36463. private _effectiveTarget;
  36464. private _property;
  36465. /**
  36466. * Instantiate the action
  36467. * @param triggerOptions defines the trigger options
  36468. * @param target defines the object containing the value to interpolate
  36469. * @param propertyPath defines the path to the property in the target object
  36470. * @param value defines the target value at the end of the interpolation
  36471. * @param duration deines the time it will take for the property to interpolate to the value.
  36472. * @param condition defines the trigger related conditions
  36473. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36474. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36475. */
  36476. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36477. /** @hidden */
  36478. _prepare(): void;
  36479. /**
  36480. * Execute the action starts the value interpolation.
  36481. */
  36482. execute(): void;
  36483. /**
  36484. * Serializes the actions and its related information.
  36485. * @param parent defines the object to serialize in
  36486. * @returns the serialized object
  36487. */
  36488. serialize(parent: any): any;
  36489. }
  36490. }
  36491. declare module "babylonjs/Actions/index" {
  36492. export * from "babylonjs/Actions/abstractActionManager";
  36493. export * from "babylonjs/Actions/action";
  36494. export * from "babylonjs/Actions/actionEvent";
  36495. export * from "babylonjs/Actions/actionManager";
  36496. export * from "babylonjs/Actions/condition";
  36497. export * from "babylonjs/Actions/directActions";
  36498. export * from "babylonjs/Actions/directAudioActions";
  36499. export * from "babylonjs/Actions/interpolateValueAction";
  36500. }
  36501. declare module "babylonjs/Animations/index" {
  36502. export * from "babylonjs/Animations/animatable";
  36503. export * from "babylonjs/Animations/animation";
  36504. export * from "babylonjs/Animations/animationGroup";
  36505. export * from "babylonjs/Animations/animationPropertiesOverride";
  36506. export * from "babylonjs/Animations/easing";
  36507. export * from "babylonjs/Animations/runtimeAnimation";
  36508. export * from "babylonjs/Animations/animationEvent";
  36509. export * from "babylonjs/Animations/animationGroup";
  36510. export * from "babylonjs/Animations/animationKey";
  36511. export * from "babylonjs/Animations/animationRange";
  36512. export * from "babylonjs/Animations/animatable.interface";
  36513. }
  36514. declare module "babylonjs/Audio/soundTrack" {
  36515. import { Sound } from "babylonjs/Audio/sound";
  36516. import { Analyser } from "babylonjs/Audio/analyser";
  36517. import { Scene } from "babylonjs/scene";
  36518. /**
  36519. * Options allowed during the creation of a sound track.
  36520. */
  36521. export interface ISoundTrackOptions {
  36522. /**
  36523. * The volume the sound track should take during creation
  36524. */
  36525. volume?: number;
  36526. /**
  36527. * Define if the sound track is the main sound track of the scene
  36528. */
  36529. mainTrack?: boolean;
  36530. }
  36531. /**
  36532. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36533. * It will be also used in a future release to apply effects on a specific track.
  36534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36535. */
  36536. export class SoundTrack {
  36537. /**
  36538. * The unique identifier of the sound track in the scene.
  36539. */
  36540. id: number;
  36541. /**
  36542. * The list of sounds included in the sound track.
  36543. */
  36544. soundCollection: Array<Sound>;
  36545. private _outputAudioNode;
  36546. private _scene;
  36547. private _isMainTrack;
  36548. private _connectedAnalyser;
  36549. private _options;
  36550. private _isInitialized;
  36551. /**
  36552. * Creates a new sound track.
  36553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36554. * @param scene Define the scene the sound track belongs to
  36555. * @param options
  36556. */
  36557. constructor(scene: Scene, options?: ISoundTrackOptions);
  36558. private _initializeSoundTrackAudioGraph;
  36559. /**
  36560. * Release the sound track and its associated resources
  36561. */
  36562. dispose(): void;
  36563. /**
  36564. * Adds a sound to this sound track
  36565. * @param sound define the cound to add
  36566. * @ignoreNaming
  36567. */
  36568. AddSound(sound: Sound): void;
  36569. /**
  36570. * Removes a sound to this sound track
  36571. * @param sound define the cound to remove
  36572. * @ignoreNaming
  36573. */
  36574. RemoveSound(sound: Sound): void;
  36575. /**
  36576. * Set a global volume for the full sound track.
  36577. * @param newVolume Define the new volume of the sound track
  36578. */
  36579. setVolume(newVolume: number): void;
  36580. /**
  36581. * Switch the panning model to HRTF:
  36582. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36584. */
  36585. switchPanningModelToHRTF(): void;
  36586. /**
  36587. * Switch the panning model to Equal Power:
  36588. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36590. */
  36591. switchPanningModelToEqualPower(): void;
  36592. /**
  36593. * Connect the sound track to an audio analyser allowing some amazing
  36594. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36596. * @param analyser The analyser to connect to the engine
  36597. */
  36598. connectToAnalyser(analyser: Analyser): void;
  36599. }
  36600. }
  36601. declare module "babylonjs/Audio/audioSceneComponent" {
  36602. import { Sound } from "babylonjs/Audio/sound";
  36603. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36604. import { Nullable } from "babylonjs/types";
  36605. import { Vector3 } from "babylonjs/Maths/math.vector";
  36606. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36607. import { Scene } from "babylonjs/scene";
  36608. import { AbstractScene } from "babylonjs/abstractScene";
  36609. import "babylonjs/Audio/audioEngine";
  36610. module "babylonjs/abstractScene" {
  36611. interface AbstractScene {
  36612. /**
  36613. * The list of sounds used in the scene.
  36614. */
  36615. sounds: Nullable<Array<Sound>>;
  36616. }
  36617. }
  36618. module "babylonjs/scene" {
  36619. interface Scene {
  36620. /**
  36621. * @hidden
  36622. * Backing field
  36623. */
  36624. _mainSoundTrack: SoundTrack;
  36625. /**
  36626. * The main sound track played by the scene.
  36627. * It cotains your primary collection of sounds.
  36628. */
  36629. mainSoundTrack: SoundTrack;
  36630. /**
  36631. * The list of sound tracks added to the scene
  36632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36633. */
  36634. soundTracks: Nullable<Array<SoundTrack>>;
  36635. /**
  36636. * Gets a sound using a given name
  36637. * @param name defines the name to search for
  36638. * @return the found sound or null if not found at all.
  36639. */
  36640. getSoundByName(name: string): Nullable<Sound>;
  36641. /**
  36642. * Gets or sets if audio support is enabled
  36643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36644. */
  36645. audioEnabled: boolean;
  36646. /**
  36647. * Gets or sets if audio will be output to headphones
  36648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36649. */
  36650. headphone: boolean;
  36651. /**
  36652. * Gets or sets custom audio listener position provider
  36653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36654. */
  36655. audioListenerPositionProvider: Nullable<() => Vector3>;
  36656. }
  36657. }
  36658. /**
  36659. * Defines the sound scene component responsible to manage any sounds
  36660. * in a given scene.
  36661. */
  36662. export class AudioSceneComponent implements ISceneSerializableComponent {
  36663. /**
  36664. * The component name helpfull to identify the component in the list of scene components.
  36665. */
  36666. readonly name: string;
  36667. /**
  36668. * The scene the component belongs to.
  36669. */
  36670. scene: Scene;
  36671. private _audioEnabled;
  36672. /**
  36673. * Gets whether audio is enabled or not.
  36674. * Please use related enable/disable method to switch state.
  36675. */
  36676. readonly audioEnabled: boolean;
  36677. private _headphone;
  36678. /**
  36679. * Gets whether audio is outputing to headphone or not.
  36680. * Please use the according Switch methods to change output.
  36681. */
  36682. readonly headphone: boolean;
  36683. private _audioListenerPositionProvider;
  36684. /**
  36685. * Gets the current audio listener position provider
  36686. */
  36687. /**
  36688. * Sets a custom listener position for all sounds in the scene
  36689. * By default, this is the position of the first active camera
  36690. */
  36691. audioListenerPositionProvider: Nullable<() => Vector3>;
  36692. /**
  36693. * Creates a new instance of the component for the given scene
  36694. * @param scene Defines the scene to register the component in
  36695. */
  36696. constructor(scene: Scene);
  36697. /**
  36698. * Registers the component in a given scene
  36699. */
  36700. register(): void;
  36701. /**
  36702. * Rebuilds the elements related to this component in case of
  36703. * context lost for instance.
  36704. */
  36705. rebuild(): void;
  36706. /**
  36707. * Serializes the component data to the specified json object
  36708. * @param serializationObject The object to serialize to
  36709. */
  36710. serialize(serializationObject: any): void;
  36711. /**
  36712. * Adds all the elements from the container to the scene
  36713. * @param container the container holding the elements
  36714. */
  36715. addFromContainer(container: AbstractScene): void;
  36716. /**
  36717. * Removes all the elements in the container from the scene
  36718. * @param container contains the elements to remove
  36719. * @param dispose if the removed element should be disposed (default: false)
  36720. */
  36721. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36722. /**
  36723. * Disposes the component and the associated ressources.
  36724. */
  36725. dispose(): void;
  36726. /**
  36727. * Disables audio in the associated scene.
  36728. */
  36729. disableAudio(): void;
  36730. /**
  36731. * Enables audio in the associated scene.
  36732. */
  36733. enableAudio(): void;
  36734. /**
  36735. * Switch audio to headphone output.
  36736. */
  36737. switchAudioModeForHeadphones(): void;
  36738. /**
  36739. * Switch audio to normal speakers.
  36740. */
  36741. switchAudioModeForNormalSpeakers(): void;
  36742. private _afterRender;
  36743. }
  36744. }
  36745. declare module "babylonjs/Audio/weightedsound" {
  36746. import { Sound } from "babylonjs/Audio/sound";
  36747. /**
  36748. * Wraps one or more Sound objects and selects one with random weight for playback.
  36749. */
  36750. export class WeightedSound {
  36751. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36752. loop: boolean;
  36753. private _coneInnerAngle;
  36754. private _coneOuterAngle;
  36755. private _volume;
  36756. /** A Sound is currently playing. */
  36757. isPlaying: boolean;
  36758. /** A Sound is currently paused. */
  36759. isPaused: boolean;
  36760. private _sounds;
  36761. private _weights;
  36762. private _currentIndex?;
  36763. /**
  36764. * Creates a new WeightedSound from the list of sounds given.
  36765. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36766. * @param sounds Array of Sounds that will be selected from.
  36767. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36768. */
  36769. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36770. /**
  36771. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36772. */
  36773. /**
  36774. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36775. */
  36776. directionalConeInnerAngle: number;
  36777. /**
  36778. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36779. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36780. */
  36781. /**
  36782. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36783. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36784. */
  36785. directionalConeOuterAngle: number;
  36786. /**
  36787. * Playback volume.
  36788. */
  36789. /**
  36790. * Playback volume.
  36791. */
  36792. volume: number;
  36793. private _onended;
  36794. /**
  36795. * Suspend playback
  36796. */
  36797. pause(): void;
  36798. /**
  36799. * Stop playback
  36800. */
  36801. stop(): void;
  36802. /**
  36803. * Start playback.
  36804. * @param startOffset Position the clip head at a specific time in seconds.
  36805. */
  36806. play(startOffset?: number): void;
  36807. }
  36808. }
  36809. declare module "babylonjs/Audio/index" {
  36810. export * from "babylonjs/Audio/analyser";
  36811. export * from "babylonjs/Audio/audioEngine";
  36812. export * from "babylonjs/Audio/audioSceneComponent";
  36813. export * from "babylonjs/Audio/sound";
  36814. export * from "babylonjs/Audio/soundTrack";
  36815. export * from "babylonjs/Audio/weightedsound";
  36816. }
  36817. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36818. import { Behavior } from "babylonjs/Behaviors/behavior";
  36819. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36820. import { BackEase } from "babylonjs/Animations/easing";
  36821. /**
  36822. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36823. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36824. */
  36825. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36826. /**
  36827. * Gets the name of the behavior.
  36828. */
  36829. readonly name: string;
  36830. /**
  36831. * The easing function used by animations
  36832. */
  36833. static EasingFunction: BackEase;
  36834. /**
  36835. * The easing mode used by animations
  36836. */
  36837. static EasingMode: number;
  36838. /**
  36839. * The duration of the animation, in milliseconds
  36840. */
  36841. transitionDuration: number;
  36842. /**
  36843. * Length of the distance animated by the transition when lower radius is reached
  36844. */
  36845. lowerRadiusTransitionRange: number;
  36846. /**
  36847. * Length of the distance animated by the transition when upper radius is reached
  36848. */
  36849. upperRadiusTransitionRange: number;
  36850. private _autoTransitionRange;
  36851. /**
  36852. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36853. */
  36854. /**
  36855. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36856. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36857. */
  36858. autoTransitionRange: boolean;
  36859. private _attachedCamera;
  36860. private _onAfterCheckInputsObserver;
  36861. private _onMeshTargetChangedObserver;
  36862. /**
  36863. * Initializes the behavior.
  36864. */
  36865. init(): void;
  36866. /**
  36867. * Attaches the behavior to its arc rotate camera.
  36868. * @param camera Defines the camera to attach the behavior to
  36869. */
  36870. attach(camera: ArcRotateCamera): void;
  36871. /**
  36872. * Detaches the behavior from its current arc rotate camera.
  36873. */
  36874. detach(): void;
  36875. private _radiusIsAnimating;
  36876. private _radiusBounceTransition;
  36877. private _animatables;
  36878. private _cachedWheelPrecision;
  36879. /**
  36880. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36881. * @param radiusLimit The limit to check against.
  36882. * @return Bool to indicate if at limit.
  36883. */
  36884. private _isRadiusAtLimit;
  36885. /**
  36886. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36887. * @param radiusDelta The delta by which to animate to. Can be negative.
  36888. */
  36889. private _applyBoundRadiusAnimation;
  36890. /**
  36891. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36892. */
  36893. protected _clearAnimationLocks(): void;
  36894. /**
  36895. * Stops and removes all animations that have been applied to the camera
  36896. */
  36897. stopAllAnimations(): void;
  36898. }
  36899. }
  36900. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36901. import { Behavior } from "babylonjs/Behaviors/behavior";
  36902. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36903. import { ExponentialEase } from "babylonjs/Animations/easing";
  36904. import { Nullable } from "babylonjs/types";
  36905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36906. import { Vector3 } from "babylonjs/Maths/math.vector";
  36907. /**
  36908. * 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.
  36909. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36910. */
  36911. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36912. /**
  36913. * Gets the name of the behavior.
  36914. */
  36915. readonly name: string;
  36916. private _mode;
  36917. private _radiusScale;
  36918. private _positionScale;
  36919. private _defaultElevation;
  36920. private _elevationReturnTime;
  36921. private _elevationReturnWaitTime;
  36922. private _zoomStopsAnimation;
  36923. private _framingTime;
  36924. /**
  36925. * The easing function used by animations
  36926. */
  36927. static EasingFunction: ExponentialEase;
  36928. /**
  36929. * The easing mode used by animations
  36930. */
  36931. static EasingMode: number;
  36932. /**
  36933. * Sets the current mode used by the behavior
  36934. */
  36935. /**
  36936. * Gets current mode used by the behavior.
  36937. */
  36938. mode: number;
  36939. /**
  36940. * Sets the scale applied to the radius (1 by default)
  36941. */
  36942. /**
  36943. * Gets the scale applied to the radius
  36944. */
  36945. radiusScale: number;
  36946. /**
  36947. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36948. */
  36949. /**
  36950. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36951. */
  36952. positionScale: number;
  36953. /**
  36954. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36955. * behaviour is triggered, in radians.
  36956. */
  36957. /**
  36958. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36959. * behaviour is triggered, in radians.
  36960. */
  36961. defaultElevation: number;
  36962. /**
  36963. * Sets the time (in milliseconds) taken to return to the default beta position.
  36964. * Negative value indicates camera should not return to default.
  36965. */
  36966. /**
  36967. * Gets the time (in milliseconds) taken to return to the default beta position.
  36968. * Negative value indicates camera should not return to default.
  36969. */
  36970. elevationReturnTime: number;
  36971. /**
  36972. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36973. */
  36974. /**
  36975. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36976. */
  36977. elevationReturnWaitTime: number;
  36978. /**
  36979. * Sets the flag that indicates if user zooming should stop animation.
  36980. */
  36981. /**
  36982. * Gets the flag that indicates if user zooming should stop animation.
  36983. */
  36984. zoomStopsAnimation: boolean;
  36985. /**
  36986. * Sets the transition time when framing the mesh, in milliseconds
  36987. */
  36988. /**
  36989. * Gets the transition time when framing the mesh, in milliseconds
  36990. */
  36991. framingTime: number;
  36992. /**
  36993. * Define if the behavior should automatically change the configured
  36994. * camera limits and sensibilities.
  36995. */
  36996. autoCorrectCameraLimitsAndSensibility: boolean;
  36997. private _onPrePointerObservableObserver;
  36998. private _onAfterCheckInputsObserver;
  36999. private _onMeshTargetChangedObserver;
  37000. private _attachedCamera;
  37001. private _isPointerDown;
  37002. private _lastInteractionTime;
  37003. /**
  37004. * Initializes the behavior.
  37005. */
  37006. init(): void;
  37007. /**
  37008. * Attaches the behavior to its arc rotate camera.
  37009. * @param camera Defines the camera to attach the behavior to
  37010. */
  37011. attach(camera: ArcRotateCamera): void;
  37012. /**
  37013. * Detaches the behavior from its current arc rotate camera.
  37014. */
  37015. detach(): void;
  37016. private _animatables;
  37017. private _betaIsAnimating;
  37018. private _betaTransition;
  37019. private _radiusTransition;
  37020. private _vectorTransition;
  37021. /**
  37022. * Targets the given mesh and updates zoom level accordingly.
  37023. * @param mesh The mesh to target.
  37024. * @param radius Optional. If a cached radius position already exists, overrides default.
  37025. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37026. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37027. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37028. */
  37029. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37030. /**
  37031. * Targets the given mesh with its children and updates zoom level accordingly.
  37032. * @param mesh The mesh to target.
  37033. * @param radius Optional. If a cached radius position already exists, overrides default.
  37034. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37035. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37036. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37037. */
  37038. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37039. /**
  37040. * Targets the given meshes with their children and updates zoom level accordingly.
  37041. * @param meshes The mesh to target.
  37042. * @param radius Optional. If a cached radius position already exists, overrides default.
  37043. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37044. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37045. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37046. */
  37047. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37048. /**
  37049. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37050. * @param minimumWorld Determines the smaller position of the bounding box extend
  37051. * @param maximumWorld Determines the bigger position of the bounding box extend
  37052. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37053. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37054. */
  37055. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37056. /**
  37057. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37058. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37059. * frustum width.
  37060. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37061. * to fully enclose the mesh in the viewing frustum.
  37062. */
  37063. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37064. /**
  37065. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37066. * is automatically returned to its default position (expected to be above ground plane).
  37067. */
  37068. private _maintainCameraAboveGround;
  37069. /**
  37070. * Returns the frustum slope based on the canvas ratio and camera FOV
  37071. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37072. */
  37073. private _getFrustumSlope;
  37074. /**
  37075. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37076. */
  37077. private _clearAnimationLocks;
  37078. /**
  37079. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37080. */
  37081. private _applyUserInteraction;
  37082. /**
  37083. * Stops and removes all animations that have been applied to the camera
  37084. */
  37085. stopAllAnimations(): void;
  37086. /**
  37087. * Gets a value indicating if the user is moving the camera
  37088. */
  37089. readonly isUserIsMoving: boolean;
  37090. /**
  37091. * The camera can move all the way towards the mesh.
  37092. */
  37093. static IgnoreBoundsSizeMode: number;
  37094. /**
  37095. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37096. */
  37097. static FitFrustumSidesMode: number;
  37098. }
  37099. }
  37100. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37101. import { Nullable } from "babylonjs/types";
  37102. import { Camera } from "babylonjs/Cameras/camera";
  37103. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37104. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37105. /**
  37106. * Base class for Camera Pointer Inputs.
  37107. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37108. * for example usage.
  37109. */
  37110. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37111. /**
  37112. * Defines the camera the input is attached to.
  37113. */
  37114. abstract camera: Camera;
  37115. /**
  37116. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37117. */
  37118. protected _altKey: boolean;
  37119. protected _ctrlKey: boolean;
  37120. protected _metaKey: boolean;
  37121. protected _shiftKey: boolean;
  37122. /**
  37123. * Which mouse buttons were pressed at time of last mouse event.
  37124. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37125. */
  37126. protected _buttonsPressed: number;
  37127. /**
  37128. * Defines the buttons associated with the input to handle camera move.
  37129. */
  37130. buttons: number[];
  37131. /**
  37132. * Attach the input controls to a specific dom element to get the input from.
  37133. * @param element Defines the element the controls should be listened from
  37134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37135. */
  37136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37137. /**
  37138. * Detach the current controls from the specified dom element.
  37139. * @param element Defines the element to stop listening the inputs from
  37140. */
  37141. detachControl(element: Nullable<HTMLElement>): void;
  37142. /**
  37143. * Gets the class name of the current input.
  37144. * @returns the class name
  37145. */
  37146. getClassName(): string;
  37147. /**
  37148. * Get the friendly name associated with the input class.
  37149. * @returns the input friendly name
  37150. */
  37151. getSimpleName(): string;
  37152. /**
  37153. * Called on pointer POINTERDOUBLETAP event.
  37154. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37155. */
  37156. protected onDoubleTap(type: string): void;
  37157. /**
  37158. * Called on pointer POINTERMOVE event if only a single touch is active.
  37159. * Override this method to provide functionality.
  37160. */
  37161. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37162. /**
  37163. * Called on pointer POINTERMOVE event if multiple touches are active.
  37164. * Override this method to provide functionality.
  37165. */
  37166. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37167. /**
  37168. * Called on JS contextmenu event.
  37169. * Override this method to provide functionality.
  37170. */
  37171. protected onContextMenu(evt: PointerEvent): void;
  37172. /**
  37173. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37174. * press.
  37175. * Override this method to provide functionality.
  37176. */
  37177. protected onButtonDown(evt: PointerEvent): void;
  37178. /**
  37179. * Called each time a new POINTERUP event occurs. Ie, for each button
  37180. * release.
  37181. * Override this method to provide functionality.
  37182. */
  37183. protected onButtonUp(evt: PointerEvent): void;
  37184. /**
  37185. * Called when window becomes inactive.
  37186. * Override this method to provide functionality.
  37187. */
  37188. protected onLostFocus(): void;
  37189. private _pointerInput;
  37190. private _observer;
  37191. private _onLostFocus;
  37192. private pointA;
  37193. private pointB;
  37194. }
  37195. }
  37196. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37197. import { Nullable } from "babylonjs/types";
  37198. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37199. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37200. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37201. /**
  37202. * Manage the pointers inputs to control an arc rotate camera.
  37203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37204. */
  37205. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37206. /**
  37207. * Defines the camera the input is attached to.
  37208. */
  37209. camera: ArcRotateCamera;
  37210. /**
  37211. * Gets the class name of the current input.
  37212. * @returns the class name
  37213. */
  37214. getClassName(): string;
  37215. /**
  37216. * Defines the buttons associated with the input to handle camera move.
  37217. */
  37218. buttons: number[];
  37219. /**
  37220. * Defines the pointer angular sensibility along the X axis or how fast is
  37221. * the camera rotating.
  37222. */
  37223. angularSensibilityX: number;
  37224. /**
  37225. * Defines the pointer angular sensibility along the Y axis or how fast is
  37226. * the camera rotating.
  37227. */
  37228. angularSensibilityY: number;
  37229. /**
  37230. * Defines the pointer pinch precision or how fast is the camera zooming.
  37231. */
  37232. pinchPrecision: number;
  37233. /**
  37234. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37235. * from 0.
  37236. * It defines the percentage of current camera.radius to use as delta when
  37237. * pinch zoom is used.
  37238. */
  37239. pinchDeltaPercentage: number;
  37240. /**
  37241. * Defines the pointer panning sensibility or how fast is the camera moving.
  37242. */
  37243. panningSensibility: number;
  37244. /**
  37245. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37246. */
  37247. multiTouchPanning: boolean;
  37248. /**
  37249. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37250. * zoom (pinch) through multitouch.
  37251. */
  37252. multiTouchPanAndZoom: boolean;
  37253. /**
  37254. * Revers pinch action direction.
  37255. */
  37256. pinchInwards: boolean;
  37257. private _isPanClick;
  37258. private _twoFingerActivityCount;
  37259. private _isPinching;
  37260. /**
  37261. * Called on pointer POINTERMOVE event if only a single touch is active.
  37262. */
  37263. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37264. /**
  37265. * Called on pointer POINTERDOUBLETAP event.
  37266. */
  37267. protected onDoubleTap(type: string): void;
  37268. /**
  37269. * Called on pointer POINTERMOVE event if multiple touches are active.
  37270. */
  37271. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37272. /**
  37273. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37274. * press.
  37275. */
  37276. protected onButtonDown(evt: PointerEvent): void;
  37277. /**
  37278. * Called each time a new POINTERUP event occurs. Ie, for each button
  37279. * release.
  37280. */
  37281. protected onButtonUp(evt: PointerEvent): void;
  37282. /**
  37283. * Called when window becomes inactive.
  37284. */
  37285. protected onLostFocus(): void;
  37286. }
  37287. }
  37288. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37289. import { Nullable } from "babylonjs/types";
  37290. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37291. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37292. /**
  37293. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37295. */
  37296. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37297. /**
  37298. * Defines the camera the input is attached to.
  37299. */
  37300. camera: ArcRotateCamera;
  37301. /**
  37302. * Defines the list of key codes associated with the up action (increase alpha)
  37303. */
  37304. keysUp: number[];
  37305. /**
  37306. * Defines the list of key codes associated with the down action (decrease alpha)
  37307. */
  37308. keysDown: number[];
  37309. /**
  37310. * Defines the list of key codes associated with the left action (increase beta)
  37311. */
  37312. keysLeft: number[];
  37313. /**
  37314. * Defines the list of key codes associated with the right action (decrease beta)
  37315. */
  37316. keysRight: number[];
  37317. /**
  37318. * Defines the list of key codes associated with the reset action.
  37319. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37320. */
  37321. keysReset: number[];
  37322. /**
  37323. * Defines the panning sensibility of the inputs.
  37324. * (How fast is the camera paning)
  37325. */
  37326. panningSensibility: number;
  37327. /**
  37328. * Defines the zooming sensibility of the inputs.
  37329. * (How fast is the camera zooming)
  37330. */
  37331. zoomingSensibility: number;
  37332. /**
  37333. * Defines wether maintaining the alt key down switch the movement mode from
  37334. * orientation to zoom.
  37335. */
  37336. useAltToZoom: boolean;
  37337. /**
  37338. * Rotation speed of the camera
  37339. */
  37340. angularSpeed: number;
  37341. private _keys;
  37342. private _ctrlPressed;
  37343. private _altPressed;
  37344. private _onCanvasBlurObserver;
  37345. private _onKeyboardObserver;
  37346. private _engine;
  37347. private _scene;
  37348. /**
  37349. * Attach the input controls to a specific dom element to get the input from.
  37350. * @param element Defines the element the controls should be listened from
  37351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37352. */
  37353. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37354. /**
  37355. * Detach the current controls from the specified dom element.
  37356. * @param element Defines the element to stop listening the inputs from
  37357. */
  37358. detachControl(element: Nullable<HTMLElement>): void;
  37359. /**
  37360. * Update the current camera state depending on the inputs that have been used this frame.
  37361. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37362. */
  37363. checkInputs(): void;
  37364. /**
  37365. * Gets the class name of the current intput.
  37366. * @returns the class name
  37367. */
  37368. getClassName(): string;
  37369. /**
  37370. * Get the friendly name associated with the input class.
  37371. * @returns the input friendly name
  37372. */
  37373. getSimpleName(): string;
  37374. }
  37375. }
  37376. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37377. import { Nullable } from "babylonjs/types";
  37378. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37379. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37380. /**
  37381. * Manage the mouse wheel inputs to control an arc rotate camera.
  37382. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37383. */
  37384. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37385. /**
  37386. * Defines the camera the input is attached to.
  37387. */
  37388. camera: ArcRotateCamera;
  37389. /**
  37390. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37391. */
  37392. wheelPrecision: number;
  37393. /**
  37394. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37395. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37396. */
  37397. wheelDeltaPercentage: number;
  37398. private _wheel;
  37399. private _observer;
  37400. private computeDeltaFromMouseWheelLegacyEvent;
  37401. /**
  37402. * Attach the input controls to a specific dom element to get the input from.
  37403. * @param element Defines the element the controls should be listened from
  37404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37405. */
  37406. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37407. /**
  37408. * Detach the current controls from the specified dom element.
  37409. * @param element Defines the element to stop listening the inputs from
  37410. */
  37411. detachControl(element: Nullable<HTMLElement>): void;
  37412. /**
  37413. * Gets the class name of the current intput.
  37414. * @returns the class name
  37415. */
  37416. getClassName(): string;
  37417. /**
  37418. * Get the friendly name associated with the input class.
  37419. * @returns the input friendly name
  37420. */
  37421. getSimpleName(): string;
  37422. }
  37423. }
  37424. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37425. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37426. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37427. /**
  37428. * Default Inputs manager for the ArcRotateCamera.
  37429. * It groups all the default supported inputs for ease of use.
  37430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37431. */
  37432. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37433. /**
  37434. * Instantiates a new ArcRotateCameraInputsManager.
  37435. * @param camera Defines the camera the inputs belong to
  37436. */
  37437. constructor(camera: ArcRotateCamera);
  37438. /**
  37439. * Add mouse wheel input support to the input manager.
  37440. * @returns the current input manager
  37441. */
  37442. addMouseWheel(): ArcRotateCameraInputsManager;
  37443. /**
  37444. * Add pointers input support to the input manager.
  37445. * @returns the current input manager
  37446. */
  37447. addPointers(): ArcRotateCameraInputsManager;
  37448. /**
  37449. * Add keyboard input support to the input manager.
  37450. * @returns the current input manager
  37451. */
  37452. addKeyboard(): ArcRotateCameraInputsManager;
  37453. }
  37454. }
  37455. declare module "babylonjs/Cameras/arcRotateCamera" {
  37456. import { Observable } from "babylonjs/Misc/observable";
  37457. import { Nullable } from "babylonjs/types";
  37458. import { Scene } from "babylonjs/scene";
  37459. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37461. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37462. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37463. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37464. import { Camera } from "babylonjs/Cameras/camera";
  37465. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37466. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37467. import { Collider } from "babylonjs/Collisions/collider";
  37468. /**
  37469. * This represents an orbital type of camera.
  37470. *
  37471. * 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.
  37472. * 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.
  37473. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37474. */
  37475. export class ArcRotateCamera extends TargetCamera {
  37476. /**
  37477. * Defines the rotation angle of the camera along the longitudinal axis.
  37478. */
  37479. alpha: number;
  37480. /**
  37481. * Defines the rotation angle of the camera along the latitudinal axis.
  37482. */
  37483. beta: number;
  37484. /**
  37485. * Defines the radius of the camera from it s target point.
  37486. */
  37487. radius: number;
  37488. protected _target: Vector3;
  37489. protected _targetHost: Nullable<AbstractMesh>;
  37490. /**
  37491. * Defines the target point of the camera.
  37492. * The camera looks towards it form the radius distance.
  37493. */
  37494. target: Vector3;
  37495. /**
  37496. * Define the current local position of the camera in the scene
  37497. */
  37498. position: Vector3;
  37499. protected _upVector: Vector3;
  37500. protected _upToYMatrix: Matrix;
  37501. protected _YToUpMatrix: Matrix;
  37502. /**
  37503. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37504. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37505. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37506. */
  37507. upVector: Vector3;
  37508. /**
  37509. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37510. */
  37511. setMatUp(): void;
  37512. /**
  37513. * Current inertia value on the longitudinal axis.
  37514. * The bigger this number the longer it will take for the camera to stop.
  37515. */
  37516. inertialAlphaOffset: number;
  37517. /**
  37518. * Current inertia value on the latitudinal axis.
  37519. * The bigger this number the longer it will take for the camera to stop.
  37520. */
  37521. inertialBetaOffset: number;
  37522. /**
  37523. * Current inertia value on the radius axis.
  37524. * The bigger this number the longer it will take for the camera to stop.
  37525. */
  37526. inertialRadiusOffset: number;
  37527. /**
  37528. * Minimum allowed angle on the longitudinal axis.
  37529. * This can help limiting how the Camera is able to move in the scene.
  37530. */
  37531. lowerAlphaLimit: Nullable<number>;
  37532. /**
  37533. * Maximum allowed angle on the longitudinal axis.
  37534. * This can help limiting how the Camera is able to move in the scene.
  37535. */
  37536. upperAlphaLimit: Nullable<number>;
  37537. /**
  37538. * Minimum allowed angle on the latitudinal axis.
  37539. * This can help limiting how the Camera is able to move in the scene.
  37540. */
  37541. lowerBetaLimit: number;
  37542. /**
  37543. * Maximum allowed angle on the latitudinal axis.
  37544. * This can help limiting how the Camera is able to move in the scene.
  37545. */
  37546. upperBetaLimit: number;
  37547. /**
  37548. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37549. * This can help limiting how the Camera is able to move in the scene.
  37550. */
  37551. lowerRadiusLimit: Nullable<number>;
  37552. /**
  37553. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37554. * This can help limiting how the Camera is able to move in the scene.
  37555. */
  37556. upperRadiusLimit: Nullable<number>;
  37557. /**
  37558. * Defines the current inertia value used during panning of the camera along the X axis.
  37559. */
  37560. inertialPanningX: number;
  37561. /**
  37562. * Defines the current inertia value used during panning of the camera along the Y axis.
  37563. */
  37564. inertialPanningY: number;
  37565. /**
  37566. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37567. * Basically if your fingers moves away from more than this distance you will be considered
  37568. * in pinch mode.
  37569. */
  37570. pinchToPanMaxDistance: number;
  37571. /**
  37572. * Defines the maximum distance the camera can pan.
  37573. * This could help keeping the cammera always in your scene.
  37574. */
  37575. panningDistanceLimit: Nullable<number>;
  37576. /**
  37577. * Defines the target of the camera before paning.
  37578. */
  37579. panningOriginTarget: Vector3;
  37580. /**
  37581. * Defines the value of the inertia used during panning.
  37582. * 0 would mean stop inertia and one would mean no decelleration at all.
  37583. */
  37584. panningInertia: number;
  37585. /**
  37586. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37587. */
  37588. angularSensibilityX: number;
  37589. /**
  37590. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37591. */
  37592. angularSensibilityY: number;
  37593. /**
  37594. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37595. */
  37596. pinchPrecision: number;
  37597. /**
  37598. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37599. * It will be used instead of pinchDeltaPrecision if different from 0.
  37600. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37601. */
  37602. pinchDeltaPercentage: number;
  37603. /**
  37604. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37605. */
  37606. panningSensibility: number;
  37607. /**
  37608. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37609. */
  37610. keysUp: number[];
  37611. /**
  37612. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37613. */
  37614. keysDown: number[];
  37615. /**
  37616. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37617. */
  37618. keysLeft: number[];
  37619. /**
  37620. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37621. */
  37622. keysRight: number[];
  37623. /**
  37624. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37625. */
  37626. wheelPrecision: number;
  37627. /**
  37628. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37629. * It will be used instead of pinchDeltaPrecision if different from 0.
  37630. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37631. */
  37632. wheelDeltaPercentage: number;
  37633. /**
  37634. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37635. */
  37636. zoomOnFactor: number;
  37637. /**
  37638. * Defines a screen offset for the camera position.
  37639. */
  37640. targetScreenOffset: Vector2;
  37641. /**
  37642. * Allows the camera to be completely reversed.
  37643. * If false the camera can not arrive upside down.
  37644. */
  37645. allowUpsideDown: boolean;
  37646. /**
  37647. * Define if double tap/click is used to restore the previously saved state of the camera.
  37648. */
  37649. useInputToRestoreState: boolean;
  37650. /** @hidden */
  37651. _viewMatrix: Matrix;
  37652. /** @hidden */
  37653. _useCtrlForPanning: boolean;
  37654. /** @hidden */
  37655. _panningMouseButton: number;
  37656. /**
  37657. * Defines the input associated to the camera.
  37658. */
  37659. inputs: ArcRotateCameraInputsManager;
  37660. /** @hidden */
  37661. _reset: () => void;
  37662. /**
  37663. * Defines the allowed panning axis.
  37664. */
  37665. panningAxis: Vector3;
  37666. protected _localDirection: Vector3;
  37667. protected _transformedDirection: Vector3;
  37668. private _bouncingBehavior;
  37669. /**
  37670. * Gets the bouncing behavior of the camera if it has been enabled.
  37671. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37672. */
  37673. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37674. /**
  37675. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37676. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37677. */
  37678. useBouncingBehavior: boolean;
  37679. private _framingBehavior;
  37680. /**
  37681. * Gets the framing behavior of the camera if it has been enabled.
  37682. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37683. */
  37684. readonly framingBehavior: Nullable<FramingBehavior>;
  37685. /**
  37686. * Defines if the framing behavior of the camera is enabled on the camera.
  37687. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37688. */
  37689. useFramingBehavior: boolean;
  37690. private _autoRotationBehavior;
  37691. /**
  37692. * Gets the auto rotation behavior of the camera if it has been enabled.
  37693. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37694. */
  37695. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37696. /**
  37697. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37698. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37699. */
  37700. useAutoRotationBehavior: boolean;
  37701. /**
  37702. * Observable triggered when the mesh target has been changed on the camera.
  37703. */
  37704. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37705. /**
  37706. * Event raised when the camera is colliding with a mesh.
  37707. */
  37708. onCollide: (collidedMesh: AbstractMesh) => void;
  37709. /**
  37710. * Defines whether the camera should check collision with the objects oh the scene.
  37711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37712. */
  37713. checkCollisions: boolean;
  37714. /**
  37715. * Defines the collision radius of the camera.
  37716. * This simulates a sphere around the camera.
  37717. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37718. */
  37719. collisionRadius: Vector3;
  37720. protected _collider: Collider;
  37721. protected _previousPosition: Vector3;
  37722. protected _collisionVelocity: Vector3;
  37723. protected _newPosition: Vector3;
  37724. protected _previousAlpha: number;
  37725. protected _previousBeta: number;
  37726. protected _previousRadius: number;
  37727. protected _collisionTriggered: boolean;
  37728. protected _targetBoundingCenter: Nullable<Vector3>;
  37729. private _computationVector;
  37730. /**
  37731. * Instantiates a new ArcRotateCamera in a given scene
  37732. * @param name Defines the name of the camera
  37733. * @param alpha Defines the camera rotation along the logitudinal axis
  37734. * @param beta Defines the camera rotation along the latitudinal axis
  37735. * @param radius Defines the camera distance from its target
  37736. * @param target Defines the camera target
  37737. * @param scene Defines the scene the camera belongs to
  37738. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37739. */
  37740. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37741. /** @hidden */
  37742. _initCache(): void;
  37743. /** @hidden */
  37744. _updateCache(ignoreParentClass?: boolean): void;
  37745. protected _getTargetPosition(): Vector3;
  37746. private _storedAlpha;
  37747. private _storedBeta;
  37748. private _storedRadius;
  37749. private _storedTarget;
  37750. private _storedTargetScreenOffset;
  37751. /**
  37752. * Stores the current state of the camera (alpha, beta, radius and target)
  37753. * @returns the camera itself
  37754. */
  37755. storeState(): Camera;
  37756. /**
  37757. * @hidden
  37758. * Restored camera state. You must call storeState() first
  37759. */
  37760. _restoreStateValues(): boolean;
  37761. /** @hidden */
  37762. _isSynchronizedViewMatrix(): boolean;
  37763. /**
  37764. * Attached controls to the current camera.
  37765. * @param element Defines the element the controls should be listened from
  37766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37767. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37768. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37769. */
  37770. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37771. /**
  37772. * Detach the current controls from the camera.
  37773. * The camera will stop reacting to inputs.
  37774. * @param element Defines the element to stop listening the inputs from
  37775. */
  37776. detachControl(element: HTMLElement): void;
  37777. /** @hidden */
  37778. _checkInputs(): void;
  37779. protected _checkLimits(): void;
  37780. /**
  37781. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37782. */
  37783. rebuildAnglesAndRadius(): void;
  37784. /**
  37785. * Use a position to define the current camera related information like alpha, beta and radius
  37786. * @param position Defines the position to set the camera at
  37787. */
  37788. setPosition(position: Vector3): void;
  37789. /**
  37790. * Defines the target the camera should look at.
  37791. * This will automatically adapt alpha beta and radius to fit within the new target.
  37792. * @param target Defines the new target as a Vector or a mesh
  37793. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37794. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37795. */
  37796. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37797. /** @hidden */
  37798. _getViewMatrix(): Matrix;
  37799. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37800. /**
  37801. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37802. * @param meshes Defines the mesh to zoom on
  37803. * @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)
  37804. */
  37805. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37806. /**
  37807. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37808. * The target will be changed but the radius
  37809. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37810. * @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)
  37811. */
  37812. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37813. min: Vector3;
  37814. max: Vector3;
  37815. distance: number;
  37816. }, doNotUpdateMaxZ?: boolean): void;
  37817. /**
  37818. * @override
  37819. * Override Camera.createRigCamera
  37820. */
  37821. createRigCamera(name: string, cameraIndex: number): Camera;
  37822. /**
  37823. * @hidden
  37824. * @override
  37825. * Override Camera._updateRigCameras
  37826. */
  37827. _updateRigCameras(): void;
  37828. /**
  37829. * Destroy the camera and release the current resources hold by it.
  37830. */
  37831. dispose(): void;
  37832. /**
  37833. * Gets the current object class name.
  37834. * @return the class name
  37835. */
  37836. getClassName(): string;
  37837. }
  37838. }
  37839. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37840. import { Behavior } from "babylonjs/Behaviors/behavior";
  37841. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37842. /**
  37843. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37844. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37845. */
  37846. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37847. /**
  37848. * Gets the name of the behavior.
  37849. */
  37850. readonly name: string;
  37851. private _zoomStopsAnimation;
  37852. private _idleRotationSpeed;
  37853. private _idleRotationWaitTime;
  37854. private _idleRotationSpinupTime;
  37855. /**
  37856. * Sets the flag that indicates if user zooming should stop animation.
  37857. */
  37858. /**
  37859. * Gets the flag that indicates if user zooming should stop animation.
  37860. */
  37861. zoomStopsAnimation: boolean;
  37862. /**
  37863. * Sets the default speed at which the camera rotates around the model.
  37864. */
  37865. /**
  37866. * Gets the default speed at which the camera rotates around the model.
  37867. */
  37868. idleRotationSpeed: number;
  37869. /**
  37870. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37871. */
  37872. /**
  37873. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37874. */
  37875. idleRotationWaitTime: number;
  37876. /**
  37877. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37878. */
  37879. /**
  37880. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37881. */
  37882. idleRotationSpinupTime: number;
  37883. /**
  37884. * Gets a value indicating if the camera is currently rotating because of this behavior
  37885. */
  37886. readonly rotationInProgress: boolean;
  37887. private _onPrePointerObservableObserver;
  37888. private _onAfterCheckInputsObserver;
  37889. private _attachedCamera;
  37890. private _isPointerDown;
  37891. private _lastFrameTime;
  37892. private _lastInteractionTime;
  37893. private _cameraRotationSpeed;
  37894. /**
  37895. * Initializes the behavior.
  37896. */
  37897. init(): void;
  37898. /**
  37899. * Attaches the behavior to its arc rotate camera.
  37900. * @param camera Defines the camera to attach the behavior to
  37901. */
  37902. attach(camera: ArcRotateCamera): void;
  37903. /**
  37904. * Detaches the behavior from its current arc rotate camera.
  37905. */
  37906. detach(): void;
  37907. /**
  37908. * Returns true if user is scrolling.
  37909. * @return true if user is scrolling.
  37910. */
  37911. private _userIsZooming;
  37912. private _lastFrameRadius;
  37913. private _shouldAnimationStopForInteraction;
  37914. /**
  37915. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37916. */
  37917. private _applyUserInteraction;
  37918. private _userIsMoving;
  37919. }
  37920. }
  37921. declare module "babylonjs/Behaviors/Cameras/index" {
  37922. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37923. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37924. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37925. }
  37926. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37927. import { Mesh } from "babylonjs/Meshes/mesh";
  37928. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37929. import { Behavior } from "babylonjs/Behaviors/behavior";
  37930. /**
  37931. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37932. */
  37933. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37934. private ui;
  37935. /**
  37936. * The name of the behavior
  37937. */
  37938. name: string;
  37939. /**
  37940. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37941. */
  37942. distanceAwayFromFace: number;
  37943. /**
  37944. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37945. */
  37946. distanceAwayFromBottomOfFace: number;
  37947. private _faceVectors;
  37948. private _target;
  37949. private _scene;
  37950. private _onRenderObserver;
  37951. private _tmpMatrix;
  37952. private _tmpVector;
  37953. /**
  37954. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37955. * @param ui The transform node that should be attched to the mesh
  37956. */
  37957. constructor(ui: TransformNode);
  37958. /**
  37959. * Initializes the behavior
  37960. */
  37961. init(): void;
  37962. private _closestFace;
  37963. private _zeroVector;
  37964. private _lookAtTmpMatrix;
  37965. private _lookAtToRef;
  37966. /**
  37967. * Attaches the AttachToBoxBehavior to the passed in mesh
  37968. * @param target The mesh that the specified node will be attached to
  37969. */
  37970. attach(target: Mesh): void;
  37971. /**
  37972. * Detaches the behavior from the mesh
  37973. */
  37974. detach(): void;
  37975. }
  37976. }
  37977. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37978. import { Behavior } from "babylonjs/Behaviors/behavior";
  37979. import { Mesh } from "babylonjs/Meshes/mesh";
  37980. /**
  37981. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37982. */
  37983. export class FadeInOutBehavior implements Behavior<Mesh> {
  37984. /**
  37985. * Time in milliseconds to delay before fading in (Default: 0)
  37986. */
  37987. delay: number;
  37988. /**
  37989. * Time in milliseconds for the mesh to fade in (Default: 300)
  37990. */
  37991. fadeInTime: number;
  37992. private _millisecondsPerFrame;
  37993. private _hovered;
  37994. private _hoverValue;
  37995. private _ownerNode;
  37996. /**
  37997. * Instatiates the FadeInOutBehavior
  37998. */
  37999. constructor();
  38000. /**
  38001. * The name of the behavior
  38002. */
  38003. readonly name: string;
  38004. /**
  38005. * Initializes the behavior
  38006. */
  38007. init(): void;
  38008. /**
  38009. * Attaches the fade behavior on the passed in mesh
  38010. * @param ownerNode The mesh that will be faded in/out once attached
  38011. */
  38012. attach(ownerNode: Mesh): void;
  38013. /**
  38014. * Detaches the behavior from the mesh
  38015. */
  38016. detach(): void;
  38017. /**
  38018. * Triggers the mesh to begin fading in or out
  38019. * @param value if the object should fade in or out (true to fade in)
  38020. */
  38021. fadeIn(value: boolean): void;
  38022. private _update;
  38023. private _setAllVisibility;
  38024. }
  38025. }
  38026. declare module "babylonjs/Misc/pivotTools" {
  38027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38028. /**
  38029. * Class containing a set of static utilities functions for managing Pivots
  38030. * @hidden
  38031. */
  38032. export class PivotTools {
  38033. private static _PivotCached;
  38034. private static _OldPivotPoint;
  38035. private static _PivotTranslation;
  38036. private static _PivotTmpVector;
  38037. /** @hidden */
  38038. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38039. /** @hidden */
  38040. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38041. }
  38042. }
  38043. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38044. import { Scene } from "babylonjs/scene";
  38045. import { Vector4 } from "babylonjs/Maths/math.vector";
  38046. import { Mesh } from "babylonjs/Meshes/mesh";
  38047. import { Nullable } from "babylonjs/types";
  38048. import { Plane } from "babylonjs/Maths/math.plane";
  38049. /**
  38050. * Class containing static functions to help procedurally build meshes
  38051. */
  38052. export class PlaneBuilder {
  38053. /**
  38054. * Creates a plane mesh
  38055. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38056. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38057. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38061. * @param name defines the name of the mesh
  38062. * @param options defines the options used to create the mesh
  38063. * @param scene defines the hosting scene
  38064. * @returns the plane mesh
  38065. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38066. */
  38067. static CreatePlane(name: string, options: {
  38068. size?: number;
  38069. width?: number;
  38070. height?: number;
  38071. sideOrientation?: number;
  38072. frontUVs?: Vector4;
  38073. backUVs?: Vector4;
  38074. updatable?: boolean;
  38075. sourcePlane?: Plane;
  38076. }, scene?: Nullable<Scene>): Mesh;
  38077. }
  38078. }
  38079. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38080. import { Behavior } from "babylonjs/Behaviors/behavior";
  38081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38082. import { Observable } from "babylonjs/Misc/observable";
  38083. import { Vector3 } from "babylonjs/Maths/math.vector";
  38084. import { Ray } from "babylonjs/Culling/ray";
  38085. import "babylonjs/Meshes/Builders/planeBuilder";
  38086. /**
  38087. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38088. */
  38089. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38090. private static _AnyMouseID;
  38091. /**
  38092. * Abstract mesh the behavior is set on
  38093. */
  38094. attachedNode: AbstractMesh;
  38095. private _dragPlane;
  38096. private _scene;
  38097. private _pointerObserver;
  38098. private _beforeRenderObserver;
  38099. private static _planeScene;
  38100. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38101. /**
  38102. * 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)
  38103. */
  38104. maxDragAngle: number;
  38105. /**
  38106. * @hidden
  38107. */
  38108. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38109. /**
  38110. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38111. */
  38112. currentDraggingPointerID: number;
  38113. /**
  38114. * The last position where the pointer hit the drag plane in world space
  38115. */
  38116. lastDragPosition: Vector3;
  38117. /**
  38118. * If the behavior is currently in a dragging state
  38119. */
  38120. dragging: boolean;
  38121. /**
  38122. * 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)
  38123. */
  38124. dragDeltaRatio: number;
  38125. /**
  38126. * If the drag plane orientation should be updated during the dragging (Default: true)
  38127. */
  38128. updateDragPlane: boolean;
  38129. private _debugMode;
  38130. private _moving;
  38131. /**
  38132. * Fires each time the attached mesh is dragged with the pointer
  38133. * * delta between last drag position and current drag position in world space
  38134. * * dragDistance along the drag axis
  38135. * * dragPlaneNormal normal of the current drag plane used during the drag
  38136. * * dragPlanePoint in world space where the drag intersects the drag plane
  38137. */
  38138. onDragObservable: Observable<{
  38139. delta: Vector3;
  38140. dragPlanePoint: Vector3;
  38141. dragPlaneNormal: Vector3;
  38142. dragDistance: number;
  38143. pointerId: number;
  38144. }>;
  38145. /**
  38146. * Fires each time a drag begins (eg. mouse down on mesh)
  38147. */
  38148. onDragStartObservable: Observable<{
  38149. dragPlanePoint: Vector3;
  38150. pointerId: number;
  38151. }>;
  38152. /**
  38153. * Fires each time a drag ends (eg. mouse release after drag)
  38154. */
  38155. onDragEndObservable: Observable<{
  38156. dragPlanePoint: Vector3;
  38157. pointerId: number;
  38158. }>;
  38159. /**
  38160. * If the attached mesh should be moved when dragged
  38161. */
  38162. moveAttached: boolean;
  38163. /**
  38164. * If the drag behavior will react to drag events (Default: true)
  38165. */
  38166. enabled: boolean;
  38167. /**
  38168. * If pointer events should start and release the drag (Default: true)
  38169. */
  38170. startAndReleaseDragOnPointerEvents: boolean;
  38171. /**
  38172. * If camera controls should be detached during the drag
  38173. */
  38174. detachCameraControls: boolean;
  38175. /**
  38176. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38177. */
  38178. useObjectOrienationForDragging: boolean;
  38179. private _options;
  38180. /**
  38181. * Creates a pointer drag behavior that can be attached to a mesh
  38182. * @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)
  38183. */
  38184. constructor(options?: {
  38185. dragAxis?: Vector3;
  38186. dragPlaneNormal?: Vector3;
  38187. });
  38188. /**
  38189. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38190. */
  38191. validateDrag: (targetPosition: Vector3) => boolean;
  38192. /**
  38193. * The name of the behavior
  38194. */
  38195. readonly name: string;
  38196. /**
  38197. * Initializes the behavior
  38198. */
  38199. init(): void;
  38200. private _tmpVector;
  38201. private _alternatePickedPoint;
  38202. private _worldDragAxis;
  38203. private _targetPosition;
  38204. private _attachedElement;
  38205. /**
  38206. * Attaches the drag behavior the passed in mesh
  38207. * @param ownerNode The mesh that will be dragged around once attached
  38208. * @param predicate Predicate to use for pick filtering
  38209. */
  38210. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38211. /**
  38212. * Force relase the drag action by code.
  38213. */
  38214. releaseDrag(): void;
  38215. private _startDragRay;
  38216. private _lastPointerRay;
  38217. /**
  38218. * Simulates the start of a pointer drag event on the behavior
  38219. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38220. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38221. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38222. */
  38223. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38224. private _startDrag;
  38225. private _dragDelta;
  38226. private _moveDrag;
  38227. private _pickWithRayOnDragPlane;
  38228. private _pointA;
  38229. private _pointB;
  38230. private _pointC;
  38231. private _lineA;
  38232. private _lineB;
  38233. private _localAxis;
  38234. private _lookAt;
  38235. private _updateDragPlanePosition;
  38236. /**
  38237. * Detaches the behavior from the mesh
  38238. */
  38239. detach(): void;
  38240. }
  38241. }
  38242. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38243. import { Mesh } from "babylonjs/Meshes/mesh";
  38244. import { Behavior } from "babylonjs/Behaviors/behavior";
  38245. /**
  38246. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38247. */
  38248. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38249. private _dragBehaviorA;
  38250. private _dragBehaviorB;
  38251. private _startDistance;
  38252. private _initialScale;
  38253. private _targetScale;
  38254. private _ownerNode;
  38255. private _sceneRenderObserver;
  38256. /**
  38257. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38258. */
  38259. constructor();
  38260. /**
  38261. * The name of the behavior
  38262. */
  38263. readonly name: string;
  38264. /**
  38265. * Initializes the behavior
  38266. */
  38267. init(): void;
  38268. private _getCurrentDistance;
  38269. /**
  38270. * Attaches the scale behavior the passed in mesh
  38271. * @param ownerNode The mesh that will be scaled around once attached
  38272. */
  38273. attach(ownerNode: Mesh): void;
  38274. /**
  38275. * Detaches the behavior from the mesh
  38276. */
  38277. detach(): void;
  38278. }
  38279. }
  38280. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38281. import { Behavior } from "babylonjs/Behaviors/behavior";
  38282. import { Mesh } from "babylonjs/Meshes/mesh";
  38283. import { Observable } from "babylonjs/Misc/observable";
  38284. /**
  38285. * 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
  38286. */
  38287. export class SixDofDragBehavior implements Behavior<Mesh> {
  38288. private static _virtualScene;
  38289. private _ownerNode;
  38290. private _sceneRenderObserver;
  38291. private _scene;
  38292. private _targetPosition;
  38293. private _virtualOriginMesh;
  38294. private _virtualDragMesh;
  38295. private _pointerObserver;
  38296. private _moving;
  38297. private _startingOrientation;
  38298. /**
  38299. * 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)
  38300. */
  38301. private zDragFactor;
  38302. /**
  38303. * If the object should rotate to face the drag origin
  38304. */
  38305. rotateDraggedObject: boolean;
  38306. /**
  38307. * If the behavior is currently in a dragging state
  38308. */
  38309. dragging: boolean;
  38310. /**
  38311. * 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)
  38312. */
  38313. dragDeltaRatio: number;
  38314. /**
  38315. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38316. */
  38317. currentDraggingPointerID: number;
  38318. /**
  38319. * If camera controls should be detached during the drag
  38320. */
  38321. detachCameraControls: boolean;
  38322. /**
  38323. * Fires each time a drag starts
  38324. */
  38325. onDragStartObservable: Observable<{}>;
  38326. /**
  38327. * Fires each time a drag ends (eg. mouse release after drag)
  38328. */
  38329. onDragEndObservable: Observable<{}>;
  38330. /**
  38331. * 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
  38332. */
  38333. constructor();
  38334. /**
  38335. * The name of the behavior
  38336. */
  38337. readonly name: string;
  38338. /**
  38339. * Initializes the behavior
  38340. */
  38341. init(): void;
  38342. /**
  38343. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38344. */
  38345. private readonly _pointerCamera;
  38346. /**
  38347. * Attaches the scale behavior the passed in mesh
  38348. * @param ownerNode The mesh that will be scaled around once attached
  38349. */
  38350. attach(ownerNode: Mesh): void;
  38351. /**
  38352. * Detaches the behavior from the mesh
  38353. */
  38354. detach(): void;
  38355. }
  38356. }
  38357. declare module "babylonjs/Behaviors/Meshes/index" {
  38358. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38359. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38360. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38361. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38362. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38363. }
  38364. declare module "babylonjs/Behaviors/index" {
  38365. export * from "babylonjs/Behaviors/behavior";
  38366. export * from "babylonjs/Behaviors/Cameras/index";
  38367. export * from "babylonjs/Behaviors/Meshes/index";
  38368. }
  38369. declare module "babylonjs/Bones/boneIKController" {
  38370. import { Bone } from "babylonjs/Bones/bone";
  38371. import { Vector3 } from "babylonjs/Maths/math.vector";
  38372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38373. import { Nullable } from "babylonjs/types";
  38374. /**
  38375. * Class used to apply inverse kinematics to bones
  38376. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38377. */
  38378. export class BoneIKController {
  38379. private static _tmpVecs;
  38380. private static _tmpQuat;
  38381. private static _tmpMats;
  38382. /**
  38383. * Gets or sets the target mesh
  38384. */
  38385. targetMesh: AbstractMesh;
  38386. /** Gets or sets the mesh used as pole */
  38387. poleTargetMesh: AbstractMesh;
  38388. /**
  38389. * Gets or sets the bone used as pole
  38390. */
  38391. poleTargetBone: Nullable<Bone>;
  38392. /**
  38393. * Gets or sets the target position
  38394. */
  38395. targetPosition: Vector3;
  38396. /**
  38397. * Gets or sets the pole target position
  38398. */
  38399. poleTargetPosition: Vector3;
  38400. /**
  38401. * Gets or sets the pole target local offset
  38402. */
  38403. poleTargetLocalOffset: Vector3;
  38404. /**
  38405. * Gets or sets the pole angle
  38406. */
  38407. poleAngle: number;
  38408. /**
  38409. * Gets or sets the mesh associated with the controller
  38410. */
  38411. mesh: AbstractMesh;
  38412. /**
  38413. * 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)
  38414. */
  38415. slerpAmount: number;
  38416. private _bone1Quat;
  38417. private _bone1Mat;
  38418. private _bone2Ang;
  38419. private _bone1;
  38420. private _bone2;
  38421. private _bone1Length;
  38422. private _bone2Length;
  38423. private _maxAngle;
  38424. private _maxReach;
  38425. private _rightHandedSystem;
  38426. private _bendAxis;
  38427. private _slerping;
  38428. private _adjustRoll;
  38429. /**
  38430. * Gets or sets maximum allowed angle
  38431. */
  38432. maxAngle: number;
  38433. /**
  38434. * Creates a new BoneIKController
  38435. * @param mesh defines the mesh to control
  38436. * @param bone defines the bone to control
  38437. * @param options defines options to set up the controller
  38438. */
  38439. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38440. targetMesh?: AbstractMesh;
  38441. poleTargetMesh?: AbstractMesh;
  38442. poleTargetBone?: Bone;
  38443. poleTargetLocalOffset?: Vector3;
  38444. poleAngle?: number;
  38445. bendAxis?: Vector3;
  38446. maxAngle?: number;
  38447. slerpAmount?: number;
  38448. });
  38449. private _setMaxAngle;
  38450. /**
  38451. * Force the controller to update the bones
  38452. */
  38453. update(): void;
  38454. }
  38455. }
  38456. declare module "babylonjs/Bones/boneLookController" {
  38457. import { Vector3 } from "babylonjs/Maths/math.vector";
  38458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38459. import { Bone } from "babylonjs/Bones/bone";
  38460. import { Space } from "babylonjs/Maths/math.axis";
  38461. /**
  38462. * Class used to make a bone look toward a point in space
  38463. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38464. */
  38465. export class BoneLookController {
  38466. private static _tmpVecs;
  38467. private static _tmpQuat;
  38468. private static _tmpMats;
  38469. /**
  38470. * The target Vector3 that the bone will look at
  38471. */
  38472. target: Vector3;
  38473. /**
  38474. * The mesh that the bone is attached to
  38475. */
  38476. mesh: AbstractMesh;
  38477. /**
  38478. * The bone that will be looking to the target
  38479. */
  38480. bone: Bone;
  38481. /**
  38482. * The up axis of the coordinate system that is used when the bone is rotated
  38483. */
  38484. upAxis: Vector3;
  38485. /**
  38486. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38487. */
  38488. upAxisSpace: Space;
  38489. /**
  38490. * Used to make an adjustment to the yaw of the bone
  38491. */
  38492. adjustYaw: number;
  38493. /**
  38494. * Used to make an adjustment to the pitch of the bone
  38495. */
  38496. adjustPitch: number;
  38497. /**
  38498. * Used to make an adjustment to the roll of the bone
  38499. */
  38500. adjustRoll: number;
  38501. /**
  38502. * 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)
  38503. */
  38504. slerpAmount: number;
  38505. private _minYaw;
  38506. private _maxYaw;
  38507. private _minPitch;
  38508. private _maxPitch;
  38509. private _minYawSin;
  38510. private _minYawCos;
  38511. private _maxYawSin;
  38512. private _maxYawCos;
  38513. private _midYawConstraint;
  38514. private _minPitchTan;
  38515. private _maxPitchTan;
  38516. private _boneQuat;
  38517. private _slerping;
  38518. private _transformYawPitch;
  38519. private _transformYawPitchInv;
  38520. private _firstFrameSkipped;
  38521. private _yawRange;
  38522. private _fowardAxis;
  38523. /**
  38524. * Gets or sets the minimum yaw angle that the bone can look to
  38525. */
  38526. minYaw: number;
  38527. /**
  38528. * Gets or sets the maximum yaw angle that the bone can look to
  38529. */
  38530. maxYaw: number;
  38531. /**
  38532. * Gets or sets the minimum pitch angle that the bone can look to
  38533. */
  38534. minPitch: number;
  38535. /**
  38536. * Gets or sets the maximum pitch angle that the bone can look to
  38537. */
  38538. maxPitch: number;
  38539. /**
  38540. * Create a BoneLookController
  38541. * @param mesh the mesh that the bone belongs to
  38542. * @param bone the bone that will be looking to the target
  38543. * @param target the target Vector3 to look at
  38544. * @param options optional settings:
  38545. * * maxYaw: the maximum angle the bone will yaw to
  38546. * * minYaw: the minimum angle the bone will yaw to
  38547. * * maxPitch: the maximum angle the bone will pitch to
  38548. * * minPitch: the minimum angle the bone will yaw to
  38549. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38550. * * upAxis: the up axis of the coordinate system
  38551. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38552. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38553. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38554. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38555. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38556. * * adjustRoll: used to make an adjustment to the roll of the bone
  38557. **/
  38558. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38559. maxYaw?: number;
  38560. minYaw?: number;
  38561. maxPitch?: number;
  38562. minPitch?: number;
  38563. slerpAmount?: number;
  38564. upAxis?: Vector3;
  38565. upAxisSpace?: Space;
  38566. yawAxis?: Vector3;
  38567. pitchAxis?: Vector3;
  38568. adjustYaw?: number;
  38569. adjustPitch?: number;
  38570. adjustRoll?: number;
  38571. });
  38572. /**
  38573. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38574. */
  38575. update(): void;
  38576. private _getAngleDiff;
  38577. private _getAngleBetween;
  38578. private _isAngleBetween;
  38579. }
  38580. }
  38581. declare module "babylonjs/Bones/index" {
  38582. export * from "babylonjs/Bones/bone";
  38583. export * from "babylonjs/Bones/boneIKController";
  38584. export * from "babylonjs/Bones/boneLookController";
  38585. export * from "babylonjs/Bones/skeleton";
  38586. }
  38587. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38588. import { Nullable } from "babylonjs/types";
  38589. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38590. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38591. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38592. /**
  38593. * Manage the gamepad inputs to control an arc rotate camera.
  38594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38595. */
  38596. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38597. /**
  38598. * Defines the camera the input is attached to.
  38599. */
  38600. camera: ArcRotateCamera;
  38601. /**
  38602. * Defines the gamepad the input is gathering event from.
  38603. */
  38604. gamepad: Nullable<Gamepad>;
  38605. /**
  38606. * Defines the gamepad rotation sensiblity.
  38607. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38608. */
  38609. gamepadRotationSensibility: number;
  38610. /**
  38611. * Defines the gamepad move sensiblity.
  38612. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38613. */
  38614. gamepadMoveSensibility: number;
  38615. private _yAxisScale;
  38616. /**
  38617. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38618. */
  38619. invertYAxis: boolean;
  38620. private _onGamepadConnectedObserver;
  38621. private _onGamepadDisconnectedObserver;
  38622. /**
  38623. * Attach the input controls to a specific dom element to get the input from.
  38624. * @param element Defines the element the controls should be listened from
  38625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38626. */
  38627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38628. /**
  38629. * Detach the current controls from the specified dom element.
  38630. * @param element Defines the element to stop listening the inputs from
  38631. */
  38632. detachControl(element: Nullable<HTMLElement>): void;
  38633. /**
  38634. * Update the current camera state depending on the inputs that have been used this frame.
  38635. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38636. */
  38637. checkInputs(): void;
  38638. /**
  38639. * Gets the class name of the current intput.
  38640. * @returns the class name
  38641. */
  38642. getClassName(): string;
  38643. /**
  38644. * Get the friendly name associated with the input class.
  38645. * @returns the input friendly name
  38646. */
  38647. getSimpleName(): string;
  38648. }
  38649. }
  38650. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38651. import { Nullable } from "babylonjs/types";
  38652. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38653. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38654. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38655. interface ArcRotateCameraInputsManager {
  38656. /**
  38657. * Add orientation input support to the input manager.
  38658. * @returns the current input manager
  38659. */
  38660. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38661. }
  38662. }
  38663. /**
  38664. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38666. */
  38667. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38668. /**
  38669. * Defines the camera the input is attached to.
  38670. */
  38671. camera: ArcRotateCamera;
  38672. /**
  38673. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38674. */
  38675. alphaCorrection: number;
  38676. /**
  38677. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38678. */
  38679. gammaCorrection: number;
  38680. private _alpha;
  38681. private _gamma;
  38682. private _dirty;
  38683. private _deviceOrientationHandler;
  38684. /**
  38685. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38686. */
  38687. constructor();
  38688. /**
  38689. * Attach the input controls to a specific dom element to get the input from.
  38690. * @param element Defines the element the controls should be listened from
  38691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38692. */
  38693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38694. /** @hidden */
  38695. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38696. /**
  38697. * Update the current camera state depending on the inputs that have been used this frame.
  38698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38699. */
  38700. checkInputs(): void;
  38701. /**
  38702. * Detach the current controls from the specified dom element.
  38703. * @param element Defines the element to stop listening the inputs from
  38704. */
  38705. detachControl(element: Nullable<HTMLElement>): void;
  38706. /**
  38707. * Gets the class name of the current intput.
  38708. * @returns the class name
  38709. */
  38710. getClassName(): string;
  38711. /**
  38712. * Get the friendly name associated with the input class.
  38713. * @returns the input friendly name
  38714. */
  38715. getSimpleName(): string;
  38716. }
  38717. }
  38718. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38719. import { Nullable } from "babylonjs/types";
  38720. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38721. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38722. /**
  38723. * Listen to mouse events to control the camera.
  38724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38725. */
  38726. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38727. /**
  38728. * Defines the camera the input is attached to.
  38729. */
  38730. camera: FlyCamera;
  38731. /**
  38732. * Defines if touch is enabled. (Default is true.)
  38733. */
  38734. touchEnabled: boolean;
  38735. /**
  38736. * Defines the buttons associated with the input to handle camera rotation.
  38737. */
  38738. buttons: number[];
  38739. /**
  38740. * Assign buttons for Yaw control.
  38741. */
  38742. buttonsYaw: number[];
  38743. /**
  38744. * Assign buttons for Pitch control.
  38745. */
  38746. buttonsPitch: number[];
  38747. /**
  38748. * Assign buttons for Roll control.
  38749. */
  38750. buttonsRoll: number[];
  38751. /**
  38752. * Detect if any button is being pressed while mouse is moved.
  38753. * -1 = Mouse locked.
  38754. * 0 = Left button.
  38755. * 1 = Middle Button.
  38756. * 2 = Right Button.
  38757. */
  38758. activeButton: number;
  38759. /**
  38760. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38761. * Higher values reduce its sensitivity.
  38762. */
  38763. angularSensibility: number;
  38764. private _mousemoveCallback;
  38765. private _observer;
  38766. private _rollObserver;
  38767. private previousPosition;
  38768. private noPreventDefault;
  38769. private element;
  38770. /**
  38771. * Listen to mouse events to control the camera.
  38772. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38773. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38774. */
  38775. constructor(touchEnabled?: boolean);
  38776. /**
  38777. * Attach the mouse control to the HTML DOM element.
  38778. * @param element Defines the element that listens to the input events.
  38779. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38780. */
  38781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38782. /**
  38783. * Detach the current controls from the specified dom element.
  38784. * @param element Defines the element to stop listening the inputs from
  38785. */
  38786. detachControl(element: Nullable<HTMLElement>): void;
  38787. /**
  38788. * Gets the class name of the current input.
  38789. * @returns the class name.
  38790. */
  38791. getClassName(): string;
  38792. /**
  38793. * Get the friendly name associated with the input class.
  38794. * @returns the input's friendly name.
  38795. */
  38796. getSimpleName(): string;
  38797. private _pointerInput;
  38798. private _onMouseMove;
  38799. /**
  38800. * Rotate camera by mouse offset.
  38801. */
  38802. private rotateCamera;
  38803. }
  38804. }
  38805. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38806. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38807. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38808. /**
  38809. * Default Inputs manager for the FlyCamera.
  38810. * It groups all the default supported inputs for ease of use.
  38811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38812. */
  38813. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38814. /**
  38815. * Instantiates a new FlyCameraInputsManager.
  38816. * @param camera Defines the camera the inputs belong to.
  38817. */
  38818. constructor(camera: FlyCamera);
  38819. /**
  38820. * Add keyboard input support to the input manager.
  38821. * @returns the new FlyCameraKeyboardMoveInput().
  38822. */
  38823. addKeyboard(): FlyCameraInputsManager;
  38824. /**
  38825. * Add mouse input support to the input manager.
  38826. * @param touchEnabled Enable touch screen support.
  38827. * @returns the new FlyCameraMouseInput().
  38828. */
  38829. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38830. }
  38831. }
  38832. declare module "babylonjs/Cameras/flyCamera" {
  38833. import { Scene } from "babylonjs/scene";
  38834. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38836. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38837. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38838. /**
  38839. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38840. * such as in a 3D Space Shooter or a Flight Simulator.
  38841. */
  38842. export class FlyCamera extends TargetCamera {
  38843. /**
  38844. * Define the collision ellipsoid of the camera.
  38845. * This is helpful for simulating a camera body, like a player's body.
  38846. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38847. */
  38848. ellipsoid: Vector3;
  38849. /**
  38850. * Define an offset for the position of the ellipsoid around the camera.
  38851. * This can be helpful if the camera is attached away from the player's body center,
  38852. * such as at its head.
  38853. */
  38854. ellipsoidOffset: Vector3;
  38855. /**
  38856. * Enable or disable collisions of the camera with the rest of the scene objects.
  38857. */
  38858. checkCollisions: boolean;
  38859. /**
  38860. * Enable or disable gravity on the camera.
  38861. */
  38862. applyGravity: boolean;
  38863. /**
  38864. * Define the current direction the camera is moving to.
  38865. */
  38866. cameraDirection: Vector3;
  38867. /**
  38868. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38869. * This overrides and empties cameraRotation.
  38870. */
  38871. rotationQuaternion: Quaternion;
  38872. /**
  38873. * Track Roll to maintain the wanted Rolling when looking around.
  38874. */
  38875. _trackRoll: number;
  38876. /**
  38877. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38878. */
  38879. rollCorrect: number;
  38880. /**
  38881. * Mimic a banked turn, Rolling the camera when Yawing.
  38882. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38883. */
  38884. bankedTurn: boolean;
  38885. /**
  38886. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38887. */
  38888. bankedTurnLimit: number;
  38889. /**
  38890. * Value of 0 disables the banked Roll.
  38891. * Value of 1 is equal to the Yaw angle in radians.
  38892. */
  38893. bankedTurnMultiplier: number;
  38894. /**
  38895. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38896. */
  38897. inputs: FlyCameraInputsManager;
  38898. /**
  38899. * Gets the input sensibility for mouse input.
  38900. * Higher values reduce sensitivity.
  38901. */
  38902. /**
  38903. * Sets the input sensibility for a mouse input.
  38904. * Higher values reduce sensitivity.
  38905. */
  38906. angularSensibility: number;
  38907. /**
  38908. * Get the keys for camera movement forward.
  38909. */
  38910. /**
  38911. * Set the keys for camera movement forward.
  38912. */
  38913. keysForward: number[];
  38914. /**
  38915. * Get the keys for camera movement backward.
  38916. */
  38917. keysBackward: number[];
  38918. /**
  38919. * Get the keys for camera movement up.
  38920. */
  38921. /**
  38922. * Set the keys for camera movement up.
  38923. */
  38924. keysUp: number[];
  38925. /**
  38926. * Get the keys for camera movement down.
  38927. */
  38928. /**
  38929. * Set the keys for camera movement down.
  38930. */
  38931. keysDown: number[];
  38932. /**
  38933. * Get the keys for camera movement left.
  38934. */
  38935. /**
  38936. * Set the keys for camera movement left.
  38937. */
  38938. keysLeft: number[];
  38939. /**
  38940. * Set the keys for camera movement right.
  38941. */
  38942. /**
  38943. * Set the keys for camera movement right.
  38944. */
  38945. keysRight: number[];
  38946. /**
  38947. * Event raised when the camera collides with a mesh in the scene.
  38948. */
  38949. onCollide: (collidedMesh: AbstractMesh) => void;
  38950. private _collider;
  38951. private _needMoveForGravity;
  38952. private _oldPosition;
  38953. private _diffPosition;
  38954. private _newPosition;
  38955. /** @hidden */
  38956. _localDirection: Vector3;
  38957. /** @hidden */
  38958. _transformedDirection: Vector3;
  38959. /**
  38960. * Instantiates a FlyCamera.
  38961. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38962. * such as in a 3D Space Shooter or a Flight Simulator.
  38963. * @param name Define the name of the camera in the scene.
  38964. * @param position Define the starting position of the camera in the scene.
  38965. * @param scene Define the scene the camera belongs to.
  38966. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38967. */
  38968. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38969. /**
  38970. * Attach a control to the HTML DOM element.
  38971. * @param element Defines the element that listens to the input events.
  38972. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38973. */
  38974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38975. /**
  38976. * Detach a control from the HTML DOM element.
  38977. * The camera will stop reacting to that input.
  38978. * @param element Defines the element that listens to the input events.
  38979. */
  38980. detachControl(element: HTMLElement): void;
  38981. private _collisionMask;
  38982. /**
  38983. * Get the mask that the camera ignores in collision events.
  38984. */
  38985. /**
  38986. * Set the mask that the camera ignores in collision events.
  38987. */
  38988. collisionMask: number;
  38989. /** @hidden */
  38990. _collideWithWorld(displacement: Vector3): void;
  38991. /** @hidden */
  38992. private _onCollisionPositionChange;
  38993. /** @hidden */
  38994. _checkInputs(): void;
  38995. /** @hidden */
  38996. _decideIfNeedsToMove(): boolean;
  38997. /** @hidden */
  38998. _updatePosition(): void;
  38999. /**
  39000. * Restore the Roll to its target value at the rate specified.
  39001. * @param rate - Higher means slower restoring.
  39002. * @hidden
  39003. */
  39004. restoreRoll(rate: number): void;
  39005. /**
  39006. * Destroy the camera and release the current resources held by it.
  39007. */
  39008. dispose(): void;
  39009. /**
  39010. * Get the current object class name.
  39011. * @returns the class name.
  39012. */
  39013. getClassName(): string;
  39014. }
  39015. }
  39016. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39017. import { Nullable } from "babylonjs/types";
  39018. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39019. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39020. /**
  39021. * Listen to keyboard events to control the camera.
  39022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39023. */
  39024. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39025. /**
  39026. * Defines the camera the input is attached to.
  39027. */
  39028. camera: FlyCamera;
  39029. /**
  39030. * The list of keyboard keys used to control the forward move of the camera.
  39031. */
  39032. keysForward: number[];
  39033. /**
  39034. * The list of keyboard keys used to control the backward move of the camera.
  39035. */
  39036. keysBackward: number[];
  39037. /**
  39038. * The list of keyboard keys used to control the forward move of the camera.
  39039. */
  39040. keysUp: number[];
  39041. /**
  39042. * The list of keyboard keys used to control the backward move of the camera.
  39043. */
  39044. keysDown: number[];
  39045. /**
  39046. * The list of keyboard keys used to control the right strafe move of the camera.
  39047. */
  39048. keysRight: number[];
  39049. /**
  39050. * The list of keyboard keys used to control the left strafe move of the camera.
  39051. */
  39052. keysLeft: number[];
  39053. private _keys;
  39054. private _onCanvasBlurObserver;
  39055. private _onKeyboardObserver;
  39056. private _engine;
  39057. private _scene;
  39058. /**
  39059. * Attach the input controls to a specific dom element to get the input from.
  39060. * @param element Defines the element the controls should be listened from
  39061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39062. */
  39063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39064. /**
  39065. * Detach the current controls from the specified dom element.
  39066. * @param element Defines the element to stop listening the inputs from
  39067. */
  39068. detachControl(element: Nullable<HTMLElement>): void;
  39069. /**
  39070. * Gets the class name of the current intput.
  39071. * @returns the class name
  39072. */
  39073. getClassName(): string;
  39074. /** @hidden */
  39075. _onLostFocus(e: FocusEvent): void;
  39076. /**
  39077. * Get the friendly name associated with the input class.
  39078. * @returns the input friendly name
  39079. */
  39080. getSimpleName(): string;
  39081. /**
  39082. * Update the current camera state depending on the inputs that have been used this frame.
  39083. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39084. */
  39085. checkInputs(): void;
  39086. }
  39087. }
  39088. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39089. import { Nullable } from "babylonjs/types";
  39090. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39091. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39092. /**
  39093. * Manage the mouse wheel inputs to control a follow camera.
  39094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39095. */
  39096. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39097. /**
  39098. * Defines the camera the input is attached to.
  39099. */
  39100. camera: FollowCamera;
  39101. /**
  39102. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39103. */
  39104. axisControlRadius: boolean;
  39105. /**
  39106. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39107. */
  39108. axisControlHeight: boolean;
  39109. /**
  39110. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39111. */
  39112. axisControlRotation: boolean;
  39113. /**
  39114. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39115. * relation to mouseWheel events.
  39116. */
  39117. wheelPrecision: number;
  39118. /**
  39119. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39120. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39121. */
  39122. wheelDeltaPercentage: number;
  39123. private _wheel;
  39124. private _observer;
  39125. /**
  39126. * Attach the input controls to a specific dom element to get the input from.
  39127. * @param element Defines the element the controls should be listened from
  39128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39129. */
  39130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39131. /**
  39132. * Detach the current controls from the specified dom element.
  39133. * @param element Defines the element to stop listening the inputs from
  39134. */
  39135. detachControl(element: Nullable<HTMLElement>): void;
  39136. /**
  39137. * Gets the class name of the current intput.
  39138. * @returns the class name
  39139. */
  39140. getClassName(): string;
  39141. /**
  39142. * Get the friendly name associated with the input class.
  39143. * @returns the input friendly name
  39144. */
  39145. getSimpleName(): string;
  39146. }
  39147. }
  39148. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39149. import { Nullable } from "babylonjs/types";
  39150. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39151. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39152. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39153. /**
  39154. * Manage the pointers inputs to control an follow camera.
  39155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39156. */
  39157. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39158. /**
  39159. * Defines the camera the input is attached to.
  39160. */
  39161. camera: FollowCamera;
  39162. /**
  39163. * Gets the class name of the current input.
  39164. * @returns the class name
  39165. */
  39166. getClassName(): string;
  39167. /**
  39168. * Defines the pointer angular sensibility along the X axis or how fast is
  39169. * the camera rotating.
  39170. * A negative number will reverse the axis direction.
  39171. */
  39172. angularSensibilityX: number;
  39173. /**
  39174. * Defines the pointer angular sensibility along the Y axis or how fast is
  39175. * the camera rotating.
  39176. * A negative number will reverse the axis direction.
  39177. */
  39178. angularSensibilityY: number;
  39179. /**
  39180. * Defines the pointer pinch precision or how fast is the camera zooming.
  39181. * A negative number will reverse the axis direction.
  39182. */
  39183. pinchPrecision: number;
  39184. /**
  39185. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39186. * from 0.
  39187. * It defines the percentage of current camera.radius to use as delta when
  39188. * pinch zoom is used.
  39189. */
  39190. pinchDeltaPercentage: number;
  39191. /**
  39192. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39193. */
  39194. axisXControlRadius: boolean;
  39195. /**
  39196. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39197. */
  39198. axisXControlHeight: boolean;
  39199. /**
  39200. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39201. */
  39202. axisXControlRotation: boolean;
  39203. /**
  39204. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39205. */
  39206. axisYControlRadius: boolean;
  39207. /**
  39208. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39209. */
  39210. axisYControlHeight: boolean;
  39211. /**
  39212. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39213. */
  39214. axisYControlRotation: boolean;
  39215. /**
  39216. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39217. */
  39218. axisPinchControlRadius: boolean;
  39219. /**
  39220. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39221. */
  39222. axisPinchControlHeight: boolean;
  39223. /**
  39224. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39225. */
  39226. axisPinchControlRotation: boolean;
  39227. /**
  39228. * Log error messages if basic misconfiguration has occurred.
  39229. */
  39230. warningEnable: boolean;
  39231. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39232. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39233. private _warningCounter;
  39234. private _warning;
  39235. }
  39236. }
  39237. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39238. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39239. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39240. /**
  39241. * Default Inputs manager for the FollowCamera.
  39242. * It groups all the default supported inputs for ease of use.
  39243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39244. */
  39245. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39246. /**
  39247. * Instantiates a new FollowCameraInputsManager.
  39248. * @param camera Defines the camera the inputs belong to
  39249. */
  39250. constructor(camera: FollowCamera);
  39251. /**
  39252. * Add keyboard input support to the input manager.
  39253. * @returns the current input manager
  39254. */
  39255. addKeyboard(): FollowCameraInputsManager;
  39256. /**
  39257. * Add mouse wheel input support to the input manager.
  39258. * @returns the current input manager
  39259. */
  39260. addMouseWheel(): FollowCameraInputsManager;
  39261. /**
  39262. * Add pointers input support to the input manager.
  39263. * @returns the current input manager
  39264. */
  39265. addPointers(): FollowCameraInputsManager;
  39266. /**
  39267. * Add orientation input support to the input manager.
  39268. * @returns the current input manager
  39269. */
  39270. addVRDeviceOrientation(): FollowCameraInputsManager;
  39271. }
  39272. }
  39273. declare module "babylonjs/Cameras/followCamera" {
  39274. import { Nullable } from "babylonjs/types";
  39275. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39276. import { Scene } from "babylonjs/scene";
  39277. import { Vector3 } from "babylonjs/Maths/math.vector";
  39278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39279. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39280. /**
  39281. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39282. * an arc rotate version arcFollowCamera are available.
  39283. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39284. */
  39285. export class FollowCamera extends TargetCamera {
  39286. /**
  39287. * Distance the follow camera should follow an object at
  39288. */
  39289. radius: number;
  39290. /**
  39291. * Minimum allowed distance of the camera to the axis of rotation
  39292. * (The camera can not get closer).
  39293. * This can help limiting how the Camera is able to move in the scene.
  39294. */
  39295. lowerRadiusLimit: Nullable<number>;
  39296. /**
  39297. * Maximum allowed distance of the camera to the axis of rotation
  39298. * (The camera can not get further).
  39299. * This can help limiting how the Camera is able to move in the scene.
  39300. */
  39301. upperRadiusLimit: Nullable<number>;
  39302. /**
  39303. * Define a rotation offset between the camera and the object it follows
  39304. */
  39305. rotationOffset: number;
  39306. /**
  39307. * Minimum allowed angle to camera position relative to target object.
  39308. * This can help limiting how the Camera is able to move in the scene.
  39309. */
  39310. lowerRotationOffsetLimit: Nullable<number>;
  39311. /**
  39312. * Maximum allowed angle to camera position relative to target object.
  39313. * This can help limiting how the Camera is able to move in the scene.
  39314. */
  39315. upperRotationOffsetLimit: Nullable<number>;
  39316. /**
  39317. * Define a height offset between the camera and the object it follows.
  39318. * It can help following an object from the top (like a car chaing a plane)
  39319. */
  39320. heightOffset: number;
  39321. /**
  39322. * Minimum allowed height of camera position relative to target object.
  39323. * This can help limiting how the Camera is able to move in the scene.
  39324. */
  39325. lowerHeightOffsetLimit: Nullable<number>;
  39326. /**
  39327. * Maximum allowed height of camera position relative to target object.
  39328. * This can help limiting how the Camera is able to move in the scene.
  39329. */
  39330. upperHeightOffsetLimit: Nullable<number>;
  39331. /**
  39332. * Define how fast the camera can accelerate to follow it s target.
  39333. */
  39334. cameraAcceleration: number;
  39335. /**
  39336. * Define the speed limit of the camera following an object.
  39337. */
  39338. maxCameraSpeed: number;
  39339. /**
  39340. * Define the target of the camera.
  39341. */
  39342. lockedTarget: Nullable<AbstractMesh>;
  39343. /**
  39344. * Defines the input associated with the camera.
  39345. */
  39346. inputs: FollowCameraInputsManager;
  39347. /**
  39348. * Instantiates the follow camera.
  39349. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39350. * @param name Define the name of the camera in the scene
  39351. * @param position Define the position of the camera
  39352. * @param scene Define the scene the camera belong to
  39353. * @param lockedTarget Define the target of the camera
  39354. */
  39355. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39356. private _follow;
  39357. /**
  39358. * Attached controls to the current camera.
  39359. * @param element Defines the element the controls should be listened from
  39360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39361. */
  39362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39363. /**
  39364. * Detach the current controls from the camera.
  39365. * The camera will stop reacting to inputs.
  39366. * @param element Defines the element to stop listening the inputs from
  39367. */
  39368. detachControl(element: HTMLElement): void;
  39369. /** @hidden */
  39370. _checkInputs(): void;
  39371. private _checkLimits;
  39372. /**
  39373. * Gets the camera class name.
  39374. * @returns the class name
  39375. */
  39376. getClassName(): string;
  39377. }
  39378. /**
  39379. * Arc Rotate version of the follow camera.
  39380. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39381. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39382. */
  39383. export class ArcFollowCamera extends TargetCamera {
  39384. /** The longitudinal angle of the camera */
  39385. alpha: number;
  39386. /** The latitudinal angle of the camera */
  39387. beta: number;
  39388. /** The radius of the camera from its target */
  39389. radius: number;
  39390. /** Define the camera target (the messh it should follow) */
  39391. target: Nullable<AbstractMesh>;
  39392. private _cartesianCoordinates;
  39393. /**
  39394. * Instantiates a new ArcFollowCamera
  39395. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39396. * @param name Define the name of the camera
  39397. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39398. * @param beta Define the rotation angle of the camera around the elevation axis
  39399. * @param radius Define the radius of the camera from its target point
  39400. * @param target Define the target of the camera
  39401. * @param scene Define the scene the camera belongs to
  39402. */
  39403. constructor(name: string,
  39404. /** The longitudinal angle of the camera */
  39405. alpha: number,
  39406. /** The latitudinal angle of the camera */
  39407. beta: number,
  39408. /** The radius of the camera from its target */
  39409. radius: number,
  39410. /** Define the camera target (the messh it should follow) */
  39411. target: Nullable<AbstractMesh>, scene: Scene);
  39412. private _follow;
  39413. /** @hidden */
  39414. _checkInputs(): void;
  39415. /**
  39416. * Returns the class name of the object.
  39417. * It is mostly used internally for serialization purposes.
  39418. */
  39419. getClassName(): string;
  39420. }
  39421. }
  39422. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39423. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39424. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39425. import { Nullable } from "babylonjs/types";
  39426. /**
  39427. * Manage the keyboard inputs to control the movement of a follow camera.
  39428. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39429. */
  39430. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39431. /**
  39432. * Defines the camera the input is attached to.
  39433. */
  39434. camera: FollowCamera;
  39435. /**
  39436. * Defines the list of key codes associated with the up action (increase heightOffset)
  39437. */
  39438. keysHeightOffsetIncr: number[];
  39439. /**
  39440. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39441. */
  39442. keysHeightOffsetDecr: number[];
  39443. /**
  39444. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39445. */
  39446. keysHeightOffsetModifierAlt: boolean;
  39447. /**
  39448. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39449. */
  39450. keysHeightOffsetModifierCtrl: boolean;
  39451. /**
  39452. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39453. */
  39454. keysHeightOffsetModifierShift: boolean;
  39455. /**
  39456. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39457. */
  39458. keysRotationOffsetIncr: number[];
  39459. /**
  39460. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39461. */
  39462. keysRotationOffsetDecr: number[];
  39463. /**
  39464. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39465. */
  39466. keysRotationOffsetModifierAlt: boolean;
  39467. /**
  39468. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39469. */
  39470. keysRotationOffsetModifierCtrl: boolean;
  39471. /**
  39472. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39473. */
  39474. keysRotationOffsetModifierShift: boolean;
  39475. /**
  39476. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39477. */
  39478. keysRadiusIncr: number[];
  39479. /**
  39480. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39481. */
  39482. keysRadiusDecr: number[];
  39483. /**
  39484. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39485. */
  39486. keysRadiusModifierAlt: boolean;
  39487. /**
  39488. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39489. */
  39490. keysRadiusModifierCtrl: boolean;
  39491. /**
  39492. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39493. */
  39494. keysRadiusModifierShift: boolean;
  39495. /**
  39496. * Defines the rate of change of heightOffset.
  39497. */
  39498. heightSensibility: number;
  39499. /**
  39500. * Defines the rate of change of rotationOffset.
  39501. */
  39502. rotationSensibility: number;
  39503. /**
  39504. * Defines the rate of change of radius.
  39505. */
  39506. radiusSensibility: number;
  39507. private _keys;
  39508. private _ctrlPressed;
  39509. private _altPressed;
  39510. private _shiftPressed;
  39511. private _onCanvasBlurObserver;
  39512. private _onKeyboardObserver;
  39513. private _engine;
  39514. private _scene;
  39515. /**
  39516. * Attach the input controls to a specific dom element to get the input from.
  39517. * @param element Defines the element the controls should be listened from
  39518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39519. */
  39520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39521. /**
  39522. * Detach the current controls from the specified dom element.
  39523. * @param element Defines the element to stop listening the inputs from
  39524. */
  39525. detachControl(element: Nullable<HTMLElement>): void;
  39526. /**
  39527. * Update the current camera state depending on the inputs that have been used this frame.
  39528. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39529. */
  39530. checkInputs(): void;
  39531. /**
  39532. * Gets the class name of the current input.
  39533. * @returns the class name
  39534. */
  39535. getClassName(): string;
  39536. /**
  39537. * Get the friendly name associated with the input class.
  39538. * @returns the input friendly name
  39539. */
  39540. getSimpleName(): string;
  39541. /**
  39542. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39543. * allow modification of the heightOffset value.
  39544. */
  39545. private _modifierHeightOffset;
  39546. /**
  39547. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39548. * allow modification of the rotationOffset value.
  39549. */
  39550. private _modifierRotationOffset;
  39551. /**
  39552. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39553. * allow modification of the radius value.
  39554. */
  39555. private _modifierRadius;
  39556. }
  39557. }
  39558. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39559. import { Nullable } from "babylonjs/types";
  39560. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39561. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39562. import { Observable } from "babylonjs/Misc/observable";
  39563. module "babylonjs/Cameras/freeCameraInputsManager" {
  39564. interface FreeCameraInputsManager {
  39565. /**
  39566. * @hidden
  39567. */
  39568. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39569. /**
  39570. * Add orientation input support to the input manager.
  39571. * @returns the current input manager
  39572. */
  39573. addDeviceOrientation(): FreeCameraInputsManager;
  39574. }
  39575. }
  39576. /**
  39577. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39578. * Screen rotation is taken into account.
  39579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39580. */
  39581. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39582. private _camera;
  39583. private _screenOrientationAngle;
  39584. private _constantTranform;
  39585. private _screenQuaternion;
  39586. private _alpha;
  39587. private _beta;
  39588. private _gamma;
  39589. /**
  39590. * Can be used to detect if a device orientation sensor is availible on a device
  39591. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39592. * @returns a promise that will resolve on orientation change
  39593. */
  39594. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39595. /**
  39596. * @hidden
  39597. */
  39598. _onDeviceOrientationChangedObservable: Observable<void>;
  39599. /**
  39600. * Instantiates a new input
  39601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39602. */
  39603. constructor();
  39604. /**
  39605. * Define the camera controlled by the input.
  39606. */
  39607. camera: FreeCamera;
  39608. /**
  39609. * Attach the input controls to a specific dom element to get the input from.
  39610. * @param element Defines the element the controls should be listened from
  39611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39612. */
  39613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39614. private _orientationChanged;
  39615. private _deviceOrientation;
  39616. /**
  39617. * Detach the current controls from the specified dom element.
  39618. * @param element Defines the element to stop listening the inputs from
  39619. */
  39620. detachControl(element: Nullable<HTMLElement>): void;
  39621. /**
  39622. * Update the current camera state depending on the inputs that have been used this frame.
  39623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39624. */
  39625. checkInputs(): void;
  39626. /**
  39627. * Gets the class name of the current intput.
  39628. * @returns the class name
  39629. */
  39630. getClassName(): string;
  39631. /**
  39632. * Get the friendly name associated with the input class.
  39633. * @returns the input friendly name
  39634. */
  39635. getSimpleName(): string;
  39636. }
  39637. }
  39638. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39639. import { Nullable } from "babylonjs/types";
  39640. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39641. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39642. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39643. /**
  39644. * Manage the gamepad inputs to control a free camera.
  39645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39646. */
  39647. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39648. /**
  39649. * Define the camera the input is attached to.
  39650. */
  39651. camera: FreeCamera;
  39652. /**
  39653. * Define the Gamepad controlling the input
  39654. */
  39655. gamepad: Nullable<Gamepad>;
  39656. /**
  39657. * Defines the gamepad rotation sensiblity.
  39658. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39659. */
  39660. gamepadAngularSensibility: number;
  39661. /**
  39662. * Defines the gamepad move sensiblity.
  39663. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39664. */
  39665. gamepadMoveSensibility: number;
  39666. private _yAxisScale;
  39667. /**
  39668. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39669. */
  39670. invertYAxis: boolean;
  39671. private _onGamepadConnectedObserver;
  39672. private _onGamepadDisconnectedObserver;
  39673. private _cameraTransform;
  39674. private _deltaTransform;
  39675. private _vector3;
  39676. private _vector2;
  39677. /**
  39678. * Attach the input controls to a specific dom element to get the input from.
  39679. * @param element Defines the element the controls should be listened from
  39680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39681. */
  39682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39683. /**
  39684. * Detach the current controls from the specified dom element.
  39685. * @param element Defines the element to stop listening the inputs from
  39686. */
  39687. detachControl(element: Nullable<HTMLElement>): void;
  39688. /**
  39689. * Update the current camera state depending on the inputs that have been used this frame.
  39690. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39691. */
  39692. checkInputs(): void;
  39693. /**
  39694. * Gets the class name of the current intput.
  39695. * @returns the class name
  39696. */
  39697. getClassName(): string;
  39698. /**
  39699. * Get the friendly name associated with the input class.
  39700. * @returns the input friendly name
  39701. */
  39702. getSimpleName(): string;
  39703. }
  39704. }
  39705. declare module "babylonjs/Misc/virtualJoystick" {
  39706. import { Nullable } from "babylonjs/types";
  39707. import { Vector3 } from "babylonjs/Maths/math.vector";
  39708. /**
  39709. * Defines the potential axis of a Joystick
  39710. */
  39711. export enum JoystickAxis {
  39712. /** X axis */
  39713. X = 0,
  39714. /** Y axis */
  39715. Y = 1,
  39716. /** Z axis */
  39717. Z = 2
  39718. }
  39719. /**
  39720. * Class used to define virtual joystick (used in touch mode)
  39721. */
  39722. export class VirtualJoystick {
  39723. /**
  39724. * Gets or sets a boolean indicating that left and right values must be inverted
  39725. */
  39726. reverseLeftRight: boolean;
  39727. /**
  39728. * Gets or sets a boolean indicating that up and down values must be inverted
  39729. */
  39730. reverseUpDown: boolean;
  39731. /**
  39732. * Gets the offset value for the position (ie. the change of the position value)
  39733. */
  39734. deltaPosition: Vector3;
  39735. /**
  39736. * Gets a boolean indicating if the virtual joystick was pressed
  39737. */
  39738. pressed: boolean;
  39739. /**
  39740. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39741. */
  39742. static Canvas: Nullable<HTMLCanvasElement>;
  39743. private static _globalJoystickIndex;
  39744. private static vjCanvasContext;
  39745. private static vjCanvasWidth;
  39746. private static vjCanvasHeight;
  39747. private static halfWidth;
  39748. private _action;
  39749. private _axisTargetedByLeftAndRight;
  39750. private _axisTargetedByUpAndDown;
  39751. private _joystickSensibility;
  39752. private _inversedSensibility;
  39753. private _joystickPointerID;
  39754. private _joystickColor;
  39755. private _joystickPointerPos;
  39756. private _joystickPreviousPointerPos;
  39757. private _joystickPointerStartPos;
  39758. private _deltaJoystickVector;
  39759. private _leftJoystick;
  39760. private _touches;
  39761. private _onPointerDownHandlerRef;
  39762. private _onPointerMoveHandlerRef;
  39763. private _onPointerUpHandlerRef;
  39764. private _onResize;
  39765. /**
  39766. * Creates a new virtual joystick
  39767. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39768. */
  39769. constructor(leftJoystick?: boolean);
  39770. /**
  39771. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39772. * @param newJoystickSensibility defines the new sensibility
  39773. */
  39774. setJoystickSensibility(newJoystickSensibility: number): void;
  39775. private _onPointerDown;
  39776. private _onPointerMove;
  39777. private _onPointerUp;
  39778. /**
  39779. * Change the color of the virtual joystick
  39780. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39781. */
  39782. setJoystickColor(newColor: string): void;
  39783. /**
  39784. * Defines a callback to call when the joystick is touched
  39785. * @param action defines the callback
  39786. */
  39787. setActionOnTouch(action: () => any): void;
  39788. /**
  39789. * Defines which axis you'd like to control for left & right
  39790. * @param axis defines the axis to use
  39791. */
  39792. setAxisForLeftRight(axis: JoystickAxis): void;
  39793. /**
  39794. * Defines which axis you'd like to control for up & down
  39795. * @param axis defines the axis to use
  39796. */
  39797. setAxisForUpDown(axis: JoystickAxis): void;
  39798. private _drawVirtualJoystick;
  39799. /**
  39800. * Release internal HTML canvas
  39801. */
  39802. releaseCanvas(): void;
  39803. }
  39804. }
  39805. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39806. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39807. import { Nullable } from "babylonjs/types";
  39808. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39809. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39810. module "babylonjs/Cameras/freeCameraInputsManager" {
  39811. interface FreeCameraInputsManager {
  39812. /**
  39813. * Add virtual joystick input support to the input manager.
  39814. * @returns the current input manager
  39815. */
  39816. addVirtualJoystick(): FreeCameraInputsManager;
  39817. }
  39818. }
  39819. /**
  39820. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39822. */
  39823. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39824. /**
  39825. * Defines the camera the input is attached to.
  39826. */
  39827. camera: FreeCamera;
  39828. private _leftjoystick;
  39829. private _rightjoystick;
  39830. /**
  39831. * Gets the left stick of the virtual joystick.
  39832. * @returns The virtual Joystick
  39833. */
  39834. getLeftJoystick(): VirtualJoystick;
  39835. /**
  39836. * Gets the right stick of the virtual joystick.
  39837. * @returns The virtual Joystick
  39838. */
  39839. getRightJoystick(): VirtualJoystick;
  39840. /**
  39841. * Update the current camera state depending on the inputs that have been used this frame.
  39842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39843. */
  39844. checkInputs(): void;
  39845. /**
  39846. * Attach the input controls to a specific dom element to get the input from.
  39847. * @param element Defines the element the controls should be listened from
  39848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39849. */
  39850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39851. /**
  39852. * Detach the current controls from the specified dom element.
  39853. * @param element Defines the element to stop listening the inputs from
  39854. */
  39855. detachControl(element: Nullable<HTMLElement>): void;
  39856. /**
  39857. * Gets the class name of the current intput.
  39858. * @returns the class name
  39859. */
  39860. getClassName(): string;
  39861. /**
  39862. * Get the friendly name associated with the input class.
  39863. * @returns the input friendly name
  39864. */
  39865. getSimpleName(): string;
  39866. }
  39867. }
  39868. declare module "babylonjs/Cameras/Inputs/index" {
  39869. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39870. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39871. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39872. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39873. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39874. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39875. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39876. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39877. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39878. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39879. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39880. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39881. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39882. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39883. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39884. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39885. }
  39886. declare module "babylonjs/Cameras/touchCamera" {
  39887. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39888. import { Scene } from "babylonjs/scene";
  39889. import { Vector3 } from "babylonjs/Maths/math.vector";
  39890. /**
  39891. * This represents a FPS type of camera controlled by touch.
  39892. * This is like a universal camera minus the Gamepad controls.
  39893. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39894. */
  39895. export class TouchCamera extends FreeCamera {
  39896. /**
  39897. * Defines the touch sensibility for rotation.
  39898. * The higher the faster.
  39899. */
  39900. touchAngularSensibility: number;
  39901. /**
  39902. * Defines the touch sensibility for move.
  39903. * The higher the faster.
  39904. */
  39905. touchMoveSensibility: number;
  39906. /**
  39907. * Instantiates a new touch camera.
  39908. * This represents a FPS type of camera controlled by touch.
  39909. * This is like a universal camera minus the Gamepad controls.
  39910. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39911. * @param name Define the name of the camera in the scene
  39912. * @param position Define the start position of the camera in the scene
  39913. * @param scene Define the scene the camera belongs to
  39914. */
  39915. constructor(name: string, position: Vector3, scene: Scene);
  39916. /**
  39917. * Gets the current object class name.
  39918. * @return the class name
  39919. */
  39920. getClassName(): string;
  39921. /** @hidden */
  39922. _setupInputs(): void;
  39923. }
  39924. }
  39925. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39926. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39927. import { Scene } from "babylonjs/scene";
  39928. import { Vector3 } from "babylonjs/Maths/math.vector";
  39929. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39930. import { Axis } from "babylonjs/Maths/math.axis";
  39931. /**
  39932. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39933. * being tilted forward or back and left or right.
  39934. */
  39935. export class DeviceOrientationCamera extends FreeCamera {
  39936. private _initialQuaternion;
  39937. private _quaternionCache;
  39938. private _tmpDragQuaternion;
  39939. private _disablePointerInputWhenUsingDeviceOrientation;
  39940. /**
  39941. * Creates a new device orientation camera
  39942. * @param name The name of the camera
  39943. * @param position The start position camera
  39944. * @param scene The scene the camera belongs to
  39945. */
  39946. constructor(name: string, position: Vector3, scene: Scene);
  39947. /**
  39948. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39949. */
  39950. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39951. private _dragFactor;
  39952. /**
  39953. * Enabled turning on the y axis when the orientation sensor is active
  39954. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39955. */
  39956. enableHorizontalDragging(dragFactor?: number): void;
  39957. /**
  39958. * Gets the current instance class name ("DeviceOrientationCamera").
  39959. * This helps avoiding instanceof at run time.
  39960. * @returns the class name
  39961. */
  39962. getClassName(): string;
  39963. /**
  39964. * @hidden
  39965. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39966. */
  39967. _checkInputs(): void;
  39968. /**
  39969. * Reset the camera to its default orientation on the specified axis only.
  39970. * @param axis The axis to reset
  39971. */
  39972. resetToCurrentRotation(axis?: Axis): void;
  39973. }
  39974. }
  39975. declare module "babylonjs/Gamepads/xboxGamepad" {
  39976. import { Observable } from "babylonjs/Misc/observable";
  39977. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39978. /**
  39979. * Defines supported buttons for XBox360 compatible gamepads
  39980. */
  39981. export enum Xbox360Button {
  39982. /** A */
  39983. A = 0,
  39984. /** B */
  39985. B = 1,
  39986. /** X */
  39987. X = 2,
  39988. /** Y */
  39989. Y = 3,
  39990. /** Start */
  39991. Start = 4,
  39992. /** Back */
  39993. Back = 5,
  39994. /** Left button */
  39995. LB = 6,
  39996. /** Right button */
  39997. RB = 7,
  39998. /** Left stick */
  39999. LeftStick = 8,
  40000. /** Right stick */
  40001. RightStick = 9
  40002. }
  40003. /** Defines values for XBox360 DPad */
  40004. export enum Xbox360Dpad {
  40005. /** Up */
  40006. Up = 0,
  40007. /** Down */
  40008. Down = 1,
  40009. /** Left */
  40010. Left = 2,
  40011. /** Right */
  40012. Right = 3
  40013. }
  40014. /**
  40015. * Defines a XBox360 gamepad
  40016. */
  40017. export class Xbox360Pad extends Gamepad {
  40018. private _leftTrigger;
  40019. private _rightTrigger;
  40020. private _onlefttriggerchanged;
  40021. private _onrighttriggerchanged;
  40022. private _onbuttondown;
  40023. private _onbuttonup;
  40024. private _ondpaddown;
  40025. private _ondpadup;
  40026. /** Observable raised when a button is pressed */
  40027. onButtonDownObservable: Observable<Xbox360Button>;
  40028. /** Observable raised when a button is released */
  40029. onButtonUpObservable: Observable<Xbox360Button>;
  40030. /** Observable raised when a pad is pressed */
  40031. onPadDownObservable: Observable<Xbox360Dpad>;
  40032. /** Observable raised when a pad is released */
  40033. onPadUpObservable: Observable<Xbox360Dpad>;
  40034. private _buttonA;
  40035. private _buttonB;
  40036. private _buttonX;
  40037. private _buttonY;
  40038. private _buttonBack;
  40039. private _buttonStart;
  40040. private _buttonLB;
  40041. private _buttonRB;
  40042. private _buttonLeftStick;
  40043. private _buttonRightStick;
  40044. private _dPadUp;
  40045. private _dPadDown;
  40046. private _dPadLeft;
  40047. private _dPadRight;
  40048. private _isXboxOnePad;
  40049. /**
  40050. * Creates a new XBox360 gamepad object
  40051. * @param id defines the id of this gamepad
  40052. * @param index defines its index
  40053. * @param gamepad defines the internal HTML gamepad object
  40054. * @param xboxOne defines if it is a XBox One gamepad
  40055. */
  40056. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40057. /**
  40058. * Defines the callback to call when left trigger is pressed
  40059. * @param callback defines the callback to use
  40060. */
  40061. onlefttriggerchanged(callback: (value: number) => void): void;
  40062. /**
  40063. * Defines the callback to call when right trigger is pressed
  40064. * @param callback defines the callback to use
  40065. */
  40066. onrighttriggerchanged(callback: (value: number) => void): void;
  40067. /**
  40068. * Gets the left trigger value
  40069. */
  40070. /**
  40071. * Sets the left trigger value
  40072. */
  40073. leftTrigger: number;
  40074. /**
  40075. * Gets the right trigger value
  40076. */
  40077. /**
  40078. * Sets the right trigger value
  40079. */
  40080. rightTrigger: number;
  40081. /**
  40082. * Defines the callback to call when a button is pressed
  40083. * @param callback defines the callback to use
  40084. */
  40085. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40086. /**
  40087. * Defines the callback to call when a button is released
  40088. * @param callback defines the callback to use
  40089. */
  40090. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40091. /**
  40092. * Defines the callback to call when a pad is pressed
  40093. * @param callback defines the callback to use
  40094. */
  40095. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40096. /**
  40097. * Defines the callback to call when a pad is released
  40098. * @param callback defines the callback to use
  40099. */
  40100. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40101. private _setButtonValue;
  40102. private _setDPadValue;
  40103. /**
  40104. * Gets the value of the `A` button
  40105. */
  40106. /**
  40107. * Sets the value of the `A` button
  40108. */
  40109. buttonA: number;
  40110. /**
  40111. * Gets the value of the `B` button
  40112. */
  40113. /**
  40114. * Sets the value of the `B` button
  40115. */
  40116. buttonB: number;
  40117. /**
  40118. * Gets the value of the `X` button
  40119. */
  40120. /**
  40121. * Sets the value of the `X` button
  40122. */
  40123. buttonX: number;
  40124. /**
  40125. * Gets the value of the `Y` button
  40126. */
  40127. /**
  40128. * Sets the value of the `Y` button
  40129. */
  40130. buttonY: number;
  40131. /**
  40132. * Gets the value of the `Start` button
  40133. */
  40134. /**
  40135. * Sets the value of the `Start` button
  40136. */
  40137. buttonStart: number;
  40138. /**
  40139. * Gets the value of the `Back` button
  40140. */
  40141. /**
  40142. * Sets the value of the `Back` button
  40143. */
  40144. buttonBack: number;
  40145. /**
  40146. * Gets the value of the `Left` button
  40147. */
  40148. /**
  40149. * Sets the value of the `Left` button
  40150. */
  40151. buttonLB: number;
  40152. /**
  40153. * Gets the value of the `Right` button
  40154. */
  40155. /**
  40156. * Sets the value of the `Right` button
  40157. */
  40158. buttonRB: number;
  40159. /**
  40160. * Gets the value of the Left joystick
  40161. */
  40162. /**
  40163. * Sets the value of the Left joystick
  40164. */
  40165. buttonLeftStick: number;
  40166. /**
  40167. * Gets the value of the Right joystick
  40168. */
  40169. /**
  40170. * Sets the value of the Right joystick
  40171. */
  40172. buttonRightStick: number;
  40173. /**
  40174. * Gets the value of D-pad up
  40175. */
  40176. /**
  40177. * Sets the value of D-pad up
  40178. */
  40179. dPadUp: number;
  40180. /**
  40181. * Gets the value of D-pad down
  40182. */
  40183. /**
  40184. * Sets the value of D-pad down
  40185. */
  40186. dPadDown: number;
  40187. /**
  40188. * Gets the value of D-pad left
  40189. */
  40190. /**
  40191. * Sets the value of D-pad left
  40192. */
  40193. dPadLeft: number;
  40194. /**
  40195. * Gets the value of D-pad right
  40196. */
  40197. /**
  40198. * Sets the value of D-pad right
  40199. */
  40200. dPadRight: number;
  40201. /**
  40202. * Force the gamepad to synchronize with device values
  40203. */
  40204. update(): void;
  40205. /**
  40206. * Disposes the gamepad
  40207. */
  40208. dispose(): void;
  40209. }
  40210. }
  40211. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40212. import { Observable } from "babylonjs/Misc/observable";
  40213. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40214. /**
  40215. * Defines supported buttons for DualShock compatible gamepads
  40216. */
  40217. export enum DualShockButton {
  40218. /** Cross */
  40219. Cross = 0,
  40220. /** Circle */
  40221. Circle = 1,
  40222. /** Square */
  40223. Square = 2,
  40224. /** Triangle */
  40225. Triangle = 3,
  40226. /** Options */
  40227. Options = 4,
  40228. /** Share */
  40229. Share = 5,
  40230. /** L1 */
  40231. L1 = 6,
  40232. /** R1 */
  40233. R1 = 7,
  40234. /** Left stick */
  40235. LeftStick = 8,
  40236. /** Right stick */
  40237. RightStick = 9
  40238. }
  40239. /** Defines values for DualShock DPad */
  40240. export enum DualShockDpad {
  40241. /** Up */
  40242. Up = 0,
  40243. /** Down */
  40244. Down = 1,
  40245. /** Left */
  40246. Left = 2,
  40247. /** Right */
  40248. Right = 3
  40249. }
  40250. /**
  40251. * Defines a DualShock gamepad
  40252. */
  40253. export class DualShockPad extends Gamepad {
  40254. private _leftTrigger;
  40255. private _rightTrigger;
  40256. private _onlefttriggerchanged;
  40257. private _onrighttriggerchanged;
  40258. private _onbuttondown;
  40259. private _onbuttonup;
  40260. private _ondpaddown;
  40261. private _ondpadup;
  40262. /** Observable raised when a button is pressed */
  40263. onButtonDownObservable: Observable<DualShockButton>;
  40264. /** Observable raised when a button is released */
  40265. onButtonUpObservable: Observable<DualShockButton>;
  40266. /** Observable raised when a pad is pressed */
  40267. onPadDownObservable: Observable<DualShockDpad>;
  40268. /** Observable raised when a pad is released */
  40269. onPadUpObservable: Observable<DualShockDpad>;
  40270. private _buttonCross;
  40271. private _buttonCircle;
  40272. private _buttonSquare;
  40273. private _buttonTriangle;
  40274. private _buttonShare;
  40275. private _buttonOptions;
  40276. private _buttonL1;
  40277. private _buttonR1;
  40278. private _buttonLeftStick;
  40279. private _buttonRightStick;
  40280. private _dPadUp;
  40281. private _dPadDown;
  40282. private _dPadLeft;
  40283. private _dPadRight;
  40284. /**
  40285. * Creates a new DualShock gamepad object
  40286. * @param id defines the id of this gamepad
  40287. * @param index defines its index
  40288. * @param gamepad defines the internal HTML gamepad object
  40289. */
  40290. constructor(id: string, index: number, gamepad: any);
  40291. /**
  40292. * Defines the callback to call when left trigger is pressed
  40293. * @param callback defines the callback to use
  40294. */
  40295. onlefttriggerchanged(callback: (value: number) => void): void;
  40296. /**
  40297. * Defines the callback to call when right trigger is pressed
  40298. * @param callback defines the callback to use
  40299. */
  40300. onrighttriggerchanged(callback: (value: number) => void): void;
  40301. /**
  40302. * Gets the left trigger value
  40303. */
  40304. /**
  40305. * Sets the left trigger value
  40306. */
  40307. leftTrigger: number;
  40308. /**
  40309. * Gets the right trigger value
  40310. */
  40311. /**
  40312. * Sets the right trigger value
  40313. */
  40314. rightTrigger: number;
  40315. /**
  40316. * Defines the callback to call when a button is pressed
  40317. * @param callback defines the callback to use
  40318. */
  40319. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40320. /**
  40321. * Defines the callback to call when a button is released
  40322. * @param callback defines the callback to use
  40323. */
  40324. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40325. /**
  40326. * Defines the callback to call when a pad is pressed
  40327. * @param callback defines the callback to use
  40328. */
  40329. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40330. /**
  40331. * Defines the callback to call when a pad is released
  40332. * @param callback defines the callback to use
  40333. */
  40334. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40335. private _setButtonValue;
  40336. private _setDPadValue;
  40337. /**
  40338. * Gets the value of the `Cross` button
  40339. */
  40340. /**
  40341. * Sets the value of the `Cross` button
  40342. */
  40343. buttonCross: number;
  40344. /**
  40345. * Gets the value of the `Circle` button
  40346. */
  40347. /**
  40348. * Sets the value of the `Circle` button
  40349. */
  40350. buttonCircle: number;
  40351. /**
  40352. * Gets the value of the `Square` button
  40353. */
  40354. /**
  40355. * Sets the value of the `Square` button
  40356. */
  40357. buttonSquare: number;
  40358. /**
  40359. * Gets the value of the `Triangle` button
  40360. */
  40361. /**
  40362. * Sets the value of the `Triangle` button
  40363. */
  40364. buttonTriangle: number;
  40365. /**
  40366. * Gets the value of the `Options` button
  40367. */
  40368. /**
  40369. * Sets the value of the `Options` button
  40370. */
  40371. buttonOptions: number;
  40372. /**
  40373. * Gets the value of the `Share` button
  40374. */
  40375. /**
  40376. * Sets the value of the `Share` button
  40377. */
  40378. buttonShare: number;
  40379. /**
  40380. * Gets the value of the `L1` button
  40381. */
  40382. /**
  40383. * Sets the value of the `L1` button
  40384. */
  40385. buttonL1: number;
  40386. /**
  40387. * Gets the value of the `R1` button
  40388. */
  40389. /**
  40390. * Sets the value of the `R1` button
  40391. */
  40392. buttonR1: number;
  40393. /**
  40394. * Gets the value of the Left joystick
  40395. */
  40396. /**
  40397. * Sets the value of the Left joystick
  40398. */
  40399. buttonLeftStick: number;
  40400. /**
  40401. * Gets the value of the Right joystick
  40402. */
  40403. /**
  40404. * Sets the value of the Right joystick
  40405. */
  40406. buttonRightStick: number;
  40407. /**
  40408. * Gets the value of D-pad up
  40409. */
  40410. /**
  40411. * Sets the value of D-pad up
  40412. */
  40413. dPadUp: number;
  40414. /**
  40415. * Gets the value of D-pad down
  40416. */
  40417. /**
  40418. * Sets the value of D-pad down
  40419. */
  40420. dPadDown: number;
  40421. /**
  40422. * Gets the value of D-pad left
  40423. */
  40424. /**
  40425. * Sets the value of D-pad left
  40426. */
  40427. dPadLeft: number;
  40428. /**
  40429. * Gets the value of D-pad right
  40430. */
  40431. /**
  40432. * Sets the value of D-pad right
  40433. */
  40434. dPadRight: number;
  40435. /**
  40436. * Force the gamepad to synchronize with device values
  40437. */
  40438. update(): void;
  40439. /**
  40440. * Disposes the gamepad
  40441. */
  40442. dispose(): void;
  40443. }
  40444. }
  40445. declare module "babylonjs/Gamepads/gamepadManager" {
  40446. import { Observable } from "babylonjs/Misc/observable";
  40447. import { Nullable } from "babylonjs/types";
  40448. import { Scene } from "babylonjs/scene";
  40449. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40450. /**
  40451. * Manager for handling gamepads
  40452. */
  40453. export class GamepadManager {
  40454. private _scene?;
  40455. private _babylonGamepads;
  40456. private _oneGamepadConnected;
  40457. /** @hidden */
  40458. _isMonitoring: boolean;
  40459. private _gamepadEventSupported;
  40460. private _gamepadSupport;
  40461. /**
  40462. * observable to be triggered when the gamepad controller has been connected
  40463. */
  40464. onGamepadConnectedObservable: Observable<Gamepad>;
  40465. /**
  40466. * observable to be triggered when the gamepad controller has been disconnected
  40467. */
  40468. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40469. private _onGamepadConnectedEvent;
  40470. private _onGamepadDisconnectedEvent;
  40471. /**
  40472. * Initializes the gamepad manager
  40473. * @param _scene BabylonJS scene
  40474. */
  40475. constructor(_scene?: Scene | undefined);
  40476. /**
  40477. * The gamepads in the game pad manager
  40478. */
  40479. readonly gamepads: Gamepad[];
  40480. /**
  40481. * Get the gamepad controllers based on type
  40482. * @param type The type of gamepad controller
  40483. * @returns Nullable gamepad
  40484. */
  40485. getGamepadByType(type?: number): Nullable<Gamepad>;
  40486. /**
  40487. * Disposes the gamepad manager
  40488. */
  40489. dispose(): void;
  40490. private _addNewGamepad;
  40491. private _startMonitoringGamepads;
  40492. private _stopMonitoringGamepads;
  40493. /** @hidden */
  40494. _checkGamepadsStatus(): void;
  40495. private _updateGamepadObjects;
  40496. }
  40497. }
  40498. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40499. import { Nullable } from "babylonjs/types";
  40500. import { Scene } from "babylonjs/scene";
  40501. import { ISceneComponent } from "babylonjs/sceneComponent";
  40502. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40503. module "babylonjs/scene" {
  40504. interface Scene {
  40505. /** @hidden */
  40506. _gamepadManager: Nullable<GamepadManager>;
  40507. /**
  40508. * Gets the gamepad manager associated with the scene
  40509. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40510. */
  40511. gamepadManager: GamepadManager;
  40512. }
  40513. }
  40514. module "babylonjs/Cameras/freeCameraInputsManager" {
  40515. /**
  40516. * Interface representing a free camera inputs manager
  40517. */
  40518. interface FreeCameraInputsManager {
  40519. /**
  40520. * Adds gamepad input support to the FreeCameraInputsManager.
  40521. * @returns the FreeCameraInputsManager
  40522. */
  40523. addGamepad(): FreeCameraInputsManager;
  40524. }
  40525. }
  40526. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40527. /**
  40528. * Interface representing an arc rotate camera inputs manager
  40529. */
  40530. interface ArcRotateCameraInputsManager {
  40531. /**
  40532. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40533. * @returns the camera inputs manager
  40534. */
  40535. addGamepad(): ArcRotateCameraInputsManager;
  40536. }
  40537. }
  40538. /**
  40539. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40540. */
  40541. export class GamepadSystemSceneComponent implements ISceneComponent {
  40542. /**
  40543. * The component name helpfull to identify the component in the list of scene components.
  40544. */
  40545. readonly name: string;
  40546. /**
  40547. * The scene the component belongs to.
  40548. */
  40549. scene: Scene;
  40550. /**
  40551. * Creates a new instance of the component for the given scene
  40552. * @param scene Defines the scene to register the component in
  40553. */
  40554. constructor(scene: Scene);
  40555. /**
  40556. * Registers the component in a given scene
  40557. */
  40558. register(): void;
  40559. /**
  40560. * Rebuilds the elements related to this component in case of
  40561. * context lost for instance.
  40562. */
  40563. rebuild(): void;
  40564. /**
  40565. * Disposes the component and the associated ressources
  40566. */
  40567. dispose(): void;
  40568. private _beforeCameraUpdate;
  40569. }
  40570. }
  40571. declare module "babylonjs/Cameras/universalCamera" {
  40572. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40573. import { Scene } from "babylonjs/scene";
  40574. import { Vector3 } from "babylonjs/Maths/math.vector";
  40575. import "babylonjs/Gamepads/gamepadSceneComponent";
  40576. /**
  40577. * 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,
  40578. * which still works and will still be found in many Playgrounds.
  40579. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40580. */
  40581. export class UniversalCamera extends TouchCamera {
  40582. /**
  40583. * Defines the gamepad rotation sensiblity.
  40584. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40585. */
  40586. gamepadAngularSensibility: number;
  40587. /**
  40588. * Defines the gamepad move sensiblity.
  40589. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40590. */
  40591. gamepadMoveSensibility: number;
  40592. /**
  40593. * 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,
  40594. * which still works and will still be found in many Playgrounds.
  40595. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40596. * @param name Define the name of the camera in the scene
  40597. * @param position Define the start position of the camera in the scene
  40598. * @param scene Define the scene the camera belongs to
  40599. */
  40600. constructor(name: string, position: Vector3, scene: Scene);
  40601. /**
  40602. * Gets the current object class name.
  40603. * @return the class name
  40604. */
  40605. getClassName(): string;
  40606. }
  40607. }
  40608. declare module "babylonjs/Cameras/gamepadCamera" {
  40609. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40610. import { Scene } from "babylonjs/scene";
  40611. import { Vector3 } from "babylonjs/Maths/math.vector";
  40612. /**
  40613. * This represents a FPS type of camera. This is only here for back compat purpose.
  40614. * Please use the UniversalCamera instead as both are identical.
  40615. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40616. */
  40617. export class GamepadCamera extends UniversalCamera {
  40618. /**
  40619. * Instantiates a new Gamepad Camera
  40620. * This represents a FPS type of camera. This is only here for back compat purpose.
  40621. * Please use the UniversalCamera instead as both are identical.
  40622. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40623. * @param name Define the name of the camera in the scene
  40624. * @param position Define the start position of the camera in the scene
  40625. * @param scene Define the scene the camera belongs to
  40626. */
  40627. constructor(name: string, position: Vector3, scene: Scene);
  40628. /**
  40629. * Gets the current object class name.
  40630. * @return the class name
  40631. */
  40632. getClassName(): string;
  40633. }
  40634. }
  40635. declare module "babylonjs/Shaders/pass.fragment" {
  40636. /** @hidden */
  40637. export var passPixelShader: {
  40638. name: string;
  40639. shader: string;
  40640. };
  40641. }
  40642. declare module "babylonjs/Shaders/passCube.fragment" {
  40643. /** @hidden */
  40644. export var passCubePixelShader: {
  40645. name: string;
  40646. shader: string;
  40647. };
  40648. }
  40649. declare module "babylonjs/PostProcesses/passPostProcess" {
  40650. import { Nullable } from "babylonjs/types";
  40651. import { Camera } from "babylonjs/Cameras/camera";
  40652. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40653. import { Engine } from "babylonjs/Engines/engine";
  40654. import "babylonjs/Shaders/pass.fragment";
  40655. import "babylonjs/Shaders/passCube.fragment";
  40656. /**
  40657. * PassPostProcess which produces an output the same as it's input
  40658. */
  40659. export class PassPostProcess extends PostProcess {
  40660. /**
  40661. * Creates the PassPostProcess
  40662. * @param name The name of the effect.
  40663. * @param options The required width/height ratio to downsize to before computing the render pass.
  40664. * @param camera The camera to apply the render pass to.
  40665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40666. * @param engine The engine which the post process will be applied. (default: current engine)
  40667. * @param reusable If the post process can be reused on the same frame. (default: false)
  40668. * @param textureType The type of texture to be used when performing the post processing.
  40669. * @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)
  40670. */
  40671. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40672. }
  40673. /**
  40674. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40675. */
  40676. export class PassCubePostProcess extends PostProcess {
  40677. private _face;
  40678. /**
  40679. * Gets or sets the cube face to display.
  40680. * * 0 is +X
  40681. * * 1 is -X
  40682. * * 2 is +Y
  40683. * * 3 is -Y
  40684. * * 4 is +Z
  40685. * * 5 is -Z
  40686. */
  40687. face: number;
  40688. /**
  40689. * Creates the PassCubePostProcess
  40690. * @param name The name of the effect.
  40691. * @param options The required width/height ratio to downsize to before computing the render pass.
  40692. * @param camera The camera to apply the render pass to.
  40693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40694. * @param engine The engine which the post process will be applied. (default: current engine)
  40695. * @param reusable If the post process can be reused on the same frame. (default: false)
  40696. * @param textureType The type of texture to be used when performing the post processing.
  40697. * @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)
  40698. */
  40699. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40700. }
  40701. }
  40702. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40703. /** @hidden */
  40704. export var anaglyphPixelShader: {
  40705. name: string;
  40706. shader: string;
  40707. };
  40708. }
  40709. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40710. import { Engine } from "babylonjs/Engines/engine";
  40711. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40712. import { Camera } from "babylonjs/Cameras/camera";
  40713. import "babylonjs/Shaders/anaglyph.fragment";
  40714. /**
  40715. * Postprocess used to generate anaglyphic rendering
  40716. */
  40717. export class AnaglyphPostProcess extends PostProcess {
  40718. private _passedProcess;
  40719. /**
  40720. * Creates a new AnaglyphPostProcess
  40721. * @param name defines postprocess name
  40722. * @param options defines creation options or target ratio scale
  40723. * @param rigCameras defines cameras using this postprocess
  40724. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40725. * @param engine defines hosting engine
  40726. * @param reusable defines if the postprocess will be reused multiple times per frame
  40727. */
  40728. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40729. }
  40730. }
  40731. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40732. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40733. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40734. import { Scene } from "babylonjs/scene";
  40735. import { Vector3 } from "babylonjs/Maths/math.vector";
  40736. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40737. /**
  40738. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40739. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40740. */
  40741. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40742. /**
  40743. * Creates a new AnaglyphArcRotateCamera
  40744. * @param name defines camera name
  40745. * @param alpha defines alpha angle (in radians)
  40746. * @param beta defines beta angle (in radians)
  40747. * @param radius defines radius
  40748. * @param target defines camera target
  40749. * @param interaxialDistance defines distance between each color axis
  40750. * @param scene defines the hosting scene
  40751. */
  40752. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40753. /**
  40754. * Gets camera class name
  40755. * @returns AnaglyphArcRotateCamera
  40756. */
  40757. getClassName(): string;
  40758. }
  40759. }
  40760. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40761. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40762. import { Scene } from "babylonjs/scene";
  40763. import { Vector3 } from "babylonjs/Maths/math.vector";
  40764. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40765. /**
  40766. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40767. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40768. */
  40769. export class AnaglyphFreeCamera extends FreeCamera {
  40770. /**
  40771. * Creates a new AnaglyphFreeCamera
  40772. * @param name defines camera name
  40773. * @param position defines initial position
  40774. * @param interaxialDistance defines distance between each color axis
  40775. * @param scene defines the hosting scene
  40776. */
  40777. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40778. /**
  40779. * Gets camera class name
  40780. * @returns AnaglyphFreeCamera
  40781. */
  40782. getClassName(): string;
  40783. }
  40784. }
  40785. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40786. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40787. import { Scene } from "babylonjs/scene";
  40788. import { Vector3 } from "babylonjs/Maths/math.vector";
  40789. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40790. /**
  40791. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40792. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40793. */
  40794. export class AnaglyphGamepadCamera extends GamepadCamera {
  40795. /**
  40796. * Creates a new AnaglyphGamepadCamera
  40797. * @param name defines camera name
  40798. * @param position defines initial position
  40799. * @param interaxialDistance defines distance between each color axis
  40800. * @param scene defines the hosting scene
  40801. */
  40802. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40803. /**
  40804. * Gets camera class name
  40805. * @returns AnaglyphGamepadCamera
  40806. */
  40807. getClassName(): string;
  40808. }
  40809. }
  40810. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40811. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40812. import { Scene } from "babylonjs/scene";
  40813. import { Vector3 } from "babylonjs/Maths/math.vector";
  40814. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40815. /**
  40816. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40817. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40818. */
  40819. export class AnaglyphUniversalCamera extends UniversalCamera {
  40820. /**
  40821. * Creates a new AnaglyphUniversalCamera
  40822. * @param name defines camera name
  40823. * @param position defines initial position
  40824. * @param interaxialDistance defines distance between each color axis
  40825. * @param scene defines the hosting scene
  40826. */
  40827. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40828. /**
  40829. * Gets camera class name
  40830. * @returns AnaglyphUniversalCamera
  40831. */
  40832. getClassName(): string;
  40833. }
  40834. }
  40835. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40836. /** @hidden */
  40837. export var stereoscopicInterlacePixelShader: {
  40838. name: string;
  40839. shader: string;
  40840. };
  40841. }
  40842. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40843. import { Camera } from "babylonjs/Cameras/camera";
  40844. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40845. import { Engine } from "babylonjs/Engines/engine";
  40846. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40847. /**
  40848. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40849. */
  40850. export class StereoscopicInterlacePostProcess extends PostProcess {
  40851. private _stepSize;
  40852. private _passedProcess;
  40853. /**
  40854. * Initializes a StereoscopicInterlacePostProcess
  40855. * @param name The name of the effect.
  40856. * @param rigCameras The rig cameras to be appled to the post process
  40857. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40859. * @param engine The engine which the post process will be applied. (default: current engine)
  40860. * @param reusable If the post process can be reused on the same frame. (default: false)
  40861. */
  40862. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40863. }
  40864. }
  40865. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40866. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40867. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40868. import { Scene } from "babylonjs/scene";
  40869. import { Vector3 } from "babylonjs/Maths/math.vector";
  40870. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40871. /**
  40872. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40873. * @see http://doc.babylonjs.com/features/cameras
  40874. */
  40875. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40876. /**
  40877. * Creates a new StereoscopicArcRotateCamera
  40878. * @param name defines camera name
  40879. * @param alpha defines alpha angle (in radians)
  40880. * @param beta defines beta angle (in radians)
  40881. * @param radius defines radius
  40882. * @param target defines camera target
  40883. * @param interaxialDistance defines distance between each color axis
  40884. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40885. * @param scene defines the hosting scene
  40886. */
  40887. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40888. /**
  40889. * Gets camera class name
  40890. * @returns StereoscopicArcRotateCamera
  40891. */
  40892. getClassName(): string;
  40893. }
  40894. }
  40895. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40896. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40897. import { Scene } from "babylonjs/scene";
  40898. import { Vector3 } from "babylonjs/Maths/math.vector";
  40899. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40900. /**
  40901. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40902. * @see http://doc.babylonjs.com/features/cameras
  40903. */
  40904. export class StereoscopicFreeCamera extends FreeCamera {
  40905. /**
  40906. * Creates a new StereoscopicFreeCamera
  40907. * @param name defines camera name
  40908. * @param position defines initial position
  40909. * @param interaxialDistance defines distance between each color axis
  40910. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40911. * @param scene defines the hosting scene
  40912. */
  40913. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40914. /**
  40915. * Gets camera class name
  40916. * @returns StereoscopicFreeCamera
  40917. */
  40918. getClassName(): string;
  40919. }
  40920. }
  40921. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40922. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40923. import { Scene } from "babylonjs/scene";
  40924. import { Vector3 } from "babylonjs/Maths/math.vector";
  40925. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40926. /**
  40927. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40928. * @see http://doc.babylonjs.com/features/cameras
  40929. */
  40930. export class StereoscopicGamepadCamera extends GamepadCamera {
  40931. /**
  40932. * Creates a new StereoscopicGamepadCamera
  40933. * @param name defines camera name
  40934. * @param position defines initial position
  40935. * @param interaxialDistance defines distance between each color axis
  40936. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40937. * @param scene defines the hosting scene
  40938. */
  40939. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40940. /**
  40941. * Gets camera class name
  40942. * @returns StereoscopicGamepadCamera
  40943. */
  40944. getClassName(): string;
  40945. }
  40946. }
  40947. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40948. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40949. import { Scene } from "babylonjs/scene";
  40950. import { Vector3 } from "babylonjs/Maths/math.vector";
  40951. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40952. /**
  40953. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40954. * @see http://doc.babylonjs.com/features/cameras
  40955. */
  40956. export class StereoscopicUniversalCamera extends UniversalCamera {
  40957. /**
  40958. * Creates a new StereoscopicUniversalCamera
  40959. * @param name defines camera name
  40960. * @param position defines initial position
  40961. * @param interaxialDistance defines distance between each color axis
  40962. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40963. * @param scene defines the hosting scene
  40964. */
  40965. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40966. /**
  40967. * Gets camera class name
  40968. * @returns StereoscopicUniversalCamera
  40969. */
  40970. getClassName(): string;
  40971. }
  40972. }
  40973. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40974. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40975. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40976. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40977. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40978. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40979. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40980. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40981. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40982. }
  40983. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40984. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40985. import { Scene } from "babylonjs/scene";
  40986. import { Vector3 } from "babylonjs/Maths/math.vector";
  40987. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40988. /**
  40989. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40990. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40991. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40992. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40993. */
  40994. export class VirtualJoysticksCamera extends FreeCamera {
  40995. /**
  40996. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40997. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40998. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40999. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41000. * @param name Define the name of the camera in the scene
  41001. * @param position Define the start position of the camera in the scene
  41002. * @param scene Define the scene the camera belongs to
  41003. */
  41004. constructor(name: string, position: Vector3, scene: Scene);
  41005. /**
  41006. * Gets the current object class name.
  41007. * @return the class name
  41008. */
  41009. getClassName(): string;
  41010. }
  41011. }
  41012. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41013. import { Matrix } from "babylonjs/Maths/math.vector";
  41014. /**
  41015. * This represents all the required metrics to create a VR camera.
  41016. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41017. */
  41018. export class VRCameraMetrics {
  41019. /**
  41020. * Define the horizontal resolution off the screen.
  41021. */
  41022. hResolution: number;
  41023. /**
  41024. * Define the vertical resolution off the screen.
  41025. */
  41026. vResolution: number;
  41027. /**
  41028. * Define the horizontal screen size.
  41029. */
  41030. hScreenSize: number;
  41031. /**
  41032. * Define the vertical screen size.
  41033. */
  41034. vScreenSize: number;
  41035. /**
  41036. * Define the vertical screen center position.
  41037. */
  41038. vScreenCenter: number;
  41039. /**
  41040. * Define the distance of the eyes to the screen.
  41041. */
  41042. eyeToScreenDistance: number;
  41043. /**
  41044. * Define the distance between both lenses
  41045. */
  41046. lensSeparationDistance: number;
  41047. /**
  41048. * Define the distance between both viewer's eyes.
  41049. */
  41050. interpupillaryDistance: number;
  41051. /**
  41052. * Define the distortion factor of the VR postprocess.
  41053. * Please, touch with care.
  41054. */
  41055. distortionK: number[];
  41056. /**
  41057. * Define the chromatic aberration correction factors for the VR post process.
  41058. */
  41059. chromaAbCorrection: number[];
  41060. /**
  41061. * Define the scale factor of the post process.
  41062. * The smaller the better but the slower.
  41063. */
  41064. postProcessScaleFactor: number;
  41065. /**
  41066. * Define an offset for the lens center.
  41067. */
  41068. lensCenterOffset: number;
  41069. /**
  41070. * Define if the current vr camera should compensate the distortion of the lense or not.
  41071. */
  41072. compensateDistortion: boolean;
  41073. /**
  41074. * Defines if multiview should be enabled when rendering (Default: false)
  41075. */
  41076. multiviewEnabled: boolean;
  41077. /**
  41078. * Gets the rendering aspect ratio based on the provided resolutions.
  41079. */
  41080. readonly aspectRatio: number;
  41081. /**
  41082. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41083. */
  41084. readonly aspectRatioFov: number;
  41085. /**
  41086. * @hidden
  41087. */
  41088. readonly leftHMatrix: Matrix;
  41089. /**
  41090. * @hidden
  41091. */
  41092. readonly rightHMatrix: Matrix;
  41093. /**
  41094. * @hidden
  41095. */
  41096. readonly leftPreViewMatrix: Matrix;
  41097. /**
  41098. * @hidden
  41099. */
  41100. readonly rightPreViewMatrix: Matrix;
  41101. /**
  41102. * Get the default VRMetrics based on the most generic setup.
  41103. * @returns the default vr metrics
  41104. */
  41105. static GetDefault(): VRCameraMetrics;
  41106. }
  41107. }
  41108. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41109. /** @hidden */
  41110. export var vrDistortionCorrectionPixelShader: {
  41111. name: string;
  41112. shader: string;
  41113. };
  41114. }
  41115. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41116. import { Camera } from "babylonjs/Cameras/camera";
  41117. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41118. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41119. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41120. /**
  41121. * VRDistortionCorrectionPostProcess used for mobile VR
  41122. */
  41123. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41124. private _isRightEye;
  41125. private _distortionFactors;
  41126. private _postProcessScaleFactor;
  41127. private _lensCenterOffset;
  41128. private _scaleIn;
  41129. private _scaleFactor;
  41130. private _lensCenter;
  41131. /**
  41132. * Initializes the VRDistortionCorrectionPostProcess
  41133. * @param name The name of the effect.
  41134. * @param camera The camera to apply the render pass to.
  41135. * @param isRightEye If this is for the right eye distortion
  41136. * @param vrMetrics All the required metrics for the VR camera
  41137. */
  41138. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41139. }
  41140. }
  41141. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41142. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41143. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41144. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41145. import { Scene } from "babylonjs/scene";
  41146. import { Vector3 } from "babylonjs/Maths/math.vector";
  41147. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41148. import "babylonjs/Cameras/RigModes/vrRigMode";
  41149. /**
  41150. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41151. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41152. */
  41153. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41154. /**
  41155. * Creates a new VRDeviceOrientationArcRotateCamera
  41156. * @param name defines camera name
  41157. * @param alpha defines the camera rotation along the logitudinal axis
  41158. * @param beta defines the camera rotation along the latitudinal axis
  41159. * @param radius defines the camera distance from its target
  41160. * @param target defines the camera target
  41161. * @param scene defines the scene the camera belongs to
  41162. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41163. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41164. */
  41165. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41166. /**
  41167. * Gets camera class name
  41168. * @returns VRDeviceOrientationArcRotateCamera
  41169. */
  41170. getClassName(): string;
  41171. }
  41172. }
  41173. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41174. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41175. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41176. import { Scene } from "babylonjs/scene";
  41177. import { Vector3 } from "babylonjs/Maths/math.vector";
  41178. import "babylonjs/Cameras/RigModes/vrRigMode";
  41179. /**
  41180. * Camera used to simulate VR rendering (based on FreeCamera)
  41181. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41182. */
  41183. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41184. /**
  41185. * Creates a new VRDeviceOrientationFreeCamera
  41186. * @param name defines camera name
  41187. * @param position defines the start position of the camera
  41188. * @param scene defines the scene the camera belongs to
  41189. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41190. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41191. */
  41192. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41193. /**
  41194. * Gets camera class name
  41195. * @returns VRDeviceOrientationFreeCamera
  41196. */
  41197. getClassName(): string;
  41198. }
  41199. }
  41200. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41201. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41202. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41203. import { Scene } from "babylonjs/scene";
  41204. import { Vector3 } from "babylonjs/Maths/math.vector";
  41205. import "babylonjs/Gamepads/gamepadSceneComponent";
  41206. /**
  41207. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41208. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41209. */
  41210. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41211. /**
  41212. * Creates a new VRDeviceOrientationGamepadCamera
  41213. * @param name defines camera name
  41214. * @param position defines the start position of the camera
  41215. * @param scene defines the scene the camera belongs to
  41216. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41217. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41218. */
  41219. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41220. /**
  41221. * Gets camera class name
  41222. * @returns VRDeviceOrientationGamepadCamera
  41223. */
  41224. getClassName(): string;
  41225. }
  41226. }
  41227. declare module "babylonjs/Materials/pushMaterial" {
  41228. import { Nullable } from "babylonjs/types";
  41229. import { Scene } from "babylonjs/scene";
  41230. import { Matrix } from "babylonjs/Maths/math.vector";
  41231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41232. import { Mesh } from "babylonjs/Meshes/mesh";
  41233. import { Material } from "babylonjs/Materials/material";
  41234. import { Effect } from "babylonjs/Materials/effect";
  41235. /**
  41236. * Base class of materials working in push mode in babylon JS
  41237. * @hidden
  41238. */
  41239. export class PushMaterial extends Material {
  41240. protected _activeEffect: Effect;
  41241. protected _normalMatrix: Matrix;
  41242. /**
  41243. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41244. * This means that the material can keep using a previous shader while a new one is being compiled.
  41245. * This is mostly used when shader parallel compilation is supported (true by default)
  41246. */
  41247. allowShaderHotSwapping: boolean;
  41248. constructor(name: string, scene: Scene);
  41249. getEffect(): Effect;
  41250. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41251. /**
  41252. * Binds the given world matrix to the active effect
  41253. *
  41254. * @param world the matrix to bind
  41255. */
  41256. bindOnlyWorldMatrix(world: Matrix): void;
  41257. /**
  41258. * Binds the given normal matrix to the active effect
  41259. *
  41260. * @param normalMatrix the matrix to bind
  41261. */
  41262. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41263. bind(world: Matrix, mesh?: Mesh): void;
  41264. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41265. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41266. }
  41267. }
  41268. declare module "babylonjs/Materials/materialFlags" {
  41269. /**
  41270. * This groups all the flags used to control the materials channel.
  41271. */
  41272. export class MaterialFlags {
  41273. private static _DiffuseTextureEnabled;
  41274. /**
  41275. * Are diffuse textures enabled in the application.
  41276. */
  41277. static DiffuseTextureEnabled: boolean;
  41278. private static _AmbientTextureEnabled;
  41279. /**
  41280. * Are ambient textures enabled in the application.
  41281. */
  41282. static AmbientTextureEnabled: boolean;
  41283. private static _OpacityTextureEnabled;
  41284. /**
  41285. * Are opacity textures enabled in the application.
  41286. */
  41287. static OpacityTextureEnabled: boolean;
  41288. private static _ReflectionTextureEnabled;
  41289. /**
  41290. * Are reflection textures enabled in the application.
  41291. */
  41292. static ReflectionTextureEnabled: boolean;
  41293. private static _EmissiveTextureEnabled;
  41294. /**
  41295. * Are emissive textures enabled in the application.
  41296. */
  41297. static EmissiveTextureEnabled: boolean;
  41298. private static _SpecularTextureEnabled;
  41299. /**
  41300. * Are specular textures enabled in the application.
  41301. */
  41302. static SpecularTextureEnabled: boolean;
  41303. private static _BumpTextureEnabled;
  41304. /**
  41305. * Are bump textures enabled in the application.
  41306. */
  41307. static BumpTextureEnabled: boolean;
  41308. private static _LightmapTextureEnabled;
  41309. /**
  41310. * Are lightmap textures enabled in the application.
  41311. */
  41312. static LightmapTextureEnabled: boolean;
  41313. private static _RefractionTextureEnabled;
  41314. /**
  41315. * Are refraction textures enabled in the application.
  41316. */
  41317. static RefractionTextureEnabled: boolean;
  41318. private static _ColorGradingTextureEnabled;
  41319. /**
  41320. * Are color grading textures enabled in the application.
  41321. */
  41322. static ColorGradingTextureEnabled: boolean;
  41323. private static _FresnelEnabled;
  41324. /**
  41325. * Are fresnels enabled in the application.
  41326. */
  41327. static FresnelEnabled: boolean;
  41328. private static _ClearCoatTextureEnabled;
  41329. /**
  41330. * Are clear coat textures enabled in the application.
  41331. */
  41332. static ClearCoatTextureEnabled: boolean;
  41333. private static _ClearCoatBumpTextureEnabled;
  41334. /**
  41335. * Are clear coat bump textures enabled in the application.
  41336. */
  41337. static ClearCoatBumpTextureEnabled: boolean;
  41338. private static _ClearCoatTintTextureEnabled;
  41339. /**
  41340. * Are clear coat tint textures enabled in the application.
  41341. */
  41342. static ClearCoatTintTextureEnabled: boolean;
  41343. private static _SheenTextureEnabled;
  41344. /**
  41345. * Are sheen textures enabled in the application.
  41346. */
  41347. static SheenTextureEnabled: boolean;
  41348. private static _AnisotropicTextureEnabled;
  41349. /**
  41350. * Are anisotropic textures enabled in the application.
  41351. */
  41352. static AnisotropicTextureEnabled: boolean;
  41353. private static _ThicknessTextureEnabled;
  41354. /**
  41355. * Are thickness textures enabled in the application.
  41356. */
  41357. static ThicknessTextureEnabled: boolean;
  41358. }
  41359. }
  41360. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41361. /** @hidden */
  41362. export var defaultFragmentDeclaration: {
  41363. name: string;
  41364. shader: string;
  41365. };
  41366. }
  41367. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41368. /** @hidden */
  41369. export var defaultUboDeclaration: {
  41370. name: string;
  41371. shader: string;
  41372. };
  41373. }
  41374. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41375. /** @hidden */
  41376. export var lightFragmentDeclaration: {
  41377. name: string;
  41378. shader: string;
  41379. };
  41380. }
  41381. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41382. /** @hidden */
  41383. export var lightUboDeclaration: {
  41384. name: string;
  41385. shader: string;
  41386. };
  41387. }
  41388. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41389. /** @hidden */
  41390. export var lightsFragmentFunctions: {
  41391. name: string;
  41392. shader: string;
  41393. };
  41394. }
  41395. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41396. /** @hidden */
  41397. export var shadowsFragmentFunctions: {
  41398. name: string;
  41399. shader: string;
  41400. };
  41401. }
  41402. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41403. /** @hidden */
  41404. export var fresnelFunction: {
  41405. name: string;
  41406. shader: string;
  41407. };
  41408. }
  41409. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41410. /** @hidden */
  41411. export var reflectionFunction: {
  41412. name: string;
  41413. shader: string;
  41414. };
  41415. }
  41416. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41417. /** @hidden */
  41418. export var bumpFragmentFunctions: {
  41419. name: string;
  41420. shader: string;
  41421. };
  41422. }
  41423. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41424. /** @hidden */
  41425. export var logDepthDeclaration: {
  41426. name: string;
  41427. shader: string;
  41428. };
  41429. }
  41430. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41431. /** @hidden */
  41432. export var bumpFragment: {
  41433. name: string;
  41434. shader: string;
  41435. };
  41436. }
  41437. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41438. /** @hidden */
  41439. export var depthPrePass: {
  41440. name: string;
  41441. shader: string;
  41442. };
  41443. }
  41444. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41445. /** @hidden */
  41446. export var lightFragment: {
  41447. name: string;
  41448. shader: string;
  41449. };
  41450. }
  41451. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41452. /** @hidden */
  41453. export var logDepthFragment: {
  41454. name: string;
  41455. shader: string;
  41456. };
  41457. }
  41458. declare module "babylonjs/Shaders/default.fragment" {
  41459. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41460. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41461. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41462. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41463. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41464. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41465. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41466. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41467. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41468. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41469. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41470. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41471. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41472. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41473. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41474. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41475. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41476. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41477. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41478. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41479. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41480. /** @hidden */
  41481. export var defaultPixelShader: {
  41482. name: string;
  41483. shader: string;
  41484. };
  41485. }
  41486. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41487. /** @hidden */
  41488. export var defaultVertexDeclaration: {
  41489. name: string;
  41490. shader: string;
  41491. };
  41492. }
  41493. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41494. /** @hidden */
  41495. export var bumpVertexDeclaration: {
  41496. name: string;
  41497. shader: string;
  41498. };
  41499. }
  41500. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41501. /** @hidden */
  41502. export var bumpVertex: {
  41503. name: string;
  41504. shader: string;
  41505. };
  41506. }
  41507. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41508. /** @hidden */
  41509. export var fogVertex: {
  41510. name: string;
  41511. shader: string;
  41512. };
  41513. }
  41514. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41515. /** @hidden */
  41516. export var shadowsVertex: {
  41517. name: string;
  41518. shader: string;
  41519. };
  41520. }
  41521. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41522. /** @hidden */
  41523. export var pointCloudVertex: {
  41524. name: string;
  41525. shader: string;
  41526. };
  41527. }
  41528. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41529. /** @hidden */
  41530. export var logDepthVertex: {
  41531. name: string;
  41532. shader: string;
  41533. };
  41534. }
  41535. declare module "babylonjs/Shaders/default.vertex" {
  41536. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41537. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41538. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41539. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41540. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41541. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41542. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41543. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41544. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41545. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41548. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41549. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41550. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41551. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41552. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41553. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41554. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41555. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41556. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41557. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41558. /** @hidden */
  41559. export var defaultVertexShader: {
  41560. name: string;
  41561. shader: string;
  41562. };
  41563. }
  41564. declare module "babylonjs/Materials/standardMaterial" {
  41565. import { SmartArray } from "babylonjs/Misc/smartArray";
  41566. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41567. import { Nullable } from "babylonjs/types";
  41568. import { Scene } from "babylonjs/scene";
  41569. import { Matrix } from "babylonjs/Maths/math.vector";
  41570. import { Color3 } from "babylonjs/Maths/math.color";
  41571. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41573. import { Mesh } from "babylonjs/Meshes/mesh";
  41574. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41575. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41576. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41577. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41578. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41580. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41581. import "babylonjs/Shaders/default.fragment";
  41582. import "babylonjs/Shaders/default.vertex";
  41583. /** @hidden */
  41584. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41585. MAINUV1: boolean;
  41586. MAINUV2: boolean;
  41587. DIFFUSE: boolean;
  41588. DIFFUSEDIRECTUV: number;
  41589. AMBIENT: boolean;
  41590. AMBIENTDIRECTUV: number;
  41591. OPACITY: boolean;
  41592. OPACITYDIRECTUV: number;
  41593. OPACITYRGB: boolean;
  41594. REFLECTION: boolean;
  41595. EMISSIVE: boolean;
  41596. EMISSIVEDIRECTUV: number;
  41597. SPECULAR: boolean;
  41598. SPECULARDIRECTUV: number;
  41599. BUMP: boolean;
  41600. BUMPDIRECTUV: number;
  41601. PARALLAX: boolean;
  41602. PARALLAXOCCLUSION: boolean;
  41603. SPECULAROVERALPHA: boolean;
  41604. CLIPPLANE: boolean;
  41605. CLIPPLANE2: boolean;
  41606. CLIPPLANE3: boolean;
  41607. CLIPPLANE4: boolean;
  41608. ALPHATEST: boolean;
  41609. DEPTHPREPASS: boolean;
  41610. ALPHAFROMDIFFUSE: boolean;
  41611. POINTSIZE: boolean;
  41612. FOG: boolean;
  41613. SPECULARTERM: boolean;
  41614. DIFFUSEFRESNEL: boolean;
  41615. OPACITYFRESNEL: boolean;
  41616. REFLECTIONFRESNEL: boolean;
  41617. REFRACTIONFRESNEL: boolean;
  41618. EMISSIVEFRESNEL: boolean;
  41619. FRESNEL: boolean;
  41620. NORMAL: boolean;
  41621. UV1: boolean;
  41622. UV2: boolean;
  41623. VERTEXCOLOR: boolean;
  41624. VERTEXALPHA: boolean;
  41625. NUM_BONE_INFLUENCERS: number;
  41626. BonesPerMesh: number;
  41627. BONETEXTURE: boolean;
  41628. INSTANCES: boolean;
  41629. GLOSSINESS: boolean;
  41630. ROUGHNESS: boolean;
  41631. EMISSIVEASILLUMINATION: boolean;
  41632. LINKEMISSIVEWITHDIFFUSE: boolean;
  41633. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41634. LIGHTMAP: boolean;
  41635. LIGHTMAPDIRECTUV: number;
  41636. OBJECTSPACE_NORMALMAP: boolean;
  41637. USELIGHTMAPASSHADOWMAP: boolean;
  41638. REFLECTIONMAP_3D: boolean;
  41639. REFLECTIONMAP_SPHERICAL: boolean;
  41640. REFLECTIONMAP_PLANAR: boolean;
  41641. REFLECTIONMAP_CUBIC: boolean;
  41642. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41643. REFLECTIONMAP_PROJECTION: boolean;
  41644. REFLECTIONMAP_SKYBOX: boolean;
  41645. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41646. REFLECTIONMAP_EXPLICIT: boolean;
  41647. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41648. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41649. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41650. INVERTCUBICMAP: boolean;
  41651. LOGARITHMICDEPTH: boolean;
  41652. REFRACTION: boolean;
  41653. REFRACTIONMAP_3D: boolean;
  41654. REFLECTIONOVERALPHA: boolean;
  41655. TWOSIDEDLIGHTING: boolean;
  41656. SHADOWFLOAT: boolean;
  41657. MORPHTARGETS: boolean;
  41658. MORPHTARGETS_NORMAL: boolean;
  41659. MORPHTARGETS_TANGENT: boolean;
  41660. MORPHTARGETS_UV: boolean;
  41661. NUM_MORPH_INFLUENCERS: number;
  41662. NONUNIFORMSCALING: boolean;
  41663. PREMULTIPLYALPHA: boolean;
  41664. IMAGEPROCESSING: boolean;
  41665. VIGNETTE: boolean;
  41666. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41667. VIGNETTEBLENDMODEOPAQUE: boolean;
  41668. TONEMAPPING: boolean;
  41669. TONEMAPPING_ACES: boolean;
  41670. CONTRAST: boolean;
  41671. COLORCURVES: boolean;
  41672. COLORGRADING: boolean;
  41673. COLORGRADING3D: boolean;
  41674. SAMPLER3DGREENDEPTH: boolean;
  41675. SAMPLER3DBGRMAP: boolean;
  41676. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41677. MULTIVIEW: boolean;
  41678. /**
  41679. * If the reflection texture on this material is in linear color space
  41680. * @hidden
  41681. */
  41682. IS_REFLECTION_LINEAR: boolean;
  41683. /**
  41684. * If the refraction texture on this material is in linear color space
  41685. * @hidden
  41686. */
  41687. IS_REFRACTION_LINEAR: boolean;
  41688. EXPOSURE: boolean;
  41689. constructor();
  41690. setReflectionMode(modeToEnable: string): void;
  41691. }
  41692. /**
  41693. * This is the default material used in Babylon. It is the best trade off between quality
  41694. * and performances.
  41695. * @see http://doc.babylonjs.com/babylon101/materials
  41696. */
  41697. export class StandardMaterial extends PushMaterial {
  41698. private _diffuseTexture;
  41699. /**
  41700. * The basic texture of the material as viewed under a light.
  41701. */
  41702. diffuseTexture: Nullable<BaseTexture>;
  41703. private _ambientTexture;
  41704. /**
  41705. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41706. */
  41707. ambientTexture: Nullable<BaseTexture>;
  41708. private _opacityTexture;
  41709. /**
  41710. * Define the transparency of the material from a texture.
  41711. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41712. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41713. */
  41714. opacityTexture: Nullable<BaseTexture>;
  41715. private _reflectionTexture;
  41716. /**
  41717. * Define the texture used to display the reflection.
  41718. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41719. */
  41720. reflectionTexture: Nullable<BaseTexture>;
  41721. private _emissiveTexture;
  41722. /**
  41723. * Define texture of the material as if self lit.
  41724. * This will be mixed in the final result even in the absence of light.
  41725. */
  41726. emissiveTexture: Nullable<BaseTexture>;
  41727. private _specularTexture;
  41728. /**
  41729. * Define how the color and intensity of the highlight given by the light in the material.
  41730. */
  41731. specularTexture: Nullable<BaseTexture>;
  41732. private _bumpTexture;
  41733. /**
  41734. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41735. * 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.
  41736. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41737. */
  41738. bumpTexture: Nullable<BaseTexture>;
  41739. private _lightmapTexture;
  41740. /**
  41741. * Complex lighting can be computationally expensive to compute at runtime.
  41742. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41743. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41744. */
  41745. lightmapTexture: Nullable<BaseTexture>;
  41746. private _refractionTexture;
  41747. /**
  41748. * Define the texture used to display the refraction.
  41749. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41750. */
  41751. refractionTexture: Nullable<BaseTexture>;
  41752. /**
  41753. * The color of the material lit by the environmental background lighting.
  41754. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41755. */
  41756. ambientColor: Color3;
  41757. /**
  41758. * The basic color of the material as viewed under a light.
  41759. */
  41760. diffuseColor: Color3;
  41761. /**
  41762. * Define how the color and intensity of the highlight given by the light in the material.
  41763. */
  41764. specularColor: Color3;
  41765. /**
  41766. * Define the color of the material as if self lit.
  41767. * This will be mixed in the final result even in the absence of light.
  41768. */
  41769. emissiveColor: Color3;
  41770. /**
  41771. * Defines how sharp are the highlights in the material.
  41772. * The bigger the value the sharper giving a more glossy feeling to the result.
  41773. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41774. */
  41775. specularPower: number;
  41776. private _useAlphaFromDiffuseTexture;
  41777. /**
  41778. * Does the transparency come from the diffuse texture alpha channel.
  41779. */
  41780. useAlphaFromDiffuseTexture: boolean;
  41781. private _useEmissiveAsIllumination;
  41782. /**
  41783. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41784. */
  41785. useEmissiveAsIllumination: boolean;
  41786. private _linkEmissiveWithDiffuse;
  41787. /**
  41788. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41789. * the emissive level when the final color is close to one.
  41790. */
  41791. linkEmissiveWithDiffuse: boolean;
  41792. private _useSpecularOverAlpha;
  41793. /**
  41794. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41795. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41796. */
  41797. useSpecularOverAlpha: boolean;
  41798. private _useReflectionOverAlpha;
  41799. /**
  41800. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41801. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41802. */
  41803. useReflectionOverAlpha: boolean;
  41804. private _disableLighting;
  41805. /**
  41806. * Does lights from the scene impacts this material.
  41807. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41808. */
  41809. disableLighting: boolean;
  41810. private _useObjectSpaceNormalMap;
  41811. /**
  41812. * Allows using an object space normal map (instead of tangent space).
  41813. */
  41814. useObjectSpaceNormalMap: boolean;
  41815. private _useParallax;
  41816. /**
  41817. * Is parallax enabled or not.
  41818. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41819. */
  41820. useParallax: boolean;
  41821. private _useParallaxOcclusion;
  41822. /**
  41823. * Is parallax occlusion enabled or not.
  41824. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41825. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41826. */
  41827. useParallaxOcclusion: boolean;
  41828. /**
  41829. * 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.
  41830. */
  41831. parallaxScaleBias: number;
  41832. private _roughness;
  41833. /**
  41834. * Helps to define how blurry the reflections should appears in the material.
  41835. */
  41836. roughness: number;
  41837. /**
  41838. * In case of refraction, define the value of the index of refraction.
  41839. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41840. */
  41841. indexOfRefraction: number;
  41842. /**
  41843. * Invert the refraction texture alongside the y axis.
  41844. * It can be useful with procedural textures or probe for instance.
  41845. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41846. */
  41847. invertRefractionY: boolean;
  41848. /**
  41849. * Defines the alpha limits in alpha test mode.
  41850. */
  41851. alphaCutOff: number;
  41852. private _useLightmapAsShadowmap;
  41853. /**
  41854. * In case of light mapping, define whether the map contains light or shadow informations.
  41855. */
  41856. useLightmapAsShadowmap: boolean;
  41857. private _diffuseFresnelParameters;
  41858. /**
  41859. * Define the diffuse fresnel parameters of the material.
  41860. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41861. */
  41862. diffuseFresnelParameters: FresnelParameters;
  41863. private _opacityFresnelParameters;
  41864. /**
  41865. * Define the opacity fresnel parameters of the material.
  41866. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41867. */
  41868. opacityFresnelParameters: FresnelParameters;
  41869. private _reflectionFresnelParameters;
  41870. /**
  41871. * Define the reflection fresnel parameters of the material.
  41872. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41873. */
  41874. reflectionFresnelParameters: FresnelParameters;
  41875. private _refractionFresnelParameters;
  41876. /**
  41877. * Define the refraction fresnel parameters of the material.
  41878. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41879. */
  41880. refractionFresnelParameters: FresnelParameters;
  41881. private _emissiveFresnelParameters;
  41882. /**
  41883. * Define the emissive fresnel parameters of the material.
  41884. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41885. */
  41886. emissiveFresnelParameters: FresnelParameters;
  41887. private _useReflectionFresnelFromSpecular;
  41888. /**
  41889. * If true automatically deducts the fresnels values from the material specularity.
  41890. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41891. */
  41892. useReflectionFresnelFromSpecular: boolean;
  41893. private _useGlossinessFromSpecularMapAlpha;
  41894. /**
  41895. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41896. */
  41897. useGlossinessFromSpecularMapAlpha: boolean;
  41898. private _maxSimultaneousLights;
  41899. /**
  41900. * Defines the maximum number of lights that can be used in the material
  41901. */
  41902. maxSimultaneousLights: number;
  41903. private _invertNormalMapX;
  41904. /**
  41905. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41906. */
  41907. invertNormalMapX: boolean;
  41908. private _invertNormalMapY;
  41909. /**
  41910. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41911. */
  41912. invertNormalMapY: boolean;
  41913. private _twoSidedLighting;
  41914. /**
  41915. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41916. */
  41917. twoSidedLighting: boolean;
  41918. /**
  41919. * Default configuration related to image processing available in the standard Material.
  41920. */
  41921. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41922. /**
  41923. * Gets the image processing configuration used either in this material.
  41924. */
  41925. /**
  41926. * Sets the Default image processing configuration used either in the this material.
  41927. *
  41928. * If sets to null, the scene one is in use.
  41929. */
  41930. imageProcessingConfiguration: ImageProcessingConfiguration;
  41931. /**
  41932. * Keep track of the image processing observer to allow dispose and replace.
  41933. */
  41934. private _imageProcessingObserver;
  41935. /**
  41936. * Attaches a new image processing configuration to the Standard Material.
  41937. * @param configuration
  41938. */
  41939. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41940. /**
  41941. * Gets wether the color curves effect is enabled.
  41942. */
  41943. /**
  41944. * Sets wether the color curves effect is enabled.
  41945. */
  41946. cameraColorCurvesEnabled: boolean;
  41947. /**
  41948. * Gets wether the color grading effect is enabled.
  41949. */
  41950. /**
  41951. * Gets wether the color grading effect is enabled.
  41952. */
  41953. cameraColorGradingEnabled: boolean;
  41954. /**
  41955. * Gets wether tonemapping is enabled or not.
  41956. */
  41957. /**
  41958. * Sets wether tonemapping is enabled or not
  41959. */
  41960. cameraToneMappingEnabled: boolean;
  41961. /**
  41962. * The camera exposure used on this material.
  41963. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41964. * This corresponds to a photographic exposure.
  41965. */
  41966. /**
  41967. * The camera exposure used on this material.
  41968. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41969. * This corresponds to a photographic exposure.
  41970. */
  41971. cameraExposure: number;
  41972. /**
  41973. * Gets The camera contrast used on this material.
  41974. */
  41975. /**
  41976. * Sets The camera contrast used on this material.
  41977. */
  41978. cameraContrast: number;
  41979. /**
  41980. * Gets the Color Grading 2D Lookup Texture.
  41981. */
  41982. /**
  41983. * Sets the Color Grading 2D Lookup Texture.
  41984. */
  41985. cameraColorGradingTexture: Nullable<BaseTexture>;
  41986. /**
  41987. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41988. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41989. * 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;
  41990. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41991. */
  41992. /**
  41993. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41994. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41995. * 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;
  41996. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41997. */
  41998. cameraColorCurves: Nullable<ColorCurves>;
  41999. /**
  42000. * Custom callback helping to override the default shader used in the material.
  42001. */
  42002. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42003. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42004. protected _worldViewProjectionMatrix: Matrix;
  42005. protected _globalAmbientColor: Color3;
  42006. protected _useLogarithmicDepth: boolean;
  42007. protected _rebuildInParallel: boolean;
  42008. /**
  42009. * Instantiates a new standard material.
  42010. * This is the default material used in Babylon. It is the best trade off between quality
  42011. * and performances.
  42012. * @see http://doc.babylonjs.com/babylon101/materials
  42013. * @param name Define the name of the material in the scene
  42014. * @param scene Define the scene the material belong to
  42015. */
  42016. constructor(name: string, scene: Scene);
  42017. /**
  42018. * Gets a boolean indicating that current material needs to register RTT
  42019. */
  42020. readonly hasRenderTargetTextures: boolean;
  42021. /**
  42022. * Gets the current class name of the material e.g. "StandardMaterial"
  42023. * Mainly use in serialization.
  42024. * @returns the class name
  42025. */
  42026. getClassName(): string;
  42027. /**
  42028. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42029. * You can try switching to logarithmic depth.
  42030. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42031. */
  42032. useLogarithmicDepth: boolean;
  42033. /**
  42034. * Specifies if the material will require alpha blending
  42035. * @returns a boolean specifying if alpha blending is needed
  42036. */
  42037. needAlphaBlending(): boolean;
  42038. /**
  42039. * Specifies if this material should be rendered in alpha test mode
  42040. * @returns a boolean specifying if an alpha test is needed.
  42041. */
  42042. needAlphaTesting(): boolean;
  42043. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42044. /**
  42045. * Get the texture used for alpha test purpose.
  42046. * @returns the diffuse texture in case of the standard material.
  42047. */
  42048. getAlphaTestTexture(): Nullable<BaseTexture>;
  42049. /**
  42050. * Get if the submesh is ready to be used and all its information available.
  42051. * Child classes can use it to update shaders
  42052. * @param mesh defines the mesh to check
  42053. * @param subMesh defines which submesh to check
  42054. * @param useInstances specifies that instances should be used
  42055. * @returns a boolean indicating that the submesh is ready or not
  42056. */
  42057. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42058. /**
  42059. * Builds the material UBO layouts.
  42060. * Used internally during the effect preparation.
  42061. */
  42062. buildUniformLayout(): void;
  42063. /**
  42064. * Unbinds the material from the mesh
  42065. */
  42066. unbind(): void;
  42067. /**
  42068. * Binds the submesh to this material by preparing the effect and shader to draw
  42069. * @param world defines the world transformation matrix
  42070. * @param mesh defines the mesh containing the submesh
  42071. * @param subMesh defines the submesh to bind the material to
  42072. */
  42073. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42074. /**
  42075. * Get the list of animatables in the material.
  42076. * @returns the list of animatables object used in the material
  42077. */
  42078. getAnimatables(): IAnimatable[];
  42079. /**
  42080. * Gets the active textures from the material
  42081. * @returns an array of textures
  42082. */
  42083. getActiveTextures(): BaseTexture[];
  42084. /**
  42085. * Specifies if the material uses a texture
  42086. * @param texture defines the texture to check against the material
  42087. * @returns a boolean specifying if the material uses the texture
  42088. */
  42089. hasTexture(texture: BaseTexture): boolean;
  42090. /**
  42091. * Disposes the material
  42092. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42093. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42094. */
  42095. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42096. /**
  42097. * Makes a duplicate of the material, and gives it a new name
  42098. * @param name defines the new name for the duplicated material
  42099. * @returns the cloned material
  42100. */
  42101. clone(name: string): StandardMaterial;
  42102. /**
  42103. * Serializes this material in a JSON representation
  42104. * @returns the serialized material object
  42105. */
  42106. serialize(): any;
  42107. /**
  42108. * Creates a standard material from parsed material data
  42109. * @param source defines the JSON representation of the material
  42110. * @param scene defines the hosting scene
  42111. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42112. * @returns a new standard material
  42113. */
  42114. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42115. /**
  42116. * Are diffuse textures enabled in the application.
  42117. */
  42118. static DiffuseTextureEnabled: boolean;
  42119. /**
  42120. * Are ambient textures enabled in the application.
  42121. */
  42122. static AmbientTextureEnabled: boolean;
  42123. /**
  42124. * Are opacity textures enabled in the application.
  42125. */
  42126. static OpacityTextureEnabled: boolean;
  42127. /**
  42128. * Are reflection textures enabled in the application.
  42129. */
  42130. static ReflectionTextureEnabled: boolean;
  42131. /**
  42132. * Are emissive textures enabled in the application.
  42133. */
  42134. static EmissiveTextureEnabled: boolean;
  42135. /**
  42136. * Are specular textures enabled in the application.
  42137. */
  42138. static SpecularTextureEnabled: boolean;
  42139. /**
  42140. * Are bump textures enabled in the application.
  42141. */
  42142. static BumpTextureEnabled: boolean;
  42143. /**
  42144. * Are lightmap textures enabled in the application.
  42145. */
  42146. static LightmapTextureEnabled: boolean;
  42147. /**
  42148. * Are refraction textures enabled in the application.
  42149. */
  42150. static RefractionTextureEnabled: boolean;
  42151. /**
  42152. * Are color grading textures enabled in the application.
  42153. */
  42154. static ColorGradingTextureEnabled: boolean;
  42155. /**
  42156. * Are fresnels enabled in the application.
  42157. */
  42158. static FresnelEnabled: boolean;
  42159. }
  42160. }
  42161. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42162. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42163. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42164. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42165. /** @hidden */
  42166. export var imageProcessingPixelShader: {
  42167. name: string;
  42168. shader: string;
  42169. };
  42170. }
  42171. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42172. import { Nullable } from "babylonjs/types";
  42173. import { Color4 } from "babylonjs/Maths/math.color";
  42174. import { Camera } from "babylonjs/Cameras/camera";
  42175. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42176. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42177. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42178. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42179. import { Engine } from "babylonjs/Engines/engine";
  42180. import "babylonjs/Shaders/imageProcessing.fragment";
  42181. import "babylonjs/Shaders/postprocess.vertex";
  42182. /**
  42183. * ImageProcessingPostProcess
  42184. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42185. */
  42186. export class ImageProcessingPostProcess extends PostProcess {
  42187. /**
  42188. * Default configuration related to image processing available in the PBR Material.
  42189. */
  42190. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42191. /**
  42192. * Gets the image processing configuration used either in this material.
  42193. */
  42194. /**
  42195. * Sets the Default image processing configuration used either in the this material.
  42196. *
  42197. * If sets to null, the scene one is in use.
  42198. */
  42199. imageProcessingConfiguration: ImageProcessingConfiguration;
  42200. /**
  42201. * Keep track of the image processing observer to allow dispose and replace.
  42202. */
  42203. private _imageProcessingObserver;
  42204. /**
  42205. * Attaches a new image processing configuration to the PBR Material.
  42206. * @param configuration
  42207. */
  42208. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42209. /**
  42210. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42211. */
  42212. /**
  42213. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42214. */
  42215. colorCurves: Nullable<ColorCurves>;
  42216. /**
  42217. * Gets wether the color curves effect is enabled.
  42218. */
  42219. /**
  42220. * Sets wether the color curves effect is enabled.
  42221. */
  42222. colorCurvesEnabled: boolean;
  42223. /**
  42224. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42225. */
  42226. /**
  42227. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42228. */
  42229. colorGradingTexture: Nullable<BaseTexture>;
  42230. /**
  42231. * Gets wether the color grading effect is enabled.
  42232. */
  42233. /**
  42234. * Gets wether the color grading effect is enabled.
  42235. */
  42236. colorGradingEnabled: boolean;
  42237. /**
  42238. * Gets exposure used in the effect.
  42239. */
  42240. /**
  42241. * Sets exposure used in the effect.
  42242. */
  42243. exposure: number;
  42244. /**
  42245. * Gets wether tonemapping is enabled or not.
  42246. */
  42247. /**
  42248. * Sets wether tonemapping is enabled or not
  42249. */
  42250. toneMappingEnabled: boolean;
  42251. /**
  42252. * Gets the type of tone mapping effect.
  42253. */
  42254. /**
  42255. * Sets the type of tone mapping effect.
  42256. */
  42257. toneMappingType: number;
  42258. /**
  42259. * Gets contrast used in the effect.
  42260. */
  42261. /**
  42262. * Sets contrast used in the effect.
  42263. */
  42264. contrast: number;
  42265. /**
  42266. * Gets Vignette stretch size.
  42267. */
  42268. /**
  42269. * Sets Vignette stretch size.
  42270. */
  42271. vignetteStretch: number;
  42272. /**
  42273. * Gets Vignette centre X Offset.
  42274. */
  42275. /**
  42276. * Sets Vignette centre X Offset.
  42277. */
  42278. vignetteCentreX: number;
  42279. /**
  42280. * Gets Vignette centre Y Offset.
  42281. */
  42282. /**
  42283. * Sets Vignette centre Y Offset.
  42284. */
  42285. vignetteCentreY: number;
  42286. /**
  42287. * Gets Vignette weight or intensity of the vignette effect.
  42288. */
  42289. /**
  42290. * Sets Vignette weight or intensity of the vignette effect.
  42291. */
  42292. vignetteWeight: number;
  42293. /**
  42294. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42295. * if vignetteEnabled is set to true.
  42296. */
  42297. /**
  42298. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42299. * if vignetteEnabled is set to true.
  42300. */
  42301. vignetteColor: Color4;
  42302. /**
  42303. * Gets Camera field of view used by the Vignette effect.
  42304. */
  42305. /**
  42306. * Sets Camera field of view used by the Vignette effect.
  42307. */
  42308. vignetteCameraFov: number;
  42309. /**
  42310. * Gets the vignette blend mode allowing different kind of effect.
  42311. */
  42312. /**
  42313. * Sets the vignette blend mode allowing different kind of effect.
  42314. */
  42315. vignetteBlendMode: number;
  42316. /**
  42317. * Gets wether the vignette effect is enabled.
  42318. */
  42319. /**
  42320. * Sets wether the vignette effect is enabled.
  42321. */
  42322. vignetteEnabled: boolean;
  42323. private _fromLinearSpace;
  42324. /**
  42325. * Gets wether the input of the processing is in Gamma or Linear Space.
  42326. */
  42327. /**
  42328. * Sets wether the input of the processing is in Gamma or Linear Space.
  42329. */
  42330. fromLinearSpace: boolean;
  42331. /**
  42332. * Defines cache preventing GC.
  42333. */
  42334. private _defines;
  42335. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42336. /**
  42337. * "ImageProcessingPostProcess"
  42338. * @returns "ImageProcessingPostProcess"
  42339. */
  42340. getClassName(): string;
  42341. protected _updateParameters(): void;
  42342. dispose(camera?: Camera): void;
  42343. }
  42344. }
  42345. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42346. import { Scene } from "babylonjs/scene";
  42347. import { Color3 } from "babylonjs/Maths/math.color";
  42348. import { Mesh } from "babylonjs/Meshes/mesh";
  42349. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42350. import { Nullable } from "babylonjs/types";
  42351. /**
  42352. * Class containing static functions to help procedurally build meshes
  42353. */
  42354. export class GroundBuilder {
  42355. /**
  42356. * Creates a ground mesh
  42357. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42358. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42360. * @param name defines the name of the mesh
  42361. * @param options defines the options used to create the mesh
  42362. * @param scene defines the hosting scene
  42363. * @returns the ground mesh
  42364. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42365. */
  42366. static CreateGround(name: string, options: {
  42367. width?: number;
  42368. height?: number;
  42369. subdivisions?: number;
  42370. subdivisionsX?: number;
  42371. subdivisionsY?: number;
  42372. updatable?: boolean;
  42373. }, scene: any): Mesh;
  42374. /**
  42375. * Creates a tiled ground mesh
  42376. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42377. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42378. * * 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
  42379. * * 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
  42380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42381. * @param name defines the name of the mesh
  42382. * @param options defines the options used to create the mesh
  42383. * @param scene defines the hosting scene
  42384. * @returns the tiled ground mesh
  42385. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42386. */
  42387. static CreateTiledGround(name: string, options: {
  42388. xmin: number;
  42389. zmin: number;
  42390. xmax: number;
  42391. zmax: number;
  42392. subdivisions?: {
  42393. w: number;
  42394. h: number;
  42395. };
  42396. precision?: {
  42397. w: number;
  42398. h: number;
  42399. };
  42400. updatable?: boolean;
  42401. }, scene?: Nullable<Scene>): Mesh;
  42402. /**
  42403. * Creates a ground mesh from a height map
  42404. * * The parameter `url` sets the URL of the height map image resource.
  42405. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42406. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42407. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42408. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42409. * * 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.
  42410. * * 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).
  42411. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42413. * @param name defines the name of the mesh
  42414. * @param url defines the url to the height map
  42415. * @param options defines the options used to create the mesh
  42416. * @param scene defines the hosting scene
  42417. * @returns the ground mesh
  42418. * @see https://doc.babylonjs.com/babylon101/height_map
  42419. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42420. */
  42421. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42422. width?: number;
  42423. height?: number;
  42424. subdivisions?: number;
  42425. minHeight?: number;
  42426. maxHeight?: number;
  42427. colorFilter?: Color3;
  42428. alphaFilter?: number;
  42429. updatable?: boolean;
  42430. onReady?: (mesh: GroundMesh) => void;
  42431. }, scene?: Nullable<Scene>): GroundMesh;
  42432. }
  42433. }
  42434. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42435. import { Vector4 } from "babylonjs/Maths/math.vector";
  42436. import { Mesh } from "babylonjs/Meshes/mesh";
  42437. /**
  42438. * Class containing static functions to help procedurally build meshes
  42439. */
  42440. export class TorusBuilder {
  42441. /**
  42442. * Creates a torus mesh
  42443. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42444. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42445. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42449. * @param name defines the name of the mesh
  42450. * @param options defines the options used to create the mesh
  42451. * @param scene defines the hosting scene
  42452. * @returns the torus mesh
  42453. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42454. */
  42455. static CreateTorus(name: string, options: {
  42456. diameter?: number;
  42457. thickness?: number;
  42458. tessellation?: number;
  42459. updatable?: boolean;
  42460. sideOrientation?: number;
  42461. frontUVs?: Vector4;
  42462. backUVs?: Vector4;
  42463. }, scene: any): Mesh;
  42464. }
  42465. }
  42466. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42467. import { Vector4 } from "babylonjs/Maths/math.vector";
  42468. import { Color4 } from "babylonjs/Maths/math.color";
  42469. import { Mesh } from "babylonjs/Meshes/mesh";
  42470. /**
  42471. * Class containing static functions to help procedurally build meshes
  42472. */
  42473. export class CylinderBuilder {
  42474. /**
  42475. * Creates a cylinder or a cone mesh
  42476. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42477. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42478. * * 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.
  42479. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42480. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42481. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42482. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42483. * * 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).
  42484. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42485. * * 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).
  42486. * * 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
  42487. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42488. * * 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
  42489. * * 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.
  42490. * * If `enclose` is false, a ring surface is one element.
  42491. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42492. * * 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
  42493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42496. * @param name defines the name of the mesh
  42497. * @param options defines the options used to create the mesh
  42498. * @param scene defines the hosting scene
  42499. * @returns the cylinder mesh
  42500. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42501. */
  42502. static CreateCylinder(name: string, options: {
  42503. height?: number;
  42504. diameterTop?: number;
  42505. diameterBottom?: number;
  42506. diameter?: number;
  42507. tessellation?: number;
  42508. subdivisions?: number;
  42509. arc?: number;
  42510. faceColors?: Color4[];
  42511. faceUV?: Vector4[];
  42512. updatable?: boolean;
  42513. hasRings?: boolean;
  42514. enclose?: boolean;
  42515. cap?: number;
  42516. sideOrientation?: number;
  42517. frontUVs?: Vector4;
  42518. backUVs?: Vector4;
  42519. }, scene: any): Mesh;
  42520. }
  42521. }
  42522. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42523. import { Observable } from "babylonjs/Misc/observable";
  42524. import { Nullable } from "babylonjs/types";
  42525. import { Camera } from "babylonjs/Cameras/camera";
  42526. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42527. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42528. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42529. import { Scene } from "babylonjs/scene";
  42530. import { Vector3 } from "babylonjs/Maths/math.vector";
  42531. import { Color3 } from "babylonjs/Maths/math.color";
  42532. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42534. import { Mesh } from "babylonjs/Meshes/mesh";
  42535. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42536. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42537. import "babylonjs/Meshes/Builders/groundBuilder";
  42538. import "babylonjs/Meshes/Builders/torusBuilder";
  42539. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42540. import "babylonjs/Gamepads/gamepadSceneComponent";
  42541. import "babylonjs/Animations/animatable";
  42542. /**
  42543. * Options to modify the vr teleportation behavior.
  42544. */
  42545. export interface VRTeleportationOptions {
  42546. /**
  42547. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42548. */
  42549. floorMeshName?: string;
  42550. /**
  42551. * A list of meshes to be used as the teleportation floor. (default: empty)
  42552. */
  42553. floorMeshes?: Mesh[];
  42554. }
  42555. /**
  42556. * Options to modify the vr experience helper's behavior.
  42557. */
  42558. export interface VRExperienceHelperOptions extends WebVROptions {
  42559. /**
  42560. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42561. */
  42562. createDeviceOrientationCamera?: boolean;
  42563. /**
  42564. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42565. */
  42566. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42567. /**
  42568. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42569. */
  42570. laserToggle?: boolean;
  42571. /**
  42572. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42573. */
  42574. floorMeshes?: Mesh[];
  42575. /**
  42576. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42577. */
  42578. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42579. }
  42580. /**
  42581. * Event containing information after VR has been entered
  42582. */
  42583. export class OnAfterEnteringVRObservableEvent {
  42584. /**
  42585. * If entering vr was successful
  42586. */
  42587. success: boolean;
  42588. }
  42589. /**
  42590. * Helps to quickly add VR support to an existing scene.
  42591. * See http://doc.babylonjs.com/how_to/webvr_helper
  42592. */
  42593. export class VRExperienceHelper {
  42594. /** Options to modify the vr experience helper's behavior. */
  42595. webVROptions: VRExperienceHelperOptions;
  42596. private _scene;
  42597. private _position;
  42598. private _btnVR;
  42599. private _btnVRDisplayed;
  42600. private _webVRsupported;
  42601. private _webVRready;
  42602. private _webVRrequesting;
  42603. private _webVRpresenting;
  42604. private _hasEnteredVR;
  42605. private _fullscreenVRpresenting;
  42606. private _canvas;
  42607. private _webVRCamera;
  42608. private _vrDeviceOrientationCamera;
  42609. private _deviceOrientationCamera;
  42610. private _existingCamera;
  42611. private _onKeyDown;
  42612. private _onVrDisplayPresentChange;
  42613. private _onVRDisplayChanged;
  42614. private _onVRRequestPresentStart;
  42615. private _onVRRequestPresentComplete;
  42616. /**
  42617. * 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)
  42618. */
  42619. enableGazeEvenWhenNoPointerLock: boolean;
  42620. /**
  42621. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42622. */
  42623. exitVROnDoubleTap: boolean;
  42624. /**
  42625. * Observable raised right before entering VR.
  42626. */
  42627. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42628. /**
  42629. * Observable raised when entering VR has completed.
  42630. */
  42631. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42632. /**
  42633. * Observable raised when exiting VR.
  42634. */
  42635. onExitingVRObservable: Observable<VRExperienceHelper>;
  42636. /**
  42637. * Observable raised when controller mesh is loaded.
  42638. */
  42639. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42640. /** Return this.onEnteringVRObservable
  42641. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42642. */
  42643. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42644. /** Return this.onExitingVRObservable
  42645. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42646. */
  42647. readonly onExitingVR: Observable<VRExperienceHelper>;
  42648. /** Return this.onControllerMeshLoadedObservable
  42649. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42650. */
  42651. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42652. private _rayLength;
  42653. private _useCustomVRButton;
  42654. private _teleportationRequested;
  42655. private _teleportActive;
  42656. private _floorMeshName;
  42657. private _floorMeshesCollection;
  42658. private _rotationAllowed;
  42659. private _teleportBackwardsVector;
  42660. private _teleportationTarget;
  42661. private _isDefaultTeleportationTarget;
  42662. private _postProcessMove;
  42663. private _teleportationFillColor;
  42664. private _teleportationBorderColor;
  42665. private _rotationAngle;
  42666. private _haloCenter;
  42667. private _cameraGazer;
  42668. private _padSensibilityUp;
  42669. private _padSensibilityDown;
  42670. private _leftController;
  42671. private _rightController;
  42672. /**
  42673. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42674. */
  42675. onNewMeshSelected: Observable<AbstractMesh>;
  42676. /**
  42677. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42678. * This observable will provide the mesh and the controller used to select the mesh
  42679. */
  42680. onMeshSelectedWithController: Observable<{
  42681. mesh: AbstractMesh;
  42682. controller: WebVRController;
  42683. }>;
  42684. /**
  42685. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42686. */
  42687. onNewMeshPicked: Observable<PickingInfo>;
  42688. private _circleEase;
  42689. /**
  42690. * Observable raised before camera teleportation
  42691. */
  42692. onBeforeCameraTeleport: Observable<Vector3>;
  42693. /**
  42694. * Observable raised after camera teleportation
  42695. */
  42696. onAfterCameraTeleport: Observable<Vector3>;
  42697. /**
  42698. * Observable raised when current selected mesh gets unselected
  42699. */
  42700. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42701. private _raySelectionPredicate;
  42702. /**
  42703. * To be optionaly changed by user to define custom ray selection
  42704. */
  42705. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42706. /**
  42707. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42708. */
  42709. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42710. /**
  42711. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42712. */
  42713. teleportationEnabled: boolean;
  42714. private _defaultHeight;
  42715. private _teleportationInitialized;
  42716. private _interactionsEnabled;
  42717. private _interactionsRequested;
  42718. private _displayGaze;
  42719. private _displayLaserPointer;
  42720. /**
  42721. * The mesh used to display where the user is going to teleport.
  42722. */
  42723. /**
  42724. * Sets the mesh to be used to display where the user is going to teleport.
  42725. */
  42726. teleportationTarget: Mesh;
  42727. /**
  42728. * 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
  42729. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42730. * See http://doc.babylonjs.com/resources/baking_transformations
  42731. */
  42732. gazeTrackerMesh: Mesh;
  42733. /**
  42734. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42735. */
  42736. updateGazeTrackerScale: boolean;
  42737. /**
  42738. * If the gaze trackers color should be updated when selecting meshes
  42739. */
  42740. updateGazeTrackerColor: boolean;
  42741. /**
  42742. * If the controller laser color should be updated when selecting meshes
  42743. */
  42744. updateControllerLaserColor: boolean;
  42745. /**
  42746. * The gaze tracking mesh corresponding to the left controller
  42747. */
  42748. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42749. /**
  42750. * The gaze tracking mesh corresponding to the right controller
  42751. */
  42752. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42753. /**
  42754. * If the ray of the gaze should be displayed.
  42755. */
  42756. /**
  42757. * Sets if the ray of the gaze should be displayed.
  42758. */
  42759. displayGaze: boolean;
  42760. /**
  42761. * If the ray of the LaserPointer should be displayed.
  42762. */
  42763. /**
  42764. * Sets if the ray of the LaserPointer should be displayed.
  42765. */
  42766. displayLaserPointer: boolean;
  42767. /**
  42768. * The deviceOrientationCamera used as the camera when not in VR.
  42769. */
  42770. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42771. /**
  42772. * Based on the current WebVR support, returns the current VR camera used.
  42773. */
  42774. readonly currentVRCamera: Nullable<Camera>;
  42775. /**
  42776. * The webVRCamera which is used when in VR.
  42777. */
  42778. readonly webVRCamera: WebVRFreeCamera;
  42779. /**
  42780. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42781. */
  42782. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42783. /**
  42784. * The html button that is used to trigger entering into VR.
  42785. */
  42786. readonly vrButton: Nullable<HTMLButtonElement>;
  42787. private readonly _teleportationRequestInitiated;
  42788. /**
  42789. * Defines wether or not Pointer lock should be requested when switching to
  42790. * full screen.
  42791. */
  42792. requestPointerLockOnFullScreen: boolean;
  42793. /**
  42794. * Instantiates a VRExperienceHelper.
  42795. * Helps to quickly add VR support to an existing scene.
  42796. * @param scene The scene the VRExperienceHelper belongs to.
  42797. * @param webVROptions Options to modify the vr experience helper's behavior.
  42798. */
  42799. constructor(scene: Scene,
  42800. /** Options to modify the vr experience helper's behavior. */
  42801. webVROptions?: VRExperienceHelperOptions);
  42802. private _onDefaultMeshLoaded;
  42803. private _onResize;
  42804. private _onFullscreenChange;
  42805. /**
  42806. * Gets a value indicating if we are currently in VR mode.
  42807. */
  42808. readonly isInVRMode: boolean;
  42809. private onVrDisplayPresentChange;
  42810. private onVRDisplayChanged;
  42811. private moveButtonToBottomRight;
  42812. private displayVRButton;
  42813. private updateButtonVisibility;
  42814. private _cachedAngularSensibility;
  42815. /**
  42816. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42817. * Otherwise, will use the fullscreen API.
  42818. */
  42819. enterVR(): void;
  42820. /**
  42821. * Attempt to exit VR, or fullscreen.
  42822. */
  42823. exitVR(): void;
  42824. /**
  42825. * The position of the vr experience helper.
  42826. */
  42827. /**
  42828. * Sets the position of the vr experience helper.
  42829. */
  42830. position: Vector3;
  42831. /**
  42832. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42833. */
  42834. enableInteractions(): void;
  42835. private readonly _noControllerIsActive;
  42836. private beforeRender;
  42837. private _isTeleportationFloor;
  42838. /**
  42839. * Adds a floor mesh to be used for teleportation.
  42840. * @param floorMesh the mesh to be used for teleportation.
  42841. */
  42842. addFloorMesh(floorMesh: Mesh): void;
  42843. /**
  42844. * Removes a floor mesh from being used for teleportation.
  42845. * @param floorMesh the mesh to be removed.
  42846. */
  42847. removeFloorMesh(floorMesh: Mesh): void;
  42848. /**
  42849. * Enables interactions and teleportation using the VR controllers and gaze.
  42850. * @param vrTeleportationOptions options to modify teleportation behavior.
  42851. */
  42852. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42853. private _onNewGamepadConnected;
  42854. private _tryEnableInteractionOnController;
  42855. private _onNewGamepadDisconnected;
  42856. private _enableInteractionOnController;
  42857. private _checkTeleportWithRay;
  42858. private _checkRotate;
  42859. private _checkTeleportBackwards;
  42860. private _enableTeleportationOnController;
  42861. private _createTeleportationCircles;
  42862. private _displayTeleportationTarget;
  42863. private _hideTeleportationTarget;
  42864. private _rotateCamera;
  42865. private _moveTeleportationSelectorTo;
  42866. private _workingVector;
  42867. private _workingQuaternion;
  42868. private _workingMatrix;
  42869. /**
  42870. * Teleports the users feet to the desired location
  42871. * @param location The location where the user's feet should be placed
  42872. */
  42873. teleportCamera(location: Vector3): void;
  42874. private _convertNormalToDirectionOfRay;
  42875. private _castRayAndSelectObject;
  42876. private _notifySelectedMeshUnselected;
  42877. /**
  42878. * Sets the color of the laser ray from the vr controllers.
  42879. * @param color new color for the ray.
  42880. */
  42881. changeLaserColor(color: Color3): void;
  42882. /**
  42883. * Sets the color of the ray from the vr headsets gaze.
  42884. * @param color new color for the ray.
  42885. */
  42886. changeGazeColor(color: Color3): void;
  42887. /**
  42888. * Exits VR and disposes of the vr experience helper
  42889. */
  42890. dispose(): void;
  42891. /**
  42892. * Gets the name of the VRExperienceHelper class
  42893. * @returns "VRExperienceHelper"
  42894. */
  42895. getClassName(): string;
  42896. }
  42897. }
  42898. declare module "babylonjs/Cameras/VR/index" {
  42899. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42900. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42901. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42902. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42903. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42904. export * from "babylonjs/Cameras/VR/webVRCamera";
  42905. }
  42906. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42907. import { Observable } from "babylonjs/Misc/observable";
  42908. import { Nullable } from "babylonjs/types";
  42909. import { IDisposable, Scene } from "babylonjs/scene";
  42910. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42911. /**
  42912. * Manages an XRSession to work with Babylon's engine
  42913. * @see https://doc.babylonjs.com/how_to/webxr
  42914. */
  42915. export class WebXRSessionManager implements IDisposable {
  42916. private scene;
  42917. /**
  42918. * Fires every time a new xrFrame arrives which can be used to update the camera
  42919. */
  42920. onXRFrameObservable: Observable<any>;
  42921. /**
  42922. * Fires when the xr session is ended either by the device or manually done
  42923. */
  42924. onXRSessionEnded: Observable<any>;
  42925. /**
  42926. * Underlying xr session
  42927. */
  42928. session: XRSession;
  42929. /**
  42930. * Type of reference space used when creating the session
  42931. */
  42932. referenceSpace: XRReferenceSpace;
  42933. /** @hidden */
  42934. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42935. /**
  42936. * Current XR frame
  42937. */
  42938. currentFrame: Nullable<XRFrame>;
  42939. private _xrNavigator;
  42940. private baseLayer;
  42941. private _sessionEnded;
  42942. /**
  42943. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42944. * @param scene The scene which the session should be created for
  42945. */
  42946. constructor(scene: Scene);
  42947. /**
  42948. * Initializes the manager
  42949. * After initialization enterXR can be called to start an XR session
  42950. * @returns Promise which resolves after it is initialized
  42951. */
  42952. initializeAsync(): Promise<void>;
  42953. /**
  42954. * Initializes an xr session
  42955. * @param xrSessionMode mode to initialize
  42956. * @returns a promise which will resolve once the session has been initialized
  42957. */
  42958. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42959. /**
  42960. * Sets the reference space on the xr session
  42961. * @param referenceSpace space to set
  42962. * @returns a promise that will resolve once the reference space has been set
  42963. */
  42964. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42965. /**
  42966. * Updates the render state of the session
  42967. * @param state state to set
  42968. * @returns a promise that resolves once the render state has been updated
  42969. */
  42970. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42971. /**
  42972. * Starts rendering to the xr layer
  42973. * @returns a promise that will resolve once rendering has started
  42974. */
  42975. startRenderingToXRAsync(): Promise<void>;
  42976. /**
  42977. * Stops the xrSession and restores the renderloop
  42978. * @returns Promise which resolves after it exits XR
  42979. */
  42980. exitXRAsync(): Promise<unknown>;
  42981. /**
  42982. * Checks if a session would be supported for the creation options specified
  42983. * @param sessionMode session mode to check if supported eg. immersive-vr
  42984. * @returns true if supported
  42985. */
  42986. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42987. /**
  42988. * @hidden
  42989. * Converts the render layer of xrSession to a render target
  42990. * @param session session to create render target for
  42991. * @param scene scene the new render target should be created for
  42992. */
  42993. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42994. /**
  42995. * Disposes of the session manager
  42996. */
  42997. dispose(): void;
  42998. }
  42999. }
  43000. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43001. import { Scene } from "babylonjs/scene";
  43002. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43003. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43004. /**
  43005. * WebXR Camera which holds the views for the xrSession
  43006. * @see https://doc.babylonjs.com/how_to/webxr
  43007. */
  43008. export class WebXRCamera extends FreeCamera {
  43009. private static _TmpMatrix;
  43010. /**
  43011. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43012. * @param name the name of the camera
  43013. * @param scene the scene to add the camera to
  43014. */
  43015. constructor(name: string, scene: Scene);
  43016. private _updateNumberOfRigCameras;
  43017. /** @hidden */
  43018. _updateForDualEyeDebugging(): void;
  43019. /**
  43020. * Updates the cameras position from the current pose information of the XR session
  43021. * @param xrSessionManager the session containing pose information
  43022. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43023. */
  43024. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43025. }
  43026. }
  43027. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43028. import { Nullable } from "babylonjs/types";
  43029. import { IDisposable } from "babylonjs/scene";
  43030. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43031. /**
  43032. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43033. */
  43034. export class WebXRManagedOutputCanvas implements IDisposable {
  43035. private helper;
  43036. private _canvas;
  43037. /**
  43038. * xrpresent context of the canvas which can be used to display/mirror xr content
  43039. */
  43040. canvasContext: WebGLRenderingContext;
  43041. /**
  43042. * xr layer for the canvas
  43043. */
  43044. xrLayer: Nullable<XRWebGLLayer>;
  43045. /**
  43046. * Initializes the xr layer for the session
  43047. * @param xrSession xr session
  43048. * @returns a promise that will resolve once the XR Layer has been created
  43049. */
  43050. initializeXRLayerAsync(xrSession: any): any;
  43051. /**
  43052. * Initializes the canvas to be added/removed upon entering/exiting xr
  43053. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43054. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43055. */
  43056. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43057. /**
  43058. * Disposes of the object
  43059. */
  43060. dispose(): void;
  43061. private _setManagedOutputCanvas;
  43062. private _addCanvas;
  43063. private _removeCanvas;
  43064. }
  43065. }
  43066. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43067. import { Observable } from "babylonjs/Misc/observable";
  43068. import { IDisposable, Scene } from "babylonjs/scene";
  43069. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43071. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43072. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43073. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43074. /**
  43075. * States of the webXR experience
  43076. */
  43077. export enum WebXRState {
  43078. /**
  43079. * Transitioning to being in XR mode
  43080. */
  43081. ENTERING_XR = 0,
  43082. /**
  43083. * Transitioning to non XR mode
  43084. */
  43085. EXITING_XR = 1,
  43086. /**
  43087. * In XR mode and presenting
  43088. */
  43089. IN_XR = 2,
  43090. /**
  43091. * Not entered XR mode
  43092. */
  43093. NOT_IN_XR = 3
  43094. }
  43095. /**
  43096. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43097. * @see https://doc.babylonjs.com/how_to/webxr
  43098. */
  43099. export class WebXRExperienceHelper implements IDisposable {
  43100. private scene;
  43101. /**
  43102. * 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
  43103. */
  43104. container: AbstractMesh;
  43105. /**
  43106. * Camera used to render xr content
  43107. */
  43108. camera: WebXRCamera;
  43109. /**
  43110. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43111. */
  43112. state: WebXRState;
  43113. private _setState;
  43114. private static _TmpVector;
  43115. /**
  43116. * Fires when the state of the experience helper has changed
  43117. */
  43118. onStateChangedObservable: Observable<WebXRState>;
  43119. /** Session manager used to keep track of xr session */
  43120. sessionManager: WebXRSessionManager;
  43121. private _nonVRCamera;
  43122. private _originalSceneAutoClear;
  43123. private _supported;
  43124. /**
  43125. * Creates the experience helper
  43126. * @param scene the scene to attach the experience helper to
  43127. * @returns a promise for the experience helper
  43128. */
  43129. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43130. /**
  43131. * Creates a WebXRExperienceHelper
  43132. * @param scene The scene the helper should be created in
  43133. */
  43134. private constructor();
  43135. /**
  43136. * Exits XR mode and returns the scene to its original state
  43137. * @returns promise that resolves after xr mode has exited
  43138. */
  43139. exitXRAsync(): Promise<unknown>;
  43140. /**
  43141. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43142. * @param sessionCreationOptions options for the XR session
  43143. * @param referenceSpaceType frame of reference of the XR session
  43144. * @param outputCanvas the output canvas that will be used to enter XR mode
  43145. * @returns promise that resolves after xr mode has entered
  43146. */
  43147. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43148. /**
  43149. * Updates the global position of the camera by moving the camera's container
  43150. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43151. * @param position The desired global position of the camera
  43152. */
  43153. setPositionOfCameraUsingContainer(position: Vector3): void;
  43154. /**
  43155. * Rotates the xr camera by rotating the camera's container around the camera's position
  43156. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43157. * @param rotation the desired quaternion rotation to apply to the camera
  43158. */
  43159. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43160. /**
  43161. * Disposes of the experience helper
  43162. */
  43163. dispose(): void;
  43164. }
  43165. }
  43166. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43167. import { Nullable } from "babylonjs/types";
  43168. import { Observable } from "babylonjs/Misc/observable";
  43169. import { IDisposable, Scene } from "babylonjs/scene";
  43170. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43171. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43172. /**
  43173. * Button which can be used to enter a different mode of XR
  43174. */
  43175. export class WebXREnterExitUIButton {
  43176. /** button element */
  43177. element: HTMLElement;
  43178. /** XR initialization options for the button */
  43179. sessionMode: XRSessionMode;
  43180. /** Reference space type */
  43181. referenceSpaceType: XRReferenceSpaceType;
  43182. /**
  43183. * Creates a WebXREnterExitUIButton
  43184. * @param element button element
  43185. * @param sessionMode XR initialization session mode
  43186. * @param referenceSpaceType the type of reference space to be used
  43187. */
  43188. constructor(
  43189. /** button element */
  43190. element: HTMLElement,
  43191. /** XR initialization options for the button */
  43192. sessionMode: XRSessionMode,
  43193. /** Reference space type */
  43194. referenceSpaceType: XRReferenceSpaceType);
  43195. /**
  43196. * Overwritable function which can be used to update the button's visuals when the state changes
  43197. * @param activeButton the current active button in the UI
  43198. */
  43199. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43200. }
  43201. /**
  43202. * Options to create the webXR UI
  43203. */
  43204. export class WebXREnterExitUIOptions {
  43205. /**
  43206. * Context to enter xr with
  43207. */
  43208. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43209. /**
  43210. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43211. */
  43212. customButtons?: Array<WebXREnterExitUIButton>;
  43213. }
  43214. /**
  43215. * UI to allow the user to enter/exit XR mode
  43216. */
  43217. export class WebXREnterExitUI implements IDisposable {
  43218. private scene;
  43219. private _overlay;
  43220. private _buttons;
  43221. private _activeButton;
  43222. /**
  43223. * Fired every time the active button is changed.
  43224. *
  43225. * When xr is entered via a button that launches xr that button will be the callback parameter
  43226. *
  43227. * When exiting xr the callback parameter will be null)
  43228. */
  43229. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43230. /**
  43231. * Creates UI to allow the user to enter/exit XR mode
  43232. * @param scene the scene to add the ui to
  43233. * @param helper the xr experience helper to enter/exit xr with
  43234. * @param options options to configure the UI
  43235. * @returns the created ui
  43236. */
  43237. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43238. private constructor();
  43239. private _updateButtons;
  43240. /**
  43241. * Disposes of the object
  43242. */
  43243. dispose(): void;
  43244. }
  43245. }
  43246. declare module "babylonjs/Cameras/XR/webXRController" {
  43247. import { Nullable } from "babylonjs/types";
  43248. import { Observable } from "babylonjs/Misc/observable";
  43249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43250. import { Ray } from "babylonjs/Culling/ray";
  43251. import { Scene } from "babylonjs/scene";
  43252. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43253. /**
  43254. * Represents an XR input
  43255. */
  43256. export class WebXRController {
  43257. private scene;
  43258. /** The underlying input source for the controller */
  43259. inputSource: XRInputSource;
  43260. private parentContainer;
  43261. /**
  43262. * 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
  43263. */
  43264. grip?: AbstractMesh;
  43265. /**
  43266. * Pointer which can be used to select objects or attach a visible laser to
  43267. */
  43268. pointer: AbstractMesh;
  43269. private _gamepadMode;
  43270. /**
  43271. * If available, this is the gamepad object related to this controller.
  43272. * Using this object it is possible to get click events and trackpad changes of the
  43273. * webxr controller that is currently being used.
  43274. */
  43275. gamepadController?: WebVRController;
  43276. /**
  43277. * Event that fires when the controller is removed/disposed
  43278. */
  43279. onDisposeObservable: Observable<{}>;
  43280. private _tmpMatrix;
  43281. private _tmpQuaternion;
  43282. private _tmpVector;
  43283. /**
  43284. * Creates the controller
  43285. * @see https://doc.babylonjs.com/how_to/webxr
  43286. * @param scene the scene which the controller should be associated to
  43287. * @param inputSource the underlying input source for the controller
  43288. * @param parentContainer parent that the controller meshes should be children of
  43289. */
  43290. constructor(scene: Scene,
  43291. /** The underlying input source for the controller */
  43292. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43293. /**
  43294. * Updates the controller pose based on the given XRFrame
  43295. * @param xrFrame xr frame to update the pose with
  43296. * @param referenceSpace reference space to use
  43297. */
  43298. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43299. /**
  43300. * Gets a world space ray coming from the controller
  43301. * @param result the resulting ray
  43302. */
  43303. getWorldPointerRayToRef(result: Ray): void;
  43304. /**
  43305. * Get the scene associated with this controller
  43306. * @returns the scene object
  43307. */
  43308. getScene(): Scene;
  43309. /**
  43310. * Disposes of the object
  43311. */
  43312. dispose(): void;
  43313. }
  43314. }
  43315. declare module "babylonjs/Cameras/XR/webXRInput" {
  43316. import { Observable } from "babylonjs/Misc/observable";
  43317. import { IDisposable } from "babylonjs/scene";
  43318. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43319. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43320. /**
  43321. * XR input used to track XR inputs such as controllers/rays
  43322. */
  43323. export class WebXRInput implements IDisposable {
  43324. /**
  43325. * Base experience the input listens to
  43326. */
  43327. baseExperience: WebXRExperienceHelper;
  43328. /**
  43329. * XR controllers being tracked
  43330. */
  43331. controllers: Array<WebXRController>;
  43332. private _frameObserver;
  43333. private _stateObserver;
  43334. /**
  43335. * Event when a controller has been connected/added
  43336. */
  43337. onControllerAddedObservable: Observable<WebXRController>;
  43338. /**
  43339. * Event when a controller has been removed/disconnected
  43340. */
  43341. onControllerRemovedObservable: Observable<WebXRController>;
  43342. /**
  43343. * Initializes the WebXRInput
  43344. * @param baseExperience experience helper which the input should be created for
  43345. */
  43346. constructor(
  43347. /**
  43348. * Base experience the input listens to
  43349. */
  43350. baseExperience: WebXRExperienceHelper);
  43351. private _onInputSourcesChange;
  43352. private _addAndRemoveControllers;
  43353. /**
  43354. * Disposes of the object
  43355. */
  43356. dispose(): void;
  43357. }
  43358. }
  43359. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43361. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43362. /**
  43363. * Enables teleportation
  43364. */
  43365. export class WebXRControllerTeleportation {
  43366. private _teleportationFillColor;
  43367. private _teleportationBorderColor;
  43368. private _tmpRay;
  43369. private _tmpVector;
  43370. /**
  43371. * Creates a WebXRControllerTeleportation
  43372. * @param input input manager to add teleportation to
  43373. * @param floorMeshes floormeshes which can be teleported to
  43374. */
  43375. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43376. }
  43377. }
  43378. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43379. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43380. /**
  43381. * Handles pointer input automatically for the pointer of XR controllers
  43382. */
  43383. export class WebXRControllerPointerSelection {
  43384. private static _idCounter;
  43385. private _tmpRay;
  43386. /**
  43387. * Creates a WebXRControllerPointerSelection
  43388. * @param input input manager to setup pointer selection
  43389. */
  43390. constructor(input: WebXRInput);
  43391. private _convertNormalToDirectionOfRay;
  43392. private _updatePointerDistance;
  43393. }
  43394. }
  43395. declare module "babylonjs/Loading/sceneLoader" {
  43396. import { Observable } from "babylonjs/Misc/observable";
  43397. import { Nullable } from "babylonjs/types";
  43398. import { Scene } from "babylonjs/scene";
  43399. import { Engine } from "babylonjs/Engines/engine";
  43400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43401. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43402. import { AssetContainer } from "babylonjs/assetContainer";
  43403. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43404. import { Skeleton } from "babylonjs/Bones/skeleton";
  43405. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43406. import { WebRequest } from "babylonjs/Misc/webRequest";
  43407. /**
  43408. * Class used to represent data loading progression
  43409. */
  43410. export class SceneLoaderProgressEvent {
  43411. /** defines if data length to load can be evaluated */
  43412. readonly lengthComputable: boolean;
  43413. /** defines the loaded data length */
  43414. readonly loaded: number;
  43415. /** defines the data length to load */
  43416. readonly total: number;
  43417. /**
  43418. * Create a new progress event
  43419. * @param lengthComputable defines if data length to load can be evaluated
  43420. * @param loaded defines the loaded data length
  43421. * @param total defines the data length to load
  43422. */
  43423. constructor(
  43424. /** defines if data length to load can be evaluated */
  43425. lengthComputable: boolean,
  43426. /** defines the loaded data length */
  43427. loaded: number,
  43428. /** defines the data length to load */
  43429. total: number);
  43430. /**
  43431. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43432. * @param event defines the source event
  43433. * @returns a new SceneLoaderProgressEvent
  43434. */
  43435. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43436. }
  43437. /**
  43438. * Interface used by SceneLoader plugins to define supported file extensions
  43439. */
  43440. export interface ISceneLoaderPluginExtensions {
  43441. /**
  43442. * Defines the list of supported extensions
  43443. */
  43444. [extension: string]: {
  43445. isBinary: boolean;
  43446. };
  43447. }
  43448. /**
  43449. * Interface used by SceneLoader plugin factory
  43450. */
  43451. export interface ISceneLoaderPluginFactory {
  43452. /**
  43453. * Defines the name of the factory
  43454. */
  43455. name: string;
  43456. /**
  43457. * Function called to create a new plugin
  43458. * @return the new plugin
  43459. */
  43460. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43461. /**
  43462. * The callback that returns true if the data can be directly loaded.
  43463. * @param data string containing the file data
  43464. * @returns if the data can be loaded directly
  43465. */
  43466. canDirectLoad?(data: string): boolean;
  43467. }
  43468. /**
  43469. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43470. */
  43471. export interface ISceneLoaderPluginBase {
  43472. /**
  43473. * The friendly name of this plugin.
  43474. */
  43475. name: string;
  43476. /**
  43477. * The file extensions supported by this plugin.
  43478. */
  43479. extensions: string | ISceneLoaderPluginExtensions;
  43480. /**
  43481. * The callback called when loading from a url.
  43482. * @param scene scene loading this url
  43483. * @param url url to load
  43484. * @param onSuccess callback called when the file successfully loads
  43485. * @param onProgress callback called while file is loading (if the server supports this mode)
  43486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43487. * @param onError callback called when the file fails to load
  43488. * @returns a file request object
  43489. */
  43490. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43491. /**
  43492. * The callback called when loading from a file object.
  43493. * @param scene scene loading this file
  43494. * @param file defines the file to load
  43495. * @param onSuccess defines the callback to call when data is loaded
  43496. * @param onProgress defines the callback to call during loading process
  43497. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43498. * @param onError defines the callback to call when an error occurs
  43499. * @returns a file request object
  43500. */
  43501. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43502. /**
  43503. * The callback that returns true if the data can be directly loaded.
  43504. * @param data string containing the file data
  43505. * @returns if the data can be loaded directly
  43506. */
  43507. canDirectLoad?(data: string): boolean;
  43508. /**
  43509. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43510. * @param scene scene loading this data
  43511. * @param data string containing the data
  43512. * @returns data to pass to the plugin
  43513. */
  43514. directLoad?(scene: Scene, data: string): any;
  43515. /**
  43516. * The callback that allows custom handling of the root url based on the response url.
  43517. * @param rootUrl the original root url
  43518. * @param responseURL the response url if available
  43519. * @returns the new root url
  43520. */
  43521. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43522. }
  43523. /**
  43524. * Interface used to define a SceneLoader plugin
  43525. */
  43526. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43527. /**
  43528. * Import meshes into a scene.
  43529. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43530. * @param scene The scene to import into
  43531. * @param data The data to import
  43532. * @param rootUrl The root url for scene and resources
  43533. * @param meshes The meshes array to import into
  43534. * @param particleSystems The particle systems array to import into
  43535. * @param skeletons The skeletons array to import into
  43536. * @param onError The callback when import fails
  43537. * @returns True if successful or false otherwise
  43538. */
  43539. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43540. /**
  43541. * Load into a scene.
  43542. * @param scene The scene to load into
  43543. * @param data The data to import
  43544. * @param rootUrl The root url for scene and resources
  43545. * @param onError The callback when import fails
  43546. * @returns True if successful or false otherwise
  43547. */
  43548. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43549. /**
  43550. * Load into an asset container.
  43551. * @param scene The scene to load into
  43552. * @param data The data to import
  43553. * @param rootUrl The root url for scene and resources
  43554. * @param onError The callback when import fails
  43555. * @returns The loaded asset container
  43556. */
  43557. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43558. }
  43559. /**
  43560. * Interface used to define an async SceneLoader plugin
  43561. */
  43562. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43563. /**
  43564. * Import meshes into a scene.
  43565. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43566. * @param scene The scene to import into
  43567. * @param data The data to import
  43568. * @param rootUrl The root url for scene and resources
  43569. * @param onProgress The callback when the load progresses
  43570. * @param fileName Defines the name of the file to load
  43571. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43572. */
  43573. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43574. meshes: AbstractMesh[];
  43575. particleSystems: IParticleSystem[];
  43576. skeletons: Skeleton[];
  43577. animationGroups: AnimationGroup[];
  43578. }>;
  43579. /**
  43580. * Load into a scene.
  43581. * @param scene The scene to load into
  43582. * @param data The data to import
  43583. * @param rootUrl The root url for scene and resources
  43584. * @param onProgress The callback when the load progresses
  43585. * @param fileName Defines the name of the file to load
  43586. * @returns Nothing
  43587. */
  43588. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43589. /**
  43590. * Load into an asset container.
  43591. * @param scene The scene to load into
  43592. * @param data The data to import
  43593. * @param rootUrl The root url for scene and resources
  43594. * @param onProgress The callback when the load progresses
  43595. * @param fileName Defines the name of the file to load
  43596. * @returns The loaded asset container
  43597. */
  43598. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43599. }
  43600. /**
  43601. * Class used to load scene from various file formats using registered plugins
  43602. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43603. */
  43604. export class SceneLoader {
  43605. /**
  43606. * No logging while loading
  43607. */
  43608. static readonly NO_LOGGING: number;
  43609. /**
  43610. * Minimal logging while loading
  43611. */
  43612. static readonly MINIMAL_LOGGING: number;
  43613. /**
  43614. * Summary logging while loading
  43615. */
  43616. static readonly SUMMARY_LOGGING: number;
  43617. /**
  43618. * Detailled logging while loading
  43619. */
  43620. static readonly DETAILED_LOGGING: number;
  43621. /**
  43622. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43623. */
  43624. static ForceFullSceneLoadingForIncremental: boolean;
  43625. /**
  43626. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43627. */
  43628. static ShowLoadingScreen: boolean;
  43629. /**
  43630. * Defines the current logging level (while loading the scene)
  43631. * @ignorenaming
  43632. */
  43633. static loggingLevel: number;
  43634. /**
  43635. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43636. */
  43637. static CleanBoneMatrixWeights: boolean;
  43638. /**
  43639. * Event raised when a plugin is used to load a scene
  43640. */
  43641. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43642. private static _registeredPlugins;
  43643. private static _getDefaultPlugin;
  43644. private static _getPluginForExtension;
  43645. private static _getPluginForDirectLoad;
  43646. private static _getPluginForFilename;
  43647. private static _getDirectLoad;
  43648. private static _loadData;
  43649. private static _getFileInfo;
  43650. /**
  43651. * Gets a plugin that can load the given extension
  43652. * @param extension defines the extension to load
  43653. * @returns a plugin or null if none works
  43654. */
  43655. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43656. /**
  43657. * Gets a boolean indicating that the given extension can be loaded
  43658. * @param extension defines the extension to load
  43659. * @returns true if the extension is supported
  43660. */
  43661. static IsPluginForExtensionAvailable(extension: string): boolean;
  43662. /**
  43663. * Adds a new plugin to the list of registered plugins
  43664. * @param plugin defines the plugin to add
  43665. */
  43666. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43667. /**
  43668. * Import meshes into a scene
  43669. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43670. * @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)
  43671. * @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)
  43672. * @param scene the instance of BABYLON.Scene to append to
  43673. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43674. * @param onProgress a callback with a progress event for each file being loaded
  43675. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43676. * @param pluginExtension the extension used to determine the plugin
  43677. * @returns The loaded plugin
  43678. */
  43679. 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>;
  43680. /**
  43681. * Import meshes into a scene
  43682. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43683. * @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)
  43684. * @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)
  43685. * @param scene the instance of BABYLON.Scene to append to
  43686. * @param onProgress a callback with a progress event for each file being loaded
  43687. * @param pluginExtension the extension used to determine the plugin
  43688. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43689. */
  43690. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43691. meshes: AbstractMesh[];
  43692. particleSystems: IParticleSystem[];
  43693. skeletons: Skeleton[];
  43694. animationGroups: AnimationGroup[];
  43695. }>;
  43696. /**
  43697. * Load a scene
  43698. * @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)
  43699. * @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)
  43700. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43701. * @param onSuccess a callback with the scene when import succeeds
  43702. * @param onProgress a callback with a progress event for each file being loaded
  43703. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43704. * @param pluginExtension the extension used to determine the plugin
  43705. * @returns The loaded plugin
  43706. */
  43707. 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>;
  43708. /**
  43709. * Load a scene
  43710. * @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)
  43711. * @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)
  43712. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43713. * @param onProgress a callback with a progress event for each file being loaded
  43714. * @param pluginExtension the extension used to determine the plugin
  43715. * @returns The loaded scene
  43716. */
  43717. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43718. /**
  43719. * Append a scene
  43720. * @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)
  43721. * @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)
  43722. * @param scene is the instance of BABYLON.Scene to append to
  43723. * @param onSuccess a callback with the scene when import succeeds
  43724. * @param onProgress a callback with a progress event for each file being loaded
  43725. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43726. * @param pluginExtension the extension used to determine the plugin
  43727. * @returns The loaded plugin
  43728. */
  43729. 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>;
  43730. /**
  43731. * Append a scene
  43732. * @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)
  43733. * @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)
  43734. * @param scene is the instance of BABYLON.Scene to append to
  43735. * @param onProgress a callback with a progress event for each file being loaded
  43736. * @param pluginExtension the extension used to determine the plugin
  43737. * @returns The given scene
  43738. */
  43739. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43740. /**
  43741. * Load a scene into an asset container
  43742. * @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)
  43743. * @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)
  43744. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43745. * @param onSuccess a callback with the scene when import succeeds
  43746. * @param onProgress a callback with a progress event for each file being loaded
  43747. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43748. * @param pluginExtension the extension used to determine the plugin
  43749. * @returns The loaded plugin
  43750. */
  43751. 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>;
  43752. /**
  43753. * Load a scene into an asset container
  43754. * @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)
  43755. * @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)
  43756. * @param scene is the instance of Scene to append to
  43757. * @param onProgress a callback with a progress event for each file being loaded
  43758. * @param pluginExtension the extension used to determine the plugin
  43759. * @returns The loaded asset container
  43760. */
  43761. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43762. }
  43763. }
  43764. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43765. import { Scene } from "babylonjs/scene";
  43766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43767. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43768. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43769. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43770. /**
  43771. * Generic Controller
  43772. */
  43773. export class GenericController extends WebVRController {
  43774. /**
  43775. * Base Url for the controller model.
  43776. */
  43777. static readonly MODEL_BASE_URL: string;
  43778. /**
  43779. * File name for the controller model.
  43780. */
  43781. static readonly MODEL_FILENAME: string;
  43782. /**
  43783. * Creates a new GenericController from a gamepad
  43784. * @param vrGamepad the gamepad that the controller should be created from
  43785. */
  43786. constructor(vrGamepad: any);
  43787. /**
  43788. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43789. * @param scene scene in which to add meshes
  43790. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43791. */
  43792. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43793. /**
  43794. * Called once for each button that changed state since the last frame
  43795. * @param buttonIdx Which button index changed
  43796. * @param state New state of the button
  43797. * @param changes Which properties on the state changed since last frame
  43798. */
  43799. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43800. }
  43801. }
  43802. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43803. import { Observable } from "babylonjs/Misc/observable";
  43804. import { Scene } from "babylonjs/scene";
  43805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43806. import { Ray } from "babylonjs/Culling/ray";
  43807. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43808. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43809. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43810. /**
  43811. * Defines the WindowsMotionController object that the state of the windows motion controller
  43812. */
  43813. export class WindowsMotionController extends WebVRController {
  43814. /**
  43815. * The base url used to load the left and right controller models
  43816. */
  43817. static MODEL_BASE_URL: string;
  43818. /**
  43819. * The name of the left controller model file
  43820. */
  43821. static MODEL_LEFT_FILENAME: string;
  43822. /**
  43823. * The name of the right controller model file
  43824. */
  43825. static MODEL_RIGHT_FILENAME: string;
  43826. /**
  43827. * The controller name prefix for this controller type
  43828. */
  43829. static readonly GAMEPAD_ID_PREFIX: string;
  43830. /**
  43831. * The controller id pattern for this controller type
  43832. */
  43833. private static readonly GAMEPAD_ID_PATTERN;
  43834. private _loadedMeshInfo;
  43835. private readonly _mapping;
  43836. /**
  43837. * Fired when the trackpad on this controller is clicked
  43838. */
  43839. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43840. /**
  43841. * Fired when the trackpad on this controller is modified
  43842. */
  43843. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43844. /**
  43845. * The current x and y values of this controller's trackpad
  43846. */
  43847. trackpad: StickValues;
  43848. /**
  43849. * Creates a new WindowsMotionController from a gamepad
  43850. * @param vrGamepad the gamepad that the controller should be created from
  43851. */
  43852. constructor(vrGamepad: any);
  43853. /**
  43854. * Fired when the trigger on this controller is modified
  43855. */
  43856. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43857. /**
  43858. * Fired when the menu button on this controller is modified
  43859. */
  43860. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43861. /**
  43862. * Fired when the grip button on this controller is modified
  43863. */
  43864. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43865. /**
  43866. * Fired when the thumbstick button on this controller is modified
  43867. */
  43868. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43869. /**
  43870. * Fired when the touchpad button on this controller is modified
  43871. */
  43872. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43873. /**
  43874. * Fired when the touchpad values on this controller are modified
  43875. */
  43876. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43877. private _updateTrackpad;
  43878. /**
  43879. * Called once per frame by the engine.
  43880. */
  43881. update(): void;
  43882. /**
  43883. * Called once for each button that changed state since the last frame
  43884. * @param buttonIdx Which button index changed
  43885. * @param state New state of the button
  43886. * @param changes Which properties on the state changed since last frame
  43887. */
  43888. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43889. /**
  43890. * Moves the buttons on the controller mesh based on their current state
  43891. * @param buttonName the name of the button to move
  43892. * @param buttonValue the value of the button which determines the buttons new position
  43893. */
  43894. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43895. /**
  43896. * Moves the axis on the controller mesh based on its current state
  43897. * @param axis the index of the axis
  43898. * @param axisValue the value of the axis which determines the meshes new position
  43899. * @hidden
  43900. */
  43901. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43902. /**
  43903. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43904. * @param scene scene in which to add meshes
  43905. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43906. */
  43907. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43908. /**
  43909. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43910. * can be transformed by button presses and axes values, based on this._mapping.
  43911. *
  43912. * @param scene scene in which the meshes exist
  43913. * @param meshes list of meshes that make up the controller model to process
  43914. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43915. */
  43916. private processModel;
  43917. private createMeshInfo;
  43918. /**
  43919. * Gets the ray of the controller in the direction the controller is pointing
  43920. * @param length the length the resulting ray should be
  43921. * @returns a ray in the direction the controller is pointing
  43922. */
  43923. getForwardRay(length?: number): Ray;
  43924. /**
  43925. * Disposes of the controller
  43926. */
  43927. dispose(): void;
  43928. }
  43929. }
  43930. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43931. import { Observable } from "babylonjs/Misc/observable";
  43932. import { Scene } from "babylonjs/scene";
  43933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43934. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43935. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43936. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43937. /**
  43938. * Oculus Touch Controller
  43939. */
  43940. export class OculusTouchController extends WebVRController {
  43941. /**
  43942. * Base Url for the controller model.
  43943. */
  43944. static MODEL_BASE_URL: string;
  43945. /**
  43946. * File name for the left controller model.
  43947. */
  43948. static MODEL_LEFT_FILENAME: string;
  43949. /**
  43950. * File name for the right controller model.
  43951. */
  43952. static MODEL_RIGHT_FILENAME: string;
  43953. /**
  43954. * Base Url for the Quest controller model.
  43955. */
  43956. static QUEST_MODEL_BASE_URL: string;
  43957. /**
  43958. * @hidden
  43959. * If the controllers are running on a device that needs the updated Quest controller models
  43960. */
  43961. static _IsQuest: boolean;
  43962. /**
  43963. * Fired when the secondary trigger on this controller is modified
  43964. */
  43965. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43966. /**
  43967. * Fired when the thumb rest on this controller is modified
  43968. */
  43969. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43970. /**
  43971. * Creates a new OculusTouchController from a gamepad
  43972. * @param vrGamepad the gamepad that the controller should be created from
  43973. */
  43974. constructor(vrGamepad: any);
  43975. /**
  43976. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43977. * @param scene scene in which to add meshes
  43978. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43979. */
  43980. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43981. /**
  43982. * Fired when the A button on this controller is modified
  43983. */
  43984. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43985. /**
  43986. * Fired when the B button on this controller is modified
  43987. */
  43988. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43989. /**
  43990. * Fired when the X button on this controller is modified
  43991. */
  43992. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43993. /**
  43994. * Fired when the Y button on this controller is modified
  43995. */
  43996. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43997. /**
  43998. * Called once for each button that changed state since the last frame
  43999. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44000. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44001. * 2) secondary trigger (same)
  44002. * 3) A (right) X (left), touch, pressed = value
  44003. * 4) B / Y
  44004. * 5) thumb rest
  44005. * @param buttonIdx Which button index changed
  44006. * @param state New state of the button
  44007. * @param changes Which properties on the state changed since last frame
  44008. */
  44009. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44010. }
  44011. }
  44012. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44013. import { Scene } from "babylonjs/scene";
  44014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44015. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44016. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44017. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44018. import { Observable } from "babylonjs/Misc/observable";
  44019. /**
  44020. * Vive Controller
  44021. */
  44022. export class ViveController extends WebVRController {
  44023. /**
  44024. * Base Url for the controller model.
  44025. */
  44026. static MODEL_BASE_URL: string;
  44027. /**
  44028. * File name for the controller model.
  44029. */
  44030. static MODEL_FILENAME: string;
  44031. /**
  44032. * Creates a new ViveController from a gamepad
  44033. * @param vrGamepad the gamepad that the controller should be created from
  44034. */
  44035. constructor(vrGamepad: any);
  44036. /**
  44037. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44038. * @param scene scene in which to add meshes
  44039. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44040. */
  44041. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44042. /**
  44043. * Fired when the left button on this controller is modified
  44044. */
  44045. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44046. /**
  44047. * Fired when the right button on this controller is modified
  44048. */
  44049. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44050. /**
  44051. * Fired when the menu button on this controller is modified
  44052. */
  44053. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44054. /**
  44055. * Called once for each button that changed state since the last frame
  44056. * Vive mapping:
  44057. * 0: touchpad
  44058. * 1: trigger
  44059. * 2: left AND right buttons
  44060. * 3: menu button
  44061. * @param buttonIdx Which button index changed
  44062. * @param state New state of the button
  44063. * @param changes Which properties on the state changed since last frame
  44064. */
  44065. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44066. }
  44067. }
  44068. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44069. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44070. /**
  44071. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44072. */
  44073. export class WebXRControllerModelLoader {
  44074. /**
  44075. * Creates the WebXRControllerModelLoader
  44076. * @param input xr input that creates the controllers
  44077. */
  44078. constructor(input: WebXRInput);
  44079. }
  44080. }
  44081. declare module "babylonjs/Cameras/XR/index" {
  44082. export * from "babylonjs/Cameras/XR/webXRCamera";
  44083. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44084. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44085. export * from "babylonjs/Cameras/XR/webXRInput";
  44086. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44087. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44088. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44089. export * from "babylonjs/Cameras/XR/webXRController";
  44090. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44091. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44092. }
  44093. declare module "babylonjs/Cameras/RigModes/index" {
  44094. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44095. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44096. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44097. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44098. }
  44099. declare module "babylonjs/Cameras/index" {
  44100. export * from "babylonjs/Cameras/Inputs/index";
  44101. export * from "babylonjs/Cameras/cameraInputsManager";
  44102. export * from "babylonjs/Cameras/camera";
  44103. export * from "babylonjs/Cameras/targetCamera";
  44104. export * from "babylonjs/Cameras/freeCamera";
  44105. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44106. export * from "babylonjs/Cameras/touchCamera";
  44107. export * from "babylonjs/Cameras/arcRotateCamera";
  44108. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44109. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44110. export * from "babylonjs/Cameras/flyCamera";
  44111. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44112. export * from "babylonjs/Cameras/followCamera";
  44113. export * from "babylonjs/Cameras/followCameraInputsManager";
  44114. export * from "babylonjs/Cameras/gamepadCamera";
  44115. export * from "babylonjs/Cameras/Stereoscopic/index";
  44116. export * from "babylonjs/Cameras/universalCamera";
  44117. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44118. export * from "babylonjs/Cameras/VR/index";
  44119. export * from "babylonjs/Cameras/XR/index";
  44120. export * from "babylonjs/Cameras/RigModes/index";
  44121. }
  44122. declare module "babylonjs/Collisions/index" {
  44123. export * from "babylonjs/Collisions/collider";
  44124. export * from "babylonjs/Collisions/collisionCoordinator";
  44125. export * from "babylonjs/Collisions/pickingInfo";
  44126. export * from "babylonjs/Collisions/intersectionInfo";
  44127. export * from "babylonjs/Collisions/meshCollisionData";
  44128. }
  44129. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44130. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44131. import { Vector3 } from "babylonjs/Maths/math.vector";
  44132. import { Ray } from "babylonjs/Culling/ray";
  44133. import { Plane } from "babylonjs/Maths/math.plane";
  44134. /**
  44135. * Contains an array of blocks representing the octree
  44136. */
  44137. export interface IOctreeContainer<T> {
  44138. /**
  44139. * Blocks within the octree
  44140. */
  44141. blocks: Array<OctreeBlock<T>>;
  44142. }
  44143. /**
  44144. * Class used to store a cell in an octree
  44145. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44146. */
  44147. export class OctreeBlock<T> {
  44148. /**
  44149. * Gets the content of the current block
  44150. */
  44151. entries: T[];
  44152. /**
  44153. * Gets the list of block children
  44154. */
  44155. blocks: Array<OctreeBlock<T>>;
  44156. private _depth;
  44157. private _maxDepth;
  44158. private _capacity;
  44159. private _minPoint;
  44160. private _maxPoint;
  44161. private _boundingVectors;
  44162. private _creationFunc;
  44163. /**
  44164. * Creates a new block
  44165. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44166. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44167. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44168. * @param depth defines the current depth of this block in the octree
  44169. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44170. * @param creationFunc defines a callback to call when an element is added to the block
  44171. */
  44172. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44173. /**
  44174. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44175. */
  44176. readonly capacity: number;
  44177. /**
  44178. * Gets the minimum vector (in world space) of the block's bounding box
  44179. */
  44180. readonly minPoint: Vector3;
  44181. /**
  44182. * Gets the maximum vector (in world space) of the block's bounding box
  44183. */
  44184. readonly maxPoint: Vector3;
  44185. /**
  44186. * Add a new element to this block
  44187. * @param entry defines the element to add
  44188. */
  44189. addEntry(entry: T): void;
  44190. /**
  44191. * Remove an element from this block
  44192. * @param entry defines the element to remove
  44193. */
  44194. removeEntry(entry: T): void;
  44195. /**
  44196. * Add an array of elements to this block
  44197. * @param entries defines the array of elements to add
  44198. */
  44199. addEntries(entries: T[]): void;
  44200. /**
  44201. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44202. * @param frustumPlanes defines the frustum planes to test
  44203. * @param selection defines the array to store current content if selection is positive
  44204. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44205. */
  44206. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44207. /**
  44208. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44209. * @param sphereCenter defines the bounding sphere center
  44210. * @param sphereRadius defines the bounding sphere radius
  44211. * @param selection defines the array to store current content if selection is positive
  44212. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44213. */
  44214. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44215. /**
  44216. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44217. * @param ray defines the ray to test with
  44218. * @param selection defines the array to store current content if selection is positive
  44219. */
  44220. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44221. /**
  44222. * Subdivide the content into child blocks (this block will then be empty)
  44223. */
  44224. createInnerBlocks(): void;
  44225. /**
  44226. * @hidden
  44227. */
  44228. 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;
  44229. }
  44230. }
  44231. declare module "babylonjs/Culling/Octrees/octree" {
  44232. import { SmartArray } from "babylonjs/Misc/smartArray";
  44233. import { Vector3 } from "babylonjs/Maths/math.vector";
  44234. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44236. import { Ray } from "babylonjs/Culling/ray";
  44237. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44238. import { Plane } from "babylonjs/Maths/math.plane";
  44239. /**
  44240. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44241. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44242. */
  44243. export class Octree<T> {
  44244. /** 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.) */
  44245. maxDepth: number;
  44246. /**
  44247. * Blocks within the octree containing objects
  44248. */
  44249. blocks: Array<OctreeBlock<T>>;
  44250. /**
  44251. * Content stored in the octree
  44252. */
  44253. dynamicContent: T[];
  44254. private _maxBlockCapacity;
  44255. private _selectionContent;
  44256. private _creationFunc;
  44257. /**
  44258. * Creates a octree
  44259. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44260. * @param creationFunc function to be used to instatiate the octree
  44261. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44262. * @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.)
  44263. */
  44264. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44265. /** 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.) */
  44266. maxDepth?: number);
  44267. /**
  44268. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44269. * @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);
  44270. * @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);
  44271. * @param entries meshes to be added to the octree blocks
  44272. */
  44273. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44274. /**
  44275. * Adds a mesh to the octree
  44276. * @param entry Mesh to add to the octree
  44277. */
  44278. addMesh(entry: T): void;
  44279. /**
  44280. * Remove an element from the octree
  44281. * @param entry defines the element to remove
  44282. */
  44283. removeMesh(entry: T): void;
  44284. /**
  44285. * Selects an array of meshes within the frustum
  44286. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44287. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44288. * @returns array of meshes within the frustum
  44289. */
  44290. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44291. /**
  44292. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44293. * @param sphereCenter defines the bounding sphere center
  44294. * @param sphereRadius defines the bounding sphere radius
  44295. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44296. * @returns an array of objects that intersect the sphere
  44297. */
  44298. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44299. /**
  44300. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44301. * @param ray defines the ray to test with
  44302. * @returns array of intersected objects
  44303. */
  44304. intersectsRay(ray: Ray): SmartArray<T>;
  44305. /**
  44306. * Adds a mesh into the octree block if it intersects the block
  44307. */
  44308. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44309. /**
  44310. * Adds a submesh into the octree block if it intersects the block
  44311. */
  44312. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44313. }
  44314. }
  44315. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44316. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44317. import { Scene } from "babylonjs/scene";
  44318. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44320. import { Ray } from "babylonjs/Culling/ray";
  44321. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44322. import { Collider } from "babylonjs/Collisions/collider";
  44323. module "babylonjs/scene" {
  44324. interface Scene {
  44325. /**
  44326. * @hidden
  44327. * Backing Filed
  44328. */
  44329. _selectionOctree: Octree<AbstractMesh>;
  44330. /**
  44331. * Gets the octree used to boost mesh selection (picking)
  44332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44333. */
  44334. selectionOctree: Octree<AbstractMesh>;
  44335. /**
  44336. * Creates or updates the octree used to boost selection (picking)
  44337. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44338. * @param maxCapacity defines the maximum capacity per leaf
  44339. * @param maxDepth defines the maximum depth of the octree
  44340. * @returns an octree of AbstractMesh
  44341. */
  44342. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44343. }
  44344. }
  44345. module "babylonjs/Meshes/abstractMesh" {
  44346. interface AbstractMesh {
  44347. /**
  44348. * @hidden
  44349. * Backing Field
  44350. */
  44351. _submeshesOctree: Octree<SubMesh>;
  44352. /**
  44353. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44354. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44355. * @param maxCapacity defines the maximum size of each block (64 by default)
  44356. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44357. * @returns the new octree
  44358. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44360. */
  44361. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44362. }
  44363. }
  44364. /**
  44365. * Defines the octree scene component responsible to manage any octrees
  44366. * in a given scene.
  44367. */
  44368. export class OctreeSceneComponent {
  44369. /**
  44370. * The component name help to identify the component in the list of scene components.
  44371. */
  44372. readonly name: string;
  44373. /**
  44374. * The scene the component belongs to.
  44375. */
  44376. scene: Scene;
  44377. /**
  44378. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44379. */
  44380. readonly checksIsEnabled: boolean;
  44381. /**
  44382. * Creates a new instance of the component for the given scene
  44383. * @param scene Defines the scene to register the component in
  44384. */
  44385. constructor(scene: Scene);
  44386. /**
  44387. * Registers the component in a given scene
  44388. */
  44389. register(): void;
  44390. /**
  44391. * Return the list of active meshes
  44392. * @returns the list of active meshes
  44393. */
  44394. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44395. /**
  44396. * Return the list of active sub meshes
  44397. * @param mesh The mesh to get the candidates sub meshes from
  44398. * @returns the list of active sub meshes
  44399. */
  44400. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44401. private _tempRay;
  44402. /**
  44403. * Return the list of sub meshes intersecting with a given local ray
  44404. * @param mesh defines the mesh to find the submesh for
  44405. * @param localRay defines the ray in local space
  44406. * @returns the list of intersecting sub meshes
  44407. */
  44408. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44409. /**
  44410. * Return the list of sub meshes colliding with a collider
  44411. * @param mesh defines the mesh to find the submesh for
  44412. * @param collider defines the collider to evaluate the collision against
  44413. * @returns the list of colliding sub meshes
  44414. */
  44415. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44416. /**
  44417. * Rebuilds the elements related to this component in case of
  44418. * context lost for instance.
  44419. */
  44420. rebuild(): void;
  44421. /**
  44422. * Disposes the component and the associated ressources.
  44423. */
  44424. dispose(): void;
  44425. }
  44426. }
  44427. declare module "babylonjs/Culling/Octrees/index" {
  44428. export * from "babylonjs/Culling/Octrees/octree";
  44429. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44430. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44431. }
  44432. declare module "babylonjs/Culling/index" {
  44433. export * from "babylonjs/Culling/boundingBox";
  44434. export * from "babylonjs/Culling/boundingInfo";
  44435. export * from "babylonjs/Culling/boundingSphere";
  44436. export * from "babylonjs/Culling/Octrees/index";
  44437. export * from "babylonjs/Culling/ray";
  44438. }
  44439. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44440. import { IDisposable, Scene } from "babylonjs/scene";
  44441. import { Nullable } from "babylonjs/types";
  44442. import { Observable } from "babylonjs/Misc/observable";
  44443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44444. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44445. import { Camera } from "babylonjs/Cameras/camera";
  44446. /**
  44447. * Renders a layer on top of an existing scene
  44448. */
  44449. export class UtilityLayerRenderer implements IDisposable {
  44450. /** the original scene that will be rendered on top of */
  44451. originalScene: Scene;
  44452. private _pointerCaptures;
  44453. private _lastPointerEvents;
  44454. private static _DefaultUtilityLayer;
  44455. private static _DefaultKeepDepthUtilityLayer;
  44456. private _sharedGizmoLight;
  44457. private _renderCamera;
  44458. /**
  44459. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44460. * @returns the camera that is used when rendering the utility layer
  44461. */
  44462. getRenderCamera(): Nullable<Camera>;
  44463. /**
  44464. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44465. * @param cam the camera that should be used when rendering the utility layer
  44466. */
  44467. setRenderCamera(cam: Nullable<Camera>): void;
  44468. /**
  44469. * @hidden
  44470. * Light which used by gizmos to get light shading
  44471. */
  44472. _getSharedGizmoLight(): HemisphericLight;
  44473. /**
  44474. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44475. */
  44476. pickUtilitySceneFirst: boolean;
  44477. /**
  44478. * 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)
  44479. */
  44480. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44481. /**
  44482. * 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)
  44483. */
  44484. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44485. /**
  44486. * The scene that is rendered on top of the original scene
  44487. */
  44488. utilityLayerScene: Scene;
  44489. /**
  44490. * If the utility layer should automatically be rendered on top of existing scene
  44491. */
  44492. shouldRender: boolean;
  44493. /**
  44494. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44495. */
  44496. onlyCheckPointerDownEvents: boolean;
  44497. /**
  44498. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44499. */
  44500. processAllEvents: boolean;
  44501. /**
  44502. * Observable raised when the pointer move from the utility layer scene to the main scene
  44503. */
  44504. onPointerOutObservable: Observable<number>;
  44505. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44506. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44507. private _afterRenderObserver;
  44508. private _sceneDisposeObserver;
  44509. private _originalPointerObserver;
  44510. /**
  44511. * Instantiates a UtilityLayerRenderer
  44512. * @param originalScene the original scene that will be rendered on top of
  44513. * @param handleEvents boolean indicating if the utility layer should handle events
  44514. */
  44515. constructor(
  44516. /** the original scene that will be rendered on top of */
  44517. originalScene: Scene, handleEvents?: boolean);
  44518. private _notifyObservers;
  44519. /**
  44520. * Renders the utility layers scene on top of the original scene
  44521. */
  44522. render(): void;
  44523. /**
  44524. * Disposes of the renderer
  44525. */
  44526. dispose(): void;
  44527. private _updateCamera;
  44528. }
  44529. }
  44530. declare module "babylonjs/Gizmos/gizmo" {
  44531. import { Nullable } from "babylonjs/types";
  44532. import { IDisposable } from "babylonjs/scene";
  44533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44534. import { Mesh } from "babylonjs/Meshes/mesh";
  44535. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44536. /**
  44537. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44538. */
  44539. export class Gizmo implements IDisposable {
  44540. /** The utility layer the gizmo will be added to */
  44541. gizmoLayer: UtilityLayerRenderer;
  44542. /**
  44543. * The root mesh of the gizmo
  44544. */
  44545. _rootMesh: Mesh;
  44546. private _attachedMesh;
  44547. /**
  44548. * Ratio for the scale of the gizmo (Default: 1)
  44549. */
  44550. scaleRatio: number;
  44551. /**
  44552. * If a custom mesh has been set (Default: false)
  44553. */
  44554. protected _customMeshSet: boolean;
  44555. /**
  44556. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44557. * * When set, interactions will be enabled
  44558. */
  44559. attachedMesh: Nullable<AbstractMesh>;
  44560. /**
  44561. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44562. * @param mesh The mesh to replace the default mesh of the gizmo
  44563. */
  44564. setCustomMesh(mesh: Mesh): void;
  44565. /**
  44566. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44567. */
  44568. updateGizmoRotationToMatchAttachedMesh: boolean;
  44569. /**
  44570. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44571. */
  44572. updateGizmoPositionToMatchAttachedMesh: boolean;
  44573. /**
  44574. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44575. */
  44576. updateScale: boolean;
  44577. protected _interactionsEnabled: boolean;
  44578. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44579. private _beforeRenderObserver;
  44580. private _tempVector;
  44581. /**
  44582. * Creates a gizmo
  44583. * @param gizmoLayer The utility layer the gizmo will be added to
  44584. */
  44585. constructor(
  44586. /** The utility layer the gizmo will be added to */
  44587. gizmoLayer?: UtilityLayerRenderer);
  44588. /**
  44589. * Updates the gizmo to match the attached mesh's position/rotation
  44590. */
  44591. protected _update(): void;
  44592. /**
  44593. * Disposes of the gizmo
  44594. */
  44595. dispose(): void;
  44596. }
  44597. }
  44598. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44599. import { Observable } from "babylonjs/Misc/observable";
  44600. import { Nullable } from "babylonjs/types";
  44601. import { Vector3 } from "babylonjs/Maths/math.vector";
  44602. import { Color3 } from "babylonjs/Maths/math.color";
  44603. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44605. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44606. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44607. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44608. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44609. import { Scene } from "babylonjs/scene";
  44610. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44611. /**
  44612. * Single plane drag gizmo
  44613. */
  44614. export class PlaneDragGizmo extends Gizmo {
  44615. /**
  44616. * Drag behavior responsible for the gizmos dragging interactions
  44617. */
  44618. dragBehavior: PointerDragBehavior;
  44619. private _pointerObserver;
  44620. /**
  44621. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44622. */
  44623. snapDistance: number;
  44624. /**
  44625. * Event that fires each time the gizmo snaps to a new location.
  44626. * * snapDistance is the the change in distance
  44627. */
  44628. onSnapObservable: Observable<{
  44629. snapDistance: number;
  44630. }>;
  44631. private _plane;
  44632. private _coloredMaterial;
  44633. private _hoverMaterial;
  44634. private _isEnabled;
  44635. private _parent;
  44636. /** @hidden */
  44637. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44638. /** @hidden */
  44639. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44640. /**
  44641. * Creates a PlaneDragGizmo
  44642. * @param gizmoLayer The utility layer the gizmo will be added to
  44643. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44644. * @param color The color of the gizmo
  44645. */
  44646. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44647. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44648. /**
  44649. * If the gizmo is enabled
  44650. */
  44651. isEnabled: boolean;
  44652. /**
  44653. * Disposes of the gizmo
  44654. */
  44655. dispose(): void;
  44656. }
  44657. }
  44658. declare module "babylonjs/Gizmos/positionGizmo" {
  44659. import { Observable } from "babylonjs/Misc/observable";
  44660. import { Nullable } from "babylonjs/types";
  44661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44662. import { Mesh } from "babylonjs/Meshes/mesh";
  44663. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44664. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44665. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44666. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44667. /**
  44668. * Gizmo that enables dragging a mesh along 3 axis
  44669. */
  44670. export class PositionGizmo extends Gizmo {
  44671. /**
  44672. * Internal gizmo used for interactions on the x axis
  44673. */
  44674. xGizmo: AxisDragGizmo;
  44675. /**
  44676. * Internal gizmo used for interactions on the y axis
  44677. */
  44678. yGizmo: AxisDragGizmo;
  44679. /**
  44680. * Internal gizmo used for interactions on the z axis
  44681. */
  44682. zGizmo: AxisDragGizmo;
  44683. /**
  44684. * Internal gizmo used for interactions on the yz plane
  44685. */
  44686. xPlaneGizmo: PlaneDragGizmo;
  44687. /**
  44688. * Internal gizmo used for interactions on the xz plane
  44689. */
  44690. yPlaneGizmo: PlaneDragGizmo;
  44691. /**
  44692. * Internal gizmo used for interactions on the xy plane
  44693. */
  44694. zPlaneGizmo: PlaneDragGizmo;
  44695. /**
  44696. * private variables
  44697. */
  44698. private _meshAttached;
  44699. private _updateGizmoRotationToMatchAttachedMesh;
  44700. private _snapDistance;
  44701. private _scaleRatio;
  44702. /** Fires an event when any of it's sub gizmos are dragged */
  44703. onDragStartObservable: Observable<unknown>;
  44704. /** Fires an event when any of it's sub gizmos are released from dragging */
  44705. onDragEndObservable: Observable<unknown>;
  44706. /**
  44707. * If set to true, planar drag is enabled
  44708. */
  44709. private _planarGizmoEnabled;
  44710. attachedMesh: Nullable<AbstractMesh>;
  44711. /**
  44712. * Creates a PositionGizmo
  44713. * @param gizmoLayer The utility layer the gizmo will be added to
  44714. */
  44715. constructor(gizmoLayer?: UtilityLayerRenderer);
  44716. /**
  44717. * If the planar drag gizmo is enabled
  44718. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44719. */
  44720. planarGizmoEnabled: boolean;
  44721. updateGizmoRotationToMatchAttachedMesh: boolean;
  44722. /**
  44723. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44724. */
  44725. snapDistance: number;
  44726. /**
  44727. * Ratio for the scale of the gizmo (Default: 1)
  44728. */
  44729. scaleRatio: number;
  44730. /**
  44731. * Disposes of the gizmo
  44732. */
  44733. dispose(): void;
  44734. /**
  44735. * CustomMeshes are not supported by this gizmo
  44736. * @param mesh The mesh to replace the default mesh of the gizmo
  44737. */
  44738. setCustomMesh(mesh: Mesh): void;
  44739. }
  44740. }
  44741. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44742. import { Observable } from "babylonjs/Misc/observable";
  44743. import { Nullable } from "babylonjs/types";
  44744. import { Vector3 } from "babylonjs/Maths/math.vector";
  44745. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44747. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44748. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44749. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44750. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44751. import { Scene } from "babylonjs/scene";
  44752. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44753. import { Color3 } from "babylonjs/Maths/math.color";
  44754. /**
  44755. * Single axis drag gizmo
  44756. */
  44757. export class AxisDragGizmo extends Gizmo {
  44758. /**
  44759. * Drag behavior responsible for the gizmos dragging interactions
  44760. */
  44761. dragBehavior: PointerDragBehavior;
  44762. private _pointerObserver;
  44763. /**
  44764. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44765. */
  44766. snapDistance: number;
  44767. /**
  44768. * Event that fires each time the gizmo snaps to a new location.
  44769. * * snapDistance is the the change in distance
  44770. */
  44771. onSnapObservable: Observable<{
  44772. snapDistance: number;
  44773. }>;
  44774. private _isEnabled;
  44775. private _parent;
  44776. private _arrow;
  44777. private _coloredMaterial;
  44778. private _hoverMaterial;
  44779. /** @hidden */
  44780. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44781. /** @hidden */
  44782. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44783. /**
  44784. * Creates an AxisDragGizmo
  44785. * @param gizmoLayer The utility layer the gizmo will be added to
  44786. * @param dragAxis The axis which the gizmo will be able to drag on
  44787. * @param color The color of the gizmo
  44788. */
  44789. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44790. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44791. /**
  44792. * If the gizmo is enabled
  44793. */
  44794. isEnabled: boolean;
  44795. /**
  44796. * Disposes of the gizmo
  44797. */
  44798. dispose(): void;
  44799. }
  44800. }
  44801. declare module "babylonjs/Debug/axesViewer" {
  44802. import { Vector3 } from "babylonjs/Maths/math.vector";
  44803. import { Nullable } from "babylonjs/types";
  44804. import { Scene } from "babylonjs/scene";
  44805. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44806. /**
  44807. * The Axes viewer will show 3 axes in a specific point in space
  44808. */
  44809. export class AxesViewer {
  44810. private _xAxis;
  44811. private _yAxis;
  44812. private _zAxis;
  44813. private _scaleLinesFactor;
  44814. private _instanced;
  44815. /**
  44816. * Gets the hosting scene
  44817. */
  44818. scene: Scene;
  44819. /**
  44820. * Gets or sets a number used to scale line length
  44821. */
  44822. scaleLines: number;
  44823. /** Gets the node hierarchy used to render x-axis */
  44824. readonly xAxis: TransformNode;
  44825. /** Gets the node hierarchy used to render y-axis */
  44826. readonly yAxis: TransformNode;
  44827. /** Gets the node hierarchy used to render z-axis */
  44828. readonly zAxis: TransformNode;
  44829. /**
  44830. * Creates a new AxesViewer
  44831. * @param scene defines the hosting scene
  44832. * @param scaleLines defines a number used to scale line length (1 by default)
  44833. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44834. * @param xAxis defines the node hierarchy used to render the x-axis
  44835. * @param yAxis defines the node hierarchy used to render the y-axis
  44836. * @param zAxis defines the node hierarchy used to render the z-axis
  44837. */
  44838. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44839. /**
  44840. * Force the viewer to update
  44841. * @param position defines the position of the viewer
  44842. * @param xaxis defines the x axis of the viewer
  44843. * @param yaxis defines the y axis of the viewer
  44844. * @param zaxis defines the z axis of the viewer
  44845. */
  44846. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44847. /**
  44848. * Creates an instance of this axes viewer.
  44849. * @returns a new axes viewer with instanced meshes
  44850. */
  44851. createInstance(): AxesViewer;
  44852. /** Releases resources */
  44853. dispose(): void;
  44854. private static _SetRenderingGroupId;
  44855. }
  44856. }
  44857. declare module "babylonjs/Debug/boneAxesViewer" {
  44858. import { Nullable } from "babylonjs/types";
  44859. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44860. import { Vector3 } from "babylonjs/Maths/math.vector";
  44861. import { Mesh } from "babylonjs/Meshes/mesh";
  44862. import { Bone } from "babylonjs/Bones/bone";
  44863. import { Scene } from "babylonjs/scene";
  44864. /**
  44865. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44866. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44867. */
  44868. export class BoneAxesViewer extends AxesViewer {
  44869. /**
  44870. * Gets or sets the target mesh where to display the axes viewer
  44871. */
  44872. mesh: Nullable<Mesh>;
  44873. /**
  44874. * Gets or sets the target bone where to display the axes viewer
  44875. */
  44876. bone: Nullable<Bone>;
  44877. /** Gets current position */
  44878. pos: Vector3;
  44879. /** Gets direction of X axis */
  44880. xaxis: Vector3;
  44881. /** Gets direction of Y axis */
  44882. yaxis: Vector3;
  44883. /** Gets direction of Z axis */
  44884. zaxis: Vector3;
  44885. /**
  44886. * Creates a new BoneAxesViewer
  44887. * @param scene defines the hosting scene
  44888. * @param bone defines the target bone
  44889. * @param mesh defines the target mesh
  44890. * @param scaleLines defines a scaling factor for line length (1 by default)
  44891. */
  44892. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44893. /**
  44894. * Force the viewer to update
  44895. */
  44896. update(): void;
  44897. /** Releases resources */
  44898. dispose(): void;
  44899. }
  44900. }
  44901. declare module "babylonjs/Debug/debugLayer" {
  44902. import { Scene } from "babylonjs/scene";
  44903. /**
  44904. * Interface used to define scene explorer extensibility option
  44905. */
  44906. export interface IExplorerExtensibilityOption {
  44907. /**
  44908. * Define the option label
  44909. */
  44910. label: string;
  44911. /**
  44912. * Defines the action to execute on click
  44913. */
  44914. action: (entity: any) => void;
  44915. }
  44916. /**
  44917. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44918. */
  44919. export interface IExplorerExtensibilityGroup {
  44920. /**
  44921. * Defines a predicate to test if a given type mut be extended
  44922. */
  44923. predicate: (entity: any) => boolean;
  44924. /**
  44925. * Gets the list of options added to a type
  44926. */
  44927. entries: IExplorerExtensibilityOption[];
  44928. }
  44929. /**
  44930. * Interface used to define the options to use to create the Inspector
  44931. */
  44932. export interface IInspectorOptions {
  44933. /**
  44934. * Display in overlay mode (default: false)
  44935. */
  44936. overlay?: boolean;
  44937. /**
  44938. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44939. */
  44940. globalRoot?: HTMLElement;
  44941. /**
  44942. * Display the Scene explorer
  44943. */
  44944. showExplorer?: boolean;
  44945. /**
  44946. * Display the property inspector
  44947. */
  44948. showInspector?: boolean;
  44949. /**
  44950. * Display in embed mode (both panes on the right)
  44951. */
  44952. embedMode?: boolean;
  44953. /**
  44954. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44955. */
  44956. handleResize?: boolean;
  44957. /**
  44958. * Allow the panes to popup (default: true)
  44959. */
  44960. enablePopup?: boolean;
  44961. /**
  44962. * Allow the panes to be closed by users (default: true)
  44963. */
  44964. enableClose?: boolean;
  44965. /**
  44966. * Optional list of extensibility entries
  44967. */
  44968. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44969. /**
  44970. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44971. */
  44972. inspectorURL?: string;
  44973. }
  44974. module "babylonjs/scene" {
  44975. interface Scene {
  44976. /**
  44977. * @hidden
  44978. * Backing field
  44979. */
  44980. _debugLayer: DebugLayer;
  44981. /**
  44982. * Gets the debug layer (aka Inspector) associated with the scene
  44983. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44984. */
  44985. debugLayer: DebugLayer;
  44986. }
  44987. }
  44988. /**
  44989. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44990. * what is happening in your scene
  44991. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44992. */
  44993. export class DebugLayer {
  44994. /**
  44995. * Define the url to get the inspector script from.
  44996. * By default it uses the babylonjs CDN.
  44997. * @ignoreNaming
  44998. */
  44999. static InspectorURL: string;
  45000. private _scene;
  45001. private BJSINSPECTOR;
  45002. private _onPropertyChangedObservable?;
  45003. /**
  45004. * Observable triggered when a property is changed through the inspector.
  45005. */
  45006. readonly onPropertyChangedObservable: any;
  45007. /**
  45008. * Instantiates a new debug layer.
  45009. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45010. * what is happening in your scene
  45011. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45012. * @param scene Defines the scene to inspect
  45013. */
  45014. constructor(scene: Scene);
  45015. /** Creates the inspector window. */
  45016. private _createInspector;
  45017. /**
  45018. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45019. * @param entity defines the entity to select
  45020. * @param lineContainerTitle defines the specific block to highlight
  45021. */
  45022. select(entity: any, lineContainerTitle?: string): void;
  45023. /** Get the inspector from bundle or global */
  45024. private _getGlobalInspector;
  45025. /**
  45026. * Get if the inspector is visible or not.
  45027. * @returns true if visible otherwise, false
  45028. */
  45029. isVisible(): boolean;
  45030. /**
  45031. * Hide the inspector and close its window.
  45032. */
  45033. hide(): void;
  45034. /**
  45035. * Launch the debugLayer.
  45036. * @param config Define the configuration of the inspector
  45037. * @return a promise fulfilled when the debug layer is visible
  45038. */
  45039. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45040. }
  45041. }
  45042. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45043. import { Nullable } from "babylonjs/types";
  45044. import { Scene } from "babylonjs/scene";
  45045. import { Vector4 } from "babylonjs/Maths/math.vector";
  45046. import { Color4 } from "babylonjs/Maths/math.color";
  45047. import { Mesh } from "babylonjs/Meshes/mesh";
  45048. /**
  45049. * Class containing static functions to help procedurally build meshes
  45050. */
  45051. export class BoxBuilder {
  45052. /**
  45053. * Creates a box mesh
  45054. * * The parameter `size` sets the size (float) of each box side (default 1)
  45055. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45056. * * 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)
  45057. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45061. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45062. * @param name defines the name of the mesh
  45063. * @param options defines the options used to create the mesh
  45064. * @param scene defines the hosting scene
  45065. * @returns the box mesh
  45066. */
  45067. static CreateBox(name: string, options: {
  45068. size?: number;
  45069. width?: number;
  45070. height?: number;
  45071. depth?: number;
  45072. faceUV?: Vector4[];
  45073. faceColors?: Color4[];
  45074. sideOrientation?: number;
  45075. frontUVs?: Vector4;
  45076. backUVs?: Vector4;
  45077. wrap?: boolean;
  45078. topBaseAt?: number;
  45079. bottomBaseAt?: number;
  45080. updatable?: boolean;
  45081. }, scene?: Nullable<Scene>): Mesh;
  45082. }
  45083. }
  45084. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45085. import { Vector4 } from "babylonjs/Maths/math.vector";
  45086. import { Mesh } from "babylonjs/Meshes/mesh";
  45087. import { Scene } from "babylonjs/scene";
  45088. import { Nullable } from "babylonjs/types";
  45089. /**
  45090. * Class containing static functions to help procedurally build meshes
  45091. */
  45092. export class SphereBuilder {
  45093. /**
  45094. * Creates a sphere mesh
  45095. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45096. * * 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`)
  45097. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45098. * * 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
  45099. * * 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)
  45100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45103. * @param name defines the name of the mesh
  45104. * @param options defines the options used to create the mesh
  45105. * @param scene defines the hosting scene
  45106. * @returns the sphere mesh
  45107. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45108. */
  45109. static CreateSphere(name: string, options: {
  45110. segments?: number;
  45111. diameter?: number;
  45112. diameterX?: number;
  45113. diameterY?: number;
  45114. diameterZ?: number;
  45115. arc?: number;
  45116. slice?: number;
  45117. sideOrientation?: number;
  45118. frontUVs?: Vector4;
  45119. backUVs?: Vector4;
  45120. updatable?: boolean;
  45121. }, scene?: Nullable<Scene>): Mesh;
  45122. }
  45123. }
  45124. declare module "babylonjs/Debug/physicsViewer" {
  45125. import { Nullable } from "babylonjs/types";
  45126. import { Scene } from "babylonjs/scene";
  45127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45128. import { Mesh } from "babylonjs/Meshes/mesh";
  45129. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45130. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45131. /**
  45132. * Used to show the physics impostor around the specific mesh
  45133. */
  45134. export class PhysicsViewer {
  45135. /** @hidden */
  45136. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45137. /** @hidden */
  45138. protected _meshes: Array<Nullable<AbstractMesh>>;
  45139. /** @hidden */
  45140. protected _scene: Nullable<Scene>;
  45141. /** @hidden */
  45142. protected _numMeshes: number;
  45143. /** @hidden */
  45144. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45145. private _renderFunction;
  45146. private _utilityLayer;
  45147. private _debugBoxMesh;
  45148. private _debugSphereMesh;
  45149. private _debugCylinderMesh;
  45150. private _debugMaterial;
  45151. private _debugMeshMeshes;
  45152. /**
  45153. * Creates a new PhysicsViewer
  45154. * @param scene defines the hosting scene
  45155. */
  45156. constructor(scene: Scene);
  45157. /** @hidden */
  45158. protected _updateDebugMeshes(): void;
  45159. /**
  45160. * Renders a specified physic impostor
  45161. * @param impostor defines the impostor to render
  45162. * @param targetMesh defines the mesh represented by the impostor
  45163. * @returns the new debug mesh used to render the impostor
  45164. */
  45165. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45166. /**
  45167. * Hides a specified physic impostor
  45168. * @param impostor defines the impostor to hide
  45169. */
  45170. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45171. private _getDebugMaterial;
  45172. private _getDebugBoxMesh;
  45173. private _getDebugSphereMesh;
  45174. private _getDebugCylinderMesh;
  45175. private _getDebugMeshMesh;
  45176. private _getDebugMesh;
  45177. /** Releases all resources */
  45178. dispose(): void;
  45179. }
  45180. }
  45181. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45182. import { Vector3 } from "babylonjs/Maths/math.vector";
  45183. import { Color4 } from "babylonjs/Maths/math.color";
  45184. import { Nullable } from "babylonjs/types";
  45185. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45186. import { Scene } from "babylonjs/scene";
  45187. /**
  45188. * Class containing static functions to help procedurally build meshes
  45189. */
  45190. export class LinesBuilder {
  45191. /**
  45192. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45193. * * 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
  45194. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45195. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45196. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45197. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45198. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45199. * * 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
  45200. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45203. * @param name defines the name of the new line system
  45204. * @param options defines the options used to create the line system
  45205. * @param scene defines the hosting scene
  45206. * @returns a new line system mesh
  45207. */
  45208. static CreateLineSystem(name: string, options: {
  45209. lines: Vector3[][];
  45210. updatable?: boolean;
  45211. instance?: Nullable<LinesMesh>;
  45212. colors?: Nullable<Color4[][]>;
  45213. useVertexAlpha?: boolean;
  45214. }, scene: Nullable<Scene>): LinesMesh;
  45215. /**
  45216. * Creates a line mesh
  45217. * 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
  45218. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45219. * * The parameter `points` is an array successive Vector3
  45220. * * 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
  45221. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45222. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45223. * * When updating an instance, remember that only point positions can change, not the number of points
  45224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45226. * @param name defines the name of the new line system
  45227. * @param options defines the options used to create the line system
  45228. * @param scene defines the hosting scene
  45229. * @returns a new line mesh
  45230. */
  45231. static CreateLines(name: string, options: {
  45232. points: Vector3[];
  45233. updatable?: boolean;
  45234. instance?: Nullable<LinesMesh>;
  45235. colors?: Color4[];
  45236. useVertexAlpha?: boolean;
  45237. }, scene?: Nullable<Scene>): LinesMesh;
  45238. /**
  45239. * Creates a dashed line mesh
  45240. * * 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
  45241. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45242. * * The parameter `points` is an array successive Vector3
  45243. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45244. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45245. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45246. * * 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
  45247. * * When updating an instance, remember that only point positions can change, not the number of points
  45248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45249. * @param name defines the name of the mesh
  45250. * @param options defines the options used to create the mesh
  45251. * @param scene defines the hosting scene
  45252. * @returns the dashed line mesh
  45253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45254. */
  45255. static CreateDashedLines(name: string, options: {
  45256. points: Vector3[];
  45257. dashSize?: number;
  45258. gapSize?: number;
  45259. dashNb?: number;
  45260. updatable?: boolean;
  45261. instance?: LinesMesh;
  45262. }, scene?: Nullable<Scene>): LinesMesh;
  45263. }
  45264. }
  45265. declare module "babylonjs/Debug/rayHelper" {
  45266. import { Nullable } from "babylonjs/types";
  45267. import { Ray } from "babylonjs/Culling/ray";
  45268. import { Vector3 } from "babylonjs/Maths/math.vector";
  45269. import { Color3 } from "babylonjs/Maths/math.color";
  45270. import { Scene } from "babylonjs/scene";
  45271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45272. import "babylonjs/Meshes/Builders/linesBuilder";
  45273. /**
  45274. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45275. * in order to better appreciate the issue one might have.
  45276. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45277. */
  45278. export class RayHelper {
  45279. /**
  45280. * Defines the ray we are currently tryin to visualize.
  45281. */
  45282. ray: Nullable<Ray>;
  45283. private _renderPoints;
  45284. private _renderLine;
  45285. private _renderFunction;
  45286. private _scene;
  45287. private _updateToMeshFunction;
  45288. private _attachedToMesh;
  45289. private _meshSpaceDirection;
  45290. private _meshSpaceOrigin;
  45291. /**
  45292. * Helper function to create a colored helper in a scene in one line.
  45293. * @param ray Defines the ray we are currently tryin to visualize
  45294. * @param scene Defines the scene the ray is used in
  45295. * @param color Defines the color we want to see the ray in
  45296. * @returns The newly created ray helper.
  45297. */
  45298. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45299. /**
  45300. * Instantiate a new ray helper.
  45301. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45302. * in order to better appreciate the issue one might have.
  45303. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45304. * @param ray Defines the ray we are currently tryin to visualize
  45305. */
  45306. constructor(ray: Ray);
  45307. /**
  45308. * Shows the ray we are willing to debug.
  45309. * @param scene Defines the scene the ray needs to be rendered in
  45310. * @param color Defines the color the ray needs to be rendered in
  45311. */
  45312. show(scene: Scene, color?: Color3): void;
  45313. /**
  45314. * Hides the ray we are debugging.
  45315. */
  45316. hide(): void;
  45317. private _render;
  45318. /**
  45319. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45320. * @param mesh Defines the mesh we want the helper attached to
  45321. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45322. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45323. * @param length Defines the length of the ray
  45324. */
  45325. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45326. /**
  45327. * Detach the ray helper from the mesh it has previously been attached to.
  45328. */
  45329. detachFromMesh(): void;
  45330. private _updateToMesh;
  45331. /**
  45332. * Dispose the helper and release its associated resources.
  45333. */
  45334. dispose(): void;
  45335. }
  45336. }
  45337. declare module "babylonjs/Debug/skeletonViewer" {
  45338. import { Color3 } from "babylonjs/Maths/math.color";
  45339. import { Scene } from "babylonjs/scene";
  45340. import { Nullable } from "babylonjs/types";
  45341. import { Skeleton } from "babylonjs/Bones/skeleton";
  45342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45343. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45344. /**
  45345. * Class used to render a debug view of a given skeleton
  45346. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45347. */
  45348. export class SkeletonViewer {
  45349. /** defines the skeleton to render */
  45350. skeleton: Skeleton;
  45351. /** defines the mesh attached to the skeleton */
  45352. mesh: AbstractMesh;
  45353. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45354. autoUpdateBonesMatrices: boolean;
  45355. /** defines the rendering group id to use with the viewer */
  45356. renderingGroupId: number;
  45357. /** Gets or sets the color used to render the skeleton */
  45358. color: Color3;
  45359. private _scene;
  45360. private _debugLines;
  45361. private _debugMesh;
  45362. private _isEnabled;
  45363. private _renderFunction;
  45364. private _utilityLayer;
  45365. /**
  45366. * Returns the mesh used to render the bones
  45367. */
  45368. readonly debugMesh: Nullable<LinesMesh>;
  45369. /**
  45370. * Creates a new SkeletonViewer
  45371. * @param skeleton defines the skeleton to render
  45372. * @param mesh defines the mesh attached to the skeleton
  45373. * @param scene defines the hosting scene
  45374. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45375. * @param renderingGroupId defines the rendering group id to use with the viewer
  45376. */
  45377. constructor(
  45378. /** defines the skeleton to render */
  45379. skeleton: Skeleton,
  45380. /** defines the mesh attached to the skeleton */
  45381. mesh: AbstractMesh, scene: Scene,
  45382. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45383. autoUpdateBonesMatrices?: boolean,
  45384. /** defines the rendering group id to use with the viewer */
  45385. renderingGroupId?: number);
  45386. /** Gets or sets a boolean indicating if the viewer is enabled */
  45387. isEnabled: boolean;
  45388. private _getBonePosition;
  45389. private _getLinesForBonesWithLength;
  45390. private _getLinesForBonesNoLength;
  45391. /** Update the viewer to sync with current skeleton state */
  45392. update(): void;
  45393. /** Release associated resources */
  45394. dispose(): void;
  45395. }
  45396. }
  45397. declare module "babylonjs/Debug/index" {
  45398. export * from "babylonjs/Debug/axesViewer";
  45399. export * from "babylonjs/Debug/boneAxesViewer";
  45400. export * from "babylonjs/Debug/debugLayer";
  45401. export * from "babylonjs/Debug/physicsViewer";
  45402. export * from "babylonjs/Debug/rayHelper";
  45403. export * from "babylonjs/Debug/skeletonViewer";
  45404. }
  45405. declare module "babylonjs/Engines/nullEngine" {
  45406. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45407. import { Scene } from "babylonjs/scene";
  45408. import { Engine } from "babylonjs/Engines/engine";
  45409. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45410. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45411. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45412. import { Effect } from "babylonjs/Materials/effect";
  45413. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45414. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45415. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45416. /**
  45417. * Options to create the null engine
  45418. */
  45419. export class NullEngineOptions {
  45420. /**
  45421. * Render width (Default: 512)
  45422. */
  45423. renderWidth: number;
  45424. /**
  45425. * Render height (Default: 256)
  45426. */
  45427. renderHeight: number;
  45428. /**
  45429. * Texture size (Default: 512)
  45430. */
  45431. textureSize: number;
  45432. /**
  45433. * If delta time between frames should be constant
  45434. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45435. */
  45436. deterministicLockstep: boolean;
  45437. /**
  45438. * Maximum about of steps between frames (Default: 4)
  45439. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45440. */
  45441. lockstepMaxSteps: number;
  45442. }
  45443. /**
  45444. * The null engine class provides support for headless version of babylon.js.
  45445. * This can be used in server side scenario or for testing purposes
  45446. */
  45447. export class NullEngine extends Engine {
  45448. private _options;
  45449. /**
  45450. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45451. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45452. * @returns true if engine is in deterministic lock step mode
  45453. */
  45454. isDeterministicLockStep(): boolean;
  45455. /**
  45456. * Gets the max steps when engine is running in deterministic lock step
  45457. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45458. * @returns the max steps
  45459. */
  45460. getLockstepMaxSteps(): number;
  45461. /**
  45462. * Gets the current hardware scaling level.
  45463. * By default the hardware scaling level is computed from the window device ratio.
  45464. * 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.
  45465. * @returns a number indicating the current hardware scaling level
  45466. */
  45467. getHardwareScalingLevel(): number;
  45468. constructor(options?: NullEngineOptions);
  45469. /**
  45470. * Creates a vertex buffer
  45471. * @param vertices the data for the vertex buffer
  45472. * @returns the new WebGL static buffer
  45473. */
  45474. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45475. /**
  45476. * Creates a new index buffer
  45477. * @param indices defines the content of the index buffer
  45478. * @param updatable defines if the index buffer must be updatable
  45479. * @returns a new webGL buffer
  45480. */
  45481. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45482. /**
  45483. * Clear the current render buffer or the current render target (if any is set up)
  45484. * @param color defines the color to use
  45485. * @param backBuffer defines if the back buffer must be cleared
  45486. * @param depth defines if the depth buffer must be cleared
  45487. * @param stencil defines if the stencil buffer must be cleared
  45488. */
  45489. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45490. /**
  45491. * Gets the current render width
  45492. * @param useScreen defines if screen size must be used (or the current render target if any)
  45493. * @returns a number defining the current render width
  45494. */
  45495. getRenderWidth(useScreen?: boolean): number;
  45496. /**
  45497. * Gets the current render height
  45498. * @param useScreen defines if screen size must be used (or the current render target if any)
  45499. * @returns a number defining the current render height
  45500. */
  45501. getRenderHeight(useScreen?: boolean): number;
  45502. /**
  45503. * Set the WebGL's viewport
  45504. * @param viewport defines the viewport element to be used
  45505. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45506. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45507. */
  45508. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45509. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45510. /**
  45511. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45512. * @param pipelineContext defines the pipeline context to use
  45513. * @param uniformsNames defines the list of uniform names
  45514. * @returns an array of webGL uniform locations
  45515. */
  45516. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45517. /**
  45518. * Gets the lsit of active attributes for a given webGL program
  45519. * @param pipelineContext defines the pipeline context to use
  45520. * @param attributesNames defines the list of attribute names to get
  45521. * @returns an array of indices indicating the offset of each attribute
  45522. */
  45523. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45524. /**
  45525. * Binds an effect to the webGL context
  45526. * @param effect defines the effect to bind
  45527. */
  45528. bindSamplers(effect: Effect): void;
  45529. /**
  45530. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45531. * @param effect defines the effect to activate
  45532. */
  45533. enableEffect(effect: Effect): void;
  45534. /**
  45535. * Set various states to the webGL context
  45536. * @param culling defines backface culling state
  45537. * @param zOffset defines the value to apply to zOffset (0 by default)
  45538. * @param force defines if states must be applied even if cache is up to date
  45539. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45540. */
  45541. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45542. /**
  45543. * Set the value of an uniform to an array of int32
  45544. * @param uniform defines the webGL uniform location where to store the value
  45545. * @param array defines the array of int32 to store
  45546. */
  45547. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45548. /**
  45549. * Set the value of an uniform to an array of int32 (stored as vec2)
  45550. * @param uniform defines the webGL uniform location where to store the value
  45551. * @param array defines the array of int32 to store
  45552. */
  45553. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45554. /**
  45555. * Set the value of an uniform to an array of int32 (stored as vec3)
  45556. * @param uniform defines the webGL uniform location where to store the value
  45557. * @param array defines the array of int32 to store
  45558. */
  45559. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45560. /**
  45561. * Set the value of an uniform to an array of int32 (stored as vec4)
  45562. * @param uniform defines the webGL uniform location where to store the value
  45563. * @param array defines the array of int32 to store
  45564. */
  45565. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45566. /**
  45567. * Set the value of an uniform to an array of float32
  45568. * @param uniform defines the webGL uniform location where to store the value
  45569. * @param array defines the array of float32 to store
  45570. */
  45571. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45572. /**
  45573. * Set the value of an uniform to an array of float32 (stored as vec2)
  45574. * @param uniform defines the webGL uniform location where to store the value
  45575. * @param array defines the array of float32 to store
  45576. */
  45577. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45578. /**
  45579. * Set the value of an uniform to an array of float32 (stored as vec3)
  45580. * @param uniform defines the webGL uniform location where to store the value
  45581. * @param array defines the array of float32 to store
  45582. */
  45583. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45584. /**
  45585. * Set the value of an uniform to an array of float32 (stored as vec4)
  45586. * @param uniform defines the webGL uniform location where to store the value
  45587. * @param array defines the array of float32 to store
  45588. */
  45589. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45590. /**
  45591. * Set the value of an uniform to an array of number
  45592. * @param uniform defines the webGL uniform location where to store the value
  45593. * @param array defines the array of number to store
  45594. */
  45595. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45596. /**
  45597. * Set the value of an uniform to an array of number (stored as vec2)
  45598. * @param uniform defines the webGL uniform location where to store the value
  45599. * @param array defines the array of number to store
  45600. */
  45601. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45602. /**
  45603. * Set the value of an uniform to an array of number (stored as vec3)
  45604. * @param uniform defines the webGL uniform location where to store the value
  45605. * @param array defines the array of number to store
  45606. */
  45607. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45608. /**
  45609. * Set the value of an uniform to an array of number (stored as vec4)
  45610. * @param uniform defines the webGL uniform location where to store the value
  45611. * @param array defines the array of number to store
  45612. */
  45613. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45614. /**
  45615. * Set the value of an uniform to an array of float32 (stored as matrices)
  45616. * @param uniform defines the webGL uniform location where to store the value
  45617. * @param matrices defines the array of float32 to store
  45618. */
  45619. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45620. /**
  45621. * Set the value of an uniform to a matrix (3x3)
  45622. * @param uniform defines the webGL uniform location where to store the value
  45623. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45624. */
  45625. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45626. /**
  45627. * Set the value of an uniform to a matrix (2x2)
  45628. * @param uniform defines the webGL uniform location where to store the value
  45629. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45630. */
  45631. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45632. /**
  45633. * Set the value of an uniform to a number (float)
  45634. * @param uniform defines the webGL uniform location where to store the value
  45635. * @param value defines the float number to store
  45636. */
  45637. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45638. /**
  45639. * Set the value of an uniform to a vec2
  45640. * @param uniform defines the webGL uniform location where to store the value
  45641. * @param x defines the 1st component of the value
  45642. * @param y defines the 2nd component of the value
  45643. */
  45644. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45645. /**
  45646. * Set the value of an uniform to a vec3
  45647. * @param uniform defines the webGL uniform location where to store the value
  45648. * @param x defines the 1st component of the value
  45649. * @param y defines the 2nd component of the value
  45650. * @param z defines the 3rd component of the value
  45651. */
  45652. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45653. /**
  45654. * Set the value of an uniform to a boolean
  45655. * @param uniform defines the webGL uniform location where to store the value
  45656. * @param bool defines the boolean to store
  45657. */
  45658. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45659. /**
  45660. * Set the value of an uniform to a vec4
  45661. * @param uniform defines the webGL uniform location where to store the value
  45662. * @param x defines the 1st component of the value
  45663. * @param y defines the 2nd component of the value
  45664. * @param z defines the 3rd component of the value
  45665. * @param w defines the 4th component of the value
  45666. */
  45667. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45668. /**
  45669. * Sets the current alpha mode
  45670. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45671. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45672. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45673. */
  45674. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45675. /**
  45676. * Bind webGl buffers directly to the webGL context
  45677. * @param vertexBuffers defines the vertex buffer to bind
  45678. * @param indexBuffer defines the index buffer to bind
  45679. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45680. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45681. * @param effect defines the effect associated with the vertex buffer
  45682. */
  45683. bindBuffers(vertexBuffers: {
  45684. [key: string]: VertexBuffer;
  45685. }, indexBuffer: DataBuffer, effect: Effect): void;
  45686. /**
  45687. * Force the entire cache to be cleared
  45688. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45689. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45690. */
  45691. wipeCaches(bruteForce?: boolean): void;
  45692. /**
  45693. * Send a draw order
  45694. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45695. * @param indexStart defines the starting index
  45696. * @param indexCount defines the number of index to draw
  45697. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45698. */
  45699. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45700. /**
  45701. * Draw a list of indexed primitives
  45702. * @param fillMode defines the primitive to use
  45703. * @param indexStart defines the starting index
  45704. * @param indexCount defines the number of index to draw
  45705. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45706. */
  45707. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45708. /**
  45709. * Draw a list of unindexed primitives
  45710. * @param fillMode defines the primitive to use
  45711. * @param verticesStart defines the index of first vertex to draw
  45712. * @param verticesCount defines the count of vertices to draw
  45713. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45714. */
  45715. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45716. /** @hidden */
  45717. _createTexture(): WebGLTexture;
  45718. /** @hidden */
  45719. _releaseTexture(texture: InternalTexture): void;
  45720. /**
  45721. * Usually called from Texture.ts.
  45722. * Passed information to create a WebGLTexture
  45723. * @param urlArg defines a value which contains one of the following:
  45724. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45725. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45726. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45727. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45728. * @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)
  45729. * @param scene needed for loading to the correct scene
  45730. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45731. * @param onLoad optional callback to be called upon successful completion
  45732. * @param onError optional callback to be called upon failure
  45733. * @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
  45734. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45735. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45736. * @param forcedExtension defines the extension to use to pick the right loader
  45737. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45738. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45739. */
  45740. 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;
  45741. /**
  45742. * Creates a new render target texture
  45743. * @param size defines the size of the texture
  45744. * @param options defines the options used to create the texture
  45745. * @returns a new render target texture stored in an InternalTexture
  45746. */
  45747. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45748. /**
  45749. * Update the sampling mode of a given texture
  45750. * @param samplingMode defines the required sampling mode
  45751. * @param texture defines the texture to update
  45752. */
  45753. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45754. /**
  45755. * Binds the frame buffer to the specified texture.
  45756. * @param texture The texture to render to or null for the default canvas
  45757. * @param faceIndex The face of the texture to render to in case of cube texture
  45758. * @param requiredWidth The width of the target to render to
  45759. * @param requiredHeight The height of the target to render to
  45760. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45761. * @param depthStencilTexture The depth stencil texture to use to render
  45762. * @param lodLevel defines le lod level to bind to the frame buffer
  45763. */
  45764. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45765. /**
  45766. * Unbind the current render target texture from the webGL context
  45767. * @param texture defines the render target texture to unbind
  45768. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45769. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45770. */
  45771. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45772. /**
  45773. * Creates a dynamic vertex buffer
  45774. * @param vertices the data for the dynamic vertex buffer
  45775. * @returns the new WebGL dynamic buffer
  45776. */
  45777. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45778. /**
  45779. * Update the content of a dynamic texture
  45780. * @param texture defines the texture to update
  45781. * @param canvas defines the canvas containing the source
  45782. * @param invertY defines if data must be stored with Y axis inverted
  45783. * @param premulAlpha defines if alpha is stored as premultiplied
  45784. * @param format defines the format of the data
  45785. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45786. */
  45787. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45788. /**
  45789. * Gets a boolean indicating if all created effects are ready
  45790. * @returns true if all effects are ready
  45791. */
  45792. areAllEffectsReady(): boolean;
  45793. /**
  45794. * @hidden
  45795. * Get the current error code of the webGL context
  45796. * @returns the error code
  45797. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45798. */
  45799. getError(): number;
  45800. /** @hidden */
  45801. _getUnpackAlignement(): number;
  45802. /** @hidden */
  45803. _unpackFlipY(value: boolean): void;
  45804. /**
  45805. * Update a dynamic index buffer
  45806. * @param indexBuffer defines the target index buffer
  45807. * @param indices defines the data to update
  45808. * @param offset defines the offset in the target index buffer where update should start
  45809. */
  45810. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45811. /**
  45812. * Updates a dynamic vertex buffer.
  45813. * @param vertexBuffer the vertex buffer to update
  45814. * @param vertices the data used to update the vertex buffer
  45815. * @param byteOffset the byte offset of the data (optional)
  45816. * @param byteLength the byte length of the data (optional)
  45817. */
  45818. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45819. /** @hidden */
  45820. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45821. /** @hidden */
  45822. _bindTexture(channel: number, texture: InternalTexture): void;
  45823. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45824. /**
  45825. * 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
  45826. */
  45827. releaseEffects(): void;
  45828. displayLoadingUI(): void;
  45829. hideLoadingUI(): void;
  45830. /** @hidden */
  45831. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45832. /** @hidden */
  45833. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45834. /** @hidden */
  45835. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45836. /** @hidden */
  45837. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45838. }
  45839. }
  45840. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45841. import { Nullable, int } from "babylonjs/types";
  45842. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45843. /** @hidden */
  45844. export class _OcclusionDataStorage {
  45845. /** @hidden */
  45846. occlusionInternalRetryCounter: number;
  45847. /** @hidden */
  45848. isOcclusionQueryInProgress: boolean;
  45849. /** @hidden */
  45850. isOccluded: boolean;
  45851. /** @hidden */
  45852. occlusionRetryCount: number;
  45853. /** @hidden */
  45854. occlusionType: number;
  45855. /** @hidden */
  45856. occlusionQueryAlgorithmType: number;
  45857. }
  45858. module "babylonjs/Engines/engine" {
  45859. interface Engine {
  45860. /**
  45861. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45862. * @return the new query
  45863. */
  45864. createQuery(): WebGLQuery;
  45865. /**
  45866. * Delete and release a webGL query
  45867. * @param query defines the query to delete
  45868. * @return the current engine
  45869. */
  45870. deleteQuery(query: WebGLQuery): Engine;
  45871. /**
  45872. * Check if a given query has resolved and got its value
  45873. * @param query defines the query to check
  45874. * @returns true if the query got its value
  45875. */
  45876. isQueryResultAvailable(query: WebGLQuery): boolean;
  45877. /**
  45878. * Gets the value of a given query
  45879. * @param query defines the query to check
  45880. * @returns the value of the query
  45881. */
  45882. getQueryResult(query: WebGLQuery): number;
  45883. /**
  45884. * Initiates an occlusion query
  45885. * @param algorithmType defines the algorithm to use
  45886. * @param query defines the query to use
  45887. * @returns the current engine
  45888. * @see http://doc.babylonjs.com/features/occlusionquery
  45889. */
  45890. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45891. /**
  45892. * Ends an occlusion query
  45893. * @see http://doc.babylonjs.com/features/occlusionquery
  45894. * @param algorithmType defines the algorithm to use
  45895. * @returns the current engine
  45896. */
  45897. endOcclusionQuery(algorithmType: number): Engine;
  45898. /**
  45899. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45900. * Please note that only one query can be issued at a time
  45901. * @returns a time token used to track the time span
  45902. */
  45903. startTimeQuery(): Nullable<_TimeToken>;
  45904. /**
  45905. * Ends a time query
  45906. * @param token defines the token used to measure the time span
  45907. * @returns the time spent (in ns)
  45908. */
  45909. endTimeQuery(token: _TimeToken): int;
  45910. /** @hidden */
  45911. _currentNonTimestampToken: Nullable<_TimeToken>;
  45912. /** @hidden */
  45913. _createTimeQuery(): WebGLQuery;
  45914. /** @hidden */
  45915. _deleteTimeQuery(query: WebGLQuery): void;
  45916. /** @hidden */
  45917. _getGlAlgorithmType(algorithmType: number): number;
  45918. /** @hidden */
  45919. _getTimeQueryResult(query: WebGLQuery): any;
  45920. /** @hidden */
  45921. _getTimeQueryAvailability(query: WebGLQuery): any;
  45922. }
  45923. }
  45924. module "babylonjs/Meshes/abstractMesh" {
  45925. interface AbstractMesh {
  45926. /**
  45927. * Backing filed
  45928. * @hidden
  45929. */
  45930. __occlusionDataStorage: _OcclusionDataStorage;
  45931. /**
  45932. * Access property
  45933. * @hidden
  45934. */
  45935. _occlusionDataStorage: _OcclusionDataStorage;
  45936. /**
  45937. * 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.
  45938. * The default value is -1 which means don't break the query and wait till the result
  45939. * @see http://doc.babylonjs.com/features/occlusionquery
  45940. */
  45941. occlusionRetryCount: number;
  45942. /**
  45943. * 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:
  45944. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45945. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45946. * * 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.
  45947. * @see http://doc.babylonjs.com/features/occlusionquery
  45948. */
  45949. occlusionType: number;
  45950. /**
  45951. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45952. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45953. * * 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.
  45954. * @see http://doc.babylonjs.com/features/occlusionquery
  45955. */
  45956. occlusionQueryAlgorithmType: number;
  45957. /**
  45958. * 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
  45959. * @see http://doc.babylonjs.com/features/occlusionquery
  45960. */
  45961. isOccluded: boolean;
  45962. /**
  45963. * Flag to check the progress status of the query
  45964. * @see http://doc.babylonjs.com/features/occlusionquery
  45965. */
  45966. isOcclusionQueryInProgress: boolean;
  45967. }
  45968. }
  45969. }
  45970. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45971. import { Nullable } from "babylonjs/types";
  45972. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45973. /** @hidden */
  45974. export var _forceTransformFeedbackToBundle: boolean;
  45975. module "babylonjs/Engines/engine" {
  45976. interface Engine {
  45977. /**
  45978. * Creates a webGL transform feedback object
  45979. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45980. * @returns the webGL transform feedback object
  45981. */
  45982. createTransformFeedback(): WebGLTransformFeedback;
  45983. /**
  45984. * Delete a webGL transform feedback object
  45985. * @param value defines the webGL transform feedback object to delete
  45986. */
  45987. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45988. /**
  45989. * Bind a webGL transform feedback object to the webgl context
  45990. * @param value defines the webGL transform feedback object to bind
  45991. */
  45992. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45993. /**
  45994. * Begins a transform feedback operation
  45995. * @param usePoints defines if points or triangles must be used
  45996. */
  45997. beginTransformFeedback(usePoints: boolean): void;
  45998. /**
  45999. * Ends a transform feedback operation
  46000. */
  46001. endTransformFeedback(): void;
  46002. /**
  46003. * Specify the varyings to use with transform feedback
  46004. * @param program defines the associated webGL program
  46005. * @param value defines the list of strings representing the varying names
  46006. */
  46007. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46008. /**
  46009. * Bind a webGL buffer for a transform feedback operation
  46010. * @param value defines the webGL buffer to bind
  46011. */
  46012. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46013. }
  46014. }
  46015. }
  46016. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46017. import { Scene } from "babylonjs/scene";
  46018. import { Engine } from "babylonjs/Engines/engine";
  46019. import { Texture } from "babylonjs/Materials/Textures/texture";
  46020. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46021. import "babylonjs/Engines/Extensions/engine.multiRender";
  46022. /**
  46023. * Creation options of the multi render target texture.
  46024. */
  46025. export interface IMultiRenderTargetOptions {
  46026. /**
  46027. * Define if the texture needs to create mip maps after render.
  46028. */
  46029. generateMipMaps?: boolean;
  46030. /**
  46031. * Define the types of all the draw buffers we want to create
  46032. */
  46033. types?: number[];
  46034. /**
  46035. * Define the sampling modes of all the draw buffers we want to create
  46036. */
  46037. samplingModes?: number[];
  46038. /**
  46039. * Define if a depth buffer is required
  46040. */
  46041. generateDepthBuffer?: boolean;
  46042. /**
  46043. * Define if a stencil buffer is required
  46044. */
  46045. generateStencilBuffer?: boolean;
  46046. /**
  46047. * Define if a depth texture is required instead of a depth buffer
  46048. */
  46049. generateDepthTexture?: boolean;
  46050. /**
  46051. * Define the number of desired draw buffers
  46052. */
  46053. textureCount?: number;
  46054. /**
  46055. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46056. */
  46057. doNotChangeAspectRatio?: boolean;
  46058. /**
  46059. * Define the default type of the buffers we are creating
  46060. */
  46061. defaultType?: number;
  46062. }
  46063. /**
  46064. * A multi render target, like a render target provides the ability to render to a texture.
  46065. * Unlike the render target, it can render to several draw buffers in one draw.
  46066. * This is specially interesting in deferred rendering or for any effects requiring more than
  46067. * just one color from a single pass.
  46068. */
  46069. export class MultiRenderTarget extends RenderTargetTexture {
  46070. private _internalTextures;
  46071. private _textures;
  46072. private _multiRenderTargetOptions;
  46073. /**
  46074. * Get if draw buffers are currently supported by the used hardware and browser.
  46075. */
  46076. readonly isSupported: boolean;
  46077. /**
  46078. * Get the list of textures generated by the multi render target.
  46079. */
  46080. readonly textures: Texture[];
  46081. /**
  46082. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46083. */
  46084. readonly depthTexture: Texture;
  46085. /**
  46086. * Set the wrapping mode on U of all the textures we are rendering to.
  46087. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46088. */
  46089. wrapU: number;
  46090. /**
  46091. * Set the wrapping mode on V of all the textures we are rendering to.
  46092. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46093. */
  46094. wrapV: number;
  46095. /**
  46096. * Instantiate a new multi render target texture.
  46097. * A multi render target, like a render target provides the ability to render to a texture.
  46098. * Unlike the render target, it can render to several draw buffers in one draw.
  46099. * This is specially interesting in deferred rendering or for any effects requiring more than
  46100. * just one color from a single pass.
  46101. * @param name Define the name of the texture
  46102. * @param size Define the size of the buffers to render to
  46103. * @param count Define the number of target we are rendering into
  46104. * @param scene Define the scene the texture belongs to
  46105. * @param options Define the options used to create the multi render target
  46106. */
  46107. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46108. /** @hidden */
  46109. _rebuild(): void;
  46110. private _createInternalTextures;
  46111. private _createTextures;
  46112. /**
  46113. * Define the number of samples used if MSAA is enabled.
  46114. */
  46115. samples: number;
  46116. /**
  46117. * Resize all the textures in the multi render target.
  46118. * Be carrefull as it will recreate all the data in the new texture.
  46119. * @param size Define the new size
  46120. */
  46121. resize(size: any): void;
  46122. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46123. /**
  46124. * Dispose the render targets and their associated resources
  46125. */
  46126. dispose(): void;
  46127. /**
  46128. * Release all the underlying texture used as draw buffers.
  46129. */
  46130. releaseInternalTextures(): void;
  46131. }
  46132. }
  46133. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46134. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46135. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46136. import { Nullable } from "babylonjs/types";
  46137. module "babylonjs/Engines/thinEngine" {
  46138. interface ThinEngine {
  46139. /**
  46140. * Unbind a list of render target textures from the webGL context
  46141. * This is used only when drawBuffer extension or webGL2 are active
  46142. * @param textures defines the render target textures to unbind
  46143. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46144. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46145. */
  46146. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46147. /**
  46148. * Create a multi render target texture
  46149. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46150. * @param size defines the size of the texture
  46151. * @param options defines the creation options
  46152. * @returns the cube texture as an InternalTexture
  46153. */
  46154. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46155. /**
  46156. * Update the sample count for a given multiple render target texture
  46157. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46158. * @param textures defines the textures to update
  46159. * @param samples defines the sample count to set
  46160. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46161. */
  46162. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46163. }
  46164. }
  46165. }
  46166. declare module "babylonjs/Engines/Extensions/index" {
  46167. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46168. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46169. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46170. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46171. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46172. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46173. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46174. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46175. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46176. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46177. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46178. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46179. }
  46180. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46181. import { Nullable } from "babylonjs/types";
  46182. /**
  46183. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46184. */
  46185. export interface CubeMapInfo {
  46186. /**
  46187. * The pixel array for the front face.
  46188. * This is stored in format, left to right, up to down format.
  46189. */
  46190. front: Nullable<ArrayBufferView>;
  46191. /**
  46192. * The pixel array for the back face.
  46193. * This is stored in format, left to right, up to down format.
  46194. */
  46195. back: Nullable<ArrayBufferView>;
  46196. /**
  46197. * The pixel array for the left face.
  46198. * This is stored in format, left to right, up to down format.
  46199. */
  46200. left: Nullable<ArrayBufferView>;
  46201. /**
  46202. * The pixel array for the right face.
  46203. * This is stored in format, left to right, up to down format.
  46204. */
  46205. right: Nullable<ArrayBufferView>;
  46206. /**
  46207. * The pixel array for the up face.
  46208. * This is stored in format, left to right, up to down format.
  46209. */
  46210. up: Nullable<ArrayBufferView>;
  46211. /**
  46212. * The pixel array for the down face.
  46213. * This is stored in format, left to right, up to down format.
  46214. */
  46215. down: Nullable<ArrayBufferView>;
  46216. /**
  46217. * The size of the cubemap stored.
  46218. *
  46219. * Each faces will be size * size pixels.
  46220. */
  46221. size: number;
  46222. /**
  46223. * The format of the texture.
  46224. *
  46225. * RGBA, RGB.
  46226. */
  46227. format: number;
  46228. /**
  46229. * The type of the texture data.
  46230. *
  46231. * UNSIGNED_INT, FLOAT.
  46232. */
  46233. type: number;
  46234. /**
  46235. * Specifies whether the texture is in gamma space.
  46236. */
  46237. gammaSpace: boolean;
  46238. }
  46239. /**
  46240. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46241. */
  46242. export class PanoramaToCubeMapTools {
  46243. private static FACE_FRONT;
  46244. private static FACE_BACK;
  46245. private static FACE_RIGHT;
  46246. private static FACE_LEFT;
  46247. private static FACE_DOWN;
  46248. private static FACE_UP;
  46249. /**
  46250. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46251. *
  46252. * @param float32Array The source data.
  46253. * @param inputWidth The width of the input panorama.
  46254. * @param inputHeight The height of the input panorama.
  46255. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46256. * @return The cubemap data
  46257. */
  46258. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46259. private static CreateCubemapTexture;
  46260. private static CalcProjectionSpherical;
  46261. }
  46262. }
  46263. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46264. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46265. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46266. import { Nullable } from "babylonjs/types";
  46267. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46268. /**
  46269. * Helper class dealing with the extraction of spherical polynomial dataArray
  46270. * from a cube map.
  46271. */
  46272. export class CubeMapToSphericalPolynomialTools {
  46273. private static FileFaces;
  46274. /**
  46275. * Converts a texture to the according Spherical Polynomial data.
  46276. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46277. *
  46278. * @param texture The texture to extract the information from.
  46279. * @return The Spherical Polynomial data.
  46280. */
  46281. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46282. /**
  46283. * Converts a cubemap to the according Spherical Polynomial data.
  46284. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46285. *
  46286. * @param cubeInfo The Cube map to extract the information from.
  46287. * @return The Spherical Polynomial data.
  46288. */
  46289. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46290. }
  46291. }
  46292. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46293. import { Nullable } from "babylonjs/types";
  46294. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46295. module "babylonjs/Materials/Textures/baseTexture" {
  46296. interface BaseTexture {
  46297. /**
  46298. * Get the polynomial representation of the texture data.
  46299. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46300. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46301. */
  46302. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46303. }
  46304. }
  46305. }
  46306. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46307. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46308. /** @hidden */
  46309. export var rgbdEncodePixelShader: {
  46310. name: string;
  46311. shader: string;
  46312. };
  46313. }
  46314. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46315. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46316. /** @hidden */
  46317. export var rgbdDecodePixelShader: {
  46318. name: string;
  46319. shader: string;
  46320. };
  46321. }
  46322. declare module "babylonjs/Misc/environmentTextureTools" {
  46323. import { Nullable } from "babylonjs/types";
  46324. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46326. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46327. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46328. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46329. import "babylonjs/Shaders/rgbdEncode.fragment";
  46330. import "babylonjs/Shaders/rgbdDecode.fragment";
  46331. /**
  46332. * Raw texture data and descriptor sufficient for WebGL texture upload
  46333. */
  46334. export interface EnvironmentTextureInfo {
  46335. /**
  46336. * Version of the environment map
  46337. */
  46338. version: number;
  46339. /**
  46340. * Width of image
  46341. */
  46342. width: number;
  46343. /**
  46344. * Irradiance information stored in the file.
  46345. */
  46346. irradiance: any;
  46347. /**
  46348. * Specular information stored in the file.
  46349. */
  46350. specular: any;
  46351. }
  46352. /**
  46353. * Defines One Image in the file. It requires only the position in the file
  46354. * as well as the length.
  46355. */
  46356. interface BufferImageData {
  46357. /**
  46358. * Length of the image data.
  46359. */
  46360. length: number;
  46361. /**
  46362. * Position of the data from the null terminator delimiting the end of the JSON.
  46363. */
  46364. position: number;
  46365. }
  46366. /**
  46367. * Defines the specular data enclosed in the file.
  46368. * This corresponds to the version 1 of the data.
  46369. */
  46370. export interface EnvironmentTextureSpecularInfoV1 {
  46371. /**
  46372. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46373. */
  46374. specularDataPosition?: number;
  46375. /**
  46376. * This contains all the images data needed to reconstruct the cubemap.
  46377. */
  46378. mipmaps: Array<BufferImageData>;
  46379. /**
  46380. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46381. */
  46382. lodGenerationScale: number;
  46383. }
  46384. /**
  46385. * Sets of helpers addressing the serialization and deserialization of environment texture
  46386. * stored in a BabylonJS env file.
  46387. * Those files are usually stored as .env files.
  46388. */
  46389. export class EnvironmentTextureTools {
  46390. /**
  46391. * Magic number identifying the env file.
  46392. */
  46393. private static _MagicBytes;
  46394. /**
  46395. * Gets the environment info from an env file.
  46396. * @param data The array buffer containing the .env bytes.
  46397. * @returns the environment file info (the json header) if successfully parsed.
  46398. */
  46399. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46400. /**
  46401. * Creates an environment texture from a loaded cube texture.
  46402. * @param texture defines the cube texture to convert in env file
  46403. * @return a promise containing the environment data if succesfull.
  46404. */
  46405. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46406. /**
  46407. * Creates a JSON representation of the spherical data.
  46408. * @param texture defines the texture containing the polynomials
  46409. * @return the JSON representation of the spherical info
  46410. */
  46411. private static _CreateEnvTextureIrradiance;
  46412. /**
  46413. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46414. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46415. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46416. * @return the views described by info providing access to the underlying buffer
  46417. */
  46418. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46419. /**
  46420. * Uploads the texture info contained in the env file to the GPU.
  46421. * @param texture defines the internal texture to upload to
  46422. * @param arrayBuffer defines the buffer cotaining the data to load
  46423. * @param info defines the texture info retrieved through the GetEnvInfo method
  46424. * @returns a promise
  46425. */
  46426. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46427. private static _OnImageReadyAsync;
  46428. /**
  46429. * Uploads the levels of image data to the GPU.
  46430. * @param texture defines the internal texture to upload to
  46431. * @param imageData defines the array buffer views of image data [mipmap][face]
  46432. * @returns a promise
  46433. */
  46434. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46435. /**
  46436. * Uploads spherical polynomials information to the texture.
  46437. * @param texture defines the texture we are trying to upload the information to
  46438. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46439. */
  46440. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46441. /** @hidden */
  46442. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46443. }
  46444. }
  46445. declare module "babylonjs/Maths/math.vertexFormat" {
  46446. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46447. /**
  46448. * Contains position and normal vectors for a vertex
  46449. */
  46450. export class PositionNormalVertex {
  46451. /** the position of the vertex (defaut: 0,0,0) */
  46452. position: Vector3;
  46453. /** the normal of the vertex (defaut: 0,1,0) */
  46454. normal: Vector3;
  46455. /**
  46456. * Creates a PositionNormalVertex
  46457. * @param position the position of the vertex (defaut: 0,0,0)
  46458. * @param normal the normal of the vertex (defaut: 0,1,0)
  46459. */
  46460. constructor(
  46461. /** the position of the vertex (defaut: 0,0,0) */
  46462. position?: Vector3,
  46463. /** the normal of the vertex (defaut: 0,1,0) */
  46464. normal?: Vector3);
  46465. /**
  46466. * Clones the PositionNormalVertex
  46467. * @returns the cloned PositionNormalVertex
  46468. */
  46469. clone(): PositionNormalVertex;
  46470. }
  46471. /**
  46472. * Contains position, normal and uv vectors for a vertex
  46473. */
  46474. export class PositionNormalTextureVertex {
  46475. /** the position of the vertex (defaut: 0,0,0) */
  46476. position: Vector3;
  46477. /** the normal of the vertex (defaut: 0,1,0) */
  46478. normal: Vector3;
  46479. /** the uv of the vertex (default: 0,0) */
  46480. uv: Vector2;
  46481. /**
  46482. * Creates a PositionNormalTextureVertex
  46483. * @param position the position of the vertex (defaut: 0,0,0)
  46484. * @param normal the normal of the vertex (defaut: 0,1,0)
  46485. * @param uv the uv of the vertex (default: 0,0)
  46486. */
  46487. constructor(
  46488. /** the position of the vertex (defaut: 0,0,0) */
  46489. position?: Vector3,
  46490. /** the normal of the vertex (defaut: 0,1,0) */
  46491. normal?: Vector3,
  46492. /** the uv of the vertex (default: 0,0) */
  46493. uv?: Vector2);
  46494. /**
  46495. * Clones the PositionNormalTextureVertex
  46496. * @returns the cloned PositionNormalTextureVertex
  46497. */
  46498. clone(): PositionNormalTextureVertex;
  46499. }
  46500. }
  46501. declare module "babylonjs/Maths/math" {
  46502. export * from "babylonjs/Maths/math.axis";
  46503. export * from "babylonjs/Maths/math.color";
  46504. export * from "babylonjs/Maths/math.constants";
  46505. export * from "babylonjs/Maths/math.frustum";
  46506. export * from "babylonjs/Maths/math.path";
  46507. export * from "babylonjs/Maths/math.plane";
  46508. export * from "babylonjs/Maths/math.size";
  46509. export * from "babylonjs/Maths/math.vector";
  46510. export * from "babylonjs/Maths/math.vertexFormat";
  46511. export * from "babylonjs/Maths/math.viewport";
  46512. }
  46513. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46514. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46515. /** @hidden */
  46516. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46517. private _genericAttributeLocation;
  46518. private _varyingLocationCount;
  46519. private _varyingLocationMap;
  46520. private _replacements;
  46521. private _textureCount;
  46522. private _uniforms;
  46523. lineProcessor(line: string): string;
  46524. attributeProcessor(attribute: string): string;
  46525. varyingProcessor(varying: string, isFragment: boolean): string;
  46526. uniformProcessor(uniform: string): string;
  46527. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46528. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46529. }
  46530. }
  46531. declare module "babylonjs/Engines/nativeEngine" {
  46532. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46533. import { Engine } from "babylonjs/Engines/engine";
  46534. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46535. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46536. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46537. import { Effect } from "babylonjs/Materials/effect";
  46538. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46539. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46540. import { Scene } from "babylonjs/scene";
  46541. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46542. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46543. /**
  46544. * Container for accessors for natively-stored mesh data buffers.
  46545. */
  46546. class NativeDataBuffer extends DataBuffer {
  46547. /**
  46548. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46549. */
  46550. nativeIndexBuffer?: any;
  46551. /**
  46552. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46553. */
  46554. nativeVertexBuffer?: any;
  46555. }
  46556. /** @hidden */
  46557. export class NativeEngine extends Engine {
  46558. private readonly _native;
  46559. getHardwareScalingLevel(): number;
  46560. constructor();
  46561. /**
  46562. * Can be used to override the current requestAnimationFrame requester.
  46563. * @hidden
  46564. */
  46565. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46566. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46567. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46568. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46569. recordVertexArrayObject(vertexBuffers: {
  46570. [key: string]: VertexBuffer;
  46571. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46572. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46573. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46574. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46575. /**
  46576. * Draw a list of indexed primitives
  46577. * @param fillMode defines the primitive to use
  46578. * @param indexStart defines the starting index
  46579. * @param indexCount defines the number of index to draw
  46580. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46581. */
  46582. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46583. /**
  46584. * Draw a list of unindexed primitives
  46585. * @param fillMode defines the primitive to use
  46586. * @param verticesStart defines the index of first vertex to draw
  46587. * @param verticesCount defines the count of vertices to draw
  46588. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46589. */
  46590. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46591. createPipelineContext(): IPipelineContext;
  46592. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46593. /** @hidden */
  46594. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46595. /** @hidden */
  46596. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46597. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46598. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46599. protected _setProgram(program: WebGLProgram): void;
  46600. _releaseEffect(effect: Effect): void;
  46601. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46602. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46603. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46604. bindSamplers(effect: Effect): void;
  46605. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46606. getRenderWidth(useScreen?: boolean): number;
  46607. getRenderHeight(useScreen?: boolean): number;
  46608. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46609. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46610. /**
  46611. * Set the z offset to apply to current rendering
  46612. * @param value defines the offset to apply
  46613. */
  46614. setZOffset(value: number): void;
  46615. /**
  46616. * Gets the current value of the zOffset
  46617. * @returns the current zOffset state
  46618. */
  46619. getZOffset(): number;
  46620. /**
  46621. * Enable or disable depth buffering
  46622. * @param enable defines the state to set
  46623. */
  46624. setDepthBuffer(enable: boolean): void;
  46625. /**
  46626. * Gets a boolean indicating if depth writing is enabled
  46627. * @returns the current depth writing state
  46628. */
  46629. getDepthWrite(): boolean;
  46630. /**
  46631. * Enable or disable depth writing
  46632. * @param enable defines the state to set
  46633. */
  46634. setDepthWrite(enable: boolean): void;
  46635. /**
  46636. * Enable or disable color writing
  46637. * @param enable defines the state to set
  46638. */
  46639. setColorWrite(enable: boolean): void;
  46640. /**
  46641. * Gets a boolean indicating if color writing is enabled
  46642. * @returns the current color writing state
  46643. */
  46644. getColorWrite(): boolean;
  46645. /**
  46646. * Sets alpha constants used by some alpha blending modes
  46647. * @param r defines the red component
  46648. * @param g defines the green component
  46649. * @param b defines the blue component
  46650. * @param a defines the alpha component
  46651. */
  46652. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46653. /**
  46654. * Sets the current alpha mode
  46655. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46656. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46657. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46658. */
  46659. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46660. /**
  46661. * Gets the current alpha mode
  46662. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46663. * @returns the current alpha mode
  46664. */
  46665. getAlphaMode(): number;
  46666. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46667. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46668. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46669. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46670. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46671. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46672. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46673. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46674. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46675. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46676. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46677. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46678. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46679. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46680. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46681. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46682. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46683. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46684. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46685. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46686. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46687. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46688. wipeCaches(bruteForce?: boolean): void;
  46689. _createTexture(): WebGLTexture;
  46690. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46691. /**
  46692. * Usually called from BABYLON.Texture.ts.
  46693. * Passed information to create a WebGLTexture
  46694. * @param urlArg defines a value which contains one of the following:
  46695. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46696. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46697. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46698. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46699. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46700. * @param scene needed for loading to the correct scene
  46701. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46702. * @param onLoad optional callback to be called upon successful completion
  46703. * @param onError optional callback to be called upon failure
  46704. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46705. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46706. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46707. * @param forcedExtension defines the extension to use to pick the right loader
  46708. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46709. */
  46710. 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;
  46711. /**
  46712. * Creates a cube texture
  46713. * @param rootUrl defines the url where the files to load is located
  46714. * @param scene defines the current scene
  46715. * @param files defines the list of files to load (1 per face)
  46716. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46717. * @param onLoad defines an optional callback raised when the texture is loaded
  46718. * @param onError defines an optional callback raised if there is an issue to load the texture
  46719. * @param format defines the format of the data
  46720. * @param forcedExtension defines the extension to use to pick the right loader
  46721. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46722. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46723. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46724. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46725. * @returns the cube texture as an InternalTexture
  46726. */
  46727. 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;
  46728. private _getSamplingFilter;
  46729. private static _GetNativeTextureFormat;
  46730. createRenderTargetTexture(size: number | {
  46731. width: number;
  46732. height: number;
  46733. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46734. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46735. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46736. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46737. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46738. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46739. /**
  46740. * Updates a dynamic vertex buffer.
  46741. * @param vertexBuffer the vertex buffer to update
  46742. * @param data the data used to update the vertex buffer
  46743. * @param byteOffset the byte offset of the data (optional)
  46744. * @param byteLength the byte length of the data (optional)
  46745. */
  46746. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46747. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46748. private _updateAnisotropicLevel;
  46749. private _getAddressMode;
  46750. /** @hidden */
  46751. _bindTexture(channel: number, texture: InternalTexture): void;
  46752. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46753. releaseEffects(): void;
  46754. /** @hidden */
  46755. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46756. /** @hidden */
  46757. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46758. /** @hidden */
  46759. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46760. /** @hidden */
  46761. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46762. }
  46763. }
  46764. declare module "babylonjs/Engines/index" {
  46765. export * from "babylonjs/Engines/constants";
  46766. export * from "babylonjs/Engines/engineCapabilities";
  46767. export * from "babylonjs/Engines/instancingAttributeInfo";
  46768. export * from "babylonjs/Engines/thinEngine";
  46769. export * from "babylonjs/Engines/engine";
  46770. export * from "babylonjs/Engines/engineStore";
  46771. export * from "babylonjs/Engines/nullEngine";
  46772. export * from "babylonjs/Engines/Extensions/index";
  46773. export * from "babylonjs/Engines/IPipelineContext";
  46774. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46775. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46776. export * from "babylonjs/Engines/nativeEngine";
  46777. }
  46778. declare module "babylonjs/Events/clipboardEvents" {
  46779. /**
  46780. * Gather the list of clipboard event types as constants.
  46781. */
  46782. export class ClipboardEventTypes {
  46783. /**
  46784. * The clipboard event is fired when a copy command is active (pressed).
  46785. */
  46786. static readonly COPY: number;
  46787. /**
  46788. * The clipboard event is fired when a cut command is active (pressed).
  46789. */
  46790. static readonly CUT: number;
  46791. /**
  46792. * The clipboard event is fired when a paste command is active (pressed).
  46793. */
  46794. static readonly PASTE: number;
  46795. }
  46796. /**
  46797. * This class is used to store clipboard related info for the onClipboardObservable event.
  46798. */
  46799. export class ClipboardInfo {
  46800. /**
  46801. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46802. */
  46803. type: number;
  46804. /**
  46805. * Defines the related dom event
  46806. */
  46807. event: ClipboardEvent;
  46808. /**
  46809. *Creates an instance of ClipboardInfo.
  46810. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46811. * @param event Defines the related dom event
  46812. */
  46813. constructor(
  46814. /**
  46815. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46816. */
  46817. type: number,
  46818. /**
  46819. * Defines the related dom event
  46820. */
  46821. event: ClipboardEvent);
  46822. /**
  46823. * Get the clipboard event's type from the keycode.
  46824. * @param keyCode Defines the keyCode for the current keyboard event.
  46825. * @return {number}
  46826. */
  46827. static GetTypeFromCharacter(keyCode: number): number;
  46828. }
  46829. }
  46830. declare module "babylonjs/Events/index" {
  46831. export * from "babylonjs/Events/keyboardEvents";
  46832. export * from "babylonjs/Events/pointerEvents";
  46833. export * from "babylonjs/Events/clipboardEvents";
  46834. }
  46835. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46836. import { Scene } from "babylonjs/scene";
  46837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46838. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46839. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46840. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46841. /**
  46842. * Google Daydream controller
  46843. */
  46844. export class DaydreamController extends WebVRController {
  46845. /**
  46846. * Base Url for the controller model.
  46847. */
  46848. static MODEL_BASE_URL: string;
  46849. /**
  46850. * File name for the controller model.
  46851. */
  46852. static MODEL_FILENAME: string;
  46853. /**
  46854. * Gamepad Id prefix used to identify Daydream Controller.
  46855. */
  46856. static readonly GAMEPAD_ID_PREFIX: string;
  46857. /**
  46858. * Creates a new DaydreamController from a gamepad
  46859. * @param vrGamepad the gamepad that the controller should be created from
  46860. */
  46861. constructor(vrGamepad: any);
  46862. /**
  46863. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46864. * @param scene scene in which to add meshes
  46865. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46866. */
  46867. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46868. /**
  46869. * Called once for each button that changed state since the last frame
  46870. * @param buttonIdx Which button index changed
  46871. * @param state New state of the button
  46872. * @param changes Which properties on the state changed since last frame
  46873. */
  46874. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46875. }
  46876. }
  46877. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46878. import { Scene } from "babylonjs/scene";
  46879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46880. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46881. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46882. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46883. /**
  46884. * Gear VR Controller
  46885. */
  46886. export class GearVRController extends WebVRController {
  46887. /**
  46888. * Base Url for the controller model.
  46889. */
  46890. static MODEL_BASE_URL: string;
  46891. /**
  46892. * File name for the controller model.
  46893. */
  46894. static MODEL_FILENAME: string;
  46895. /**
  46896. * Gamepad Id prefix used to identify this controller.
  46897. */
  46898. static readonly GAMEPAD_ID_PREFIX: string;
  46899. private readonly _buttonIndexToObservableNameMap;
  46900. /**
  46901. * Creates a new GearVRController from a gamepad
  46902. * @param vrGamepad the gamepad that the controller should be created from
  46903. */
  46904. constructor(vrGamepad: any);
  46905. /**
  46906. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46907. * @param scene scene in which to add meshes
  46908. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46909. */
  46910. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46911. /**
  46912. * Called once for each button that changed state since the last frame
  46913. * @param buttonIdx Which button index changed
  46914. * @param state New state of the button
  46915. * @param changes Which properties on the state changed since last frame
  46916. */
  46917. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46918. }
  46919. }
  46920. declare module "babylonjs/Gamepads/Controllers/index" {
  46921. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46922. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46923. export * from "babylonjs/Gamepads/Controllers/genericController";
  46924. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46925. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46926. export * from "babylonjs/Gamepads/Controllers/viveController";
  46927. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46928. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46929. }
  46930. declare module "babylonjs/Gamepads/index" {
  46931. export * from "babylonjs/Gamepads/Controllers/index";
  46932. export * from "babylonjs/Gamepads/gamepad";
  46933. export * from "babylonjs/Gamepads/gamepadManager";
  46934. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46935. export * from "babylonjs/Gamepads/xboxGamepad";
  46936. export * from "babylonjs/Gamepads/dualShockGamepad";
  46937. }
  46938. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46939. import { Scene } from "babylonjs/scene";
  46940. import { Vector4 } from "babylonjs/Maths/math.vector";
  46941. import { Color4 } from "babylonjs/Maths/math.color";
  46942. import { Mesh } from "babylonjs/Meshes/mesh";
  46943. import { Nullable } from "babylonjs/types";
  46944. /**
  46945. * Class containing static functions to help procedurally build meshes
  46946. */
  46947. export class PolyhedronBuilder {
  46948. /**
  46949. * Creates a polyhedron mesh
  46950. * * 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
  46951. * * The parameter `size` (positive float, default 1) sets the polygon size
  46952. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46953. * * 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`
  46954. * * 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
  46955. * * 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)`)
  46956. * * 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
  46957. * * 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
  46958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46961. * @param name defines the name of the mesh
  46962. * @param options defines the options used to create the mesh
  46963. * @param scene defines the hosting scene
  46964. * @returns the polyhedron mesh
  46965. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46966. */
  46967. static CreatePolyhedron(name: string, options: {
  46968. type?: number;
  46969. size?: number;
  46970. sizeX?: number;
  46971. sizeY?: number;
  46972. sizeZ?: number;
  46973. custom?: any;
  46974. faceUV?: Vector4[];
  46975. faceColors?: Color4[];
  46976. flat?: boolean;
  46977. updatable?: boolean;
  46978. sideOrientation?: number;
  46979. frontUVs?: Vector4;
  46980. backUVs?: Vector4;
  46981. }, scene?: Nullable<Scene>): Mesh;
  46982. }
  46983. }
  46984. declare module "babylonjs/Gizmos/scaleGizmo" {
  46985. import { Observable } from "babylonjs/Misc/observable";
  46986. import { Nullable } from "babylonjs/types";
  46987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46988. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46989. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46990. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46991. /**
  46992. * Gizmo that enables scaling a mesh along 3 axis
  46993. */
  46994. export class ScaleGizmo extends Gizmo {
  46995. /**
  46996. * Internal gizmo used for interactions on the x axis
  46997. */
  46998. xGizmo: AxisScaleGizmo;
  46999. /**
  47000. * Internal gizmo used for interactions on the y axis
  47001. */
  47002. yGizmo: AxisScaleGizmo;
  47003. /**
  47004. * Internal gizmo used for interactions on the z axis
  47005. */
  47006. zGizmo: AxisScaleGizmo;
  47007. /**
  47008. * Internal gizmo used to scale all axis equally
  47009. */
  47010. uniformScaleGizmo: AxisScaleGizmo;
  47011. private _meshAttached;
  47012. private _updateGizmoRotationToMatchAttachedMesh;
  47013. private _snapDistance;
  47014. private _scaleRatio;
  47015. private _uniformScalingMesh;
  47016. private _octahedron;
  47017. /** Fires an event when any of it's sub gizmos are dragged */
  47018. onDragStartObservable: Observable<unknown>;
  47019. /** Fires an event when any of it's sub gizmos are released from dragging */
  47020. onDragEndObservable: Observable<unknown>;
  47021. attachedMesh: Nullable<AbstractMesh>;
  47022. /**
  47023. * Creates a ScaleGizmo
  47024. * @param gizmoLayer The utility layer the gizmo will be added to
  47025. */
  47026. constructor(gizmoLayer?: UtilityLayerRenderer);
  47027. updateGizmoRotationToMatchAttachedMesh: boolean;
  47028. /**
  47029. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47030. */
  47031. snapDistance: number;
  47032. /**
  47033. * Ratio for the scale of the gizmo (Default: 1)
  47034. */
  47035. scaleRatio: number;
  47036. /**
  47037. * Disposes of the gizmo
  47038. */
  47039. dispose(): void;
  47040. }
  47041. }
  47042. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47043. import { Observable } from "babylonjs/Misc/observable";
  47044. import { Nullable } from "babylonjs/types";
  47045. import { Vector3 } from "babylonjs/Maths/math.vector";
  47046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47047. import { Mesh } from "babylonjs/Meshes/mesh";
  47048. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47049. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47050. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47051. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47052. import { Color3 } from "babylonjs/Maths/math.color";
  47053. /**
  47054. * Single axis scale gizmo
  47055. */
  47056. export class AxisScaleGizmo extends Gizmo {
  47057. /**
  47058. * Drag behavior responsible for the gizmos dragging interactions
  47059. */
  47060. dragBehavior: PointerDragBehavior;
  47061. private _pointerObserver;
  47062. /**
  47063. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47064. */
  47065. snapDistance: number;
  47066. /**
  47067. * Event that fires each time the gizmo snaps to a new location.
  47068. * * snapDistance is the the change in distance
  47069. */
  47070. onSnapObservable: Observable<{
  47071. snapDistance: number;
  47072. }>;
  47073. /**
  47074. * If the scaling operation should be done on all axis (default: false)
  47075. */
  47076. uniformScaling: boolean;
  47077. private _isEnabled;
  47078. private _parent;
  47079. private _arrow;
  47080. private _coloredMaterial;
  47081. private _hoverMaterial;
  47082. /**
  47083. * Creates an AxisScaleGizmo
  47084. * @param gizmoLayer The utility layer the gizmo will be added to
  47085. * @param dragAxis The axis which the gizmo will be able to scale on
  47086. * @param color The color of the gizmo
  47087. */
  47088. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47089. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47090. /**
  47091. * If the gizmo is enabled
  47092. */
  47093. isEnabled: boolean;
  47094. /**
  47095. * Disposes of the gizmo
  47096. */
  47097. dispose(): void;
  47098. /**
  47099. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47100. * @param mesh The mesh to replace the default mesh of the gizmo
  47101. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47102. */
  47103. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47104. }
  47105. }
  47106. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47107. import { Observable } from "babylonjs/Misc/observable";
  47108. import { Nullable } from "babylonjs/types";
  47109. import { Vector3 } from "babylonjs/Maths/math.vector";
  47110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47111. import { Mesh } from "babylonjs/Meshes/mesh";
  47112. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47113. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47114. import { Color3 } from "babylonjs/Maths/math.color";
  47115. import "babylonjs/Meshes/Builders/boxBuilder";
  47116. /**
  47117. * Bounding box gizmo
  47118. */
  47119. export class BoundingBoxGizmo extends Gizmo {
  47120. private _lineBoundingBox;
  47121. private _rotateSpheresParent;
  47122. private _scaleBoxesParent;
  47123. private _boundingDimensions;
  47124. private _renderObserver;
  47125. private _pointerObserver;
  47126. private _scaleDragSpeed;
  47127. private _tmpQuaternion;
  47128. private _tmpVector;
  47129. private _tmpRotationMatrix;
  47130. /**
  47131. * 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)
  47132. */
  47133. ignoreChildren: boolean;
  47134. /**
  47135. * 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)
  47136. */
  47137. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47138. /**
  47139. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47140. */
  47141. rotationSphereSize: number;
  47142. /**
  47143. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47144. */
  47145. scaleBoxSize: number;
  47146. /**
  47147. * 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)
  47148. */
  47149. fixedDragMeshScreenSize: boolean;
  47150. /**
  47151. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47152. */
  47153. fixedDragMeshScreenSizeDistanceFactor: number;
  47154. /**
  47155. * Fired when a rotation sphere or scale box is dragged
  47156. */
  47157. onDragStartObservable: Observable<{}>;
  47158. /**
  47159. * Fired when a scale box is dragged
  47160. */
  47161. onScaleBoxDragObservable: Observable<{}>;
  47162. /**
  47163. * Fired when a scale box drag is ended
  47164. */
  47165. onScaleBoxDragEndObservable: Observable<{}>;
  47166. /**
  47167. * Fired when a rotation sphere is dragged
  47168. */
  47169. onRotationSphereDragObservable: Observable<{}>;
  47170. /**
  47171. * Fired when a rotation sphere drag is ended
  47172. */
  47173. onRotationSphereDragEndObservable: Observable<{}>;
  47174. /**
  47175. * 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)
  47176. */
  47177. scalePivot: Nullable<Vector3>;
  47178. /**
  47179. * Mesh used as a pivot to rotate the attached mesh
  47180. */
  47181. private _anchorMesh;
  47182. private _existingMeshScale;
  47183. private _dragMesh;
  47184. private pointerDragBehavior;
  47185. private coloredMaterial;
  47186. private hoverColoredMaterial;
  47187. /**
  47188. * Sets the color of the bounding box gizmo
  47189. * @param color the color to set
  47190. */
  47191. setColor(color: Color3): void;
  47192. /**
  47193. * Creates an BoundingBoxGizmo
  47194. * @param gizmoLayer The utility layer the gizmo will be added to
  47195. * @param color The color of the gizmo
  47196. */
  47197. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47198. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47199. private _selectNode;
  47200. /**
  47201. * Updates the bounding box information for the Gizmo
  47202. */
  47203. updateBoundingBox(): void;
  47204. private _updateRotationSpheres;
  47205. private _updateScaleBoxes;
  47206. /**
  47207. * Enables rotation on the specified axis and disables rotation on the others
  47208. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47209. */
  47210. setEnabledRotationAxis(axis: string): void;
  47211. /**
  47212. * Enables/disables scaling
  47213. * @param enable if scaling should be enabled
  47214. */
  47215. setEnabledScaling(enable: boolean): void;
  47216. private _updateDummy;
  47217. /**
  47218. * Enables a pointer drag behavior on the bounding box of the gizmo
  47219. */
  47220. enableDragBehavior(): void;
  47221. /**
  47222. * Disposes of the gizmo
  47223. */
  47224. dispose(): void;
  47225. /**
  47226. * 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)
  47227. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47228. * @returns the bounding box mesh with the passed in mesh as a child
  47229. */
  47230. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47231. /**
  47232. * CustomMeshes are not supported by this gizmo
  47233. * @param mesh The mesh to replace the default mesh of the gizmo
  47234. */
  47235. setCustomMesh(mesh: Mesh): void;
  47236. }
  47237. }
  47238. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47239. import { Observable } from "babylonjs/Misc/observable";
  47240. import { Nullable } from "babylonjs/types";
  47241. import { Vector3 } from "babylonjs/Maths/math.vector";
  47242. import { Color3 } from "babylonjs/Maths/math.color";
  47243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47244. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47245. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47246. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47247. import "babylonjs/Meshes/Builders/linesBuilder";
  47248. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47249. /**
  47250. * Single plane rotation gizmo
  47251. */
  47252. export class PlaneRotationGizmo extends Gizmo {
  47253. /**
  47254. * Drag behavior responsible for the gizmos dragging interactions
  47255. */
  47256. dragBehavior: PointerDragBehavior;
  47257. private _pointerObserver;
  47258. /**
  47259. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47260. */
  47261. snapDistance: number;
  47262. /**
  47263. * Event that fires each time the gizmo snaps to a new location.
  47264. * * snapDistance is the the change in distance
  47265. */
  47266. onSnapObservable: Observable<{
  47267. snapDistance: number;
  47268. }>;
  47269. private _isEnabled;
  47270. private _parent;
  47271. /**
  47272. * Creates a PlaneRotationGizmo
  47273. * @param gizmoLayer The utility layer the gizmo will be added to
  47274. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47275. * @param color The color of the gizmo
  47276. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47277. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47278. */
  47279. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47280. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47281. /**
  47282. * If the gizmo is enabled
  47283. */
  47284. isEnabled: boolean;
  47285. /**
  47286. * Disposes of the gizmo
  47287. */
  47288. dispose(): void;
  47289. }
  47290. }
  47291. declare module "babylonjs/Gizmos/rotationGizmo" {
  47292. import { Observable } from "babylonjs/Misc/observable";
  47293. import { Nullable } from "babylonjs/types";
  47294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47295. import { Mesh } from "babylonjs/Meshes/mesh";
  47296. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47297. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47298. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47299. /**
  47300. * Gizmo that enables rotating a mesh along 3 axis
  47301. */
  47302. export class RotationGizmo extends Gizmo {
  47303. /**
  47304. * Internal gizmo used for interactions on the x axis
  47305. */
  47306. xGizmo: PlaneRotationGizmo;
  47307. /**
  47308. * Internal gizmo used for interactions on the y axis
  47309. */
  47310. yGizmo: PlaneRotationGizmo;
  47311. /**
  47312. * Internal gizmo used for interactions on the z axis
  47313. */
  47314. zGizmo: PlaneRotationGizmo;
  47315. /** Fires an event when any of it's sub gizmos are dragged */
  47316. onDragStartObservable: Observable<unknown>;
  47317. /** Fires an event when any of it's sub gizmos are released from dragging */
  47318. onDragEndObservable: Observable<unknown>;
  47319. private _meshAttached;
  47320. attachedMesh: Nullable<AbstractMesh>;
  47321. /**
  47322. * Creates a RotationGizmo
  47323. * @param gizmoLayer The utility layer the gizmo will be added to
  47324. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47325. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47326. */
  47327. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47328. updateGizmoRotationToMatchAttachedMesh: boolean;
  47329. /**
  47330. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47331. */
  47332. snapDistance: number;
  47333. /**
  47334. * Ratio for the scale of the gizmo (Default: 1)
  47335. */
  47336. scaleRatio: number;
  47337. /**
  47338. * Disposes of the gizmo
  47339. */
  47340. dispose(): void;
  47341. /**
  47342. * CustomMeshes are not supported by this gizmo
  47343. * @param mesh The mesh to replace the default mesh of the gizmo
  47344. */
  47345. setCustomMesh(mesh: Mesh): void;
  47346. }
  47347. }
  47348. declare module "babylonjs/Gizmos/gizmoManager" {
  47349. import { Observable } from "babylonjs/Misc/observable";
  47350. import { Nullable } from "babylonjs/types";
  47351. import { Scene, IDisposable } from "babylonjs/scene";
  47352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47353. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47354. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47355. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47356. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47357. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47358. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47359. /**
  47360. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47361. */
  47362. export class GizmoManager implements IDisposable {
  47363. private scene;
  47364. /**
  47365. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47366. */
  47367. gizmos: {
  47368. positionGizmo: Nullable<PositionGizmo>;
  47369. rotationGizmo: Nullable<RotationGizmo>;
  47370. scaleGizmo: Nullable<ScaleGizmo>;
  47371. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47372. };
  47373. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47374. clearGizmoOnEmptyPointerEvent: boolean;
  47375. /** Fires an event when the manager is attached to a mesh */
  47376. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47377. private _gizmosEnabled;
  47378. private _pointerObserver;
  47379. private _attachedMesh;
  47380. private _boundingBoxColor;
  47381. private _defaultUtilityLayer;
  47382. private _defaultKeepDepthUtilityLayer;
  47383. /**
  47384. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47385. */
  47386. boundingBoxDragBehavior: SixDofDragBehavior;
  47387. /**
  47388. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47389. */
  47390. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47391. /**
  47392. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47393. */
  47394. usePointerToAttachGizmos: boolean;
  47395. /**
  47396. * Utility layer that the bounding box gizmo belongs to
  47397. */
  47398. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47399. /**
  47400. * Utility layer that all gizmos besides bounding box belong to
  47401. */
  47402. readonly utilityLayer: UtilityLayerRenderer;
  47403. /**
  47404. * Instatiates a gizmo manager
  47405. * @param scene the scene to overlay the gizmos on top of
  47406. */
  47407. constructor(scene: Scene);
  47408. /**
  47409. * Attaches a set of gizmos to the specified mesh
  47410. * @param mesh The mesh the gizmo's should be attached to
  47411. */
  47412. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47413. /**
  47414. * If the position gizmo is enabled
  47415. */
  47416. positionGizmoEnabled: boolean;
  47417. /**
  47418. * If the rotation gizmo is enabled
  47419. */
  47420. rotationGizmoEnabled: boolean;
  47421. /**
  47422. * If the scale gizmo is enabled
  47423. */
  47424. scaleGizmoEnabled: boolean;
  47425. /**
  47426. * If the boundingBox gizmo is enabled
  47427. */
  47428. boundingBoxGizmoEnabled: boolean;
  47429. /**
  47430. * Disposes of the gizmo manager
  47431. */
  47432. dispose(): void;
  47433. }
  47434. }
  47435. declare module "babylonjs/Lights/directionalLight" {
  47436. import { Camera } from "babylonjs/Cameras/camera";
  47437. import { Scene } from "babylonjs/scene";
  47438. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47440. import { Light } from "babylonjs/Lights/light";
  47441. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47442. import { Effect } from "babylonjs/Materials/effect";
  47443. /**
  47444. * A directional light is defined by a direction (what a surprise!).
  47445. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47446. * 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.
  47447. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47448. */
  47449. export class DirectionalLight extends ShadowLight {
  47450. private _shadowFrustumSize;
  47451. /**
  47452. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47453. */
  47454. /**
  47455. * Specifies a fix frustum size for the shadow generation.
  47456. */
  47457. shadowFrustumSize: number;
  47458. private _shadowOrthoScale;
  47459. /**
  47460. * Gets the shadow projection scale against the optimal computed one.
  47461. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47462. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47463. */
  47464. /**
  47465. * Sets the shadow projection scale against the optimal computed one.
  47466. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47467. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47468. */
  47469. shadowOrthoScale: number;
  47470. /**
  47471. * Automatically compute the projection matrix to best fit (including all the casters)
  47472. * on each frame.
  47473. */
  47474. autoUpdateExtends: boolean;
  47475. private _orthoLeft;
  47476. private _orthoRight;
  47477. private _orthoTop;
  47478. private _orthoBottom;
  47479. /**
  47480. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47481. * The directional light is emitted from everywhere in the given direction.
  47482. * It can cast shadows.
  47483. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47484. * @param name The friendly name of the light
  47485. * @param direction The direction of the light
  47486. * @param scene The scene the light belongs to
  47487. */
  47488. constructor(name: string, direction: Vector3, scene: Scene);
  47489. /**
  47490. * Returns the string "DirectionalLight".
  47491. * @return The class name
  47492. */
  47493. getClassName(): string;
  47494. /**
  47495. * Returns the integer 1.
  47496. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47497. */
  47498. getTypeID(): number;
  47499. /**
  47500. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47501. * Returns the DirectionalLight Shadow projection matrix.
  47502. */
  47503. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47504. /**
  47505. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47506. * Returns the DirectionalLight Shadow projection matrix.
  47507. */
  47508. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47509. /**
  47510. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47511. * Returns the DirectionalLight Shadow projection matrix.
  47512. */
  47513. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47514. protected _buildUniformLayout(): void;
  47515. /**
  47516. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47517. * @param effect The effect to update
  47518. * @param lightIndex The index of the light in the effect to update
  47519. * @returns The directional light
  47520. */
  47521. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47522. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47523. /**
  47524. * Gets the minZ used for shadow according to both the scene and the light.
  47525. *
  47526. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47527. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47528. * @param activeCamera The camera we are returning the min for
  47529. * @returns the depth min z
  47530. */
  47531. getDepthMinZ(activeCamera: Camera): number;
  47532. /**
  47533. * Gets the maxZ used for shadow according to both the scene and the light.
  47534. *
  47535. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47536. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47537. * @param activeCamera The camera we are returning the max for
  47538. * @returns the depth max z
  47539. */
  47540. getDepthMaxZ(activeCamera: Camera): number;
  47541. /**
  47542. * Prepares the list of defines specific to the light type.
  47543. * @param defines the list of defines
  47544. * @param lightIndex defines the index of the light for the effect
  47545. */
  47546. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47547. }
  47548. }
  47549. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47550. import { Mesh } from "babylonjs/Meshes/mesh";
  47551. /**
  47552. * Class containing static functions to help procedurally build meshes
  47553. */
  47554. export class HemisphereBuilder {
  47555. /**
  47556. * Creates a hemisphere mesh
  47557. * @param name defines the name of the mesh
  47558. * @param options defines the options used to create the mesh
  47559. * @param scene defines the hosting scene
  47560. * @returns the hemisphere mesh
  47561. */
  47562. static CreateHemisphere(name: string, options: {
  47563. segments?: number;
  47564. diameter?: number;
  47565. sideOrientation?: number;
  47566. }, scene: any): Mesh;
  47567. }
  47568. }
  47569. declare module "babylonjs/Lights/spotLight" {
  47570. import { Nullable } from "babylonjs/types";
  47571. import { Scene } from "babylonjs/scene";
  47572. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47574. import { Effect } from "babylonjs/Materials/effect";
  47575. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47576. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47577. /**
  47578. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47579. * These values define a cone of light starting from the position, emitting toward the direction.
  47580. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47581. * and the exponent defines the speed of the decay of the light with distance (reach).
  47582. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47583. */
  47584. export class SpotLight extends ShadowLight {
  47585. private _angle;
  47586. private _innerAngle;
  47587. private _cosHalfAngle;
  47588. private _lightAngleScale;
  47589. private _lightAngleOffset;
  47590. /**
  47591. * Gets the cone angle of the spot light in Radians.
  47592. */
  47593. /**
  47594. * Sets the cone angle of the spot light in Radians.
  47595. */
  47596. angle: number;
  47597. /**
  47598. * Only used in gltf falloff mode, this defines the angle where
  47599. * the directional falloff will start before cutting at angle which could be seen
  47600. * as outer angle.
  47601. */
  47602. /**
  47603. * Only used in gltf falloff mode, this defines the angle where
  47604. * the directional falloff will start before cutting at angle which could be seen
  47605. * as outer angle.
  47606. */
  47607. innerAngle: number;
  47608. private _shadowAngleScale;
  47609. /**
  47610. * Allows scaling the angle of the light for shadow generation only.
  47611. */
  47612. /**
  47613. * Allows scaling the angle of the light for shadow generation only.
  47614. */
  47615. shadowAngleScale: number;
  47616. /**
  47617. * The light decay speed with the distance from the emission spot.
  47618. */
  47619. exponent: number;
  47620. private _projectionTextureMatrix;
  47621. /**
  47622. * Allows reading the projecton texture
  47623. */
  47624. readonly projectionTextureMatrix: Matrix;
  47625. protected _projectionTextureLightNear: number;
  47626. /**
  47627. * Gets the near clip of the Spotlight for texture projection.
  47628. */
  47629. /**
  47630. * Sets the near clip of the Spotlight for texture projection.
  47631. */
  47632. projectionTextureLightNear: number;
  47633. protected _projectionTextureLightFar: number;
  47634. /**
  47635. * Gets the far clip of the Spotlight for texture projection.
  47636. */
  47637. /**
  47638. * Sets the far clip of the Spotlight for texture projection.
  47639. */
  47640. projectionTextureLightFar: number;
  47641. protected _projectionTextureUpDirection: Vector3;
  47642. /**
  47643. * Gets the Up vector of the Spotlight for texture projection.
  47644. */
  47645. /**
  47646. * Sets the Up vector of the Spotlight for texture projection.
  47647. */
  47648. projectionTextureUpDirection: Vector3;
  47649. private _projectionTexture;
  47650. /**
  47651. * Gets the projection texture of the light.
  47652. */
  47653. /**
  47654. * Sets the projection texture of the light.
  47655. */
  47656. projectionTexture: Nullable<BaseTexture>;
  47657. private _projectionTextureViewLightDirty;
  47658. private _projectionTextureProjectionLightDirty;
  47659. private _projectionTextureDirty;
  47660. private _projectionTextureViewTargetVector;
  47661. private _projectionTextureViewLightMatrix;
  47662. private _projectionTextureProjectionLightMatrix;
  47663. private _projectionTextureScalingMatrix;
  47664. /**
  47665. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47666. * It can cast shadows.
  47667. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47668. * @param name The light friendly name
  47669. * @param position The position of the spot light in the scene
  47670. * @param direction The direction of the light in the scene
  47671. * @param angle The cone angle of the light in Radians
  47672. * @param exponent The light decay speed with the distance from the emission spot
  47673. * @param scene The scene the lights belongs to
  47674. */
  47675. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47676. /**
  47677. * Returns the string "SpotLight".
  47678. * @returns the class name
  47679. */
  47680. getClassName(): string;
  47681. /**
  47682. * Returns the integer 2.
  47683. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47684. */
  47685. getTypeID(): number;
  47686. /**
  47687. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47688. */
  47689. protected _setDirection(value: Vector3): void;
  47690. /**
  47691. * Overrides the position setter to recompute the projection texture view light Matrix.
  47692. */
  47693. protected _setPosition(value: Vector3): void;
  47694. /**
  47695. * 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.
  47696. * Returns the SpotLight.
  47697. */
  47698. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47699. protected _computeProjectionTextureViewLightMatrix(): void;
  47700. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47701. /**
  47702. * Main function for light texture projection matrix computing.
  47703. */
  47704. protected _computeProjectionTextureMatrix(): void;
  47705. protected _buildUniformLayout(): void;
  47706. private _computeAngleValues;
  47707. /**
  47708. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47709. * @param effect The effect to update
  47710. * @param lightIndex The index of the light in the effect to update
  47711. * @returns The spot light
  47712. */
  47713. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47714. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47715. /**
  47716. * Disposes the light and the associated resources.
  47717. */
  47718. dispose(): void;
  47719. /**
  47720. * Prepares the list of defines specific to the light type.
  47721. * @param defines the list of defines
  47722. * @param lightIndex defines the index of the light for the effect
  47723. */
  47724. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47725. }
  47726. }
  47727. declare module "babylonjs/Gizmos/lightGizmo" {
  47728. import { Nullable } from "babylonjs/types";
  47729. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47730. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47731. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47732. import { Light } from "babylonjs/Lights/light";
  47733. /**
  47734. * Gizmo that enables viewing a light
  47735. */
  47736. export class LightGizmo extends Gizmo {
  47737. private _lightMesh;
  47738. private _material;
  47739. private cachedPosition;
  47740. private cachedForward;
  47741. /**
  47742. * Creates a LightGizmo
  47743. * @param gizmoLayer The utility layer the gizmo will be added to
  47744. */
  47745. constructor(gizmoLayer?: UtilityLayerRenderer);
  47746. private _light;
  47747. /**
  47748. * The light that the gizmo is attached to
  47749. */
  47750. light: Nullable<Light>;
  47751. /**
  47752. * Gets the material used to render the light gizmo
  47753. */
  47754. readonly material: StandardMaterial;
  47755. /**
  47756. * @hidden
  47757. * Updates the gizmo to match the attached mesh's position/rotation
  47758. */
  47759. protected _update(): void;
  47760. private static _Scale;
  47761. /**
  47762. * Creates the lines for a light mesh
  47763. */
  47764. private static _createLightLines;
  47765. /**
  47766. * Disposes of the light gizmo
  47767. */
  47768. dispose(): void;
  47769. private static _CreateHemisphericLightMesh;
  47770. private static _CreatePointLightMesh;
  47771. private static _CreateSpotLightMesh;
  47772. private static _CreateDirectionalLightMesh;
  47773. }
  47774. }
  47775. declare module "babylonjs/Gizmos/index" {
  47776. export * from "babylonjs/Gizmos/axisDragGizmo";
  47777. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47778. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47779. export * from "babylonjs/Gizmos/gizmo";
  47780. export * from "babylonjs/Gizmos/gizmoManager";
  47781. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47782. export * from "babylonjs/Gizmos/positionGizmo";
  47783. export * from "babylonjs/Gizmos/rotationGizmo";
  47784. export * from "babylonjs/Gizmos/scaleGizmo";
  47785. export * from "babylonjs/Gizmos/lightGizmo";
  47786. export * from "babylonjs/Gizmos/planeDragGizmo";
  47787. }
  47788. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47789. /** @hidden */
  47790. export var backgroundFragmentDeclaration: {
  47791. name: string;
  47792. shader: string;
  47793. };
  47794. }
  47795. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47796. /** @hidden */
  47797. export var backgroundUboDeclaration: {
  47798. name: string;
  47799. shader: string;
  47800. };
  47801. }
  47802. declare module "babylonjs/Shaders/background.fragment" {
  47803. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47804. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47805. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47806. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47807. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47808. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47809. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47810. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47811. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47812. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47813. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47814. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47815. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47816. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47817. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47818. /** @hidden */
  47819. export var backgroundPixelShader: {
  47820. name: string;
  47821. shader: string;
  47822. };
  47823. }
  47824. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47825. /** @hidden */
  47826. export var backgroundVertexDeclaration: {
  47827. name: string;
  47828. shader: string;
  47829. };
  47830. }
  47831. declare module "babylonjs/Shaders/background.vertex" {
  47832. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47833. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47834. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47835. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47836. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47837. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47838. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47839. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47840. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47841. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47842. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47843. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47844. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47845. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47846. /** @hidden */
  47847. export var backgroundVertexShader: {
  47848. name: string;
  47849. shader: string;
  47850. };
  47851. }
  47852. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47853. import { Nullable, int, float } from "babylonjs/types";
  47854. import { Scene } from "babylonjs/scene";
  47855. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47856. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47858. import { Mesh } from "babylonjs/Meshes/mesh";
  47859. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47860. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47861. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47863. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47864. import { Color3 } from "babylonjs/Maths/math.color";
  47865. import "babylonjs/Shaders/background.fragment";
  47866. import "babylonjs/Shaders/background.vertex";
  47867. /**
  47868. * Background material used to create an efficient environement around your scene.
  47869. */
  47870. export class BackgroundMaterial extends PushMaterial {
  47871. /**
  47872. * Standard reflectance value at parallel view angle.
  47873. */
  47874. static StandardReflectance0: number;
  47875. /**
  47876. * Standard reflectance value at grazing angle.
  47877. */
  47878. static StandardReflectance90: number;
  47879. protected _primaryColor: Color3;
  47880. /**
  47881. * Key light Color (multiply against the environement texture)
  47882. */
  47883. primaryColor: Color3;
  47884. protected __perceptualColor: Nullable<Color3>;
  47885. /**
  47886. * Experimental Internal Use Only.
  47887. *
  47888. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47889. * This acts as a helper to set the primary color to a more "human friendly" value.
  47890. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47891. * output color as close as possible from the chosen value.
  47892. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47893. * part of lighting setup.)
  47894. */
  47895. _perceptualColor: Nullable<Color3>;
  47896. protected _primaryColorShadowLevel: float;
  47897. /**
  47898. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47899. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47900. */
  47901. primaryColorShadowLevel: float;
  47902. protected _primaryColorHighlightLevel: float;
  47903. /**
  47904. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47905. * The primary color is used at the level chosen to define what the white area would look.
  47906. */
  47907. primaryColorHighlightLevel: float;
  47908. protected _reflectionTexture: Nullable<BaseTexture>;
  47909. /**
  47910. * Reflection Texture used in the material.
  47911. * Should be author in a specific way for the best result (refer to the documentation).
  47912. */
  47913. reflectionTexture: Nullable<BaseTexture>;
  47914. protected _reflectionBlur: float;
  47915. /**
  47916. * Reflection Texture level of blur.
  47917. *
  47918. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47919. * texture twice.
  47920. */
  47921. reflectionBlur: float;
  47922. protected _diffuseTexture: Nullable<BaseTexture>;
  47923. /**
  47924. * Diffuse Texture used in the material.
  47925. * Should be author in a specific way for the best result (refer to the documentation).
  47926. */
  47927. diffuseTexture: Nullable<BaseTexture>;
  47928. protected _shadowLights: Nullable<IShadowLight[]>;
  47929. /**
  47930. * Specify the list of lights casting shadow on the material.
  47931. * All scene shadow lights will be included if null.
  47932. */
  47933. shadowLights: Nullable<IShadowLight[]>;
  47934. protected _shadowLevel: float;
  47935. /**
  47936. * Helps adjusting the shadow to a softer level if required.
  47937. * 0 means black shadows and 1 means no shadows.
  47938. */
  47939. shadowLevel: float;
  47940. protected _sceneCenter: Vector3;
  47941. /**
  47942. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47943. * It is usually zero but might be interesting to modify according to your setup.
  47944. */
  47945. sceneCenter: Vector3;
  47946. protected _opacityFresnel: boolean;
  47947. /**
  47948. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47949. * This helps ensuring a nice transition when the camera goes under the ground.
  47950. */
  47951. opacityFresnel: boolean;
  47952. protected _reflectionFresnel: boolean;
  47953. /**
  47954. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47955. * This helps adding a mirror texture on the ground.
  47956. */
  47957. reflectionFresnel: boolean;
  47958. protected _reflectionFalloffDistance: number;
  47959. /**
  47960. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47961. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47962. */
  47963. reflectionFalloffDistance: number;
  47964. protected _reflectionAmount: number;
  47965. /**
  47966. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47967. */
  47968. reflectionAmount: number;
  47969. protected _reflectionReflectance0: number;
  47970. /**
  47971. * This specifies the weight of the reflection at grazing angle.
  47972. */
  47973. reflectionReflectance0: number;
  47974. protected _reflectionReflectance90: number;
  47975. /**
  47976. * This specifies the weight of the reflection at a perpendicular point of view.
  47977. */
  47978. reflectionReflectance90: number;
  47979. /**
  47980. * Sets the reflection reflectance fresnel values according to the default standard
  47981. * empirically know to work well :-)
  47982. */
  47983. reflectionStandardFresnelWeight: number;
  47984. protected _useRGBColor: boolean;
  47985. /**
  47986. * Helps to directly use the maps channels instead of their level.
  47987. */
  47988. useRGBColor: boolean;
  47989. protected _enableNoise: boolean;
  47990. /**
  47991. * This helps reducing the banding effect that could occur on the background.
  47992. */
  47993. enableNoise: boolean;
  47994. /**
  47995. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47996. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47997. * Recommended to be keep at 1.0 except for special cases.
  47998. */
  47999. fovMultiplier: number;
  48000. private _fovMultiplier;
  48001. /**
  48002. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48003. */
  48004. useEquirectangularFOV: boolean;
  48005. private _maxSimultaneousLights;
  48006. /**
  48007. * Number of Simultaneous lights allowed on the material.
  48008. */
  48009. maxSimultaneousLights: int;
  48010. /**
  48011. * Default configuration related to image processing available in the Background Material.
  48012. */
  48013. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48014. /**
  48015. * Keep track of the image processing observer to allow dispose and replace.
  48016. */
  48017. private _imageProcessingObserver;
  48018. /**
  48019. * Attaches a new image processing configuration to the PBR Material.
  48020. * @param configuration (if null the scene configuration will be use)
  48021. */
  48022. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48023. /**
  48024. * Gets the image processing configuration used either in this material.
  48025. */
  48026. /**
  48027. * Sets the Default image processing configuration used either in the this material.
  48028. *
  48029. * If sets to null, the scene one is in use.
  48030. */
  48031. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48032. /**
  48033. * Gets wether the color curves effect is enabled.
  48034. */
  48035. /**
  48036. * Sets wether the color curves effect is enabled.
  48037. */
  48038. cameraColorCurvesEnabled: boolean;
  48039. /**
  48040. * Gets wether the color grading effect is enabled.
  48041. */
  48042. /**
  48043. * Gets wether the color grading effect is enabled.
  48044. */
  48045. cameraColorGradingEnabled: boolean;
  48046. /**
  48047. * Gets wether tonemapping is enabled or not.
  48048. */
  48049. /**
  48050. * Sets wether tonemapping is enabled or not
  48051. */
  48052. cameraToneMappingEnabled: boolean;
  48053. /**
  48054. * The camera exposure used on this material.
  48055. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48056. * This corresponds to a photographic exposure.
  48057. */
  48058. /**
  48059. * The camera exposure used on this material.
  48060. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48061. * This corresponds to a photographic exposure.
  48062. */
  48063. cameraExposure: float;
  48064. /**
  48065. * Gets The camera contrast used on this material.
  48066. */
  48067. /**
  48068. * Sets The camera contrast used on this material.
  48069. */
  48070. cameraContrast: float;
  48071. /**
  48072. * Gets the Color Grading 2D Lookup Texture.
  48073. */
  48074. /**
  48075. * Sets the Color Grading 2D Lookup Texture.
  48076. */
  48077. cameraColorGradingTexture: Nullable<BaseTexture>;
  48078. /**
  48079. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48080. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48081. * 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;
  48082. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48083. */
  48084. /**
  48085. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48086. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48087. * 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;
  48088. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48089. */
  48090. cameraColorCurves: Nullable<ColorCurves>;
  48091. /**
  48092. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48093. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48094. */
  48095. switchToBGR: boolean;
  48096. private _renderTargets;
  48097. private _reflectionControls;
  48098. private _white;
  48099. private _primaryShadowColor;
  48100. private _primaryHighlightColor;
  48101. /**
  48102. * Instantiates a Background Material in the given scene
  48103. * @param name The friendly name of the material
  48104. * @param scene The scene to add the material to
  48105. */
  48106. constructor(name: string, scene: Scene);
  48107. /**
  48108. * Gets a boolean indicating that current material needs to register RTT
  48109. */
  48110. readonly hasRenderTargetTextures: boolean;
  48111. /**
  48112. * The entire material has been created in order to prevent overdraw.
  48113. * @returns false
  48114. */
  48115. needAlphaTesting(): boolean;
  48116. /**
  48117. * The entire material has been created in order to prevent overdraw.
  48118. * @returns true if blending is enable
  48119. */
  48120. needAlphaBlending(): boolean;
  48121. /**
  48122. * Checks wether the material is ready to be rendered for a given mesh.
  48123. * @param mesh The mesh to render
  48124. * @param subMesh The submesh to check against
  48125. * @param useInstances Specify wether or not the material is used with instances
  48126. * @returns true if all the dependencies are ready (Textures, Effects...)
  48127. */
  48128. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48129. /**
  48130. * Compute the primary color according to the chosen perceptual color.
  48131. */
  48132. private _computePrimaryColorFromPerceptualColor;
  48133. /**
  48134. * Compute the highlights and shadow colors according to their chosen levels.
  48135. */
  48136. private _computePrimaryColors;
  48137. /**
  48138. * Build the uniform buffer used in the material.
  48139. */
  48140. buildUniformLayout(): void;
  48141. /**
  48142. * Unbind the material.
  48143. */
  48144. unbind(): void;
  48145. /**
  48146. * Bind only the world matrix to the material.
  48147. * @param world The world matrix to bind.
  48148. */
  48149. bindOnlyWorldMatrix(world: Matrix): void;
  48150. /**
  48151. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48152. * @param world The world matrix to bind.
  48153. * @param subMesh The submesh to bind for.
  48154. */
  48155. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48156. /**
  48157. * Checks to see if a texture is used in the material.
  48158. * @param texture - Base texture to use.
  48159. * @returns - Boolean specifying if a texture is used in the material.
  48160. */
  48161. hasTexture(texture: BaseTexture): boolean;
  48162. /**
  48163. * Dispose the material.
  48164. * @param forceDisposeEffect Force disposal of the associated effect.
  48165. * @param forceDisposeTextures Force disposal of the associated textures.
  48166. */
  48167. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48168. /**
  48169. * Clones the material.
  48170. * @param name The cloned name.
  48171. * @returns The cloned material.
  48172. */
  48173. clone(name: string): BackgroundMaterial;
  48174. /**
  48175. * Serializes the current material to its JSON representation.
  48176. * @returns The JSON representation.
  48177. */
  48178. serialize(): any;
  48179. /**
  48180. * Gets the class name of the material
  48181. * @returns "BackgroundMaterial"
  48182. */
  48183. getClassName(): string;
  48184. /**
  48185. * Parse a JSON input to create back a background material.
  48186. * @param source The JSON data to parse
  48187. * @param scene The scene to create the parsed material in
  48188. * @param rootUrl The root url of the assets the material depends upon
  48189. * @returns the instantiated BackgroundMaterial.
  48190. */
  48191. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48192. }
  48193. }
  48194. declare module "babylonjs/Helpers/environmentHelper" {
  48195. import { Observable } from "babylonjs/Misc/observable";
  48196. import { Nullable } from "babylonjs/types";
  48197. import { Scene } from "babylonjs/scene";
  48198. import { Vector3 } from "babylonjs/Maths/math.vector";
  48199. import { Color3 } from "babylonjs/Maths/math.color";
  48200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48201. import { Mesh } from "babylonjs/Meshes/mesh";
  48202. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48203. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48204. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48205. import "babylonjs/Meshes/Builders/planeBuilder";
  48206. import "babylonjs/Meshes/Builders/boxBuilder";
  48207. /**
  48208. * Represents the different options available during the creation of
  48209. * a Environment helper.
  48210. *
  48211. * This can control the default ground, skybox and image processing setup of your scene.
  48212. */
  48213. export interface IEnvironmentHelperOptions {
  48214. /**
  48215. * Specifies wether or not to create a ground.
  48216. * True by default.
  48217. */
  48218. createGround: boolean;
  48219. /**
  48220. * Specifies the ground size.
  48221. * 15 by default.
  48222. */
  48223. groundSize: number;
  48224. /**
  48225. * The texture used on the ground for the main color.
  48226. * Comes from the BabylonJS CDN by default.
  48227. *
  48228. * Remarks: Can be either a texture or a url.
  48229. */
  48230. groundTexture: string | BaseTexture;
  48231. /**
  48232. * The color mixed in the ground texture by default.
  48233. * BabylonJS clearColor by default.
  48234. */
  48235. groundColor: Color3;
  48236. /**
  48237. * Specifies the ground opacity.
  48238. * 1 by default.
  48239. */
  48240. groundOpacity: number;
  48241. /**
  48242. * Enables the ground to receive shadows.
  48243. * True by default.
  48244. */
  48245. enableGroundShadow: boolean;
  48246. /**
  48247. * Helps preventing the shadow to be fully black on the ground.
  48248. * 0.5 by default.
  48249. */
  48250. groundShadowLevel: number;
  48251. /**
  48252. * Creates a mirror texture attach to the ground.
  48253. * false by default.
  48254. */
  48255. enableGroundMirror: boolean;
  48256. /**
  48257. * Specifies the ground mirror size ratio.
  48258. * 0.3 by default as the default kernel is 64.
  48259. */
  48260. groundMirrorSizeRatio: number;
  48261. /**
  48262. * Specifies the ground mirror blur kernel size.
  48263. * 64 by default.
  48264. */
  48265. groundMirrorBlurKernel: number;
  48266. /**
  48267. * Specifies the ground mirror visibility amount.
  48268. * 1 by default
  48269. */
  48270. groundMirrorAmount: number;
  48271. /**
  48272. * Specifies the ground mirror reflectance weight.
  48273. * This uses the standard weight of the background material to setup the fresnel effect
  48274. * of the mirror.
  48275. * 1 by default.
  48276. */
  48277. groundMirrorFresnelWeight: number;
  48278. /**
  48279. * Specifies the ground mirror Falloff distance.
  48280. * This can helps reducing the size of the reflection.
  48281. * 0 by Default.
  48282. */
  48283. groundMirrorFallOffDistance: number;
  48284. /**
  48285. * Specifies the ground mirror texture type.
  48286. * Unsigned Int by Default.
  48287. */
  48288. groundMirrorTextureType: number;
  48289. /**
  48290. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48291. * the shown objects.
  48292. */
  48293. groundYBias: number;
  48294. /**
  48295. * Specifies wether or not to create a skybox.
  48296. * True by default.
  48297. */
  48298. createSkybox: boolean;
  48299. /**
  48300. * Specifies the skybox size.
  48301. * 20 by default.
  48302. */
  48303. skyboxSize: number;
  48304. /**
  48305. * The texture used on the skybox for the main color.
  48306. * Comes from the BabylonJS CDN by default.
  48307. *
  48308. * Remarks: Can be either a texture or a url.
  48309. */
  48310. skyboxTexture: string | BaseTexture;
  48311. /**
  48312. * The color mixed in the skybox texture by default.
  48313. * BabylonJS clearColor by default.
  48314. */
  48315. skyboxColor: Color3;
  48316. /**
  48317. * The background rotation around the Y axis of the scene.
  48318. * This helps aligning the key lights of your scene with the background.
  48319. * 0 by default.
  48320. */
  48321. backgroundYRotation: number;
  48322. /**
  48323. * Compute automatically the size of the elements to best fit with the scene.
  48324. */
  48325. sizeAuto: boolean;
  48326. /**
  48327. * Default position of the rootMesh if autoSize is not true.
  48328. */
  48329. rootPosition: Vector3;
  48330. /**
  48331. * Sets up the image processing in the scene.
  48332. * true by default.
  48333. */
  48334. setupImageProcessing: boolean;
  48335. /**
  48336. * The texture used as your environment texture in the scene.
  48337. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48338. *
  48339. * Remarks: Can be either a texture or a url.
  48340. */
  48341. environmentTexture: string | BaseTexture;
  48342. /**
  48343. * The value of the exposure to apply to the scene.
  48344. * 0.6 by default if setupImageProcessing is true.
  48345. */
  48346. cameraExposure: number;
  48347. /**
  48348. * The value of the contrast to apply to the scene.
  48349. * 1.6 by default if setupImageProcessing is true.
  48350. */
  48351. cameraContrast: number;
  48352. /**
  48353. * Specifies wether or not tonemapping should be enabled in the scene.
  48354. * true by default if setupImageProcessing is true.
  48355. */
  48356. toneMappingEnabled: boolean;
  48357. }
  48358. /**
  48359. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48360. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48361. * It also helps with the default setup of your imageProcessing configuration.
  48362. */
  48363. export class EnvironmentHelper {
  48364. /**
  48365. * Default ground texture URL.
  48366. */
  48367. private static _groundTextureCDNUrl;
  48368. /**
  48369. * Default skybox texture URL.
  48370. */
  48371. private static _skyboxTextureCDNUrl;
  48372. /**
  48373. * Default environment texture URL.
  48374. */
  48375. private static _environmentTextureCDNUrl;
  48376. /**
  48377. * Creates the default options for the helper.
  48378. */
  48379. private static _getDefaultOptions;
  48380. private _rootMesh;
  48381. /**
  48382. * Gets the root mesh created by the helper.
  48383. */
  48384. readonly rootMesh: Mesh;
  48385. private _skybox;
  48386. /**
  48387. * Gets the skybox created by the helper.
  48388. */
  48389. readonly skybox: Nullable<Mesh>;
  48390. private _skyboxTexture;
  48391. /**
  48392. * Gets the skybox texture created by the helper.
  48393. */
  48394. readonly skyboxTexture: Nullable<BaseTexture>;
  48395. private _skyboxMaterial;
  48396. /**
  48397. * Gets the skybox material created by the helper.
  48398. */
  48399. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48400. private _ground;
  48401. /**
  48402. * Gets the ground mesh created by the helper.
  48403. */
  48404. readonly ground: Nullable<Mesh>;
  48405. private _groundTexture;
  48406. /**
  48407. * Gets the ground texture created by the helper.
  48408. */
  48409. readonly groundTexture: Nullable<BaseTexture>;
  48410. private _groundMirror;
  48411. /**
  48412. * Gets the ground mirror created by the helper.
  48413. */
  48414. readonly groundMirror: Nullable<MirrorTexture>;
  48415. /**
  48416. * Gets the ground mirror render list to helps pushing the meshes
  48417. * you wish in the ground reflection.
  48418. */
  48419. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48420. private _groundMaterial;
  48421. /**
  48422. * Gets the ground material created by the helper.
  48423. */
  48424. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48425. /**
  48426. * Stores the creation options.
  48427. */
  48428. private readonly _scene;
  48429. private _options;
  48430. /**
  48431. * This observable will be notified with any error during the creation of the environment,
  48432. * mainly texture creation errors.
  48433. */
  48434. onErrorObservable: Observable<{
  48435. message?: string;
  48436. exception?: any;
  48437. }>;
  48438. /**
  48439. * constructor
  48440. * @param options Defines the options we want to customize the helper
  48441. * @param scene The scene to add the material to
  48442. */
  48443. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48444. /**
  48445. * Updates the background according to the new options
  48446. * @param options
  48447. */
  48448. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48449. /**
  48450. * Sets the primary color of all the available elements.
  48451. * @param color the main color to affect to the ground and the background
  48452. */
  48453. setMainColor(color: Color3): void;
  48454. /**
  48455. * Setup the image processing according to the specified options.
  48456. */
  48457. private _setupImageProcessing;
  48458. /**
  48459. * Setup the environment texture according to the specified options.
  48460. */
  48461. private _setupEnvironmentTexture;
  48462. /**
  48463. * Setup the background according to the specified options.
  48464. */
  48465. private _setupBackground;
  48466. /**
  48467. * Get the scene sizes according to the setup.
  48468. */
  48469. private _getSceneSize;
  48470. /**
  48471. * Setup the ground according to the specified options.
  48472. */
  48473. private _setupGround;
  48474. /**
  48475. * Setup the ground material according to the specified options.
  48476. */
  48477. private _setupGroundMaterial;
  48478. /**
  48479. * Setup the ground diffuse texture according to the specified options.
  48480. */
  48481. private _setupGroundDiffuseTexture;
  48482. /**
  48483. * Setup the ground mirror texture according to the specified options.
  48484. */
  48485. private _setupGroundMirrorTexture;
  48486. /**
  48487. * Setup the ground to receive the mirror texture.
  48488. */
  48489. private _setupMirrorInGroundMaterial;
  48490. /**
  48491. * Setup the skybox according to the specified options.
  48492. */
  48493. private _setupSkybox;
  48494. /**
  48495. * Setup the skybox material according to the specified options.
  48496. */
  48497. private _setupSkyboxMaterial;
  48498. /**
  48499. * Setup the skybox reflection texture according to the specified options.
  48500. */
  48501. private _setupSkyboxReflectionTexture;
  48502. private _errorHandler;
  48503. /**
  48504. * Dispose all the elements created by the Helper.
  48505. */
  48506. dispose(): void;
  48507. }
  48508. }
  48509. declare module "babylonjs/Helpers/photoDome" {
  48510. import { Observable } from "babylonjs/Misc/observable";
  48511. import { Nullable } from "babylonjs/types";
  48512. import { Scene } from "babylonjs/scene";
  48513. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48514. import { Mesh } from "babylonjs/Meshes/mesh";
  48515. import { Texture } from "babylonjs/Materials/Textures/texture";
  48516. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48517. import "babylonjs/Meshes/Builders/sphereBuilder";
  48518. /**
  48519. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48520. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48521. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48522. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48523. */
  48524. export class PhotoDome extends TransformNode {
  48525. /**
  48526. * Define the image as a Monoscopic panoramic 360 image.
  48527. */
  48528. static readonly MODE_MONOSCOPIC: number;
  48529. /**
  48530. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48531. */
  48532. static readonly MODE_TOPBOTTOM: number;
  48533. /**
  48534. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48535. */
  48536. static readonly MODE_SIDEBYSIDE: number;
  48537. private _useDirectMapping;
  48538. /**
  48539. * The texture being displayed on the sphere
  48540. */
  48541. protected _photoTexture: Texture;
  48542. /**
  48543. * Gets or sets the texture being displayed on the sphere
  48544. */
  48545. photoTexture: Texture;
  48546. /**
  48547. * Observable raised when an error occured while loading the 360 image
  48548. */
  48549. onLoadErrorObservable: Observable<string>;
  48550. /**
  48551. * The skybox material
  48552. */
  48553. protected _material: BackgroundMaterial;
  48554. /**
  48555. * The surface used for the skybox
  48556. */
  48557. protected _mesh: Mesh;
  48558. /**
  48559. * Gets the mesh used for the skybox.
  48560. */
  48561. readonly mesh: Mesh;
  48562. /**
  48563. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48564. * Also see the options.resolution property.
  48565. */
  48566. fovMultiplier: number;
  48567. private _imageMode;
  48568. /**
  48569. * Gets or set the current video mode for the video. It can be:
  48570. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48571. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48572. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48573. */
  48574. imageMode: number;
  48575. /**
  48576. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48577. * @param name Element's name, child elements will append suffixes for their own names.
  48578. * @param urlsOfPhoto defines the url of the photo to display
  48579. * @param options defines an object containing optional or exposed sub element properties
  48580. * @param onError defines a callback called when an error occured while loading the texture
  48581. */
  48582. constructor(name: string, urlOfPhoto: string, options: {
  48583. resolution?: number;
  48584. size?: number;
  48585. useDirectMapping?: boolean;
  48586. faceForward?: boolean;
  48587. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48588. private _onBeforeCameraRenderObserver;
  48589. private _changeImageMode;
  48590. /**
  48591. * Releases resources associated with this node.
  48592. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48593. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48594. */
  48595. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48596. }
  48597. }
  48598. declare module "babylonjs/Misc/rgbdTextureTools" {
  48599. import "babylonjs/Shaders/rgbdDecode.fragment";
  48600. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48601. import { Texture } from "babylonjs/Materials/Textures/texture";
  48602. /**
  48603. * Class used to host RGBD texture specific utilities
  48604. */
  48605. export class RGBDTextureTools {
  48606. /**
  48607. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48608. * @param texture the texture to expand.
  48609. */
  48610. static ExpandRGBDTexture(texture: Texture): void;
  48611. }
  48612. }
  48613. declare module "babylonjs/Misc/brdfTextureTools" {
  48614. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48615. import { Scene } from "babylonjs/scene";
  48616. /**
  48617. * Class used to host texture specific utilities
  48618. */
  48619. export class BRDFTextureTools {
  48620. /**
  48621. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48622. * @param scene defines the hosting scene
  48623. * @returns the environment BRDF texture
  48624. */
  48625. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48626. private static _environmentBRDFBase64Texture;
  48627. }
  48628. }
  48629. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48630. import { Nullable } from "babylonjs/types";
  48631. import { Color3 } from "babylonjs/Maths/math.color";
  48632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48633. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48634. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48635. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48636. import { Engine } from "babylonjs/Engines/engine";
  48637. import { Scene } from "babylonjs/scene";
  48638. /**
  48639. * @hidden
  48640. */
  48641. export interface IMaterialClearCoatDefines {
  48642. CLEARCOAT: boolean;
  48643. CLEARCOAT_DEFAULTIOR: boolean;
  48644. CLEARCOAT_TEXTURE: boolean;
  48645. CLEARCOAT_TEXTUREDIRECTUV: number;
  48646. CLEARCOAT_BUMP: boolean;
  48647. CLEARCOAT_BUMPDIRECTUV: number;
  48648. CLEARCOAT_TINT: boolean;
  48649. CLEARCOAT_TINT_TEXTURE: boolean;
  48650. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48651. /** @hidden */
  48652. _areTexturesDirty: boolean;
  48653. }
  48654. /**
  48655. * Define the code related to the clear coat parameters of the pbr material.
  48656. */
  48657. export class PBRClearCoatConfiguration {
  48658. /**
  48659. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48660. * The default fits with a polyurethane material.
  48661. */
  48662. private static readonly _DefaultIndexOfRefraction;
  48663. private _isEnabled;
  48664. /**
  48665. * Defines if the clear coat is enabled in the material.
  48666. */
  48667. isEnabled: boolean;
  48668. /**
  48669. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48670. */
  48671. intensity: number;
  48672. /**
  48673. * Defines the clear coat layer roughness.
  48674. */
  48675. roughness: number;
  48676. private _indexOfRefraction;
  48677. /**
  48678. * Defines the index of refraction of the clear coat.
  48679. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48680. * The default fits with a polyurethane material.
  48681. * Changing the default value is more performance intensive.
  48682. */
  48683. indexOfRefraction: number;
  48684. private _texture;
  48685. /**
  48686. * Stores the clear coat values in a texture.
  48687. */
  48688. texture: Nullable<BaseTexture>;
  48689. private _bumpTexture;
  48690. /**
  48691. * Define the clear coat specific bump texture.
  48692. */
  48693. bumpTexture: Nullable<BaseTexture>;
  48694. private _isTintEnabled;
  48695. /**
  48696. * Defines if the clear coat tint is enabled in the material.
  48697. */
  48698. isTintEnabled: boolean;
  48699. /**
  48700. * Defines the clear coat tint of the material.
  48701. * This is only use if tint is enabled
  48702. */
  48703. tintColor: Color3;
  48704. /**
  48705. * Defines the distance at which the tint color should be found in the
  48706. * clear coat media.
  48707. * This is only use if tint is enabled
  48708. */
  48709. tintColorAtDistance: number;
  48710. /**
  48711. * Defines the clear coat layer thickness.
  48712. * This is only use if tint is enabled
  48713. */
  48714. tintThickness: number;
  48715. private _tintTexture;
  48716. /**
  48717. * Stores the clear tint values in a texture.
  48718. * rgb is tint
  48719. * a is a thickness factor
  48720. */
  48721. tintTexture: Nullable<BaseTexture>;
  48722. /** @hidden */
  48723. private _internalMarkAllSubMeshesAsTexturesDirty;
  48724. /** @hidden */
  48725. _markAllSubMeshesAsTexturesDirty(): void;
  48726. /**
  48727. * Instantiate a new istance of clear coat configuration.
  48728. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48729. */
  48730. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48731. /**
  48732. * Gets wehter the submesh is ready to be used or not.
  48733. * @param defines the list of "defines" to update.
  48734. * @param scene defines the scene the material belongs to.
  48735. * @param engine defines the engine the material belongs to.
  48736. * @param disableBumpMap defines wether the material disables bump or not.
  48737. * @returns - boolean indicating that the submesh is ready or not.
  48738. */
  48739. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48740. /**
  48741. * Checks to see if a texture is used in the material.
  48742. * @param defines the list of "defines" to update.
  48743. * @param scene defines the scene to the material belongs to.
  48744. */
  48745. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48746. /**
  48747. * Binds the material data.
  48748. * @param uniformBuffer defines the Uniform buffer to fill in.
  48749. * @param scene defines the scene the material belongs to.
  48750. * @param engine defines the engine the material belongs to.
  48751. * @param disableBumpMap defines wether the material disables bump or not.
  48752. * @param isFrozen defines wether the material is frozen or not.
  48753. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48754. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48755. */
  48756. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48757. /**
  48758. * Checks to see if a texture is used in the material.
  48759. * @param texture - Base texture to use.
  48760. * @returns - Boolean specifying if a texture is used in the material.
  48761. */
  48762. hasTexture(texture: BaseTexture): boolean;
  48763. /**
  48764. * Returns an array of the actively used textures.
  48765. * @param activeTextures Array of BaseTextures
  48766. */
  48767. getActiveTextures(activeTextures: BaseTexture[]): void;
  48768. /**
  48769. * Returns the animatable textures.
  48770. * @param animatables Array of animatable textures.
  48771. */
  48772. getAnimatables(animatables: IAnimatable[]): void;
  48773. /**
  48774. * Disposes the resources of the material.
  48775. * @param forceDisposeTextures - Forces the disposal of all textures.
  48776. */
  48777. dispose(forceDisposeTextures?: boolean): void;
  48778. /**
  48779. * Get the current class name of the texture useful for serialization or dynamic coding.
  48780. * @returns "PBRClearCoatConfiguration"
  48781. */
  48782. getClassName(): string;
  48783. /**
  48784. * Add fallbacks to the effect fallbacks list.
  48785. * @param defines defines the Base texture to use.
  48786. * @param fallbacks defines the current fallback list.
  48787. * @param currentRank defines the current fallback rank.
  48788. * @returns the new fallback rank.
  48789. */
  48790. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48791. /**
  48792. * Add the required uniforms to the current list.
  48793. * @param uniforms defines the current uniform list.
  48794. */
  48795. static AddUniforms(uniforms: string[]): void;
  48796. /**
  48797. * Add the required samplers to the current list.
  48798. * @param samplers defines the current sampler list.
  48799. */
  48800. static AddSamplers(samplers: string[]): void;
  48801. /**
  48802. * Add the required uniforms to the current buffer.
  48803. * @param uniformBuffer defines the current uniform buffer.
  48804. */
  48805. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48806. /**
  48807. * Makes a duplicate of the current configuration into another one.
  48808. * @param clearCoatConfiguration define the config where to copy the info
  48809. */
  48810. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48811. /**
  48812. * Serializes this clear coat configuration.
  48813. * @returns - An object with the serialized config.
  48814. */
  48815. serialize(): any;
  48816. /**
  48817. * Parses a anisotropy Configuration from a serialized object.
  48818. * @param source - Serialized object.
  48819. * @param scene Defines the scene we are parsing for
  48820. * @param rootUrl Defines the rootUrl to load from
  48821. */
  48822. parse(source: any, scene: Scene, rootUrl: string): void;
  48823. }
  48824. }
  48825. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48826. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48828. import { Vector2 } from "babylonjs/Maths/math.vector";
  48829. import { Scene } from "babylonjs/scene";
  48830. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48831. import { Nullable } from "babylonjs/types";
  48832. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48833. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48834. /**
  48835. * @hidden
  48836. */
  48837. export interface IMaterialAnisotropicDefines {
  48838. ANISOTROPIC: boolean;
  48839. ANISOTROPIC_TEXTURE: boolean;
  48840. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48841. MAINUV1: boolean;
  48842. _areTexturesDirty: boolean;
  48843. _needUVs: boolean;
  48844. }
  48845. /**
  48846. * Define the code related to the anisotropic parameters of the pbr material.
  48847. */
  48848. export class PBRAnisotropicConfiguration {
  48849. private _isEnabled;
  48850. /**
  48851. * Defines if the anisotropy is enabled in the material.
  48852. */
  48853. isEnabled: boolean;
  48854. /**
  48855. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48856. */
  48857. intensity: number;
  48858. /**
  48859. * Defines if the effect is along the tangents, bitangents or in between.
  48860. * By default, the effect is "strectching" the highlights along the tangents.
  48861. */
  48862. direction: Vector2;
  48863. private _texture;
  48864. /**
  48865. * Stores the anisotropy values in a texture.
  48866. * rg is direction (like normal from -1 to 1)
  48867. * b is a intensity
  48868. */
  48869. texture: Nullable<BaseTexture>;
  48870. /** @hidden */
  48871. private _internalMarkAllSubMeshesAsTexturesDirty;
  48872. /** @hidden */
  48873. _markAllSubMeshesAsTexturesDirty(): void;
  48874. /**
  48875. * Instantiate a new istance of anisotropy configuration.
  48876. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48877. */
  48878. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48879. /**
  48880. * Specifies that the submesh is ready to be used.
  48881. * @param defines the list of "defines" to update.
  48882. * @param scene defines the scene the material belongs to.
  48883. * @returns - boolean indicating that the submesh is ready or not.
  48884. */
  48885. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48886. /**
  48887. * Checks to see if a texture is used in the material.
  48888. * @param defines the list of "defines" to update.
  48889. * @param mesh the mesh we are preparing the defines for.
  48890. * @param scene defines the scene the material belongs to.
  48891. */
  48892. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48893. /**
  48894. * Binds the material data.
  48895. * @param uniformBuffer defines the Uniform buffer to fill in.
  48896. * @param scene defines the scene the material belongs to.
  48897. * @param isFrozen defines wether the material is frozen or not.
  48898. */
  48899. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48900. /**
  48901. * Checks to see if a texture is used in the material.
  48902. * @param texture - Base texture to use.
  48903. * @returns - Boolean specifying if a texture is used in the material.
  48904. */
  48905. hasTexture(texture: BaseTexture): boolean;
  48906. /**
  48907. * Returns an array of the actively used textures.
  48908. * @param activeTextures Array of BaseTextures
  48909. */
  48910. getActiveTextures(activeTextures: BaseTexture[]): void;
  48911. /**
  48912. * Returns the animatable textures.
  48913. * @param animatables Array of animatable textures.
  48914. */
  48915. getAnimatables(animatables: IAnimatable[]): void;
  48916. /**
  48917. * Disposes the resources of the material.
  48918. * @param forceDisposeTextures - Forces the disposal of all textures.
  48919. */
  48920. dispose(forceDisposeTextures?: boolean): void;
  48921. /**
  48922. * Get the current class name of the texture useful for serialization or dynamic coding.
  48923. * @returns "PBRAnisotropicConfiguration"
  48924. */
  48925. getClassName(): string;
  48926. /**
  48927. * Add fallbacks to the effect fallbacks list.
  48928. * @param defines defines the Base texture to use.
  48929. * @param fallbacks defines the current fallback list.
  48930. * @param currentRank defines the current fallback rank.
  48931. * @returns the new fallback rank.
  48932. */
  48933. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48934. /**
  48935. * Add the required uniforms to the current list.
  48936. * @param uniforms defines the current uniform list.
  48937. */
  48938. static AddUniforms(uniforms: string[]): void;
  48939. /**
  48940. * Add the required uniforms to the current buffer.
  48941. * @param uniformBuffer defines the current uniform buffer.
  48942. */
  48943. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48944. /**
  48945. * Add the required samplers to the current list.
  48946. * @param samplers defines the current sampler list.
  48947. */
  48948. static AddSamplers(samplers: string[]): void;
  48949. /**
  48950. * Makes a duplicate of the current configuration into another one.
  48951. * @param anisotropicConfiguration define the config where to copy the info
  48952. */
  48953. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48954. /**
  48955. * Serializes this anisotropy configuration.
  48956. * @returns - An object with the serialized config.
  48957. */
  48958. serialize(): any;
  48959. /**
  48960. * Parses a anisotropy Configuration from a serialized object.
  48961. * @param source - Serialized object.
  48962. * @param scene Defines the scene we are parsing for
  48963. * @param rootUrl Defines the rootUrl to load from
  48964. */
  48965. parse(source: any, scene: Scene, rootUrl: string): void;
  48966. }
  48967. }
  48968. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48969. import { Scene } from "babylonjs/scene";
  48970. /**
  48971. * @hidden
  48972. */
  48973. export interface IMaterialBRDFDefines {
  48974. BRDF_V_HEIGHT_CORRELATED: boolean;
  48975. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48976. SPHERICAL_HARMONICS: boolean;
  48977. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48978. /** @hidden */
  48979. _areMiscDirty: boolean;
  48980. }
  48981. /**
  48982. * Define the code related to the BRDF parameters of the pbr material.
  48983. */
  48984. export class PBRBRDFConfiguration {
  48985. /**
  48986. * Default value used for the energy conservation.
  48987. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48988. */
  48989. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48990. /**
  48991. * Default value used for the Smith Visibility Height Correlated mode.
  48992. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48993. */
  48994. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48995. /**
  48996. * Default value used for the IBL diffuse part.
  48997. * This can help switching back to the polynomials mode globally which is a tiny bit
  48998. * less GPU intensive at the drawback of a lower quality.
  48999. */
  49000. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49001. /**
  49002. * Default value used for activating energy conservation for the specular workflow.
  49003. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49004. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49005. */
  49006. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49007. private _useEnergyConservation;
  49008. /**
  49009. * Defines if the material uses energy conservation.
  49010. */
  49011. useEnergyConservation: boolean;
  49012. private _useSmithVisibilityHeightCorrelated;
  49013. /**
  49014. * LEGACY Mode set to false
  49015. * Defines if the material uses height smith correlated visibility term.
  49016. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49017. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49018. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49019. * Not relying on height correlated will also disable energy conservation.
  49020. */
  49021. useSmithVisibilityHeightCorrelated: boolean;
  49022. private _useSphericalHarmonics;
  49023. /**
  49024. * LEGACY Mode set to false
  49025. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49026. * diffuse part of the IBL.
  49027. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49028. * to the ground truth.
  49029. */
  49030. useSphericalHarmonics: boolean;
  49031. private _useSpecularGlossinessInputEnergyConservation;
  49032. /**
  49033. * Defines if the material uses energy conservation, when the specular workflow is active.
  49034. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49035. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49036. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49037. */
  49038. useSpecularGlossinessInputEnergyConservation: boolean;
  49039. /** @hidden */
  49040. private _internalMarkAllSubMeshesAsMiscDirty;
  49041. /** @hidden */
  49042. _markAllSubMeshesAsMiscDirty(): void;
  49043. /**
  49044. * Instantiate a new istance of clear coat configuration.
  49045. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49046. */
  49047. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49048. /**
  49049. * Checks to see if a texture is used in the material.
  49050. * @param defines the list of "defines" to update.
  49051. */
  49052. prepareDefines(defines: IMaterialBRDFDefines): void;
  49053. /**
  49054. * Get the current class name of the texture useful for serialization or dynamic coding.
  49055. * @returns "PBRClearCoatConfiguration"
  49056. */
  49057. getClassName(): string;
  49058. /**
  49059. * Makes a duplicate of the current configuration into another one.
  49060. * @param brdfConfiguration define the config where to copy the info
  49061. */
  49062. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49063. /**
  49064. * Serializes this BRDF configuration.
  49065. * @returns - An object with the serialized config.
  49066. */
  49067. serialize(): any;
  49068. /**
  49069. * Parses a anisotropy Configuration from a serialized object.
  49070. * @param source - Serialized object.
  49071. * @param scene Defines the scene we are parsing for
  49072. * @param rootUrl Defines the rootUrl to load from
  49073. */
  49074. parse(source: any, scene: Scene, rootUrl: string): void;
  49075. }
  49076. }
  49077. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49078. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49079. import { Color3 } from "babylonjs/Maths/math.color";
  49080. import { Scene } from "babylonjs/scene";
  49081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49082. import { Nullable } from "babylonjs/types";
  49083. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49084. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49085. /**
  49086. * @hidden
  49087. */
  49088. export interface IMaterialSheenDefines {
  49089. SHEEN: boolean;
  49090. SHEEN_TEXTURE: boolean;
  49091. SHEEN_TEXTUREDIRECTUV: number;
  49092. SHEEN_LINKWITHALBEDO: boolean;
  49093. /** @hidden */
  49094. _areTexturesDirty: boolean;
  49095. }
  49096. /**
  49097. * Define the code related to the Sheen parameters of the pbr material.
  49098. */
  49099. export class PBRSheenConfiguration {
  49100. private _isEnabled;
  49101. /**
  49102. * Defines if the material uses sheen.
  49103. */
  49104. isEnabled: boolean;
  49105. private _linkSheenWithAlbedo;
  49106. /**
  49107. * Defines if the sheen is linked to the sheen color.
  49108. */
  49109. linkSheenWithAlbedo: boolean;
  49110. /**
  49111. * Defines the sheen intensity.
  49112. */
  49113. intensity: number;
  49114. /**
  49115. * Defines the sheen color.
  49116. */
  49117. color: Color3;
  49118. private _texture;
  49119. /**
  49120. * Stores the sheen tint values in a texture.
  49121. * rgb is tint
  49122. * a is a intensity
  49123. */
  49124. texture: Nullable<BaseTexture>;
  49125. /** @hidden */
  49126. private _internalMarkAllSubMeshesAsTexturesDirty;
  49127. /** @hidden */
  49128. _markAllSubMeshesAsTexturesDirty(): void;
  49129. /**
  49130. * Instantiate a new istance of clear coat configuration.
  49131. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49132. */
  49133. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49134. /**
  49135. * Specifies that the submesh is ready to be used.
  49136. * @param defines the list of "defines" to update.
  49137. * @param scene defines the scene the material belongs to.
  49138. * @returns - boolean indicating that the submesh is ready or not.
  49139. */
  49140. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49141. /**
  49142. * Checks to see if a texture is used in the material.
  49143. * @param defines the list of "defines" to update.
  49144. * @param scene defines the scene the material belongs to.
  49145. */
  49146. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49147. /**
  49148. * Binds the material data.
  49149. * @param uniformBuffer defines the Uniform buffer to fill in.
  49150. * @param scene defines the scene the material belongs to.
  49151. * @param isFrozen defines wether the material is frozen or not.
  49152. */
  49153. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49154. /**
  49155. * Checks to see if a texture is used in the material.
  49156. * @param texture - Base texture to use.
  49157. * @returns - Boolean specifying if a texture is used in the material.
  49158. */
  49159. hasTexture(texture: BaseTexture): boolean;
  49160. /**
  49161. * Returns an array of the actively used textures.
  49162. * @param activeTextures Array of BaseTextures
  49163. */
  49164. getActiveTextures(activeTextures: BaseTexture[]): void;
  49165. /**
  49166. * Returns the animatable textures.
  49167. * @param animatables Array of animatable textures.
  49168. */
  49169. getAnimatables(animatables: IAnimatable[]): void;
  49170. /**
  49171. * Disposes the resources of the material.
  49172. * @param forceDisposeTextures - Forces the disposal of all textures.
  49173. */
  49174. dispose(forceDisposeTextures?: boolean): void;
  49175. /**
  49176. * Get the current class name of the texture useful for serialization or dynamic coding.
  49177. * @returns "PBRSheenConfiguration"
  49178. */
  49179. getClassName(): string;
  49180. /**
  49181. * Add fallbacks to the effect fallbacks list.
  49182. * @param defines defines the Base texture to use.
  49183. * @param fallbacks defines the current fallback list.
  49184. * @param currentRank defines the current fallback rank.
  49185. * @returns the new fallback rank.
  49186. */
  49187. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49188. /**
  49189. * Add the required uniforms to the current list.
  49190. * @param uniforms defines the current uniform list.
  49191. */
  49192. static AddUniforms(uniforms: string[]): void;
  49193. /**
  49194. * Add the required uniforms to the current buffer.
  49195. * @param uniformBuffer defines the current uniform buffer.
  49196. */
  49197. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49198. /**
  49199. * Add the required samplers to the current list.
  49200. * @param samplers defines the current sampler list.
  49201. */
  49202. static AddSamplers(samplers: string[]): void;
  49203. /**
  49204. * Makes a duplicate of the current configuration into another one.
  49205. * @param sheenConfiguration define the config where to copy the info
  49206. */
  49207. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49208. /**
  49209. * Serializes this BRDF configuration.
  49210. * @returns - An object with the serialized config.
  49211. */
  49212. serialize(): any;
  49213. /**
  49214. * Parses a anisotropy Configuration from a serialized object.
  49215. * @param source - Serialized object.
  49216. * @param scene Defines the scene we are parsing for
  49217. * @param rootUrl Defines the rootUrl to load from
  49218. */
  49219. parse(source: any, scene: Scene, rootUrl: string): void;
  49220. }
  49221. }
  49222. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49223. import { Nullable } from "babylonjs/types";
  49224. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49225. import { Color3 } from "babylonjs/Maths/math.color";
  49226. import { SmartArray } from "babylonjs/Misc/smartArray";
  49227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49228. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49229. import { Effect } from "babylonjs/Materials/effect";
  49230. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49231. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49232. import { Engine } from "babylonjs/Engines/engine";
  49233. import { Scene } from "babylonjs/scene";
  49234. /**
  49235. * @hidden
  49236. */
  49237. export interface IMaterialSubSurfaceDefines {
  49238. SUBSURFACE: boolean;
  49239. SS_REFRACTION: boolean;
  49240. SS_TRANSLUCENCY: boolean;
  49241. SS_SCATERRING: boolean;
  49242. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49243. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49244. SS_REFRACTIONMAP_3D: boolean;
  49245. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49246. SS_LODINREFRACTIONALPHA: boolean;
  49247. SS_GAMMAREFRACTION: boolean;
  49248. SS_RGBDREFRACTION: boolean;
  49249. SS_LINEARSPECULARREFRACTION: boolean;
  49250. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49251. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49252. /** @hidden */
  49253. _areTexturesDirty: boolean;
  49254. }
  49255. /**
  49256. * Define the code related to the sub surface parameters of the pbr material.
  49257. */
  49258. export class PBRSubSurfaceConfiguration {
  49259. private _isRefractionEnabled;
  49260. /**
  49261. * Defines if the refraction is enabled in the material.
  49262. */
  49263. isRefractionEnabled: boolean;
  49264. private _isTranslucencyEnabled;
  49265. /**
  49266. * Defines if the translucency is enabled in the material.
  49267. */
  49268. isTranslucencyEnabled: boolean;
  49269. private _isScatteringEnabled;
  49270. /**
  49271. * Defines the refraction intensity of the material.
  49272. * The refraction when enabled replaces the Diffuse part of the material.
  49273. * The intensity helps transitionning between diffuse and refraction.
  49274. */
  49275. refractionIntensity: number;
  49276. /**
  49277. * Defines the translucency intensity of the material.
  49278. * When translucency has been enabled, this defines how much of the "translucency"
  49279. * is addded to the diffuse part of the material.
  49280. */
  49281. translucencyIntensity: number;
  49282. /**
  49283. * Defines the scattering intensity of the material.
  49284. * When scattering has been enabled, this defines how much of the "scattered light"
  49285. * is addded to the diffuse part of the material.
  49286. */
  49287. scatteringIntensity: number;
  49288. private _thicknessTexture;
  49289. /**
  49290. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49291. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49292. * 0 would mean minimumThickness
  49293. * 1 would mean maximumThickness
  49294. * The other channels might be use as a mask to vary the different effects intensity.
  49295. */
  49296. thicknessTexture: Nullable<BaseTexture>;
  49297. private _refractionTexture;
  49298. /**
  49299. * Defines the texture to use for refraction.
  49300. */
  49301. refractionTexture: Nullable<BaseTexture>;
  49302. private _indexOfRefraction;
  49303. /**
  49304. * Defines the index of refraction used in the material.
  49305. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49306. */
  49307. indexOfRefraction: number;
  49308. private _invertRefractionY;
  49309. /**
  49310. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49311. */
  49312. invertRefractionY: boolean;
  49313. private _linkRefractionWithTransparency;
  49314. /**
  49315. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49316. * Materials half opaque for instance using refraction could benefit from this control.
  49317. */
  49318. linkRefractionWithTransparency: boolean;
  49319. /**
  49320. * Defines the minimum thickness stored in the thickness map.
  49321. * If no thickness map is defined, this value will be used to simulate thickness.
  49322. */
  49323. minimumThickness: number;
  49324. /**
  49325. * Defines the maximum thickness stored in the thickness map.
  49326. */
  49327. maximumThickness: number;
  49328. /**
  49329. * Defines the volume tint of the material.
  49330. * This is used for both translucency and scattering.
  49331. */
  49332. tintColor: Color3;
  49333. /**
  49334. * Defines the distance at which the tint color should be found in the media.
  49335. * This is used for refraction only.
  49336. */
  49337. tintColorAtDistance: number;
  49338. /**
  49339. * Defines how far each channel transmit through the media.
  49340. * It is defined as a color to simplify it selection.
  49341. */
  49342. diffusionDistance: Color3;
  49343. private _useMaskFromThicknessTexture;
  49344. /**
  49345. * Stores the intensity of the different subsurface effects in the thickness texture.
  49346. * * the green channel is the translucency intensity.
  49347. * * the blue channel is the scattering intensity.
  49348. * * the alpha channel is the refraction intensity.
  49349. */
  49350. useMaskFromThicknessTexture: boolean;
  49351. /** @hidden */
  49352. private _internalMarkAllSubMeshesAsTexturesDirty;
  49353. /** @hidden */
  49354. _markAllSubMeshesAsTexturesDirty(): void;
  49355. /**
  49356. * Instantiate a new istance of sub surface configuration.
  49357. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49358. */
  49359. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49360. /**
  49361. * Gets wehter the submesh is ready to be used or not.
  49362. * @param defines the list of "defines" to update.
  49363. * @param scene defines the scene the material belongs to.
  49364. * @returns - boolean indicating that the submesh is ready or not.
  49365. */
  49366. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49367. /**
  49368. * Checks to see if a texture is used in the material.
  49369. * @param defines the list of "defines" to update.
  49370. * @param scene defines the scene to the material belongs to.
  49371. */
  49372. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49373. /**
  49374. * Binds the material data.
  49375. * @param uniformBuffer defines the Uniform buffer to fill in.
  49376. * @param scene defines the scene the material belongs to.
  49377. * @param engine defines the engine the material belongs to.
  49378. * @param isFrozen defines wether the material is frozen or not.
  49379. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49380. */
  49381. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49382. /**
  49383. * Unbinds the material from the mesh.
  49384. * @param activeEffect defines the effect that should be unbound from.
  49385. * @returns true if unbound, otherwise false
  49386. */
  49387. unbind(activeEffect: Effect): boolean;
  49388. /**
  49389. * Returns the texture used for refraction or null if none is used.
  49390. * @param scene defines the scene the material belongs to.
  49391. * @returns - Refraction texture if present. If no refraction texture and refraction
  49392. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49393. */
  49394. private _getRefractionTexture;
  49395. /**
  49396. * Returns true if alpha blending should be disabled.
  49397. */
  49398. readonly disableAlphaBlending: boolean;
  49399. /**
  49400. * Fills the list of render target textures.
  49401. * @param renderTargets the list of render targets to update
  49402. */
  49403. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49404. /**
  49405. * Checks to see if a texture is used in the material.
  49406. * @param texture - Base texture to use.
  49407. * @returns - Boolean specifying if a texture is used in the material.
  49408. */
  49409. hasTexture(texture: BaseTexture): boolean;
  49410. /**
  49411. * Gets a boolean indicating that current material needs to register RTT
  49412. * @returns true if this uses a render target otherwise false.
  49413. */
  49414. hasRenderTargetTextures(): boolean;
  49415. /**
  49416. * Returns an array of the actively used textures.
  49417. * @param activeTextures Array of BaseTextures
  49418. */
  49419. getActiveTextures(activeTextures: BaseTexture[]): void;
  49420. /**
  49421. * Returns the animatable textures.
  49422. * @param animatables Array of animatable textures.
  49423. */
  49424. getAnimatables(animatables: IAnimatable[]): void;
  49425. /**
  49426. * Disposes the resources of the material.
  49427. * @param forceDisposeTextures - Forces the disposal of all textures.
  49428. */
  49429. dispose(forceDisposeTextures?: boolean): void;
  49430. /**
  49431. * Get the current class name of the texture useful for serialization or dynamic coding.
  49432. * @returns "PBRSubSurfaceConfiguration"
  49433. */
  49434. getClassName(): string;
  49435. /**
  49436. * Add fallbacks to the effect fallbacks list.
  49437. * @param defines defines the Base texture to use.
  49438. * @param fallbacks defines the current fallback list.
  49439. * @param currentRank defines the current fallback rank.
  49440. * @returns the new fallback rank.
  49441. */
  49442. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49443. /**
  49444. * Add the required uniforms to the current list.
  49445. * @param uniforms defines the current uniform list.
  49446. */
  49447. static AddUniforms(uniforms: string[]): void;
  49448. /**
  49449. * Add the required samplers to the current list.
  49450. * @param samplers defines the current sampler list.
  49451. */
  49452. static AddSamplers(samplers: string[]): void;
  49453. /**
  49454. * Add the required uniforms to the current buffer.
  49455. * @param uniformBuffer defines the current uniform buffer.
  49456. */
  49457. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49458. /**
  49459. * Makes a duplicate of the current configuration into another one.
  49460. * @param configuration define the config where to copy the info
  49461. */
  49462. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49463. /**
  49464. * Serializes this Sub Surface configuration.
  49465. * @returns - An object with the serialized config.
  49466. */
  49467. serialize(): any;
  49468. /**
  49469. * Parses a anisotropy Configuration from a serialized object.
  49470. * @param source - Serialized object.
  49471. * @param scene Defines the scene we are parsing for
  49472. * @param rootUrl Defines the rootUrl to load from
  49473. */
  49474. parse(source: any, scene: Scene, rootUrl: string): void;
  49475. }
  49476. }
  49477. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49478. /** @hidden */
  49479. export var pbrFragmentDeclaration: {
  49480. name: string;
  49481. shader: string;
  49482. };
  49483. }
  49484. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49485. /** @hidden */
  49486. export var pbrUboDeclaration: {
  49487. name: string;
  49488. shader: string;
  49489. };
  49490. }
  49491. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49492. /** @hidden */
  49493. export var pbrFragmentExtraDeclaration: {
  49494. name: string;
  49495. shader: string;
  49496. };
  49497. }
  49498. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49499. /** @hidden */
  49500. export var pbrFragmentSamplersDeclaration: {
  49501. name: string;
  49502. shader: string;
  49503. };
  49504. }
  49505. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49506. /** @hidden */
  49507. export var pbrHelperFunctions: {
  49508. name: string;
  49509. shader: string;
  49510. };
  49511. }
  49512. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49513. /** @hidden */
  49514. export var harmonicsFunctions: {
  49515. name: string;
  49516. shader: string;
  49517. };
  49518. }
  49519. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49520. /** @hidden */
  49521. export var pbrDirectLightingSetupFunctions: {
  49522. name: string;
  49523. shader: string;
  49524. };
  49525. }
  49526. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49527. /** @hidden */
  49528. export var pbrDirectLightingFalloffFunctions: {
  49529. name: string;
  49530. shader: string;
  49531. };
  49532. }
  49533. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49534. /** @hidden */
  49535. export var pbrBRDFFunctions: {
  49536. name: string;
  49537. shader: string;
  49538. };
  49539. }
  49540. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49541. /** @hidden */
  49542. export var pbrDirectLightingFunctions: {
  49543. name: string;
  49544. shader: string;
  49545. };
  49546. }
  49547. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49548. /** @hidden */
  49549. export var pbrIBLFunctions: {
  49550. name: string;
  49551. shader: string;
  49552. };
  49553. }
  49554. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49555. /** @hidden */
  49556. export var pbrDebug: {
  49557. name: string;
  49558. shader: string;
  49559. };
  49560. }
  49561. declare module "babylonjs/Shaders/pbr.fragment" {
  49562. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49563. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49564. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49565. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49566. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49567. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49568. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49569. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49570. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49571. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49572. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49573. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49574. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49575. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49576. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49577. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49578. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49579. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49580. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49581. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49582. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49583. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49584. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49585. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49586. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49587. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49588. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49589. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49590. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49591. /** @hidden */
  49592. export var pbrPixelShader: {
  49593. name: string;
  49594. shader: string;
  49595. };
  49596. }
  49597. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49598. /** @hidden */
  49599. export var pbrVertexDeclaration: {
  49600. name: string;
  49601. shader: string;
  49602. };
  49603. }
  49604. declare module "babylonjs/Shaders/pbr.vertex" {
  49605. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49606. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49607. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49608. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49609. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49610. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49611. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49612. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49613. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49614. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49615. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49616. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49617. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49618. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49619. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49620. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49621. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49622. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49623. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49624. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49625. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49626. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49627. /** @hidden */
  49628. export var pbrVertexShader: {
  49629. name: string;
  49630. shader: string;
  49631. };
  49632. }
  49633. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49634. import { Nullable } from "babylonjs/types";
  49635. import { Scene } from "babylonjs/scene";
  49636. import { Matrix } from "babylonjs/Maths/math.vector";
  49637. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49639. import { Mesh } from "babylonjs/Meshes/mesh";
  49640. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49641. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49642. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49643. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49644. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49645. import { Color3 } from "babylonjs/Maths/math.color";
  49646. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49647. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  49648. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49649. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49650. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49651. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49652. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49653. import "babylonjs/Shaders/pbr.fragment";
  49654. import "babylonjs/Shaders/pbr.vertex";
  49655. /**
  49656. * Manages the defines for the PBR Material.
  49657. * @hidden
  49658. */
  49659. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49660. PBR: boolean;
  49661. MAINUV1: boolean;
  49662. MAINUV2: boolean;
  49663. UV1: boolean;
  49664. UV2: boolean;
  49665. ALBEDO: boolean;
  49666. ALBEDODIRECTUV: number;
  49667. VERTEXCOLOR: boolean;
  49668. AMBIENT: boolean;
  49669. AMBIENTDIRECTUV: number;
  49670. AMBIENTINGRAYSCALE: boolean;
  49671. OPACITY: boolean;
  49672. VERTEXALPHA: boolean;
  49673. OPACITYDIRECTUV: number;
  49674. OPACITYRGB: boolean;
  49675. ALPHATEST: boolean;
  49676. DEPTHPREPASS: boolean;
  49677. ALPHABLEND: boolean;
  49678. ALPHAFROMALBEDO: boolean;
  49679. ALPHATESTVALUE: string;
  49680. SPECULAROVERALPHA: boolean;
  49681. RADIANCEOVERALPHA: boolean;
  49682. ALPHAFRESNEL: boolean;
  49683. LINEARALPHAFRESNEL: boolean;
  49684. PREMULTIPLYALPHA: boolean;
  49685. EMISSIVE: boolean;
  49686. EMISSIVEDIRECTUV: number;
  49687. REFLECTIVITY: boolean;
  49688. REFLECTIVITYDIRECTUV: number;
  49689. SPECULARTERM: boolean;
  49690. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49691. MICROSURFACEAUTOMATIC: boolean;
  49692. LODBASEDMICROSFURACE: boolean;
  49693. MICROSURFACEMAP: boolean;
  49694. MICROSURFACEMAPDIRECTUV: number;
  49695. METALLICWORKFLOW: boolean;
  49696. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49697. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49698. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49699. AOSTOREINMETALMAPRED: boolean;
  49700. ENVIRONMENTBRDF: boolean;
  49701. ENVIRONMENTBRDF_RGBD: boolean;
  49702. NORMAL: boolean;
  49703. TANGENT: boolean;
  49704. BUMP: boolean;
  49705. BUMPDIRECTUV: number;
  49706. OBJECTSPACE_NORMALMAP: boolean;
  49707. PARALLAX: boolean;
  49708. PARALLAXOCCLUSION: boolean;
  49709. NORMALXYSCALE: boolean;
  49710. LIGHTMAP: boolean;
  49711. LIGHTMAPDIRECTUV: number;
  49712. USELIGHTMAPASSHADOWMAP: boolean;
  49713. GAMMALIGHTMAP: boolean;
  49714. RGBDLIGHTMAP: boolean;
  49715. REFLECTION: boolean;
  49716. REFLECTIONMAP_3D: boolean;
  49717. REFLECTIONMAP_SPHERICAL: boolean;
  49718. REFLECTIONMAP_PLANAR: boolean;
  49719. REFLECTIONMAP_CUBIC: boolean;
  49720. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49721. REFLECTIONMAP_PROJECTION: boolean;
  49722. REFLECTIONMAP_SKYBOX: boolean;
  49723. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49724. REFLECTIONMAP_EXPLICIT: boolean;
  49725. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49726. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49727. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49728. INVERTCUBICMAP: boolean;
  49729. USESPHERICALFROMREFLECTIONMAP: boolean;
  49730. USEIRRADIANCEMAP: boolean;
  49731. SPHERICAL_HARMONICS: boolean;
  49732. USESPHERICALINVERTEX: boolean;
  49733. REFLECTIONMAP_OPPOSITEZ: boolean;
  49734. LODINREFLECTIONALPHA: boolean;
  49735. GAMMAREFLECTION: boolean;
  49736. RGBDREFLECTION: boolean;
  49737. LINEARSPECULARREFLECTION: boolean;
  49738. RADIANCEOCCLUSION: boolean;
  49739. HORIZONOCCLUSION: boolean;
  49740. INSTANCES: boolean;
  49741. NUM_BONE_INFLUENCERS: number;
  49742. BonesPerMesh: number;
  49743. BONETEXTURE: boolean;
  49744. NONUNIFORMSCALING: boolean;
  49745. MORPHTARGETS: boolean;
  49746. MORPHTARGETS_NORMAL: boolean;
  49747. MORPHTARGETS_TANGENT: boolean;
  49748. MORPHTARGETS_UV: boolean;
  49749. NUM_MORPH_INFLUENCERS: number;
  49750. IMAGEPROCESSING: boolean;
  49751. VIGNETTE: boolean;
  49752. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49753. VIGNETTEBLENDMODEOPAQUE: boolean;
  49754. TONEMAPPING: boolean;
  49755. TONEMAPPING_ACES: boolean;
  49756. CONTRAST: boolean;
  49757. COLORCURVES: boolean;
  49758. COLORGRADING: boolean;
  49759. COLORGRADING3D: boolean;
  49760. SAMPLER3DGREENDEPTH: boolean;
  49761. SAMPLER3DBGRMAP: boolean;
  49762. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49763. EXPOSURE: boolean;
  49764. MULTIVIEW: boolean;
  49765. USEPHYSICALLIGHTFALLOFF: boolean;
  49766. USEGLTFLIGHTFALLOFF: boolean;
  49767. TWOSIDEDLIGHTING: boolean;
  49768. SHADOWFLOAT: boolean;
  49769. CLIPPLANE: boolean;
  49770. CLIPPLANE2: boolean;
  49771. CLIPPLANE3: boolean;
  49772. CLIPPLANE4: boolean;
  49773. POINTSIZE: boolean;
  49774. FOG: boolean;
  49775. LOGARITHMICDEPTH: boolean;
  49776. FORCENORMALFORWARD: boolean;
  49777. SPECULARAA: boolean;
  49778. CLEARCOAT: boolean;
  49779. CLEARCOAT_DEFAULTIOR: boolean;
  49780. CLEARCOAT_TEXTURE: boolean;
  49781. CLEARCOAT_TEXTUREDIRECTUV: number;
  49782. CLEARCOAT_BUMP: boolean;
  49783. CLEARCOAT_BUMPDIRECTUV: number;
  49784. CLEARCOAT_TINT: boolean;
  49785. CLEARCOAT_TINT_TEXTURE: boolean;
  49786. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49787. ANISOTROPIC: boolean;
  49788. ANISOTROPIC_TEXTURE: boolean;
  49789. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49790. BRDF_V_HEIGHT_CORRELATED: boolean;
  49791. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49792. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49793. SHEEN: boolean;
  49794. SHEEN_TEXTURE: boolean;
  49795. SHEEN_TEXTUREDIRECTUV: number;
  49796. SHEEN_LINKWITHALBEDO: boolean;
  49797. SUBSURFACE: boolean;
  49798. SS_REFRACTION: boolean;
  49799. SS_TRANSLUCENCY: boolean;
  49800. SS_SCATERRING: boolean;
  49801. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49802. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49803. SS_REFRACTIONMAP_3D: boolean;
  49804. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49805. SS_LODINREFRACTIONALPHA: boolean;
  49806. SS_GAMMAREFRACTION: boolean;
  49807. SS_RGBDREFRACTION: boolean;
  49808. SS_LINEARSPECULARREFRACTION: boolean;
  49809. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49810. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49811. UNLIT: boolean;
  49812. DEBUGMODE: number;
  49813. /**
  49814. * Initializes the PBR Material defines.
  49815. */
  49816. constructor();
  49817. /**
  49818. * Resets the PBR Material defines.
  49819. */
  49820. reset(): void;
  49821. }
  49822. /**
  49823. * The Physically based material base class of BJS.
  49824. *
  49825. * This offers the main features of a standard PBR material.
  49826. * For more information, please refer to the documentation :
  49827. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49828. */
  49829. export abstract class PBRBaseMaterial extends PushMaterial {
  49830. /**
  49831. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49832. */
  49833. static readonly PBRMATERIAL_OPAQUE: number;
  49834. /**
  49835. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49836. */
  49837. static readonly PBRMATERIAL_ALPHATEST: number;
  49838. /**
  49839. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49840. */
  49841. static readonly PBRMATERIAL_ALPHABLEND: number;
  49842. /**
  49843. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49844. * They are also discarded below the alpha cutoff threshold to improve performances.
  49845. */
  49846. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49847. /**
  49848. * Defines the default value of how much AO map is occluding the analytical lights
  49849. * (point spot...).
  49850. */
  49851. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49852. /**
  49853. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49854. */
  49855. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49856. /**
  49857. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49858. * to enhance interoperability with other engines.
  49859. */
  49860. static readonly LIGHTFALLOFF_GLTF: number;
  49861. /**
  49862. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49863. * to enhance interoperability with other materials.
  49864. */
  49865. static readonly LIGHTFALLOFF_STANDARD: number;
  49866. /**
  49867. * Intensity of the direct lights e.g. the four lights available in your scene.
  49868. * This impacts both the direct diffuse and specular highlights.
  49869. */
  49870. protected _directIntensity: number;
  49871. /**
  49872. * Intensity of the emissive part of the material.
  49873. * This helps controlling the emissive effect without modifying the emissive color.
  49874. */
  49875. protected _emissiveIntensity: number;
  49876. /**
  49877. * Intensity of the environment e.g. how much the environment will light the object
  49878. * either through harmonics for rough material or through the refelction for shiny ones.
  49879. */
  49880. protected _environmentIntensity: number;
  49881. /**
  49882. * This is a special control allowing the reduction of the specular highlights coming from the
  49883. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49884. */
  49885. protected _specularIntensity: number;
  49886. /**
  49887. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49888. */
  49889. private _lightingInfos;
  49890. /**
  49891. * Debug Control allowing disabling the bump map on this material.
  49892. */
  49893. protected _disableBumpMap: boolean;
  49894. /**
  49895. * AKA Diffuse Texture in standard nomenclature.
  49896. */
  49897. protected _albedoTexture: Nullable<BaseTexture>;
  49898. /**
  49899. * AKA Occlusion Texture in other nomenclature.
  49900. */
  49901. protected _ambientTexture: Nullable<BaseTexture>;
  49902. /**
  49903. * AKA Occlusion Texture Intensity in other nomenclature.
  49904. */
  49905. protected _ambientTextureStrength: number;
  49906. /**
  49907. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49908. * 1 means it completely occludes it
  49909. * 0 mean it has no impact
  49910. */
  49911. protected _ambientTextureImpactOnAnalyticalLights: number;
  49912. /**
  49913. * Stores the alpha values in a texture.
  49914. */
  49915. protected _opacityTexture: Nullable<BaseTexture>;
  49916. /**
  49917. * Stores the reflection values in a texture.
  49918. */
  49919. protected _reflectionTexture: Nullable<BaseTexture>;
  49920. /**
  49921. * Stores the emissive values in a texture.
  49922. */
  49923. protected _emissiveTexture: Nullable<BaseTexture>;
  49924. /**
  49925. * AKA Specular texture in other nomenclature.
  49926. */
  49927. protected _reflectivityTexture: Nullable<BaseTexture>;
  49928. /**
  49929. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49930. */
  49931. protected _metallicTexture: Nullable<BaseTexture>;
  49932. /**
  49933. * Specifies the metallic scalar of the metallic/roughness workflow.
  49934. * Can also be used to scale the metalness values of the metallic texture.
  49935. */
  49936. protected _metallic: Nullable<number>;
  49937. /**
  49938. * Specifies the roughness scalar of the metallic/roughness workflow.
  49939. * Can also be used to scale the roughness values of the metallic texture.
  49940. */
  49941. protected _roughness: Nullable<number>;
  49942. /**
  49943. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49944. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49945. */
  49946. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49947. /**
  49948. * Stores surface normal data used to displace a mesh in a texture.
  49949. */
  49950. protected _bumpTexture: Nullable<BaseTexture>;
  49951. /**
  49952. * Stores the pre-calculated light information of a mesh in a texture.
  49953. */
  49954. protected _lightmapTexture: Nullable<BaseTexture>;
  49955. /**
  49956. * The color of a material in ambient lighting.
  49957. */
  49958. protected _ambientColor: Color3;
  49959. /**
  49960. * AKA Diffuse Color in other nomenclature.
  49961. */
  49962. protected _albedoColor: Color3;
  49963. /**
  49964. * AKA Specular Color in other nomenclature.
  49965. */
  49966. protected _reflectivityColor: Color3;
  49967. /**
  49968. * The color applied when light is reflected from a material.
  49969. */
  49970. protected _reflectionColor: Color3;
  49971. /**
  49972. * The color applied when light is emitted from a material.
  49973. */
  49974. protected _emissiveColor: Color3;
  49975. /**
  49976. * AKA Glossiness in other nomenclature.
  49977. */
  49978. protected _microSurface: number;
  49979. /**
  49980. * Specifies that the material will use the light map as a show map.
  49981. */
  49982. protected _useLightmapAsShadowmap: boolean;
  49983. /**
  49984. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49985. * makes the reflect vector face the model (under horizon).
  49986. */
  49987. protected _useHorizonOcclusion: boolean;
  49988. /**
  49989. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49990. * too much the area relying on ambient texture to define their ambient occlusion.
  49991. */
  49992. protected _useRadianceOcclusion: boolean;
  49993. /**
  49994. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49995. */
  49996. protected _useAlphaFromAlbedoTexture: boolean;
  49997. /**
  49998. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49999. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50000. */
  50001. protected _useSpecularOverAlpha: boolean;
  50002. /**
  50003. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50004. */
  50005. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50006. /**
  50007. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50008. */
  50009. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50010. /**
  50011. * Specifies if the metallic texture contains the roughness information in its green channel.
  50012. */
  50013. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50014. /**
  50015. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50016. */
  50017. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50018. /**
  50019. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50020. */
  50021. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50022. /**
  50023. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50024. */
  50025. protected _useAmbientInGrayScale: boolean;
  50026. /**
  50027. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50028. * The material will try to infer what glossiness each pixel should be.
  50029. */
  50030. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50031. /**
  50032. * Defines the falloff type used in this material.
  50033. * It by default is Physical.
  50034. */
  50035. protected _lightFalloff: number;
  50036. /**
  50037. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50038. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50039. */
  50040. protected _useRadianceOverAlpha: boolean;
  50041. /**
  50042. * Allows using an object space normal map (instead of tangent space).
  50043. */
  50044. protected _useObjectSpaceNormalMap: boolean;
  50045. /**
  50046. * Allows using the bump map in parallax mode.
  50047. */
  50048. protected _useParallax: boolean;
  50049. /**
  50050. * Allows using the bump map in parallax occlusion mode.
  50051. */
  50052. protected _useParallaxOcclusion: boolean;
  50053. /**
  50054. * Controls the scale bias of the parallax mode.
  50055. */
  50056. protected _parallaxScaleBias: number;
  50057. /**
  50058. * If sets to true, disables all the lights affecting the material.
  50059. */
  50060. protected _disableLighting: boolean;
  50061. /**
  50062. * Number of Simultaneous lights allowed on the material.
  50063. */
  50064. protected _maxSimultaneousLights: number;
  50065. /**
  50066. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50067. */
  50068. protected _invertNormalMapX: boolean;
  50069. /**
  50070. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50071. */
  50072. protected _invertNormalMapY: boolean;
  50073. /**
  50074. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50075. */
  50076. protected _twoSidedLighting: boolean;
  50077. /**
  50078. * Defines the alpha limits in alpha test mode.
  50079. */
  50080. protected _alphaCutOff: number;
  50081. /**
  50082. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50083. */
  50084. protected _forceAlphaTest: boolean;
  50085. /**
  50086. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50087. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50088. */
  50089. protected _useAlphaFresnel: boolean;
  50090. /**
  50091. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50092. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50093. */
  50094. protected _useLinearAlphaFresnel: boolean;
  50095. /**
  50096. * The transparency mode of the material.
  50097. */
  50098. protected _transparencyMode: Nullable<number>;
  50099. /**
  50100. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50101. * from cos thetav and roughness:
  50102. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50103. */
  50104. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50105. /**
  50106. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50107. */
  50108. protected _forceIrradianceInFragment: boolean;
  50109. /**
  50110. * Force normal to face away from face.
  50111. */
  50112. protected _forceNormalForward: boolean;
  50113. /**
  50114. * Enables specular anti aliasing in the PBR shader.
  50115. * It will both interacts on the Geometry for analytical and IBL lighting.
  50116. * It also prefilter the roughness map based on the bump values.
  50117. */
  50118. protected _enableSpecularAntiAliasing: boolean;
  50119. /**
  50120. * Default configuration related to image processing available in the PBR Material.
  50121. */
  50122. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50123. /**
  50124. * Keep track of the image processing observer to allow dispose and replace.
  50125. */
  50126. private _imageProcessingObserver;
  50127. /**
  50128. * Attaches a new image processing configuration to the PBR Material.
  50129. * @param configuration
  50130. */
  50131. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50132. /**
  50133. * Stores the available render targets.
  50134. */
  50135. private _renderTargets;
  50136. /**
  50137. * Sets the global ambient color for the material used in lighting calculations.
  50138. */
  50139. private _globalAmbientColor;
  50140. /**
  50141. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50142. */
  50143. private _useLogarithmicDepth;
  50144. /**
  50145. * If set to true, no lighting calculations will be applied.
  50146. */
  50147. private _unlit;
  50148. private _debugMode;
  50149. /**
  50150. * @hidden
  50151. * This is reserved for the inspector.
  50152. * Defines the material debug mode.
  50153. * It helps seeing only some components of the material while troubleshooting.
  50154. */
  50155. debugMode: number;
  50156. /**
  50157. * @hidden
  50158. * This is reserved for the inspector.
  50159. * Specify from where on screen the debug mode should start.
  50160. * The value goes from -1 (full screen) to 1 (not visible)
  50161. * It helps with side by side comparison against the final render
  50162. * This defaults to -1
  50163. */
  50164. private debugLimit;
  50165. /**
  50166. * @hidden
  50167. * This is reserved for the inspector.
  50168. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50169. * You can use the factor to better multiply the final value.
  50170. */
  50171. private debugFactor;
  50172. /**
  50173. * Defines the clear coat layer parameters for the material.
  50174. */
  50175. readonly clearCoat: PBRClearCoatConfiguration;
  50176. /**
  50177. * Defines the anisotropic parameters for the material.
  50178. */
  50179. readonly anisotropy: PBRAnisotropicConfiguration;
  50180. /**
  50181. * Defines the BRDF parameters for the material.
  50182. */
  50183. readonly brdf: PBRBRDFConfiguration;
  50184. /**
  50185. * Defines the Sheen parameters for the material.
  50186. */
  50187. readonly sheen: PBRSheenConfiguration;
  50188. /**
  50189. * Defines the SubSurface parameters for the material.
  50190. */
  50191. readonly subSurface: PBRSubSurfaceConfiguration;
  50192. /**
  50193. * Custom callback helping to override the default shader used in the material.
  50194. */
  50195. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50196. protected _rebuildInParallel: boolean;
  50197. /**
  50198. * Instantiates a new PBRMaterial instance.
  50199. *
  50200. * @param name The material name
  50201. * @param scene The scene the material will be use in.
  50202. */
  50203. constructor(name: string, scene: Scene);
  50204. /**
  50205. * Gets a boolean indicating that current material needs to register RTT
  50206. */
  50207. readonly hasRenderTargetTextures: boolean;
  50208. /**
  50209. * Gets the name of the material class.
  50210. */
  50211. getClassName(): string;
  50212. /**
  50213. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50214. */
  50215. /**
  50216. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50217. */
  50218. useLogarithmicDepth: boolean;
  50219. /**
  50220. * Gets the current transparency mode.
  50221. */
  50222. /**
  50223. * Sets the transparency mode of the material.
  50224. *
  50225. * | Value | Type | Description |
  50226. * | ----- | ----------------------------------- | ----------- |
  50227. * | 0 | OPAQUE | |
  50228. * | 1 | ALPHATEST | |
  50229. * | 2 | ALPHABLEND | |
  50230. * | 3 | ALPHATESTANDBLEND | |
  50231. *
  50232. */
  50233. transparencyMode: Nullable<number>;
  50234. /**
  50235. * Returns true if alpha blending should be disabled.
  50236. */
  50237. private readonly _disableAlphaBlending;
  50238. /**
  50239. * Specifies whether or not this material should be rendered in alpha blend mode.
  50240. */
  50241. needAlphaBlending(): boolean;
  50242. /**
  50243. * Specifies if the mesh will require alpha blending.
  50244. * @param mesh - BJS mesh.
  50245. */
  50246. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50247. /**
  50248. * Specifies whether or not this material should be rendered in alpha test mode.
  50249. */
  50250. needAlphaTesting(): boolean;
  50251. /**
  50252. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50253. */
  50254. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50255. /**
  50256. * Gets the texture used for the alpha test.
  50257. */
  50258. getAlphaTestTexture(): Nullable<BaseTexture>;
  50259. /**
  50260. * Specifies that the submesh is ready to be used.
  50261. * @param mesh - BJS mesh.
  50262. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50263. * @param useInstances - Specifies that instances should be used.
  50264. * @returns - boolean indicating that the submesh is ready or not.
  50265. */
  50266. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50267. /**
  50268. * Specifies if the material uses metallic roughness workflow.
  50269. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50270. */
  50271. isMetallicWorkflow(): boolean;
  50272. private _prepareEffect;
  50273. private _prepareDefines;
  50274. /**
  50275. * Force shader compilation
  50276. */
  50277. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50278. /**
  50279. * Initializes the uniform buffer layout for the shader.
  50280. */
  50281. buildUniformLayout(): void;
  50282. /**
  50283. * Unbinds the material from the mesh
  50284. */
  50285. unbind(): void;
  50286. /**
  50287. * Binds the submesh data.
  50288. * @param world - The world matrix.
  50289. * @param mesh - The BJS mesh.
  50290. * @param subMesh - A submesh of the BJS mesh.
  50291. */
  50292. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50293. /**
  50294. * Returns the animatable textures.
  50295. * @returns - Array of animatable textures.
  50296. */
  50297. getAnimatables(): IAnimatable[];
  50298. /**
  50299. * Returns the texture used for reflections.
  50300. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50301. */
  50302. private _getReflectionTexture;
  50303. /**
  50304. * Returns an array of the actively used textures.
  50305. * @returns - Array of BaseTextures
  50306. */
  50307. getActiveTextures(): BaseTexture[];
  50308. /**
  50309. * Checks to see if a texture is used in the material.
  50310. * @param texture - Base texture to use.
  50311. * @returns - Boolean specifying if a texture is used in the material.
  50312. */
  50313. hasTexture(texture: BaseTexture): boolean;
  50314. /**
  50315. * Disposes the resources of the material.
  50316. * @param forceDisposeEffect - Forces the disposal of effects.
  50317. * @param forceDisposeTextures - Forces the disposal of all textures.
  50318. */
  50319. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50320. }
  50321. }
  50322. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50323. import { Nullable } from "babylonjs/types";
  50324. import { Scene } from "babylonjs/scene";
  50325. import { Color3 } from "babylonjs/Maths/math.color";
  50326. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50327. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50328. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50329. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50330. /**
  50331. * The Physically based material of BJS.
  50332. *
  50333. * This offers the main features of a standard PBR material.
  50334. * For more information, please refer to the documentation :
  50335. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50336. */
  50337. export class PBRMaterial extends PBRBaseMaterial {
  50338. /**
  50339. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50340. */
  50341. static readonly PBRMATERIAL_OPAQUE: number;
  50342. /**
  50343. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50344. */
  50345. static readonly PBRMATERIAL_ALPHATEST: number;
  50346. /**
  50347. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50348. */
  50349. static readonly PBRMATERIAL_ALPHABLEND: number;
  50350. /**
  50351. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50352. * They are also discarded below the alpha cutoff threshold to improve performances.
  50353. */
  50354. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50355. /**
  50356. * Defines the default value of how much AO map is occluding the analytical lights
  50357. * (point spot...).
  50358. */
  50359. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50360. /**
  50361. * Intensity of the direct lights e.g. the four lights available in your scene.
  50362. * This impacts both the direct diffuse and specular highlights.
  50363. */
  50364. directIntensity: number;
  50365. /**
  50366. * Intensity of the emissive part of the material.
  50367. * This helps controlling the emissive effect without modifying the emissive color.
  50368. */
  50369. emissiveIntensity: number;
  50370. /**
  50371. * Intensity of the environment e.g. how much the environment will light the object
  50372. * either through harmonics for rough material or through the refelction for shiny ones.
  50373. */
  50374. environmentIntensity: number;
  50375. /**
  50376. * This is a special control allowing the reduction of the specular highlights coming from the
  50377. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50378. */
  50379. specularIntensity: number;
  50380. /**
  50381. * Debug Control allowing disabling the bump map on this material.
  50382. */
  50383. disableBumpMap: boolean;
  50384. /**
  50385. * AKA Diffuse Texture in standard nomenclature.
  50386. */
  50387. albedoTexture: BaseTexture;
  50388. /**
  50389. * AKA Occlusion Texture in other nomenclature.
  50390. */
  50391. ambientTexture: BaseTexture;
  50392. /**
  50393. * AKA Occlusion Texture Intensity in other nomenclature.
  50394. */
  50395. ambientTextureStrength: number;
  50396. /**
  50397. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50398. * 1 means it completely occludes it
  50399. * 0 mean it has no impact
  50400. */
  50401. ambientTextureImpactOnAnalyticalLights: number;
  50402. /**
  50403. * Stores the alpha values in a texture.
  50404. */
  50405. opacityTexture: BaseTexture;
  50406. /**
  50407. * Stores the reflection values in a texture.
  50408. */
  50409. reflectionTexture: Nullable<BaseTexture>;
  50410. /**
  50411. * Stores the emissive values in a texture.
  50412. */
  50413. emissiveTexture: BaseTexture;
  50414. /**
  50415. * AKA Specular texture in other nomenclature.
  50416. */
  50417. reflectivityTexture: BaseTexture;
  50418. /**
  50419. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50420. */
  50421. metallicTexture: BaseTexture;
  50422. /**
  50423. * Specifies the metallic scalar of the metallic/roughness workflow.
  50424. * Can also be used to scale the metalness values of the metallic texture.
  50425. */
  50426. metallic: Nullable<number>;
  50427. /**
  50428. * Specifies the roughness scalar of the metallic/roughness workflow.
  50429. * Can also be used to scale the roughness values of the metallic texture.
  50430. */
  50431. roughness: Nullable<number>;
  50432. /**
  50433. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50434. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50435. */
  50436. microSurfaceTexture: BaseTexture;
  50437. /**
  50438. * Stores surface normal data used to displace a mesh in a texture.
  50439. */
  50440. bumpTexture: BaseTexture;
  50441. /**
  50442. * Stores the pre-calculated light information of a mesh in a texture.
  50443. */
  50444. lightmapTexture: BaseTexture;
  50445. /**
  50446. * Stores the refracted light information in a texture.
  50447. */
  50448. refractionTexture: Nullable<BaseTexture>;
  50449. /**
  50450. * The color of a material in ambient lighting.
  50451. */
  50452. ambientColor: Color3;
  50453. /**
  50454. * AKA Diffuse Color in other nomenclature.
  50455. */
  50456. albedoColor: Color3;
  50457. /**
  50458. * AKA Specular Color in other nomenclature.
  50459. */
  50460. reflectivityColor: Color3;
  50461. /**
  50462. * The color reflected from the material.
  50463. */
  50464. reflectionColor: Color3;
  50465. /**
  50466. * The color emitted from the material.
  50467. */
  50468. emissiveColor: Color3;
  50469. /**
  50470. * AKA Glossiness in other nomenclature.
  50471. */
  50472. microSurface: number;
  50473. /**
  50474. * source material index of refraction (IOR)' / 'destination material IOR.
  50475. */
  50476. indexOfRefraction: number;
  50477. /**
  50478. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50479. */
  50480. invertRefractionY: boolean;
  50481. /**
  50482. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50483. * Materials half opaque for instance using refraction could benefit from this control.
  50484. */
  50485. linkRefractionWithTransparency: boolean;
  50486. /**
  50487. * If true, the light map contains occlusion information instead of lighting info.
  50488. */
  50489. useLightmapAsShadowmap: boolean;
  50490. /**
  50491. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50492. */
  50493. useAlphaFromAlbedoTexture: boolean;
  50494. /**
  50495. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50496. */
  50497. forceAlphaTest: boolean;
  50498. /**
  50499. * Defines the alpha limits in alpha test mode.
  50500. */
  50501. alphaCutOff: number;
  50502. /**
  50503. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50504. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50505. */
  50506. useSpecularOverAlpha: boolean;
  50507. /**
  50508. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50509. */
  50510. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50511. /**
  50512. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50513. */
  50514. useRoughnessFromMetallicTextureAlpha: boolean;
  50515. /**
  50516. * Specifies if the metallic texture contains the roughness information in its green channel.
  50517. */
  50518. useRoughnessFromMetallicTextureGreen: boolean;
  50519. /**
  50520. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50521. */
  50522. useMetallnessFromMetallicTextureBlue: boolean;
  50523. /**
  50524. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50525. */
  50526. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50527. /**
  50528. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50529. */
  50530. useAmbientInGrayScale: boolean;
  50531. /**
  50532. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50533. * The material will try to infer what glossiness each pixel should be.
  50534. */
  50535. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50536. /**
  50537. * BJS is using an harcoded light falloff based on a manually sets up range.
  50538. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50539. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50540. */
  50541. /**
  50542. * BJS is using an harcoded light falloff based on a manually sets up range.
  50543. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50544. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50545. */
  50546. usePhysicalLightFalloff: boolean;
  50547. /**
  50548. * In order to support the falloff compatibility with gltf, a special mode has been added
  50549. * to reproduce the gltf light falloff.
  50550. */
  50551. /**
  50552. * In order to support the falloff compatibility with gltf, a special mode has been added
  50553. * to reproduce the gltf light falloff.
  50554. */
  50555. useGLTFLightFalloff: boolean;
  50556. /**
  50557. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50558. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50559. */
  50560. useRadianceOverAlpha: boolean;
  50561. /**
  50562. * Allows using an object space normal map (instead of tangent space).
  50563. */
  50564. useObjectSpaceNormalMap: boolean;
  50565. /**
  50566. * Allows using the bump map in parallax mode.
  50567. */
  50568. useParallax: boolean;
  50569. /**
  50570. * Allows using the bump map in parallax occlusion mode.
  50571. */
  50572. useParallaxOcclusion: boolean;
  50573. /**
  50574. * Controls the scale bias of the parallax mode.
  50575. */
  50576. parallaxScaleBias: number;
  50577. /**
  50578. * If sets to true, disables all the lights affecting the material.
  50579. */
  50580. disableLighting: boolean;
  50581. /**
  50582. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50583. */
  50584. forceIrradianceInFragment: boolean;
  50585. /**
  50586. * Number of Simultaneous lights allowed on the material.
  50587. */
  50588. maxSimultaneousLights: number;
  50589. /**
  50590. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50591. */
  50592. invertNormalMapX: boolean;
  50593. /**
  50594. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50595. */
  50596. invertNormalMapY: boolean;
  50597. /**
  50598. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50599. */
  50600. twoSidedLighting: boolean;
  50601. /**
  50602. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50603. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50604. */
  50605. useAlphaFresnel: boolean;
  50606. /**
  50607. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50608. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50609. */
  50610. useLinearAlphaFresnel: boolean;
  50611. /**
  50612. * Let user defines the brdf lookup texture used for IBL.
  50613. * A default 8bit version is embedded but you could point at :
  50614. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50615. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50616. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50617. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50618. */
  50619. environmentBRDFTexture: Nullable<BaseTexture>;
  50620. /**
  50621. * Force normal to face away from face.
  50622. */
  50623. forceNormalForward: boolean;
  50624. /**
  50625. * Enables specular anti aliasing in the PBR shader.
  50626. * It will both interacts on the Geometry for analytical and IBL lighting.
  50627. * It also prefilter the roughness map based on the bump values.
  50628. */
  50629. enableSpecularAntiAliasing: boolean;
  50630. /**
  50631. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50632. * makes the reflect vector face the model (under horizon).
  50633. */
  50634. useHorizonOcclusion: boolean;
  50635. /**
  50636. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50637. * too much the area relying on ambient texture to define their ambient occlusion.
  50638. */
  50639. useRadianceOcclusion: boolean;
  50640. /**
  50641. * If set to true, no lighting calculations will be applied.
  50642. */
  50643. unlit: boolean;
  50644. /**
  50645. * Gets the image processing configuration used either in this material.
  50646. */
  50647. /**
  50648. * Sets the Default image processing configuration used either in the this material.
  50649. *
  50650. * If sets to null, the scene one is in use.
  50651. */
  50652. imageProcessingConfiguration: ImageProcessingConfiguration;
  50653. /**
  50654. * Gets wether the color curves effect is enabled.
  50655. */
  50656. /**
  50657. * Sets wether the color curves effect is enabled.
  50658. */
  50659. cameraColorCurvesEnabled: boolean;
  50660. /**
  50661. * Gets wether the color grading effect is enabled.
  50662. */
  50663. /**
  50664. * Gets wether the color grading effect is enabled.
  50665. */
  50666. cameraColorGradingEnabled: boolean;
  50667. /**
  50668. * Gets wether tonemapping is enabled or not.
  50669. */
  50670. /**
  50671. * Sets wether tonemapping is enabled or not
  50672. */
  50673. cameraToneMappingEnabled: boolean;
  50674. /**
  50675. * The camera exposure used on this material.
  50676. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50677. * This corresponds to a photographic exposure.
  50678. */
  50679. /**
  50680. * The camera exposure used on this material.
  50681. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50682. * This corresponds to a photographic exposure.
  50683. */
  50684. cameraExposure: number;
  50685. /**
  50686. * Gets The camera contrast used on this material.
  50687. */
  50688. /**
  50689. * Sets The camera contrast used on this material.
  50690. */
  50691. cameraContrast: number;
  50692. /**
  50693. * Gets the Color Grading 2D Lookup Texture.
  50694. */
  50695. /**
  50696. * Sets the Color Grading 2D Lookup Texture.
  50697. */
  50698. cameraColorGradingTexture: Nullable<BaseTexture>;
  50699. /**
  50700. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50701. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50702. * 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;
  50703. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50704. */
  50705. /**
  50706. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50707. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50708. * 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;
  50709. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50710. */
  50711. cameraColorCurves: Nullable<ColorCurves>;
  50712. /**
  50713. * Instantiates a new PBRMaterial instance.
  50714. *
  50715. * @param name The material name
  50716. * @param scene The scene the material will be use in.
  50717. */
  50718. constructor(name: string, scene: Scene);
  50719. /**
  50720. * Returns the name of this material class.
  50721. */
  50722. getClassName(): string;
  50723. /**
  50724. * Makes a duplicate of the current material.
  50725. * @param name - name to use for the new material.
  50726. */
  50727. clone(name: string): PBRMaterial;
  50728. /**
  50729. * Serializes this PBR Material.
  50730. * @returns - An object with the serialized material.
  50731. */
  50732. serialize(): any;
  50733. /**
  50734. * Parses a PBR Material from a serialized object.
  50735. * @param source - Serialized object.
  50736. * @param scene - BJS scene instance.
  50737. * @param rootUrl - url for the scene object
  50738. * @returns - PBRMaterial
  50739. */
  50740. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50741. }
  50742. }
  50743. declare module "babylonjs/Misc/dds" {
  50744. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50745. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50746. import { Nullable } from "babylonjs/types";
  50747. import { Scene } from "babylonjs/scene";
  50748. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50749. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50750. /**
  50751. * Direct draw surface info
  50752. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50753. */
  50754. export interface DDSInfo {
  50755. /**
  50756. * Width of the texture
  50757. */
  50758. width: number;
  50759. /**
  50760. * Width of the texture
  50761. */
  50762. height: number;
  50763. /**
  50764. * Number of Mipmaps for the texture
  50765. * @see https://en.wikipedia.org/wiki/Mipmap
  50766. */
  50767. mipmapCount: number;
  50768. /**
  50769. * If the textures format is a known fourCC format
  50770. * @see https://www.fourcc.org/
  50771. */
  50772. isFourCC: boolean;
  50773. /**
  50774. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50775. */
  50776. isRGB: boolean;
  50777. /**
  50778. * If the texture is a lumincance format
  50779. */
  50780. isLuminance: boolean;
  50781. /**
  50782. * If this is a cube texture
  50783. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50784. */
  50785. isCube: boolean;
  50786. /**
  50787. * If the texture is a compressed format eg. FOURCC_DXT1
  50788. */
  50789. isCompressed: boolean;
  50790. /**
  50791. * The dxgiFormat of the texture
  50792. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50793. */
  50794. dxgiFormat: number;
  50795. /**
  50796. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50797. */
  50798. textureType: number;
  50799. /**
  50800. * Sphericle polynomial created for the dds texture
  50801. */
  50802. sphericalPolynomial?: SphericalPolynomial;
  50803. }
  50804. /**
  50805. * Class used to provide DDS decompression tools
  50806. */
  50807. export class DDSTools {
  50808. /**
  50809. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50810. */
  50811. static StoreLODInAlphaChannel: boolean;
  50812. /**
  50813. * Gets DDS information from an array buffer
  50814. * @param arrayBuffer defines the array buffer to read data from
  50815. * @returns the DDS information
  50816. */
  50817. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50818. private static _FloatView;
  50819. private static _Int32View;
  50820. private static _ToHalfFloat;
  50821. private static _FromHalfFloat;
  50822. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50823. private static _GetHalfFloatRGBAArrayBuffer;
  50824. private static _GetFloatRGBAArrayBuffer;
  50825. private static _GetFloatAsUIntRGBAArrayBuffer;
  50826. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50827. private static _GetRGBAArrayBuffer;
  50828. private static _ExtractLongWordOrder;
  50829. private static _GetRGBArrayBuffer;
  50830. private static _GetLuminanceArrayBuffer;
  50831. /**
  50832. * Uploads DDS Levels to a Babylon Texture
  50833. * @hidden
  50834. */
  50835. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50836. }
  50837. module "babylonjs/Engines/thinEngine" {
  50838. interface ThinEngine {
  50839. /**
  50840. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50841. * @param rootUrl defines the url where the file to load is located
  50842. * @param scene defines the current scene
  50843. * @param lodScale defines scale to apply to the mip map selection
  50844. * @param lodOffset defines offset to apply to the mip map selection
  50845. * @param onLoad defines an optional callback raised when the texture is loaded
  50846. * @param onError defines an optional callback raised if there is an issue to load the texture
  50847. * @param format defines the format of the data
  50848. * @param forcedExtension defines the extension to use to pick the right loader
  50849. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50850. * @returns the cube texture as an InternalTexture
  50851. */
  50852. 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;
  50853. }
  50854. }
  50855. }
  50856. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50857. import { Nullable } from "babylonjs/types";
  50858. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50859. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50860. /**
  50861. * Implementation of the DDS Texture Loader.
  50862. * @hidden
  50863. */
  50864. export class _DDSTextureLoader implements IInternalTextureLoader {
  50865. /**
  50866. * Defines wether the loader supports cascade loading the different faces.
  50867. */
  50868. readonly supportCascades: boolean;
  50869. /**
  50870. * This returns if the loader support the current file information.
  50871. * @param extension defines the file extension of the file being loaded
  50872. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50873. * @param fallback defines the fallback internal texture if any
  50874. * @param isBase64 defines whether the texture is encoded as a base64
  50875. * @param isBuffer defines whether the texture data are stored as a buffer
  50876. * @returns true if the loader can load the specified file
  50877. */
  50878. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50879. /**
  50880. * Transform the url before loading if required.
  50881. * @param rootUrl the url of the texture
  50882. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50883. * @returns the transformed texture
  50884. */
  50885. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50886. /**
  50887. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50888. * @param rootUrl the url of the texture
  50889. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50890. * @returns the fallback texture
  50891. */
  50892. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50893. /**
  50894. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50895. * @param data contains the texture data
  50896. * @param texture defines the BabylonJS internal texture
  50897. * @param createPolynomials will be true if polynomials have been requested
  50898. * @param onLoad defines the callback to trigger once the texture is ready
  50899. * @param onError defines the callback to trigger in case of error
  50900. */
  50901. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50902. /**
  50903. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50904. * @param data contains the texture data
  50905. * @param texture defines the BabylonJS internal texture
  50906. * @param callback defines the method to call once ready to upload
  50907. */
  50908. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50909. }
  50910. }
  50911. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50912. import { Nullable } from "babylonjs/types";
  50913. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50914. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50915. /**
  50916. * Implementation of the ENV Texture Loader.
  50917. * @hidden
  50918. */
  50919. export class _ENVTextureLoader implements IInternalTextureLoader {
  50920. /**
  50921. * Defines wether the loader supports cascade loading the different faces.
  50922. */
  50923. readonly supportCascades: boolean;
  50924. /**
  50925. * This returns if the loader support the current file information.
  50926. * @param extension defines the file extension of the file being loaded
  50927. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50928. * @param fallback defines the fallback internal texture if any
  50929. * @param isBase64 defines whether the texture is encoded as a base64
  50930. * @param isBuffer defines whether the texture data are stored as a buffer
  50931. * @returns true if the loader can load the specified file
  50932. */
  50933. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50934. /**
  50935. * Transform the url before loading if required.
  50936. * @param rootUrl the url of the texture
  50937. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50938. * @returns the transformed texture
  50939. */
  50940. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50941. /**
  50942. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50943. * @param rootUrl the url of the texture
  50944. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50945. * @returns the fallback texture
  50946. */
  50947. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50948. /**
  50949. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50950. * @param data contains the texture data
  50951. * @param texture defines the BabylonJS internal texture
  50952. * @param createPolynomials will be true if polynomials have been requested
  50953. * @param onLoad defines the callback to trigger once the texture is ready
  50954. * @param onError defines the callback to trigger in case of error
  50955. */
  50956. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50957. /**
  50958. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50959. * @param data contains the texture data
  50960. * @param texture defines the BabylonJS internal texture
  50961. * @param callback defines the method to call once ready to upload
  50962. */
  50963. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50964. }
  50965. }
  50966. declare module "babylonjs/Misc/khronosTextureContainer" {
  50967. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50968. /**
  50969. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50970. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50971. */
  50972. export class KhronosTextureContainer {
  50973. /** contents of the KTX container file */
  50974. arrayBuffer: any;
  50975. private static HEADER_LEN;
  50976. private static COMPRESSED_2D;
  50977. private static COMPRESSED_3D;
  50978. private static TEX_2D;
  50979. private static TEX_3D;
  50980. /**
  50981. * Gets the openGL type
  50982. */
  50983. glType: number;
  50984. /**
  50985. * Gets the openGL type size
  50986. */
  50987. glTypeSize: number;
  50988. /**
  50989. * Gets the openGL format
  50990. */
  50991. glFormat: number;
  50992. /**
  50993. * Gets the openGL internal format
  50994. */
  50995. glInternalFormat: number;
  50996. /**
  50997. * Gets the base internal format
  50998. */
  50999. glBaseInternalFormat: number;
  51000. /**
  51001. * Gets image width in pixel
  51002. */
  51003. pixelWidth: number;
  51004. /**
  51005. * Gets image height in pixel
  51006. */
  51007. pixelHeight: number;
  51008. /**
  51009. * Gets image depth in pixels
  51010. */
  51011. pixelDepth: number;
  51012. /**
  51013. * Gets the number of array elements
  51014. */
  51015. numberOfArrayElements: number;
  51016. /**
  51017. * Gets the number of faces
  51018. */
  51019. numberOfFaces: number;
  51020. /**
  51021. * Gets the number of mipmap levels
  51022. */
  51023. numberOfMipmapLevels: number;
  51024. /**
  51025. * Gets the bytes of key value data
  51026. */
  51027. bytesOfKeyValueData: number;
  51028. /**
  51029. * Gets the load type
  51030. */
  51031. loadType: number;
  51032. /**
  51033. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51034. */
  51035. isInvalid: boolean;
  51036. /**
  51037. * Creates a new KhronosTextureContainer
  51038. * @param arrayBuffer contents of the KTX container file
  51039. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51040. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51041. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51042. */
  51043. constructor(
  51044. /** contents of the KTX container file */
  51045. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51046. /**
  51047. * Uploads KTX content to a Babylon Texture.
  51048. * It is assumed that the texture has already been created & is currently bound
  51049. * @hidden
  51050. */
  51051. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51052. private _upload2DCompressedLevels;
  51053. }
  51054. }
  51055. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51056. import { Nullable } from "babylonjs/types";
  51057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51058. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51059. /**
  51060. * Implementation of the KTX Texture Loader.
  51061. * @hidden
  51062. */
  51063. export class _KTXTextureLoader implements IInternalTextureLoader {
  51064. /**
  51065. * Defines wether the loader supports cascade loading the different faces.
  51066. */
  51067. readonly supportCascades: boolean;
  51068. /**
  51069. * This returns if the loader support the current file information.
  51070. * @param extension defines the file extension of the file being loaded
  51071. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51072. * @param fallback defines the fallback internal texture if any
  51073. * @param isBase64 defines whether the texture is encoded as a base64
  51074. * @param isBuffer defines whether the texture data are stored as a buffer
  51075. * @returns true if the loader can load the specified file
  51076. */
  51077. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51078. /**
  51079. * Transform the url before loading if required.
  51080. * @param rootUrl the url of the texture
  51081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51082. * @returns the transformed texture
  51083. */
  51084. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51085. /**
  51086. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51087. * @param rootUrl the url of the texture
  51088. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51089. * @returns the fallback texture
  51090. */
  51091. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51092. /**
  51093. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51094. * @param data contains the texture data
  51095. * @param texture defines the BabylonJS internal texture
  51096. * @param createPolynomials will be true if polynomials have been requested
  51097. * @param onLoad defines the callback to trigger once the texture is ready
  51098. * @param onError defines the callback to trigger in case of error
  51099. */
  51100. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51101. /**
  51102. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51103. * @param data contains the texture data
  51104. * @param texture defines the BabylonJS internal texture
  51105. * @param callback defines the method to call once ready to upload
  51106. */
  51107. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51108. }
  51109. }
  51110. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51111. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51112. import { Scene } from "babylonjs/scene";
  51113. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51114. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51115. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51116. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51117. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  51118. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51120. /**
  51121. * Options for the default xr helper
  51122. */
  51123. export class WebXRDefaultExperienceOptions {
  51124. /**
  51125. * Floor meshes that should be used for teleporting
  51126. */
  51127. floorMeshes: Array<AbstractMesh>;
  51128. }
  51129. /**
  51130. * Default experience which provides a similar setup to the previous webVRExperience
  51131. */
  51132. export class WebXRDefaultExperience {
  51133. /**
  51134. * Base experience
  51135. */
  51136. baseExperience: WebXRExperienceHelper;
  51137. /**
  51138. * Input experience extension
  51139. */
  51140. input: WebXRInput;
  51141. /**
  51142. * Loads the controller models
  51143. */
  51144. controllerModelLoader: WebXRControllerModelLoader;
  51145. /**
  51146. * Enables laser pointer and selection
  51147. */
  51148. pointerSelection: WebXRControllerPointerSelection;
  51149. /**
  51150. * Enables teleportation
  51151. */
  51152. teleportation: WebXRControllerTeleportation;
  51153. /**
  51154. * Enables ui for enetering/exiting xr
  51155. */
  51156. enterExitUI: WebXREnterExitUI;
  51157. /**
  51158. * Default output canvas xr should render to
  51159. */
  51160. outputCanvas: WebXRManagedOutputCanvas;
  51161. /**
  51162. * Creates the default xr experience
  51163. * @param scene scene
  51164. * @param options options for basic configuration
  51165. * @returns resulting WebXRDefaultExperience
  51166. */
  51167. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51168. private constructor();
  51169. /**
  51170. * DIsposes of the experience helper
  51171. */
  51172. dispose(): void;
  51173. }
  51174. }
  51175. declare module "babylonjs/Helpers/sceneHelpers" {
  51176. import { Nullable } from "babylonjs/types";
  51177. import { Mesh } from "babylonjs/Meshes/mesh";
  51178. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51179. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51180. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51181. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51182. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51183. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51184. import "babylonjs/Meshes/Builders/boxBuilder";
  51185. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51186. /** @hidden */
  51187. export var _forceSceneHelpersToBundle: boolean;
  51188. module "babylonjs/scene" {
  51189. interface Scene {
  51190. /**
  51191. * Creates a default light for the scene.
  51192. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51193. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51194. */
  51195. createDefaultLight(replace?: boolean): void;
  51196. /**
  51197. * Creates a default camera for the scene.
  51198. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51199. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51200. * @param replace has default false, when true replaces the active camera in the scene
  51201. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51202. */
  51203. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51204. /**
  51205. * Creates a default camera and a default light.
  51206. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51207. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51208. * @param replace has the default false, when true replaces the active camera/light in the scene
  51209. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51210. */
  51211. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51212. /**
  51213. * Creates a new sky box
  51214. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51215. * @param environmentTexture defines the texture to use as environment texture
  51216. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51217. * @param scale defines the overall scale of the skybox
  51218. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51219. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51220. * @returns a new mesh holding the sky box
  51221. */
  51222. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51223. /**
  51224. * Creates a new environment
  51225. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51226. * @param options defines the options you can use to configure the environment
  51227. * @returns the new EnvironmentHelper
  51228. */
  51229. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51230. /**
  51231. * Creates a new VREXperienceHelper
  51232. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51233. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51234. * @returns a new VREXperienceHelper
  51235. */
  51236. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51237. /**
  51238. * Creates a new WebXRDefaultExperience
  51239. * @see http://doc.babylonjs.com/how_to/webxr
  51240. * @param options experience options
  51241. * @returns a promise for a new WebXRDefaultExperience
  51242. */
  51243. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51244. }
  51245. }
  51246. }
  51247. declare module "babylonjs/Helpers/videoDome" {
  51248. import { Scene } from "babylonjs/scene";
  51249. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51250. import { Mesh } from "babylonjs/Meshes/mesh";
  51251. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51252. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51253. import "babylonjs/Meshes/Builders/sphereBuilder";
  51254. /**
  51255. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51256. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51257. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51258. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51259. */
  51260. export class VideoDome extends TransformNode {
  51261. /**
  51262. * Define the video source as a Monoscopic panoramic 360 video.
  51263. */
  51264. static readonly MODE_MONOSCOPIC: number;
  51265. /**
  51266. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51267. */
  51268. static readonly MODE_TOPBOTTOM: number;
  51269. /**
  51270. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51271. */
  51272. static readonly MODE_SIDEBYSIDE: number;
  51273. private _halfDome;
  51274. private _useDirectMapping;
  51275. /**
  51276. * The video texture being displayed on the sphere
  51277. */
  51278. protected _videoTexture: VideoTexture;
  51279. /**
  51280. * Gets the video texture being displayed on the sphere
  51281. */
  51282. readonly videoTexture: VideoTexture;
  51283. /**
  51284. * The skybox material
  51285. */
  51286. protected _material: BackgroundMaterial;
  51287. /**
  51288. * The surface used for the skybox
  51289. */
  51290. protected _mesh: Mesh;
  51291. /**
  51292. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51293. */
  51294. private _halfDomeMask;
  51295. /**
  51296. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51297. * Also see the options.resolution property.
  51298. */
  51299. fovMultiplier: number;
  51300. private _videoMode;
  51301. /**
  51302. * Gets or set the current video mode for the video. It can be:
  51303. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51304. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51305. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51306. */
  51307. videoMode: number;
  51308. /**
  51309. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51310. *
  51311. */
  51312. /**
  51313. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51314. */
  51315. halfDome: boolean;
  51316. /**
  51317. * Oberserver used in Stereoscopic VR Mode.
  51318. */
  51319. private _onBeforeCameraRenderObserver;
  51320. /**
  51321. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51322. * @param name Element's name, child elements will append suffixes for their own names.
  51323. * @param urlsOrVideo defines the url(s) or the video element to use
  51324. * @param options An object containing optional or exposed sub element properties
  51325. */
  51326. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51327. resolution?: number;
  51328. clickToPlay?: boolean;
  51329. autoPlay?: boolean;
  51330. loop?: boolean;
  51331. size?: number;
  51332. poster?: string;
  51333. faceForward?: boolean;
  51334. useDirectMapping?: boolean;
  51335. halfDomeMode?: boolean;
  51336. }, scene: Scene);
  51337. private _changeVideoMode;
  51338. /**
  51339. * Releases resources associated with this node.
  51340. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51341. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51342. */
  51343. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51344. }
  51345. }
  51346. declare module "babylonjs/Helpers/index" {
  51347. export * from "babylonjs/Helpers/environmentHelper";
  51348. export * from "babylonjs/Helpers/photoDome";
  51349. export * from "babylonjs/Helpers/sceneHelpers";
  51350. export * from "babylonjs/Helpers/videoDome";
  51351. }
  51352. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51353. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51354. import { IDisposable } from "babylonjs/scene";
  51355. import { Engine } from "babylonjs/Engines/engine";
  51356. /**
  51357. * This class can be used to get instrumentation data from a Babylon engine
  51358. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51359. */
  51360. export class EngineInstrumentation implements IDisposable {
  51361. /**
  51362. * Define the instrumented engine.
  51363. */
  51364. engine: Engine;
  51365. private _captureGPUFrameTime;
  51366. private _gpuFrameTimeToken;
  51367. private _gpuFrameTime;
  51368. private _captureShaderCompilationTime;
  51369. private _shaderCompilationTime;
  51370. private _onBeginFrameObserver;
  51371. private _onEndFrameObserver;
  51372. private _onBeforeShaderCompilationObserver;
  51373. private _onAfterShaderCompilationObserver;
  51374. /**
  51375. * Gets the perf counter used for GPU frame time
  51376. */
  51377. readonly gpuFrameTimeCounter: PerfCounter;
  51378. /**
  51379. * Gets the GPU frame time capture status
  51380. */
  51381. /**
  51382. * Enable or disable the GPU frame time capture
  51383. */
  51384. captureGPUFrameTime: boolean;
  51385. /**
  51386. * Gets the perf counter used for shader compilation time
  51387. */
  51388. readonly shaderCompilationTimeCounter: PerfCounter;
  51389. /**
  51390. * Gets the shader compilation time capture status
  51391. */
  51392. /**
  51393. * Enable or disable the shader compilation time capture
  51394. */
  51395. captureShaderCompilationTime: boolean;
  51396. /**
  51397. * Instantiates a new engine instrumentation.
  51398. * This class can be used to get instrumentation data from a Babylon engine
  51399. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51400. * @param engine Defines the engine to instrument
  51401. */
  51402. constructor(
  51403. /**
  51404. * Define the instrumented engine.
  51405. */
  51406. engine: Engine);
  51407. /**
  51408. * Dispose and release associated resources.
  51409. */
  51410. dispose(): void;
  51411. }
  51412. }
  51413. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51414. import { Scene, IDisposable } from "babylonjs/scene";
  51415. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51416. /**
  51417. * This class can be used to get instrumentation data from a Babylon engine
  51418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51419. */
  51420. export class SceneInstrumentation implements IDisposable {
  51421. /**
  51422. * Defines the scene to instrument
  51423. */
  51424. scene: Scene;
  51425. private _captureActiveMeshesEvaluationTime;
  51426. private _activeMeshesEvaluationTime;
  51427. private _captureRenderTargetsRenderTime;
  51428. private _renderTargetsRenderTime;
  51429. private _captureFrameTime;
  51430. private _frameTime;
  51431. private _captureRenderTime;
  51432. private _renderTime;
  51433. private _captureInterFrameTime;
  51434. private _interFrameTime;
  51435. private _captureParticlesRenderTime;
  51436. private _particlesRenderTime;
  51437. private _captureSpritesRenderTime;
  51438. private _spritesRenderTime;
  51439. private _capturePhysicsTime;
  51440. private _physicsTime;
  51441. private _captureAnimationsTime;
  51442. private _animationsTime;
  51443. private _captureCameraRenderTime;
  51444. private _cameraRenderTime;
  51445. private _onBeforeActiveMeshesEvaluationObserver;
  51446. private _onAfterActiveMeshesEvaluationObserver;
  51447. private _onBeforeRenderTargetsRenderObserver;
  51448. private _onAfterRenderTargetsRenderObserver;
  51449. private _onAfterRenderObserver;
  51450. private _onBeforeDrawPhaseObserver;
  51451. private _onAfterDrawPhaseObserver;
  51452. private _onBeforeAnimationsObserver;
  51453. private _onBeforeParticlesRenderingObserver;
  51454. private _onAfterParticlesRenderingObserver;
  51455. private _onBeforeSpritesRenderingObserver;
  51456. private _onAfterSpritesRenderingObserver;
  51457. private _onBeforePhysicsObserver;
  51458. private _onAfterPhysicsObserver;
  51459. private _onAfterAnimationsObserver;
  51460. private _onBeforeCameraRenderObserver;
  51461. private _onAfterCameraRenderObserver;
  51462. /**
  51463. * Gets the perf counter used for active meshes evaluation time
  51464. */
  51465. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51466. /**
  51467. * Gets the active meshes evaluation time capture status
  51468. */
  51469. /**
  51470. * Enable or disable the active meshes evaluation time capture
  51471. */
  51472. captureActiveMeshesEvaluationTime: boolean;
  51473. /**
  51474. * Gets the perf counter used for render targets render time
  51475. */
  51476. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51477. /**
  51478. * Gets the render targets render time capture status
  51479. */
  51480. /**
  51481. * Enable or disable the render targets render time capture
  51482. */
  51483. captureRenderTargetsRenderTime: boolean;
  51484. /**
  51485. * Gets the perf counter used for particles render time
  51486. */
  51487. readonly particlesRenderTimeCounter: PerfCounter;
  51488. /**
  51489. * Gets the particles render time capture status
  51490. */
  51491. /**
  51492. * Enable or disable the particles render time capture
  51493. */
  51494. captureParticlesRenderTime: boolean;
  51495. /**
  51496. * Gets the perf counter used for sprites render time
  51497. */
  51498. readonly spritesRenderTimeCounter: PerfCounter;
  51499. /**
  51500. * Gets the sprites render time capture status
  51501. */
  51502. /**
  51503. * Enable or disable the sprites render time capture
  51504. */
  51505. captureSpritesRenderTime: boolean;
  51506. /**
  51507. * Gets the perf counter used for physics time
  51508. */
  51509. readonly physicsTimeCounter: PerfCounter;
  51510. /**
  51511. * Gets the physics time capture status
  51512. */
  51513. /**
  51514. * Enable or disable the physics time capture
  51515. */
  51516. capturePhysicsTime: boolean;
  51517. /**
  51518. * Gets the perf counter used for animations time
  51519. */
  51520. readonly animationsTimeCounter: PerfCounter;
  51521. /**
  51522. * Gets the animations time capture status
  51523. */
  51524. /**
  51525. * Enable or disable the animations time capture
  51526. */
  51527. captureAnimationsTime: boolean;
  51528. /**
  51529. * Gets the perf counter used for frame time capture
  51530. */
  51531. readonly frameTimeCounter: PerfCounter;
  51532. /**
  51533. * Gets the frame time capture status
  51534. */
  51535. /**
  51536. * Enable or disable the frame time capture
  51537. */
  51538. captureFrameTime: boolean;
  51539. /**
  51540. * Gets the perf counter used for inter-frames time capture
  51541. */
  51542. readonly interFrameTimeCounter: PerfCounter;
  51543. /**
  51544. * Gets the inter-frames time capture status
  51545. */
  51546. /**
  51547. * Enable or disable the inter-frames time capture
  51548. */
  51549. captureInterFrameTime: boolean;
  51550. /**
  51551. * Gets the perf counter used for render time capture
  51552. */
  51553. readonly renderTimeCounter: PerfCounter;
  51554. /**
  51555. * Gets the render time capture status
  51556. */
  51557. /**
  51558. * Enable or disable the render time capture
  51559. */
  51560. captureRenderTime: boolean;
  51561. /**
  51562. * Gets the perf counter used for camera render time capture
  51563. */
  51564. readonly cameraRenderTimeCounter: PerfCounter;
  51565. /**
  51566. * Gets the camera render time capture status
  51567. */
  51568. /**
  51569. * Enable or disable the camera render time capture
  51570. */
  51571. captureCameraRenderTime: boolean;
  51572. /**
  51573. * Gets the perf counter used for draw calls
  51574. */
  51575. readonly drawCallsCounter: PerfCounter;
  51576. /**
  51577. * Instantiates a new scene instrumentation.
  51578. * This class can be used to get instrumentation data from a Babylon engine
  51579. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51580. * @param scene Defines the scene to instrument
  51581. */
  51582. constructor(
  51583. /**
  51584. * Defines the scene to instrument
  51585. */
  51586. scene: Scene);
  51587. /**
  51588. * Dispose and release associated resources.
  51589. */
  51590. dispose(): void;
  51591. }
  51592. }
  51593. declare module "babylonjs/Instrumentation/index" {
  51594. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51595. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51596. export * from "babylonjs/Instrumentation/timeToken";
  51597. }
  51598. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51599. /** @hidden */
  51600. export var glowMapGenerationPixelShader: {
  51601. name: string;
  51602. shader: string;
  51603. };
  51604. }
  51605. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51606. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51607. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51608. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51609. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51610. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51611. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51612. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51613. /** @hidden */
  51614. export var glowMapGenerationVertexShader: {
  51615. name: string;
  51616. shader: string;
  51617. };
  51618. }
  51619. declare module "babylonjs/Layers/effectLayer" {
  51620. import { Observable } from "babylonjs/Misc/observable";
  51621. import { Nullable } from "babylonjs/types";
  51622. import { Camera } from "babylonjs/Cameras/camera";
  51623. import { Scene } from "babylonjs/scene";
  51624. import { ISize } from "babylonjs/Maths/math.size";
  51625. import { Color4 } from "babylonjs/Maths/math.color";
  51626. import { Engine } from "babylonjs/Engines/engine";
  51627. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51629. import { Mesh } from "babylonjs/Meshes/mesh";
  51630. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51631. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51632. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51633. import { Effect } from "babylonjs/Materials/effect";
  51634. import { Material } from "babylonjs/Materials/material";
  51635. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51636. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51637. /**
  51638. * Effect layer options. This helps customizing the behaviour
  51639. * of the effect layer.
  51640. */
  51641. export interface IEffectLayerOptions {
  51642. /**
  51643. * Multiplication factor apply to the canvas size to compute the render target size
  51644. * used to generated the objects (the smaller the faster).
  51645. */
  51646. mainTextureRatio: number;
  51647. /**
  51648. * Enforces a fixed size texture to ensure effect stability across devices.
  51649. */
  51650. mainTextureFixedSize?: number;
  51651. /**
  51652. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51653. */
  51654. alphaBlendingMode: number;
  51655. /**
  51656. * The camera attached to the layer.
  51657. */
  51658. camera: Nullable<Camera>;
  51659. /**
  51660. * The rendering group to draw the layer in.
  51661. */
  51662. renderingGroupId: number;
  51663. }
  51664. /**
  51665. * The effect layer Helps adding post process effect blended with the main pass.
  51666. *
  51667. * This can be for instance use to generate glow or higlight effects on the scene.
  51668. *
  51669. * The effect layer class can not be used directly and is intented to inherited from to be
  51670. * customized per effects.
  51671. */
  51672. export abstract class EffectLayer {
  51673. private _vertexBuffers;
  51674. private _indexBuffer;
  51675. private _cachedDefines;
  51676. private _effectLayerMapGenerationEffect;
  51677. private _effectLayerOptions;
  51678. private _mergeEffect;
  51679. protected _scene: Scene;
  51680. protected _engine: Engine;
  51681. protected _maxSize: number;
  51682. protected _mainTextureDesiredSize: ISize;
  51683. protected _mainTexture: RenderTargetTexture;
  51684. protected _shouldRender: boolean;
  51685. protected _postProcesses: PostProcess[];
  51686. protected _textures: BaseTexture[];
  51687. protected _emissiveTextureAndColor: {
  51688. texture: Nullable<BaseTexture>;
  51689. color: Color4;
  51690. };
  51691. /**
  51692. * The name of the layer
  51693. */
  51694. name: string;
  51695. /**
  51696. * The clear color of the texture used to generate the glow map.
  51697. */
  51698. neutralColor: Color4;
  51699. /**
  51700. * Specifies wether the highlight layer is enabled or not.
  51701. */
  51702. isEnabled: boolean;
  51703. /**
  51704. * Gets the camera attached to the layer.
  51705. */
  51706. readonly camera: Nullable<Camera>;
  51707. /**
  51708. * Gets the rendering group id the layer should render in.
  51709. */
  51710. renderingGroupId: number;
  51711. /**
  51712. * An event triggered when the effect layer has been disposed.
  51713. */
  51714. onDisposeObservable: Observable<EffectLayer>;
  51715. /**
  51716. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51717. */
  51718. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51719. /**
  51720. * An event triggered when the generated texture is being merged in the scene.
  51721. */
  51722. onBeforeComposeObservable: Observable<EffectLayer>;
  51723. /**
  51724. * An event triggered when the generated texture has been merged in the scene.
  51725. */
  51726. onAfterComposeObservable: Observable<EffectLayer>;
  51727. /**
  51728. * An event triggered when the efffect layer changes its size.
  51729. */
  51730. onSizeChangedObservable: Observable<EffectLayer>;
  51731. /** @hidden */
  51732. static _SceneComponentInitialization: (scene: Scene) => void;
  51733. /**
  51734. * Instantiates a new effect Layer and references it in the scene.
  51735. * @param name The name of the layer
  51736. * @param scene The scene to use the layer in
  51737. */
  51738. constructor(
  51739. /** The Friendly of the effect in the scene */
  51740. name: string, scene: Scene);
  51741. /**
  51742. * Get the effect name of the layer.
  51743. * @return The effect name
  51744. */
  51745. abstract getEffectName(): string;
  51746. /**
  51747. * Checks for the readiness of the element composing the layer.
  51748. * @param subMesh the mesh to check for
  51749. * @param useInstances specify wether or not to use instances to render the mesh
  51750. * @return true if ready otherwise, false
  51751. */
  51752. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51753. /**
  51754. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51755. * @returns true if the effect requires stencil during the main canvas render pass.
  51756. */
  51757. abstract needStencil(): boolean;
  51758. /**
  51759. * Create the merge effect. This is the shader use to blit the information back
  51760. * to the main canvas at the end of the scene rendering.
  51761. * @returns The effect containing the shader used to merge the effect on the main canvas
  51762. */
  51763. protected abstract _createMergeEffect(): Effect;
  51764. /**
  51765. * Creates the render target textures and post processes used in the effect layer.
  51766. */
  51767. protected abstract _createTextureAndPostProcesses(): void;
  51768. /**
  51769. * Implementation specific of rendering the generating effect on the main canvas.
  51770. * @param effect The effect used to render through
  51771. */
  51772. protected abstract _internalRender(effect: Effect): void;
  51773. /**
  51774. * Sets the required values for both the emissive texture and and the main color.
  51775. */
  51776. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51777. /**
  51778. * Free any resources and references associated to a mesh.
  51779. * Internal use
  51780. * @param mesh The mesh to free.
  51781. */
  51782. abstract _disposeMesh(mesh: Mesh): void;
  51783. /**
  51784. * Serializes this layer (Glow or Highlight for example)
  51785. * @returns a serialized layer object
  51786. */
  51787. abstract serialize?(): any;
  51788. /**
  51789. * Initializes the effect layer with the required options.
  51790. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51791. */
  51792. protected _init(options: Partial<IEffectLayerOptions>): void;
  51793. /**
  51794. * Generates the index buffer of the full screen quad blending to the main canvas.
  51795. */
  51796. private _generateIndexBuffer;
  51797. /**
  51798. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51799. */
  51800. private _generateVertexBuffer;
  51801. /**
  51802. * Sets the main texture desired size which is the closest power of two
  51803. * of the engine canvas size.
  51804. */
  51805. private _setMainTextureSize;
  51806. /**
  51807. * Creates the main texture for the effect layer.
  51808. */
  51809. protected _createMainTexture(): void;
  51810. /**
  51811. * Adds specific effects defines.
  51812. * @param defines The defines to add specifics to.
  51813. */
  51814. protected _addCustomEffectDefines(defines: string[]): void;
  51815. /**
  51816. * Checks for the readiness of the element composing the layer.
  51817. * @param subMesh the mesh to check for
  51818. * @param useInstances specify wether or not to use instances to render the mesh
  51819. * @param emissiveTexture the associated emissive texture used to generate the glow
  51820. * @return true if ready otherwise, false
  51821. */
  51822. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51823. /**
  51824. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51825. */
  51826. render(): void;
  51827. /**
  51828. * Determine if a given mesh will be used in the current effect.
  51829. * @param mesh mesh to test
  51830. * @returns true if the mesh will be used
  51831. */
  51832. hasMesh(mesh: AbstractMesh): boolean;
  51833. /**
  51834. * Returns true if the layer contains information to display, otherwise false.
  51835. * @returns true if the glow layer should be rendered
  51836. */
  51837. shouldRender(): boolean;
  51838. /**
  51839. * Returns true if the mesh should render, otherwise false.
  51840. * @param mesh The mesh to render
  51841. * @returns true if it should render otherwise false
  51842. */
  51843. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51844. /**
  51845. * Returns true if the mesh can be rendered, otherwise false.
  51846. * @param mesh The mesh to render
  51847. * @param material The material used on the mesh
  51848. * @returns true if it can be rendered otherwise false
  51849. */
  51850. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51851. /**
  51852. * Returns true if the mesh should render, otherwise false.
  51853. * @param mesh The mesh to render
  51854. * @returns true if it should render otherwise false
  51855. */
  51856. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51857. /**
  51858. * Renders the submesh passed in parameter to the generation map.
  51859. */
  51860. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51861. /**
  51862. * Rebuild the required buffers.
  51863. * @hidden Internal use only.
  51864. */
  51865. _rebuild(): void;
  51866. /**
  51867. * Dispose only the render target textures and post process.
  51868. */
  51869. private _disposeTextureAndPostProcesses;
  51870. /**
  51871. * Dispose the highlight layer and free resources.
  51872. */
  51873. dispose(): void;
  51874. /**
  51875. * Gets the class name of the effect layer
  51876. * @returns the string with the class name of the effect layer
  51877. */
  51878. getClassName(): string;
  51879. /**
  51880. * Creates an effect layer from parsed effect layer data
  51881. * @param parsedEffectLayer defines effect layer data
  51882. * @param scene defines the current scene
  51883. * @param rootUrl defines the root URL containing the effect layer information
  51884. * @returns a parsed effect Layer
  51885. */
  51886. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51887. }
  51888. }
  51889. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51890. import { Scene } from "babylonjs/scene";
  51891. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51892. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51893. import { AbstractScene } from "babylonjs/abstractScene";
  51894. module "babylonjs/abstractScene" {
  51895. interface AbstractScene {
  51896. /**
  51897. * The list of effect layers (highlights/glow) added to the scene
  51898. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51899. * @see http://doc.babylonjs.com/how_to/glow_layer
  51900. */
  51901. effectLayers: Array<EffectLayer>;
  51902. /**
  51903. * Removes the given effect layer from this scene.
  51904. * @param toRemove defines the effect layer to remove
  51905. * @returns the index of the removed effect layer
  51906. */
  51907. removeEffectLayer(toRemove: EffectLayer): number;
  51908. /**
  51909. * Adds the given effect layer to this scene
  51910. * @param newEffectLayer defines the effect layer to add
  51911. */
  51912. addEffectLayer(newEffectLayer: EffectLayer): void;
  51913. }
  51914. }
  51915. /**
  51916. * Defines the layer scene component responsible to manage any effect layers
  51917. * in a given scene.
  51918. */
  51919. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51920. /**
  51921. * The component name helpfull to identify the component in the list of scene components.
  51922. */
  51923. readonly name: string;
  51924. /**
  51925. * The scene the component belongs to.
  51926. */
  51927. scene: Scene;
  51928. private _engine;
  51929. private _renderEffects;
  51930. private _needStencil;
  51931. private _previousStencilState;
  51932. /**
  51933. * Creates a new instance of the component for the given scene
  51934. * @param scene Defines the scene to register the component in
  51935. */
  51936. constructor(scene: Scene);
  51937. /**
  51938. * Registers the component in a given scene
  51939. */
  51940. register(): void;
  51941. /**
  51942. * Rebuilds the elements related to this component in case of
  51943. * context lost for instance.
  51944. */
  51945. rebuild(): void;
  51946. /**
  51947. * Serializes the component data to the specified json object
  51948. * @param serializationObject The object to serialize to
  51949. */
  51950. serialize(serializationObject: any): void;
  51951. /**
  51952. * Adds all the elements from the container to the scene
  51953. * @param container the container holding the elements
  51954. */
  51955. addFromContainer(container: AbstractScene): void;
  51956. /**
  51957. * Removes all the elements in the container from the scene
  51958. * @param container contains the elements to remove
  51959. * @param dispose if the removed element should be disposed (default: false)
  51960. */
  51961. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51962. /**
  51963. * Disposes the component and the associated ressources.
  51964. */
  51965. dispose(): void;
  51966. private _isReadyForMesh;
  51967. private _renderMainTexture;
  51968. private _setStencil;
  51969. private _setStencilBack;
  51970. private _draw;
  51971. private _drawCamera;
  51972. private _drawRenderingGroup;
  51973. }
  51974. }
  51975. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51976. /** @hidden */
  51977. export var glowMapMergePixelShader: {
  51978. name: string;
  51979. shader: string;
  51980. };
  51981. }
  51982. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51983. /** @hidden */
  51984. export var glowMapMergeVertexShader: {
  51985. name: string;
  51986. shader: string;
  51987. };
  51988. }
  51989. declare module "babylonjs/Layers/glowLayer" {
  51990. import { Nullable } from "babylonjs/types";
  51991. import { Camera } from "babylonjs/Cameras/camera";
  51992. import { Scene } from "babylonjs/scene";
  51993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51995. import { Mesh } from "babylonjs/Meshes/mesh";
  51996. import { Texture } from "babylonjs/Materials/Textures/texture";
  51997. import { Effect } from "babylonjs/Materials/effect";
  51998. import { Material } from "babylonjs/Materials/material";
  51999. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52000. import { Color4 } from "babylonjs/Maths/math.color";
  52001. import "babylonjs/Shaders/glowMapMerge.fragment";
  52002. import "babylonjs/Shaders/glowMapMerge.vertex";
  52003. import "babylonjs/Layers/effectLayerSceneComponent";
  52004. module "babylonjs/abstractScene" {
  52005. interface AbstractScene {
  52006. /**
  52007. * Return a the first highlight layer of the scene with a given name.
  52008. * @param name The name of the highlight layer to look for.
  52009. * @return The highlight layer if found otherwise null.
  52010. */
  52011. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52012. }
  52013. }
  52014. /**
  52015. * Glow layer options. This helps customizing the behaviour
  52016. * of the glow layer.
  52017. */
  52018. export interface IGlowLayerOptions {
  52019. /**
  52020. * Multiplication factor apply to the canvas size to compute the render target size
  52021. * used to generated the glowing objects (the smaller the faster).
  52022. */
  52023. mainTextureRatio: number;
  52024. /**
  52025. * Enforces a fixed size texture to ensure resize independant blur.
  52026. */
  52027. mainTextureFixedSize?: number;
  52028. /**
  52029. * How big is the kernel of the blur texture.
  52030. */
  52031. blurKernelSize: number;
  52032. /**
  52033. * The camera attached to the layer.
  52034. */
  52035. camera: Nullable<Camera>;
  52036. /**
  52037. * Enable MSAA by chosing the number of samples.
  52038. */
  52039. mainTextureSamples?: number;
  52040. /**
  52041. * The rendering group to draw the layer in.
  52042. */
  52043. renderingGroupId: number;
  52044. }
  52045. /**
  52046. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52047. *
  52048. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52049. * glowy meshes to your scene.
  52050. *
  52051. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52052. */
  52053. export class GlowLayer extends EffectLayer {
  52054. /**
  52055. * Effect Name of the layer.
  52056. */
  52057. static readonly EffectName: string;
  52058. /**
  52059. * The default blur kernel size used for the glow.
  52060. */
  52061. static DefaultBlurKernelSize: number;
  52062. /**
  52063. * The default texture size ratio used for the glow.
  52064. */
  52065. static DefaultTextureRatio: number;
  52066. /**
  52067. * Sets the kernel size of the blur.
  52068. */
  52069. /**
  52070. * Gets the kernel size of the blur.
  52071. */
  52072. blurKernelSize: number;
  52073. /**
  52074. * Sets the glow intensity.
  52075. */
  52076. /**
  52077. * Gets the glow intensity.
  52078. */
  52079. intensity: number;
  52080. private _options;
  52081. private _intensity;
  52082. private _horizontalBlurPostprocess1;
  52083. private _verticalBlurPostprocess1;
  52084. private _horizontalBlurPostprocess2;
  52085. private _verticalBlurPostprocess2;
  52086. private _blurTexture1;
  52087. private _blurTexture2;
  52088. private _postProcesses1;
  52089. private _postProcesses2;
  52090. private _includedOnlyMeshes;
  52091. private _excludedMeshes;
  52092. /**
  52093. * Callback used to let the user override the color selection on a per mesh basis
  52094. */
  52095. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52096. /**
  52097. * Callback used to let the user override the texture selection on a per mesh basis
  52098. */
  52099. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52100. /**
  52101. * Instantiates a new glow Layer and references it to the scene.
  52102. * @param name The name of the layer
  52103. * @param scene The scene to use the layer in
  52104. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52105. */
  52106. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52107. /**
  52108. * Get the effect name of the layer.
  52109. * @return The effect name
  52110. */
  52111. getEffectName(): string;
  52112. /**
  52113. * Create the merge effect. This is the shader use to blit the information back
  52114. * to the main canvas at the end of the scene rendering.
  52115. */
  52116. protected _createMergeEffect(): Effect;
  52117. /**
  52118. * Creates the render target textures and post processes used in the glow layer.
  52119. */
  52120. protected _createTextureAndPostProcesses(): void;
  52121. /**
  52122. * Checks for the readiness of the element composing the layer.
  52123. * @param subMesh the mesh to check for
  52124. * @param useInstances specify wether or not to use instances to render the mesh
  52125. * @param emissiveTexture the associated emissive texture used to generate the glow
  52126. * @return true if ready otherwise, false
  52127. */
  52128. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52129. /**
  52130. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52131. */
  52132. needStencil(): boolean;
  52133. /**
  52134. * Returns true if the mesh can be rendered, otherwise false.
  52135. * @param mesh The mesh to render
  52136. * @param material The material used on the mesh
  52137. * @returns true if it can be rendered otherwise false
  52138. */
  52139. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52140. /**
  52141. * Implementation specific of rendering the generating effect on the main canvas.
  52142. * @param effect The effect used to render through
  52143. */
  52144. protected _internalRender(effect: Effect): void;
  52145. /**
  52146. * Sets the required values for both the emissive texture and and the main color.
  52147. */
  52148. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52149. /**
  52150. * Returns true if the mesh should render, otherwise false.
  52151. * @param mesh The mesh to render
  52152. * @returns true if it should render otherwise false
  52153. */
  52154. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52155. /**
  52156. * Adds specific effects defines.
  52157. * @param defines The defines to add specifics to.
  52158. */
  52159. protected _addCustomEffectDefines(defines: string[]): void;
  52160. /**
  52161. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52162. * @param mesh The mesh to exclude from the glow layer
  52163. */
  52164. addExcludedMesh(mesh: Mesh): void;
  52165. /**
  52166. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52167. * @param mesh The mesh to remove
  52168. */
  52169. removeExcludedMesh(mesh: Mesh): void;
  52170. /**
  52171. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52172. * @param mesh The mesh to include in the glow layer
  52173. */
  52174. addIncludedOnlyMesh(mesh: Mesh): void;
  52175. /**
  52176. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52177. * @param mesh The mesh to remove
  52178. */
  52179. removeIncludedOnlyMesh(mesh: Mesh): void;
  52180. /**
  52181. * Determine if a given mesh will be used in the glow layer
  52182. * @param mesh The mesh to test
  52183. * @returns true if the mesh will be highlighted by the current glow layer
  52184. */
  52185. hasMesh(mesh: AbstractMesh): boolean;
  52186. /**
  52187. * Free any resources and references associated to a mesh.
  52188. * Internal use
  52189. * @param mesh The mesh to free.
  52190. * @hidden
  52191. */
  52192. _disposeMesh(mesh: Mesh): void;
  52193. /**
  52194. * Gets the class name of the effect layer
  52195. * @returns the string with the class name of the effect layer
  52196. */
  52197. getClassName(): string;
  52198. /**
  52199. * Serializes this glow layer
  52200. * @returns a serialized glow layer object
  52201. */
  52202. serialize(): any;
  52203. /**
  52204. * Creates a Glow Layer from parsed glow layer data
  52205. * @param parsedGlowLayer defines glow layer data
  52206. * @param scene defines the current scene
  52207. * @param rootUrl defines the root URL containing the glow layer information
  52208. * @returns a parsed Glow Layer
  52209. */
  52210. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52211. }
  52212. }
  52213. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52214. /** @hidden */
  52215. export var glowBlurPostProcessPixelShader: {
  52216. name: string;
  52217. shader: string;
  52218. };
  52219. }
  52220. declare module "babylonjs/Layers/highlightLayer" {
  52221. import { Observable } from "babylonjs/Misc/observable";
  52222. import { Nullable } from "babylonjs/types";
  52223. import { Camera } from "babylonjs/Cameras/camera";
  52224. import { Scene } from "babylonjs/scene";
  52225. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52227. import { Mesh } from "babylonjs/Meshes/mesh";
  52228. import { Effect } from "babylonjs/Materials/effect";
  52229. import { Material } from "babylonjs/Materials/material";
  52230. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52231. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52232. import "babylonjs/Shaders/glowMapMerge.fragment";
  52233. import "babylonjs/Shaders/glowMapMerge.vertex";
  52234. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52235. module "babylonjs/abstractScene" {
  52236. interface AbstractScene {
  52237. /**
  52238. * Return a the first highlight layer of the scene with a given name.
  52239. * @param name The name of the highlight layer to look for.
  52240. * @return The highlight layer if found otherwise null.
  52241. */
  52242. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52243. }
  52244. }
  52245. /**
  52246. * Highlight layer options. This helps customizing the behaviour
  52247. * of the highlight layer.
  52248. */
  52249. export interface IHighlightLayerOptions {
  52250. /**
  52251. * Multiplication factor apply to the canvas size to compute the render target size
  52252. * used to generated the glowing objects (the smaller the faster).
  52253. */
  52254. mainTextureRatio: number;
  52255. /**
  52256. * Enforces a fixed size texture to ensure resize independant blur.
  52257. */
  52258. mainTextureFixedSize?: number;
  52259. /**
  52260. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52261. * of the picture to blur (the smaller the faster).
  52262. */
  52263. blurTextureSizeRatio: number;
  52264. /**
  52265. * How big in texel of the blur texture is the vertical blur.
  52266. */
  52267. blurVerticalSize: number;
  52268. /**
  52269. * How big in texel of the blur texture is the horizontal blur.
  52270. */
  52271. blurHorizontalSize: number;
  52272. /**
  52273. * Alpha blending mode used to apply the blur. Default is combine.
  52274. */
  52275. alphaBlendingMode: number;
  52276. /**
  52277. * The camera attached to the layer.
  52278. */
  52279. camera: Nullable<Camera>;
  52280. /**
  52281. * Should we display highlight as a solid stroke?
  52282. */
  52283. isStroke?: boolean;
  52284. /**
  52285. * The rendering group to draw the layer in.
  52286. */
  52287. renderingGroupId: number;
  52288. }
  52289. /**
  52290. * The highlight layer Helps adding a glow effect around a mesh.
  52291. *
  52292. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52293. * glowy meshes to your scene.
  52294. *
  52295. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52296. */
  52297. export class HighlightLayer extends EffectLayer {
  52298. name: string;
  52299. /**
  52300. * Effect Name of the highlight layer.
  52301. */
  52302. static readonly EffectName: string;
  52303. /**
  52304. * The neutral color used during the preparation of the glow effect.
  52305. * This is black by default as the blend operation is a blend operation.
  52306. */
  52307. static NeutralColor: Color4;
  52308. /**
  52309. * Stencil value used for glowing meshes.
  52310. */
  52311. static GlowingMeshStencilReference: number;
  52312. /**
  52313. * Stencil value used for the other meshes in the scene.
  52314. */
  52315. static NormalMeshStencilReference: number;
  52316. /**
  52317. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52318. */
  52319. innerGlow: boolean;
  52320. /**
  52321. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52322. */
  52323. outerGlow: boolean;
  52324. /**
  52325. * Specifies the horizontal size of the blur.
  52326. */
  52327. /**
  52328. * Gets the horizontal size of the blur.
  52329. */
  52330. blurHorizontalSize: number;
  52331. /**
  52332. * Specifies the vertical size of the blur.
  52333. */
  52334. /**
  52335. * Gets the vertical size of the blur.
  52336. */
  52337. blurVerticalSize: number;
  52338. /**
  52339. * An event triggered when the highlight layer is being blurred.
  52340. */
  52341. onBeforeBlurObservable: Observable<HighlightLayer>;
  52342. /**
  52343. * An event triggered when the highlight layer has been blurred.
  52344. */
  52345. onAfterBlurObservable: Observable<HighlightLayer>;
  52346. private _instanceGlowingMeshStencilReference;
  52347. private _options;
  52348. private _downSamplePostprocess;
  52349. private _horizontalBlurPostprocess;
  52350. private _verticalBlurPostprocess;
  52351. private _blurTexture;
  52352. private _meshes;
  52353. private _excludedMeshes;
  52354. /**
  52355. * Instantiates a new highlight Layer and references it to the scene..
  52356. * @param name The name of the layer
  52357. * @param scene The scene to use the layer in
  52358. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52359. */
  52360. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52361. /**
  52362. * Get the effect name of the layer.
  52363. * @return The effect name
  52364. */
  52365. getEffectName(): string;
  52366. /**
  52367. * Create the merge effect. This is the shader use to blit the information back
  52368. * to the main canvas at the end of the scene rendering.
  52369. */
  52370. protected _createMergeEffect(): Effect;
  52371. /**
  52372. * Creates the render target textures and post processes used in the highlight layer.
  52373. */
  52374. protected _createTextureAndPostProcesses(): void;
  52375. /**
  52376. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52377. */
  52378. needStencil(): boolean;
  52379. /**
  52380. * Checks for the readiness of the element composing the layer.
  52381. * @param subMesh the mesh to check for
  52382. * @param useInstances specify wether or not to use instances to render the mesh
  52383. * @param emissiveTexture the associated emissive texture used to generate the glow
  52384. * @return true if ready otherwise, false
  52385. */
  52386. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52387. /**
  52388. * Implementation specific of rendering the generating effect on the main canvas.
  52389. * @param effect The effect used to render through
  52390. */
  52391. protected _internalRender(effect: Effect): void;
  52392. /**
  52393. * Returns true if the layer contains information to display, otherwise false.
  52394. */
  52395. shouldRender(): boolean;
  52396. /**
  52397. * Returns true if the mesh should render, otherwise false.
  52398. * @param mesh The mesh to render
  52399. * @returns true if it should render otherwise false
  52400. */
  52401. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52402. /**
  52403. * Sets the required values for both the emissive texture and and the main color.
  52404. */
  52405. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52406. /**
  52407. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52408. * @param mesh The mesh to exclude from the highlight layer
  52409. */
  52410. addExcludedMesh(mesh: Mesh): void;
  52411. /**
  52412. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52413. * @param mesh The mesh to highlight
  52414. */
  52415. removeExcludedMesh(mesh: Mesh): void;
  52416. /**
  52417. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52418. * @param mesh mesh to test
  52419. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52420. */
  52421. hasMesh(mesh: AbstractMesh): boolean;
  52422. /**
  52423. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52424. * @param mesh The mesh to highlight
  52425. * @param color The color of the highlight
  52426. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52427. */
  52428. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52429. /**
  52430. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52431. * @param mesh The mesh to highlight
  52432. */
  52433. removeMesh(mesh: Mesh): void;
  52434. /**
  52435. * Force the stencil to the normal expected value for none glowing parts
  52436. */
  52437. private _defaultStencilReference;
  52438. /**
  52439. * Free any resources and references associated to a mesh.
  52440. * Internal use
  52441. * @param mesh The mesh to free.
  52442. * @hidden
  52443. */
  52444. _disposeMesh(mesh: Mesh): void;
  52445. /**
  52446. * Dispose the highlight layer and free resources.
  52447. */
  52448. dispose(): void;
  52449. /**
  52450. * Gets the class name of the effect layer
  52451. * @returns the string with the class name of the effect layer
  52452. */
  52453. getClassName(): string;
  52454. /**
  52455. * Serializes this Highlight layer
  52456. * @returns a serialized Highlight layer object
  52457. */
  52458. serialize(): any;
  52459. /**
  52460. * Creates a Highlight layer from parsed Highlight layer data
  52461. * @param parsedHightlightLayer defines the Highlight layer data
  52462. * @param scene defines the current scene
  52463. * @param rootUrl defines the root URL containing the Highlight layer information
  52464. * @returns a parsed Highlight layer
  52465. */
  52466. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52467. }
  52468. }
  52469. declare module "babylonjs/Layers/layerSceneComponent" {
  52470. import { Scene } from "babylonjs/scene";
  52471. import { ISceneComponent } from "babylonjs/sceneComponent";
  52472. import { Layer } from "babylonjs/Layers/layer";
  52473. import { AbstractScene } from "babylonjs/abstractScene";
  52474. module "babylonjs/abstractScene" {
  52475. interface AbstractScene {
  52476. /**
  52477. * The list of layers (background and foreground) of the scene
  52478. */
  52479. layers: Array<Layer>;
  52480. }
  52481. }
  52482. /**
  52483. * Defines the layer scene component responsible to manage any layers
  52484. * in a given scene.
  52485. */
  52486. export class LayerSceneComponent implements ISceneComponent {
  52487. /**
  52488. * The component name helpfull to identify the component in the list of scene components.
  52489. */
  52490. readonly name: string;
  52491. /**
  52492. * The scene the component belongs to.
  52493. */
  52494. scene: Scene;
  52495. private _engine;
  52496. /**
  52497. * Creates a new instance of the component for the given scene
  52498. * @param scene Defines the scene to register the component in
  52499. */
  52500. constructor(scene: Scene);
  52501. /**
  52502. * Registers the component in a given scene
  52503. */
  52504. register(): void;
  52505. /**
  52506. * Rebuilds the elements related to this component in case of
  52507. * context lost for instance.
  52508. */
  52509. rebuild(): void;
  52510. /**
  52511. * Disposes the component and the associated ressources.
  52512. */
  52513. dispose(): void;
  52514. private _draw;
  52515. private _drawCameraPredicate;
  52516. private _drawCameraBackground;
  52517. private _drawCameraForeground;
  52518. private _drawRenderTargetPredicate;
  52519. private _drawRenderTargetBackground;
  52520. private _drawRenderTargetForeground;
  52521. /**
  52522. * Adds all the elements from the container to the scene
  52523. * @param container the container holding the elements
  52524. */
  52525. addFromContainer(container: AbstractScene): void;
  52526. /**
  52527. * Removes all the elements in the container from the scene
  52528. * @param container contains the elements to remove
  52529. * @param dispose if the removed element should be disposed (default: false)
  52530. */
  52531. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52532. }
  52533. }
  52534. declare module "babylonjs/Shaders/layer.fragment" {
  52535. /** @hidden */
  52536. export var layerPixelShader: {
  52537. name: string;
  52538. shader: string;
  52539. };
  52540. }
  52541. declare module "babylonjs/Shaders/layer.vertex" {
  52542. /** @hidden */
  52543. export var layerVertexShader: {
  52544. name: string;
  52545. shader: string;
  52546. };
  52547. }
  52548. declare module "babylonjs/Layers/layer" {
  52549. import { Observable } from "babylonjs/Misc/observable";
  52550. import { Nullable } from "babylonjs/types";
  52551. import { Scene } from "babylonjs/scene";
  52552. import { Vector2 } from "babylonjs/Maths/math.vector";
  52553. import { Color4 } from "babylonjs/Maths/math.color";
  52554. import { Texture } from "babylonjs/Materials/Textures/texture";
  52555. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52556. import "babylonjs/Shaders/layer.fragment";
  52557. import "babylonjs/Shaders/layer.vertex";
  52558. /**
  52559. * This represents a full screen 2d layer.
  52560. * This can be useful to display a picture in the background of your scene for instance.
  52561. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52562. */
  52563. export class Layer {
  52564. /**
  52565. * Define the name of the layer.
  52566. */
  52567. name: string;
  52568. /**
  52569. * Define the texture the layer should display.
  52570. */
  52571. texture: Nullable<Texture>;
  52572. /**
  52573. * Is the layer in background or foreground.
  52574. */
  52575. isBackground: boolean;
  52576. /**
  52577. * Define the color of the layer (instead of texture).
  52578. */
  52579. color: Color4;
  52580. /**
  52581. * Define the scale of the layer in order to zoom in out of the texture.
  52582. */
  52583. scale: Vector2;
  52584. /**
  52585. * Define an offset for the layer in order to shift the texture.
  52586. */
  52587. offset: Vector2;
  52588. /**
  52589. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52590. */
  52591. alphaBlendingMode: number;
  52592. /**
  52593. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52594. * Alpha test will not mix with the background color in case of transparency.
  52595. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52596. */
  52597. alphaTest: boolean;
  52598. /**
  52599. * Define a mask to restrict the layer to only some of the scene cameras.
  52600. */
  52601. layerMask: number;
  52602. /**
  52603. * Define the list of render target the layer is visible into.
  52604. */
  52605. renderTargetTextures: RenderTargetTexture[];
  52606. /**
  52607. * Define if the layer is only used in renderTarget or if it also
  52608. * renders in the main frame buffer of the canvas.
  52609. */
  52610. renderOnlyInRenderTargetTextures: boolean;
  52611. private _scene;
  52612. private _vertexBuffers;
  52613. private _indexBuffer;
  52614. private _effect;
  52615. private _alphaTestEffect;
  52616. /**
  52617. * An event triggered when the layer is disposed.
  52618. */
  52619. onDisposeObservable: Observable<Layer>;
  52620. private _onDisposeObserver;
  52621. /**
  52622. * Back compatibility with callback before the onDisposeObservable existed.
  52623. * The set callback will be triggered when the layer has been disposed.
  52624. */
  52625. onDispose: () => void;
  52626. /**
  52627. * An event triggered before rendering the scene
  52628. */
  52629. onBeforeRenderObservable: Observable<Layer>;
  52630. private _onBeforeRenderObserver;
  52631. /**
  52632. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52633. * The set callback will be triggered just before rendering the layer.
  52634. */
  52635. onBeforeRender: () => void;
  52636. /**
  52637. * An event triggered after rendering the scene
  52638. */
  52639. onAfterRenderObservable: Observable<Layer>;
  52640. private _onAfterRenderObserver;
  52641. /**
  52642. * Back compatibility with callback before the onAfterRenderObservable existed.
  52643. * The set callback will be triggered just after rendering the layer.
  52644. */
  52645. onAfterRender: () => void;
  52646. /**
  52647. * Instantiates a new layer.
  52648. * This represents a full screen 2d layer.
  52649. * This can be useful to display a picture in the background of your scene for instance.
  52650. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52651. * @param name Define the name of the layer in the scene
  52652. * @param imgUrl Define the url of the texture to display in the layer
  52653. * @param scene Define the scene the layer belongs to
  52654. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52655. * @param color Defines a color for the layer
  52656. */
  52657. constructor(
  52658. /**
  52659. * Define the name of the layer.
  52660. */
  52661. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52662. private _createIndexBuffer;
  52663. /** @hidden */
  52664. _rebuild(): void;
  52665. /**
  52666. * Renders the layer in the scene.
  52667. */
  52668. render(): void;
  52669. /**
  52670. * Disposes and releases the associated ressources.
  52671. */
  52672. dispose(): void;
  52673. }
  52674. }
  52675. declare module "babylonjs/Layers/index" {
  52676. export * from "babylonjs/Layers/effectLayer";
  52677. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52678. export * from "babylonjs/Layers/glowLayer";
  52679. export * from "babylonjs/Layers/highlightLayer";
  52680. export * from "babylonjs/Layers/layer";
  52681. export * from "babylonjs/Layers/layerSceneComponent";
  52682. }
  52683. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52684. /** @hidden */
  52685. export var lensFlarePixelShader: {
  52686. name: string;
  52687. shader: string;
  52688. };
  52689. }
  52690. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52691. /** @hidden */
  52692. export var lensFlareVertexShader: {
  52693. name: string;
  52694. shader: string;
  52695. };
  52696. }
  52697. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52698. import { Scene } from "babylonjs/scene";
  52699. import { Vector3 } from "babylonjs/Maths/math.vector";
  52700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52701. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52702. import "babylonjs/Shaders/lensFlare.fragment";
  52703. import "babylonjs/Shaders/lensFlare.vertex";
  52704. import { Viewport } from "babylonjs/Maths/math.viewport";
  52705. /**
  52706. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52707. * It is usually composed of several `lensFlare`.
  52708. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52709. */
  52710. export class LensFlareSystem {
  52711. /**
  52712. * Define the name of the lens flare system
  52713. */
  52714. name: string;
  52715. /**
  52716. * List of lens flares used in this system.
  52717. */
  52718. lensFlares: LensFlare[];
  52719. /**
  52720. * Define a limit from the border the lens flare can be visible.
  52721. */
  52722. borderLimit: number;
  52723. /**
  52724. * Define a viewport border we do not want to see the lens flare in.
  52725. */
  52726. viewportBorder: number;
  52727. /**
  52728. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52729. */
  52730. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52731. /**
  52732. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52733. */
  52734. layerMask: number;
  52735. /**
  52736. * Define the id of the lens flare system in the scene.
  52737. * (equal to name by default)
  52738. */
  52739. id: string;
  52740. private _scene;
  52741. private _emitter;
  52742. private _vertexBuffers;
  52743. private _indexBuffer;
  52744. private _effect;
  52745. private _positionX;
  52746. private _positionY;
  52747. private _isEnabled;
  52748. /** @hidden */
  52749. static _SceneComponentInitialization: (scene: Scene) => void;
  52750. /**
  52751. * Instantiates a lens flare system.
  52752. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52753. * It is usually composed of several `lensFlare`.
  52754. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52755. * @param name Define the name of the lens flare system in the scene
  52756. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52757. * @param scene Define the scene the lens flare system belongs to
  52758. */
  52759. constructor(
  52760. /**
  52761. * Define the name of the lens flare system
  52762. */
  52763. name: string, emitter: any, scene: Scene);
  52764. /**
  52765. * Define if the lens flare system is enabled.
  52766. */
  52767. isEnabled: boolean;
  52768. /**
  52769. * Get the scene the effects belongs to.
  52770. * @returns the scene holding the lens flare system
  52771. */
  52772. getScene(): Scene;
  52773. /**
  52774. * Get the emitter of the lens flare system.
  52775. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52776. * @returns the emitter of the lens flare system
  52777. */
  52778. getEmitter(): any;
  52779. /**
  52780. * Set the emitter of the lens flare system.
  52781. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52782. * @param newEmitter Define the new emitter of the system
  52783. */
  52784. setEmitter(newEmitter: any): void;
  52785. /**
  52786. * Get the lens flare system emitter position.
  52787. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52788. * @returns the position
  52789. */
  52790. getEmitterPosition(): Vector3;
  52791. /**
  52792. * @hidden
  52793. */
  52794. computeEffectivePosition(globalViewport: Viewport): boolean;
  52795. /** @hidden */
  52796. _isVisible(): boolean;
  52797. /**
  52798. * @hidden
  52799. */
  52800. render(): boolean;
  52801. /**
  52802. * Dispose and release the lens flare with its associated resources.
  52803. */
  52804. dispose(): void;
  52805. /**
  52806. * Parse a lens flare system from a JSON repressentation
  52807. * @param parsedLensFlareSystem Define the JSON to parse
  52808. * @param scene Define the scene the parsed system should be instantiated in
  52809. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52810. * @returns the parsed system
  52811. */
  52812. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52813. /**
  52814. * Serialize the current Lens Flare System into a JSON representation.
  52815. * @returns the serialized JSON
  52816. */
  52817. serialize(): any;
  52818. }
  52819. }
  52820. declare module "babylonjs/LensFlares/lensFlare" {
  52821. import { Nullable } from "babylonjs/types";
  52822. import { Color3 } from "babylonjs/Maths/math.color";
  52823. import { Texture } from "babylonjs/Materials/Textures/texture";
  52824. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52825. /**
  52826. * This represents one of the lens effect in a `lensFlareSystem`.
  52827. * It controls one of the indiviual texture used in the effect.
  52828. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52829. */
  52830. export class LensFlare {
  52831. /**
  52832. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52833. */
  52834. size: number;
  52835. /**
  52836. * 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.
  52837. */
  52838. position: number;
  52839. /**
  52840. * Define the lens color.
  52841. */
  52842. color: Color3;
  52843. /**
  52844. * Define the lens texture.
  52845. */
  52846. texture: Nullable<Texture>;
  52847. /**
  52848. * Define the alpha mode to render this particular lens.
  52849. */
  52850. alphaMode: number;
  52851. private _system;
  52852. /**
  52853. * Creates a new Lens Flare.
  52854. * This represents one of the lens effect in a `lensFlareSystem`.
  52855. * It controls one of the indiviual texture used in the effect.
  52856. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52857. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52858. * @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.
  52859. * @param color Define the lens color
  52860. * @param imgUrl Define the lens texture url
  52861. * @param system Define the `lensFlareSystem` this flare is part of
  52862. * @returns The newly created Lens Flare
  52863. */
  52864. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52865. /**
  52866. * Instantiates a new Lens Flare.
  52867. * This represents one of the lens effect in a `lensFlareSystem`.
  52868. * It controls one of the indiviual texture used in the effect.
  52869. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52870. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52871. * @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.
  52872. * @param color Define the lens color
  52873. * @param imgUrl Define the lens texture url
  52874. * @param system Define the `lensFlareSystem` this flare is part of
  52875. */
  52876. constructor(
  52877. /**
  52878. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52879. */
  52880. size: number,
  52881. /**
  52882. * 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.
  52883. */
  52884. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52885. /**
  52886. * Dispose and release the lens flare with its associated resources.
  52887. */
  52888. dispose(): void;
  52889. }
  52890. }
  52891. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52892. import { Nullable } from "babylonjs/types";
  52893. import { Scene } from "babylonjs/scene";
  52894. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52895. import { AbstractScene } from "babylonjs/abstractScene";
  52896. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52897. module "babylonjs/abstractScene" {
  52898. interface AbstractScene {
  52899. /**
  52900. * The list of lens flare system added to the scene
  52901. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52902. */
  52903. lensFlareSystems: Array<LensFlareSystem>;
  52904. /**
  52905. * Removes the given lens flare system from this scene.
  52906. * @param toRemove The lens flare system to remove
  52907. * @returns The index of the removed lens flare system
  52908. */
  52909. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52910. /**
  52911. * Adds the given lens flare system to this scene
  52912. * @param newLensFlareSystem The lens flare system to add
  52913. */
  52914. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52915. /**
  52916. * Gets a lens flare system using its name
  52917. * @param name defines the name to look for
  52918. * @returns the lens flare system or null if not found
  52919. */
  52920. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52921. /**
  52922. * Gets a lens flare system using its id
  52923. * @param id defines the id to look for
  52924. * @returns the lens flare system or null if not found
  52925. */
  52926. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52927. }
  52928. }
  52929. /**
  52930. * Defines the lens flare scene component responsible to manage any lens flares
  52931. * in a given scene.
  52932. */
  52933. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52934. /**
  52935. * The component name helpfull to identify the component in the list of scene components.
  52936. */
  52937. readonly name: string;
  52938. /**
  52939. * The scene the component belongs to.
  52940. */
  52941. scene: Scene;
  52942. /**
  52943. * Creates a new instance of the component for the given scene
  52944. * @param scene Defines the scene to register the component in
  52945. */
  52946. constructor(scene: Scene);
  52947. /**
  52948. * Registers the component in a given scene
  52949. */
  52950. register(): void;
  52951. /**
  52952. * Rebuilds the elements related to this component in case of
  52953. * context lost for instance.
  52954. */
  52955. rebuild(): void;
  52956. /**
  52957. * Adds all the elements from the container to the scene
  52958. * @param container the container holding the elements
  52959. */
  52960. addFromContainer(container: AbstractScene): void;
  52961. /**
  52962. * Removes all the elements in the container from the scene
  52963. * @param container contains the elements to remove
  52964. * @param dispose if the removed element should be disposed (default: false)
  52965. */
  52966. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52967. /**
  52968. * Serializes the component data to the specified json object
  52969. * @param serializationObject The object to serialize to
  52970. */
  52971. serialize(serializationObject: any): void;
  52972. /**
  52973. * Disposes the component and the associated ressources.
  52974. */
  52975. dispose(): void;
  52976. private _draw;
  52977. }
  52978. }
  52979. declare module "babylonjs/LensFlares/index" {
  52980. export * from "babylonjs/LensFlares/lensFlare";
  52981. export * from "babylonjs/LensFlares/lensFlareSystem";
  52982. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52983. }
  52984. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52985. import { Scene } from "babylonjs/scene";
  52986. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52987. import { AbstractScene } from "babylonjs/abstractScene";
  52988. /**
  52989. * Defines the shadow generator component responsible to manage any shadow generators
  52990. * in a given scene.
  52991. */
  52992. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52993. /**
  52994. * The component name helpfull to identify the component in the list of scene components.
  52995. */
  52996. readonly name: string;
  52997. /**
  52998. * The scene the component belongs to.
  52999. */
  53000. scene: Scene;
  53001. /**
  53002. * Creates a new instance of the component for the given scene
  53003. * @param scene Defines the scene to register the component in
  53004. */
  53005. constructor(scene: Scene);
  53006. /**
  53007. * Registers the component in a given scene
  53008. */
  53009. register(): void;
  53010. /**
  53011. * Rebuilds the elements related to this component in case of
  53012. * context lost for instance.
  53013. */
  53014. rebuild(): void;
  53015. /**
  53016. * Serializes the component data to the specified json object
  53017. * @param serializationObject The object to serialize to
  53018. */
  53019. serialize(serializationObject: any): void;
  53020. /**
  53021. * Adds all the elements from the container to the scene
  53022. * @param container the container holding the elements
  53023. */
  53024. addFromContainer(container: AbstractScene): void;
  53025. /**
  53026. * Removes all the elements in the container from the scene
  53027. * @param container contains the elements to remove
  53028. * @param dispose if the removed element should be disposed (default: false)
  53029. */
  53030. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53031. /**
  53032. * Rebuilds the elements related to this component in case of
  53033. * context lost for instance.
  53034. */
  53035. dispose(): void;
  53036. private _gatherRenderTargets;
  53037. }
  53038. }
  53039. declare module "babylonjs/Lights/Shadows/index" {
  53040. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53041. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53042. }
  53043. declare module "babylonjs/Lights/pointLight" {
  53044. import { Scene } from "babylonjs/scene";
  53045. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53047. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53048. import { Effect } from "babylonjs/Materials/effect";
  53049. /**
  53050. * A point light is a light defined by an unique point in world space.
  53051. * The light is emitted in every direction from this point.
  53052. * A good example of a point light is a standard light bulb.
  53053. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53054. */
  53055. export class PointLight extends ShadowLight {
  53056. private _shadowAngle;
  53057. /**
  53058. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53059. * This specifies what angle the shadow will use to be created.
  53060. *
  53061. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53062. */
  53063. /**
  53064. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53065. * This specifies what angle the shadow will use to be created.
  53066. *
  53067. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53068. */
  53069. shadowAngle: number;
  53070. /**
  53071. * Gets the direction if it has been set.
  53072. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53073. */
  53074. /**
  53075. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53076. */
  53077. direction: Vector3;
  53078. /**
  53079. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53080. * A PointLight emits the light in every direction.
  53081. * It can cast shadows.
  53082. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53083. * ```javascript
  53084. * var pointLight = new PointLight("pl", camera.position, scene);
  53085. * ```
  53086. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53087. * @param name The light friendly name
  53088. * @param position The position of the point light in the scene
  53089. * @param scene The scene the lights belongs to
  53090. */
  53091. constructor(name: string, position: Vector3, scene: Scene);
  53092. /**
  53093. * Returns the string "PointLight"
  53094. * @returns the class name
  53095. */
  53096. getClassName(): string;
  53097. /**
  53098. * Returns the integer 0.
  53099. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53100. */
  53101. getTypeID(): number;
  53102. /**
  53103. * Specifies wether or not the shadowmap should be a cube texture.
  53104. * @returns true if the shadowmap needs to be a cube texture.
  53105. */
  53106. needCube(): boolean;
  53107. /**
  53108. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53109. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53110. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53111. */
  53112. getShadowDirection(faceIndex?: number): Vector3;
  53113. /**
  53114. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53115. * - fov = PI / 2
  53116. * - aspect ratio : 1.0
  53117. * - z-near and far equal to the active camera minZ and maxZ.
  53118. * Returns the PointLight.
  53119. */
  53120. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53121. protected _buildUniformLayout(): void;
  53122. /**
  53123. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53124. * @param effect The effect to update
  53125. * @param lightIndex The index of the light in the effect to update
  53126. * @returns The point light
  53127. */
  53128. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53129. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53130. /**
  53131. * Prepares the list of defines specific to the light type.
  53132. * @param defines the list of defines
  53133. * @param lightIndex defines the index of the light for the effect
  53134. */
  53135. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53136. }
  53137. }
  53138. declare module "babylonjs/Lights/index" {
  53139. export * from "babylonjs/Lights/light";
  53140. export * from "babylonjs/Lights/shadowLight";
  53141. export * from "babylonjs/Lights/Shadows/index";
  53142. export * from "babylonjs/Lights/directionalLight";
  53143. export * from "babylonjs/Lights/hemisphericLight";
  53144. export * from "babylonjs/Lights/pointLight";
  53145. export * from "babylonjs/Lights/spotLight";
  53146. }
  53147. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53148. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53149. /**
  53150. * Header information of HDR texture files.
  53151. */
  53152. export interface HDRInfo {
  53153. /**
  53154. * The height of the texture in pixels.
  53155. */
  53156. height: number;
  53157. /**
  53158. * The width of the texture in pixels.
  53159. */
  53160. width: number;
  53161. /**
  53162. * The index of the beginning of the data in the binary file.
  53163. */
  53164. dataPosition: number;
  53165. }
  53166. /**
  53167. * This groups tools to convert HDR texture to native colors array.
  53168. */
  53169. export class HDRTools {
  53170. private static Ldexp;
  53171. private static Rgbe2float;
  53172. private static readStringLine;
  53173. /**
  53174. * Reads header information from an RGBE texture stored in a native array.
  53175. * More information on this format are available here:
  53176. * https://en.wikipedia.org/wiki/RGBE_image_format
  53177. *
  53178. * @param uint8array The binary file stored in native array.
  53179. * @return The header information.
  53180. */
  53181. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53182. /**
  53183. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53184. * This RGBE texture needs to store the information as a panorama.
  53185. *
  53186. * More information on this format are available here:
  53187. * https://en.wikipedia.org/wiki/RGBE_image_format
  53188. *
  53189. * @param buffer The binary file stored in an array buffer.
  53190. * @param size The expected size of the extracted cubemap.
  53191. * @return The Cube Map information.
  53192. */
  53193. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53194. /**
  53195. * Returns the pixels data extracted from an RGBE texture.
  53196. * This pixels will be stored left to right up to down in the R G B order in one array.
  53197. *
  53198. * More information on this format are available here:
  53199. * https://en.wikipedia.org/wiki/RGBE_image_format
  53200. *
  53201. * @param uint8array The binary file stored in an array buffer.
  53202. * @param hdrInfo The header information of the file.
  53203. * @return The pixels data in RGB right to left up to down order.
  53204. */
  53205. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53206. private static RGBE_ReadPixels_RLE;
  53207. }
  53208. }
  53209. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53210. import { Nullable } from "babylonjs/types";
  53211. import { Scene } from "babylonjs/scene";
  53212. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53214. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53215. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53216. /**
  53217. * This represents a texture coming from an HDR input.
  53218. *
  53219. * The only supported format is currently panorama picture stored in RGBE format.
  53220. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53221. */
  53222. export class HDRCubeTexture extends BaseTexture {
  53223. private static _facesMapping;
  53224. private _generateHarmonics;
  53225. private _noMipmap;
  53226. private _textureMatrix;
  53227. private _size;
  53228. private _onLoad;
  53229. private _onError;
  53230. /**
  53231. * The texture URL.
  53232. */
  53233. url: string;
  53234. /**
  53235. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53236. */
  53237. coordinatesMode: number;
  53238. protected _isBlocking: boolean;
  53239. /**
  53240. * Sets wether or not the texture is blocking during loading.
  53241. */
  53242. /**
  53243. * Gets wether or not the texture is blocking during loading.
  53244. */
  53245. isBlocking: boolean;
  53246. protected _rotationY: number;
  53247. /**
  53248. * Sets texture matrix rotation angle around Y axis in radians.
  53249. */
  53250. /**
  53251. * Gets texture matrix rotation angle around Y axis radians.
  53252. */
  53253. rotationY: number;
  53254. /**
  53255. * Gets or sets the center of the bounding box associated with the cube texture
  53256. * It must define where the camera used to render the texture was set
  53257. */
  53258. boundingBoxPosition: Vector3;
  53259. private _boundingBoxSize;
  53260. /**
  53261. * Gets or sets the size of the bounding box associated with the cube texture
  53262. * When defined, the cubemap will switch to local mode
  53263. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53264. * @example https://www.babylonjs-playground.com/#RNASML
  53265. */
  53266. boundingBoxSize: Vector3;
  53267. /**
  53268. * Instantiates an HDRTexture from the following parameters.
  53269. *
  53270. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53271. * @param scene The scene the texture will be used in
  53272. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53273. * @param noMipmap Forces to not generate the mipmap if true
  53274. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53275. * @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)
  53276. * @param reserved Reserved flag for internal use.
  53277. */
  53278. 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>);
  53279. /**
  53280. * Get the current class name of the texture useful for serialization or dynamic coding.
  53281. * @returns "HDRCubeTexture"
  53282. */
  53283. getClassName(): string;
  53284. /**
  53285. * Occurs when the file is raw .hdr file.
  53286. */
  53287. private loadTexture;
  53288. clone(): HDRCubeTexture;
  53289. delayLoad(): void;
  53290. /**
  53291. * Get the texture reflection matrix used to rotate/transform the reflection.
  53292. * @returns the reflection matrix
  53293. */
  53294. getReflectionTextureMatrix(): Matrix;
  53295. /**
  53296. * Set the texture reflection matrix used to rotate/transform the reflection.
  53297. * @param value Define the reflection matrix to set
  53298. */
  53299. setReflectionTextureMatrix(value: Matrix): void;
  53300. /**
  53301. * Parses a JSON representation of an HDR Texture in order to create the texture
  53302. * @param parsedTexture Define the JSON representation
  53303. * @param scene Define the scene the texture should be created in
  53304. * @param rootUrl Define the root url in case we need to load relative dependencies
  53305. * @returns the newly created texture after parsing
  53306. */
  53307. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53308. serialize(): any;
  53309. }
  53310. }
  53311. declare module "babylonjs/Physics/physicsEngine" {
  53312. import { Nullable } from "babylonjs/types";
  53313. import { Vector3 } from "babylonjs/Maths/math.vector";
  53314. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53315. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53316. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53317. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53318. /**
  53319. * Class used to control physics engine
  53320. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53321. */
  53322. export class PhysicsEngine implements IPhysicsEngine {
  53323. private _physicsPlugin;
  53324. /**
  53325. * Global value used to control the smallest number supported by the simulation
  53326. */
  53327. static Epsilon: number;
  53328. private _impostors;
  53329. private _joints;
  53330. /**
  53331. * Gets the gravity vector used by the simulation
  53332. */
  53333. gravity: Vector3;
  53334. /**
  53335. * Factory used to create the default physics plugin.
  53336. * @returns The default physics plugin
  53337. */
  53338. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53339. /**
  53340. * Creates a new Physics Engine
  53341. * @param gravity defines the gravity vector used by the simulation
  53342. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53343. */
  53344. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53345. /**
  53346. * Sets the gravity vector used by the simulation
  53347. * @param gravity defines the gravity vector to use
  53348. */
  53349. setGravity(gravity: Vector3): void;
  53350. /**
  53351. * Set the time step of the physics engine.
  53352. * Default is 1/60.
  53353. * To slow it down, enter 1/600 for example.
  53354. * To speed it up, 1/30
  53355. * @param newTimeStep defines the new timestep to apply to this world.
  53356. */
  53357. setTimeStep(newTimeStep?: number): void;
  53358. /**
  53359. * Get the time step of the physics engine.
  53360. * @returns the current time step
  53361. */
  53362. getTimeStep(): number;
  53363. /**
  53364. * Release all resources
  53365. */
  53366. dispose(): void;
  53367. /**
  53368. * Gets the name of the current physics plugin
  53369. * @returns the name of the plugin
  53370. */
  53371. getPhysicsPluginName(): string;
  53372. /**
  53373. * Adding a new impostor for the impostor tracking.
  53374. * This will be done by the impostor itself.
  53375. * @param impostor the impostor to add
  53376. */
  53377. addImpostor(impostor: PhysicsImpostor): void;
  53378. /**
  53379. * Remove an impostor from the engine.
  53380. * This impostor and its mesh will not longer be updated by the physics engine.
  53381. * @param impostor the impostor to remove
  53382. */
  53383. removeImpostor(impostor: PhysicsImpostor): void;
  53384. /**
  53385. * Add a joint to the physics engine
  53386. * @param mainImpostor defines the main impostor to which the joint is added.
  53387. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53388. * @param joint defines the joint that will connect both impostors.
  53389. */
  53390. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53391. /**
  53392. * Removes a joint from the simulation
  53393. * @param mainImpostor defines the impostor used with the joint
  53394. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53395. * @param joint defines the joint to remove
  53396. */
  53397. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53398. /**
  53399. * Called by the scene. No need to call it.
  53400. * @param delta defines the timespam between frames
  53401. */
  53402. _step(delta: number): void;
  53403. /**
  53404. * Gets the current plugin used to run the simulation
  53405. * @returns current plugin
  53406. */
  53407. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53408. /**
  53409. * Gets the list of physic impostors
  53410. * @returns an array of PhysicsImpostor
  53411. */
  53412. getImpostors(): Array<PhysicsImpostor>;
  53413. /**
  53414. * Gets the impostor for a physics enabled object
  53415. * @param object defines the object impersonated by the impostor
  53416. * @returns the PhysicsImpostor or null if not found
  53417. */
  53418. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53419. /**
  53420. * Gets the impostor for a physics body object
  53421. * @param body defines physics body used by the impostor
  53422. * @returns the PhysicsImpostor or null if not found
  53423. */
  53424. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53425. /**
  53426. * Does a raycast in the physics world
  53427. * @param from when should the ray start?
  53428. * @param to when should the ray end?
  53429. * @returns PhysicsRaycastResult
  53430. */
  53431. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53432. }
  53433. }
  53434. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53435. import { Nullable } from "babylonjs/types";
  53436. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53438. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53439. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53440. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53441. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53442. /** @hidden */
  53443. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53444. private _useDeltaForWorldStep;
  53445. world: any;
  53446. name: string;
  53447. private _physicsMaterials;
  53448. private _fixedTimeStep;
  53449. private _cannonRaycastResult;
  53450. private _raycastResult;
  53451. private _physicsBodysToRemoveAfterStep;
  53452. BJSCANNON: any;
  53453. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53454. setGravity(gravity: Vector3): void;
  53455. setTimeStep(timeStep: number): void;
  53456. getTimeStep(): number;
  53457. executeStep(delta: number): void;
  53458. private _removeMarkedPhysicsBodiesFromWorld;
  53459. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53460. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53461. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53462. private _processChildMeshes;
  53463. removePhysicsBody(impostor: PhysicsImpostor): void;
  53464. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53465. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53466. private _addMaterial;
  53467. private _checkWithEpsilon;
  53468. private _createShape;
  53469. private _createHeightmap;
  53470. private _minus90X;
  53471. private _plus90X;
  53472. private _tmpPosition;
  53473. private _tmpDeltaPosition;
  53474. private _tmpUnityRotation;
  53475. private _updatePhysicsBodyTransformation;
  53476. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53477. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53478. isSupported(): boolean;
  53479. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53480. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53481. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53482. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53483. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53484. getBodyMass(impostor: PhysicsImpostor): number;
  53485. getBodyFriction(impostor: PhysicsImpostor): number;
  53486. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53487. getBodyRestitution(impostor: PhysicsImpostor): number;
  53488. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53489. sleepBody(impostor: PhysicsImpostor): void;
  53490. wakeUpBody(impostor: PhysicsImpostor): void;
  53491. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53492. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53493. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53494. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53495. getRadius(impostor: PhysicsImpostor): number;
  53496. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53497. dispose(): void;
  53498. private _extendNamespace;
  53499. /**
  53500. * Does a raycast in the physics world
  53501. * @param from when should the ray start?
  53502. * @param to when should the ray end?
  53503. * @returns PhysicsRaycastResult
  53504. */
  53505. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53506. }
  53507. }
  53508. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53509. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53510. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53511. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53513. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53514. import { Nullable } from "babylonjs/types";
  53515. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53516. /** @hidden */
  53517. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53518. world: any;
  53519. name: string;
  53520. BJSOIMO: any;
  53521. private _raycastResult;
  53522. constructor(iterations?: number, oimoInjection?: any);
  53523. setGravity(gravity: Vector3): void;
  53524. setTimeStep(timeStep: number): void;
  53525. getTimeStep(): number;
  53526. private _tmpImpostorsArray;
  53527. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53528. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53529. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53530. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53531. private _tmpPositionVector;
  53532. removePhysicsBody(impostor: PhysicsImpostor): void;
  53533. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53534. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53535. isSupported(): boolean;
  53536. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53537. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53538. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53539. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53540. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53541. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53542. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53543. getBodyMass(impostor: PhysicsImpostor): number;
  53544. getBodyFriction(impostor: PhysicsImpostor): number;
  53545. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53546. getBodyRestitution(impostor: PhysicsImpostor): number;
  53547. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53548. sleepBody(impostor: PhysicsImpostor): void;
  53549. wakeUpBody(impostor: PhysicsImpostor): void;
  53550. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53551. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53552. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53553. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53554. getRadius(impostor: PhysicsImpostor): number;
  53555. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53556. dispose(): void;
  53557. /**
  53558. * Does a raycast in the physics world
  53559. * @param from when should the ray start?
  53560. * @param to when should the ray end?
  53561. * @returns PhysicsRaycastResult
  53562. */
  53563. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53564. }
  53565. }
  53566. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53567. import { Nullable } from "babylonjs/types";
  53568. import { Scene } from "babylonjs/scene";
  53569. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53570. import { Color4 } from "babylonjs/Maths/math.color";
  53571. import { Mesh } from "babylonjs/Meshes/mesh";
  53572. /**
  53573. * Class containing static functions to help procedurally build meshes
  53574. */
  53575. export class RibbonBuilder {
  53576. /**
  53577. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53578. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53579. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53580. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53581. * * 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
  53582. * * 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
  53583. * * 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
  53584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53587. * * 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
  53588. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53589. * * 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
  53590. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53592. * @param name defines the name of the mesh
  53593. * @param options defines the options used to create the mesh
  53594. * @param scene defines the hosting scene
  53595. * @returns the ribbon mesh
  53596. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53597. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53598. */
  53599. static CreateRibbon(name: string, options: {
  53600. pathArray: Vector3[][];
  53601. closeArray?: boolean;
  53602. closePath?: boolean;
  53603. offset?: number;
  53604. updatable?: boolean;
  53605. sideOrientation?: number;
  53606. frontUVs?: Vector4;
  53607. backUVs?: Vector4;
  53608. instance?: Mesh;
  53609. invertUV?: boolean;
  53610. uvs?: Vector2[];
  53611. colors?: Color4[];
  53612. }, scene?: Nullable<Scene>): Mesh;
  53613. }
  53614. }
  53615. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53616. import { Nullable } from "babylonjs/types";
  53617. import { Scene } from "babylonjs/scene";
  53618. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53619. import { Mesh } from "babylonjs/Meshes/mesh";
  53620. /**
  53621. * Class containing static functions to help procedurally build meshes
  53622. */
  53623. export class ShapeBuilder {
  53624. /**
  53625. * 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.
  53626. * * 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.
  53627. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53628. * * 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.
  53629. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53630. * * 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
  53631. * * 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
  53632. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53634. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53635. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53637. * @param name defines the name of the mesh
  53638. * @param options defines the options used to create the mesh
  53639. * @param scene defines the hosting scene
  53640. * @returns the extruded shape mesh
  53641. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53643. */
  53644. static ExtrudeShape(name: string, options: {
  53645. shape: Vector3[];
  53646. path: Vector3[];
  53647. scale?: number;
  53648. rotation?: number;
  53649. cap?: number;
  53650. updatable?: boolean;
  53651. sideOrientation?: number;
  53652. frontUVs?: Vector4;
  53653. backUVs?: Vector4;
  53654. instance?: Mesh;
  53655. invertUV?: boolean;
  53656. }, scene?: Nullable<Scene>): Mesh;
  53657. /**
  53658. * Creates an custom extruded shape mesh.
  53659. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53660. * * 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.
  53661. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53662. * * 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
  53663. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53664. * * 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
  53665. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53666. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53667. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53668. * * 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
  53669. * * 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
  53670. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53673. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53675. * @param name defines the name of the mesh
  53676. * @param options defines the options used to create the mesh
  53677. * @param scene defines the hosting scene
  53678. * @returns the custom extruded shape mesh
  53679. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53680. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53681. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53682. */
  53683. static ExtrudeShapeCustom(name: string, options: {
  53684. shape: Vector3[];
  53685. path: Vector3[];
  53686. scaleFunction?: any;
  53687. rotationFunction?: any;
  53688. ribbonCloseArray?: boolean;
  53689. ribbonClosePath?: boolean;
  53690. cap?: number;
  53691. updatable?: boolean;
  53692. sideOrientation?: number;
  53693. frontUVs?: Vector4;
  53694. backUVs?: Vector4;
  53695. instance?: Mesh;
  53696. invertUV?: boolean;
  53697. }, scene?: Nullable<Scene>): Mesh;
  53698. private static _ExtrudeShapeGeneric;
  53699. }
  53700. }
  53701. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53702. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53703. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53704. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53705. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53706. import { Nullable } from "babylonjs/types";
  53707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53708. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53709. /**
  53710. * AmmoJS Physics plugin
  53711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53712. * @see https://github.com/kripken/ammo.js/
  53713. */
  53714. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53715. private _useDeltaForWorldStep;
  53716. /**
  53717. * Reference to the Ammo library
  53718. */
  53719. bjsAMMO: any;
  53720. /**
  53721. * Created ammoJS world which physics bodies are added to
  53722. */
  53723. world: any;
  53724. /**
  53725. * Name of the plugin
  53726. */
  53727. name: string;
  53728. private _timeStep;
  53729. private _fixedTimeStep;
  53730. private _maxSteps;
  53731. private _tmpQuaternion;
  53732. private _tmpAmmoTransform;
  53733. private _tmpAmmoQuaternion;
  53734. private _tmpAmmoConcreteContactResultCallback;
  53735. private _collisionConfiguration;
  53736. private _dispatcher;
  53737. private _overlappingPairCache;
  53738. private _solver;
  53739. private _softBodySolver;
  53740. private _tmpAmmoVectorA;
  53741. private _tmpAmmoVectorB;
  53742. private _tmpAmmoVectorC;
  53743. private _tmpAmmoVectorD;
  53744. private _tmpContactCallbackResult;
  53745. private _tmpAmmoVectorRCA;
  53746. private _tmpAmmoVectorRCB;
  53747. private _raycastResult;
  53748. private static readonly DISABLE_COLLISION_FLAG;
  53749. private static readonly KINEMATIC_FLAG;
  53750. private static readonly DISABLE_DEACTIVATION_FLAG;
  53751. /**
  53752. * Initializes the ammoJS plugin
  53753. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53754. * @param ammoInjection can be used to inject your own ammo reference
  53755. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53756. */
  53757. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53758. /**
  53759. * Sets the gravity of the physics world (m/(s^2))
  53760. * @param gravity Gravity to set
  53761. */
  53762. setGravity(gravity: Vector3): void;
  53763. /**
  53764. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53765. * @param timeStep timestep to use in seconds
  53766. */
  53767. setTimeStep(timeStep: number): void;
  53768. /**
  53769. * 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)
  53770. * @param fixedTimeStep fixedTimeStep to use in seconds
  53771. */
  53772. setFixedTimeStep(fixedTimeStep: number): void;
  53773. /**
  53774. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53775. * @param maxSteps the maximum number of steps by the physics engine per frame
  53776. */
  53777. setMaxSteps(maxSteps: number): void;
  53778. /**
  53779. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53780. * @returns the current timestep in seconds
  53781. */
  53782. getTimeStep(): number;
  53783. private _isImpostorInContact;
  53784. private _isImpostorPairInContact;
  53785. private _stepSimulation;
  53786. /**
  53787. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53788. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53789. * After the step the babylon meshes are set to the position of the physics imposters
  53790. * @param delta amount of time to step forward
  53791. * @param impostors array of imposters to update before/after the step
  53792. */
  53793. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53794. /**
  53795. * Update babylon mesh to match physics world object
  53796. * @param impostor imposter to match
  53797. */
  53798. private _afterSoftStep;
  53799. /**
  53800. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53801. * @param impostor imposter to match
  53802. */
  53803. private _ropeStep;
  53804. /**
  53805. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53806. * @param impostor imposter to match
  53807. */
  53808. private _softbodyOrClothStep;
  53809. private _tmpVector;
  53810. private _tmpMatrix;
  53811. /**
  53812. * Applies an impulse on the imposter
  53813. * @param impostor imposter to apply impulse to
  53814. * @param force amount of force to be applied to the imposter
  53815. * @param contactPoint the location to apply the impulse on the imposter
  53816. */
  53817. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53818. /**
  53819. * Applies a force on the imposter
  53820. * @param impostor imposter to apply force
  53821. * @param force amount of force to be applied to the imposter
  53822. * @param contactPoint the location to apply the force on the imposter
  53823. */
  53824. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53825. /**
  53826. * Creates a physics body using the plugin
  53827. * @param impostor the imposter to create the physics body on
  53828. */
  53829. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53830. /**
  53831. * Removes the physics body from the imposter and disposes of the body's memory
  53832. * @param impostor imposter to remove the physics body from
  53833. */
  53834. removePhysicsBody(impostor: PhysicsImpostor): void;
  53835. /**
  53836. * Generates a joint
  53837. * @param impostorJoint the imposter joint to create the joint with
  53838. */
  53839. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53840. /**
  53841. * Removes a joint
  53842. * @param impostorJoint the imposter joint to remove the joint from
  53843. */
  53844. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53845. private _addMeshVerts;
  53846. /**
  53847. * Initialise the soft body vertices to match its object's (mesh) vertices
  53848. * Softbody vertices (nodes) are in world space and to match this
  53849. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53850. * @param impostor to create the softbody for
  53851. */
  53852. private _softVertexData;
  53853. /**
  53854. * Create an impostor's soft body
  53855. * @param impostor to create the softbody for
  53856. */
  53857. private _createSoftbody;
  53858. /**
  53859. * Create cloth for an impostor
  53860. * @param impostor to create the softbody for
  53861. */
  53862. private _createCloth;
  53863. /**
  53864. * Create rope for an impostor
  53865. * @param impostor to create the softbody for
  53866. */
  53867. private _createRope;
  53868. private _addHullVerts;
  53869. private _createShape;
  53870. /**
  53871. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53872. * @param impostor imposter containing the physics body and babylon object
  53873. */
  53874. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53875. /**
  53876. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53877. * @param impostor imposter containing the physics body and babylon object
  53878. * @param newPosition new position
  53879. * @param newRotation new rotation
  53880. */
  53881. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53882. /**
  53883. * If this plugin is supported
  53884. * @returns true if its supported
  53885. */
  53886. isSupported(): boolean;
  53887. /**
  53888. * Sets the linear velocity of the physics body
  53889. * @param impostor imposter to set the velocity on
  53890. * @param velocity velocity to set
  53891. */
  53892. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53893. /**
  53894. * Sets the angular velocity of the physics body
  53895. * @param impostor imposter to set the velocity on
  53896. * @param velocity velocity to set
  53897. */
  53898. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53899. /**
  53900. * gets the linear velocity
  53901. * @param impostor imposter to get linear velocity from
  53902. * @returns linear velocity
  53903. */
  53904. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53905. /**
  53906. * gets the angular velocity
  53907. * @param impostor imposter to get angular velocity from
  53908. * @returns angular velocity
  53909. */
  53910. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53911. /**
  53912. * Sets the mass of physics body
  53913. * @param impostor imposter to set the mass on
  53914. * @param mass mass to set
  53915. */
  53916. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53917. /**
  53918. * Gets the mass of the physics body
  53919. * @param impostor imposter to get the mass from
  53920. * @returns mass
  53921. */
  53922. getBodyMass(impostor: PhysicsImpostor): number;
  53923. /**
  53924. * Gets friction of the impostor
  53925. * @param impostor impostor to get friction from
  53926. * @returns friction value
  53927. */
  53928. getBodyFriction(impostor: PhysicsImpostor): number;
  53929. /**
  53930. * Sets friction of the impostor
  53931. * @param impostor impostor to set friction on
  53932. * @param friction friction value
  53933. */
  53934. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53935. /**
  53936. * Gets restitution of the impostor
  53937. * @param impostor impostor to get restitution from
  53938. * @returns restitution value
  53939. */
  53940. getBodyRestitution(impostor: PhysicsImpostor): number;
  53941. /**
  53942. * Sets resitution of the impostor
  53943. * @param impostor impostor to set resitution on
  53944. * @param restitution resitution value
  53945. */
  53946. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53947. /**
  53948. * Gets pressure inside the impostor
  53949. * @param impostor impostor to get pressure from
  53950. * @returns pressure value
  53951. */
  53952. getBodyPressure(impostor: PhysicsImpostor): number;
  53953. /**
  53954. * Sets pressure inside a soft body impostor
  53955. * Cloth and rope must remain 0 pressure
  53956. * @param impostor impostor to set pressure on
  53957. * @param pressure pressure value
  53958. */
  53959. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53960. /**
  53961. * Gets stiffness of the impostor
  53962. * @param impostor impostor to get stiffness from
  53963. * @returns pressure value
  53964. */
  53965. getBodyStiffness(impostor: PhysicsImpostor): number;
  53966. /**
  53967. * Sets stiffness of the impostor
  53968. * @param impostor impostor to set stiffness on
  53969. * @param stiffness stiffness value from 0 to 1
  53970. */
  53971. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53972. /**
  53973. * Gets velocityIterations of the impostor
  53974. * @param impostor impostor to get velocity iterations from
  53975. * @returns velocityIterations value
  53976. */
  53977. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53978. /**
  53979. * Sets velocityIterations of the impostor
  53980. * @param impostor impostor to set velocity iterations on
  53981. * @param velocityIterations velocityIterations value
  53982. */
  53983. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53984. /**
  53985. * Gets positionIterations of the impostor
  53986. * @param impostor impostor to get position iterations from
  53987. * @returns positionIterations value
  53988. */
  53989. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53990. /**
  53991. * Sets positionIterations of the impostor
  53992. * @param impostor impostor to set position on
  53993. * @param positionIterations positionIterations value
  53994. */
  53995. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53996. /**
  53997. * Append an anchor to a cloth object
  53998. * @param impostor is the cloth impostor to add anchor to
  53999. * @param otherImpostor is the rigid impostor to anchor to
  54000. * @param width ratio across width from 0 to 1
  54001. * @param height ratio up height from 0 to 1
  54002. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54003. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54004. */
  54005. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54006. /**
  54007. * Append an hook to a rope object
  54008. * @param impostor is the rope impostor to add hook to
  54009. * @param otherImpostor is the rigid impostor to hook to
  54010. * @param length ratio along the rope from 0 to 1
  54011. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54012. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54013. */
  54014. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54015. /**
  54016. * Sleeps the physics body and stops it from being active
  54017. * @param impostor impostor to sleep
  54018. */
  54019. sleepBody(impostor: PhysicsImpostor): void;
  54020. /**
  54021. * Activates the physics body
  54022. * @param impostor impostor to activate
  54023. */
  54024. wakeUpBody(impostor: PhysicsImpostor): void;
  54025. /**
  54026. * Updates the distance parameters of the joint
  54027. * @param joint joint to update
  54028. * @param maxDistance maximum distance of the joint
  54029. * @param minDistance minimum distance of the joint
  54030. */
  54031. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54032. /**
  54033. * Sets a motor on the joint
  54034. * @param joint joint to set motor on
  54035. * @param speed speed of the motor
  54036. * @param maxForce maximum force of the motor
  54037. * @param motorIndex index of the motor
  54038. */
  54039. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54040. /**
  54041. * Sets the motors limit
  54042. * @param joint joint to set limit on
  54043. * @param upperLimit upper limit
  54044. * @param lowerLimit lower limit
  54045. */
  54046. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54047. /**
  54048. * Syncs the position and rotation of a mesh with the impostor
  54049. * @param mesh mesh to sync
  54050. * @param impostor impostor to update the mesh with
  54051. */
  54052. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54053. /**
  54054. * Gets the radius of the impostor
  54055. * @param impostor impostor to get radius from
  54056. * @returns the radius
  54057. */
  54058. getRadius(impostor: PhysicsImpostor): number;
  54059. /**
  54060. * Gets the box size of the impostor
  54061. * @param impostor impostor to get box size from
  54062. * @param result the resulting box size
  54063. */
  54064. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54065. /**
  54066. * Disposes of the impostor
  54067. */
  54068. dispose(): void;
  54069. /**
  54070. * Does a raycast in the physics world
  54071. * @param from when should the ray start?
  54072. * @param to when should the ray end?
  54073. * @returns PhysicsRaycastResult
  54074. */
  54075. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54076. }
  54077. }
  54078. declare module "babylonjs/Probes/reflectionProbe" {
  54079. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54080. import { Vector3 } from "babylonjs/Maths/math.vector";
  54081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54082. import { Nullable } from "babylonjs/types";
  54083. import { Scene } from "babylonjs/scene";
  54084. module "babylonjs/abstractScene" {
  54085. interface AbstractScene {
  54086. /**
  54087. * The list of reflection probes added to the scene
  54088. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54089. */
  54090. reflectionProbes: Array<ReflectionProbe>;
  54091. /**
  54092. * Removes the given reflection probe from this scene.
  54093. * @param toRemove The reflection probe to remove
  54094. * @returns The index of the removed reflection probe
  54095. */
  54096. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54097. /**
  54098. * Adds the given reflection probe to this scene.
  54099. * @param newReflectionProbe The reflection probe to add
  54100. */
  54101. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54102. }
  54103. }
  54104. /**
  54105. * Class used to generate realtime reflection / refraction cube textures
  54106. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54107. */
  54108. export class ReflectionProbe {
  54109. /** defines the name of the probe */
  54110. name: string;
  54111. private _scene;
  54112. private _renderTargetTexture;
  54113. private _projectionMatrix;
  54114. private _viewMatrix;
  54115. private _target;
  54116. private _add;
  54117. private _attachedMesh;
  54118. private _invertYAxis;
  54119. /** Gets or sets probe position (center of the cube map) */
  54120. position: Vector3;
  54121. /**
  54122. * Creates a new reflection probe
  54123. * @param name defines the name of the probe
  54124. * @param size defines the texture resolution (for each face)
  54125. * @param scene defines the hosting scene
  54126. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54127. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54128. */
  54129. constructor(
  54130. /** defines the name of the probe */
  54131. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54132. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54133. samples: number;
  54134. /** Gets or sets the refresh rate to use (on every frame by default) */
  54135. refreshRate: number;
  54136. /**
  54137. * Gets the hosting scene
  54138. * @returns a Scene
  54139. */
  54140. getScene(): Scene;
  54141. /** Gets the internal CubeTexture used to render to */
  54142. readonly cubeTexture: RenderTargetTexture;
  54143. /** Gets the list of meshes to render */
  54144. readonly renderList: Nullable<AbstractMesh[]>;
  54145. /**
  54146. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54147. * @param mesh defines the mesh to attach to
  54148. */
  54149. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54150. /**
  54151. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54152. * @param renderingGroupId The rendering group id corresponding to its index
  54153. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54154. */
  54155. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54156. /**
  54157. * Clean all associated resources
  54158. */
  54159. dispose(): void;
  54160. /**
  54161. * Converts the reflection probe information to a readable string for debug purpose.
  54162. * @param fullDetails Supports for multiple levels of logging within scene loading
  54163. * @returns the human readable reflection probe info
  54164. */
  54165. toString(fullDetails?: boolean): string;
  54166. /**
  54167. * Get the class name of the relfection probe.
  54168. * @returns "ReflectionProbe"
  54169. */
  54170. getClassName(): string;
  54171. /**
  54172. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54173. * @returns The JSON representation of the texture
  54174. */
  54175. serialize(): any;
  54176. /**
  54177. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54178. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54179. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54180. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54181. * @returns The parsed reflection probe if successful
  54182. */
  54183. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54184. }
  54185. }
  54186. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54187. /** @hidden */
  54188. export var _BabylonLoaderRegistered: boolean;
  54189. }
  54190. declare module "babylonjs/Loading/Plugins/index" {
  54191. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54192. }
  54193. declare module "babylonjs/Loading/index" {
  54194. export * from "babylonjs/Loading/loadingScreen";
  54195. export * from "babylonjs/Loading/Plugins/index";
  54196. export * from "babylonjs/Loading/sceneLoader";
  54197. export * from "babylonjs/Loading/sceneLoaderFlags";
  54198. }
  54199. declare module "babylonjs/Materials/Background/index" {
  54200. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54201. }
  54202. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54203. import { Scene } from "babylonjs/scene";
  54204. import { Color3 } from "babylonjs/Maths/math.color";
  54205. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54207. /**
  54208. * The Physically based simple base material of BJS.
  54209. *
  54210. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54211. * It is used as the base class for both the specGloss and metalRough conventions.
  54212. */
  54213. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54214. /**
  54215. * Number of Simultaneous lights allowed on the material.
  54216. */
  54217. maxSimultaneousLights: number;
  54218. /**
  54219. * If sets to true, disables all the lights affecting the material.
  54220. */
  54221. disableLighting: boolean;
  54222. /**
  54223. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54224. */
  54225. environmentTexture: BaseTexture;
  54226. /**
  54227. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54228. */
  54229. invertNormalMapX: boolean;
  54230. /**
  54231. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54232. */
  54233. invertNormalMapY: boolean;
  54234. /**
  54235. * Normal map used in the model.
  54236. */
  54237. normalTexture: BaseTexture;
  54238. /**
  54239. * Emissivie color used to self-illuminate the model.
  54240. */
  54241. emissiveColor: Color3;
  54242. /**
  54243. * Emissivie texture used to self-illuminate the model.
  54244. */
  54245. emissiveTexture: BaseTexture;
  54246. /**
  54247. * Occlusion Channel Strenght.
  54248. */
  54249. occlusionStrength: number;
  54250. /**
  54251. * Occlusion Texture of the material (adding extra occlusion effects).
  54252. */
  54253. occlusionTexture: BaseTexture;
  54254. /**
  54255. * Defines the alpha limits in alpha test mode.
  54256. */
  54257. alphaCutOff: number;
  54258. /**
  54259. * Gets the current double sided mode.
  54260. */
  54261. /**
  54262. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54263. */
  54264. doubleSided: boolean;
  54265. /**
  54266. * Stores the pre-calculated light information of a mesh in a texture.
  54267. */
  54268. lightmapTexture: BaseTexture;
  54269. /**
  54270. * If true, the light map contains occlusion information instead of lighting info.
  54271. */
  54272. useLightmapAsShadowmap: boolean;
  54273. /**
  54274. * Instantiates a new PBRMaterial instance.
  54275. *
  54276. * @param name The material name
  54277. * @param scene The scene the material will be use in.
  54278. */
  54279. constructor(name: string, scene: Scene);
  54280. getClassName(): string;
  54281. }
  54282. }
  54283. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54284. import { Scene } from "babylonjs/scene";
  54285. import { Color3 } from "babylonjs/Maths/math.color";
  54286. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54287. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54288. /**
  54289. * The PBR material of BJS following the metal roughness convention.
  54290. *
  54291. * This fits to the PBR convention in the GLTF definition:
  54292. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54293. */
  54294. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54295. /**
  54296. * The base color has two different interpretations depending on the value of metalness.
  54297. * When the material is a metal, the base color is the specific measured reflectance value
  54298. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54299. * of the material.
  54300. */
  54301. baseColor: Color3;
  54302. /**
  54303. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54304. * well as opacity information in the alpha channel.
  54305. */
  54306. baseTexture: BaseTexture;
  54307. /**
  54308. * Specifies the metallic scalar value of the material.
  54309. * Can also be used to scale the metalness values of the metallic texture.
  54310. */
  54311. metallic: number;
  54312. /**
  54313. * Specifies the roughness scalar value of the material.
  54314. * Can also be used to scale the roughness values of the metallic texture.
  54315. */
  54316. roughness: number;
  54317. /**
  54318. * Texture containing both the metallic value in the B channel and the
  54319. * roughness value in the G channel to keep better precision.
  54320. */
  54321. metallicRoughnessTexture: BaseTexture;
  54322. /**
  54323. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54324. *
  54325. * @param name The material name
  54326. * @param scene The scene the material will be use in.
  54327. */
  54328. constructor(name: string, scene: Scene);
  54329. /**
  54330. * Return the currrent class name of the material.
  54331. */
  54332. getClassName(): string;
  54333. /**
  54334. * Makes a duplicate of the current material.
  54335. * @param name - name to use for the new material.
  54336. */
  54337. clone(name: string): PBRMetallicRoughnessMaterial;
  54338. /**
  54339. * Serialize the material to a parsable JSON object.
  54340. */
  54341. serialize(): any;
  54342. /**
  54343. * Parses a JSON object correponding to the serialize function.
  54344. */
  54345. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54346. }
  54347. }
  54348. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54349. import { Scene } from "babylonjs/scene";
  54350. import { Color3 } from "babylonjs/Maths/math.color";
  54351. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54352. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54353. /**
  54354. * The PBR material of BJS following the specular glossiness convention.
  54355. *
  54356. * This fits to the PBR convention in the GLTF definition:
  54357. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54358. */
  54359. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54360. /**
  54361. * Specifies the diffuse color of the material.
  54362. */
  54363. diffuseColor: Color3;
  54364. /**
  54365. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54366. * channel.
  54367. */
  54368. diffuseTexture: BaseTexture;
  54369. /**
  54370. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54371. */
  54372. specularColor: Color3;
  54373. /**
  54374. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54375. */
  54376. glossiness: number;
  54377. /**
  54378. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54379. */
  54380. specularGlossinessTexture: BaseTexture;
  54381. /**
  54382. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54383. *
  54384. * @param name The material name
  54385. * @param scene The scene the material will be use in.
  54386. */
  54387. constructor(name: string, scene: Scene);
  54388. /**
  54389. * Return the currrent class name of the material.
  54390. */
  54391. getClassName(): string;
  54392. /**
  54393. * Makes a duplicate of the current material.
  54394. * @param name - name to use for the new material.
  54395. */
  54396. clone(name: string): PBRSpecularGlossinessMaterial;
  54397. /**
  54398. * Serialize the material to a parsable JSON object.
  54399. */
  54400. serialize(): any;
  54401. /**
  54402. * Parses a JSON object correponding to the serialize function.
  54403. */
  54404. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54405. }
  54406. }
  54407. declare module "babylonjs/Materials/PBR/index" {
  54408. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54409. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54410. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54411. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54412. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54413. }
  54414. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54415. import { Nullable } from "babylonjs/types";
  54416. import { Scene } from "babylonjs/scene";
  54417. import { Matrix } from "babylonjs/Maths/math.vector";
  54418. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54419. /**
  54420. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54421. * It can help converting any input color in a desired output one. This can then be used to create effects
  54422. * from sepia, black and white to sixties or futuristic rendering...
  54423. *
  54424. * The only supported format is currently 3dl.
  54425. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54426. */
  54427. export class ColorGradingTexture extends BaseTexture {
  54428. /**
  54429. * The current texture matrix. (will always be identity in color grading texture)
  54430. */
  54431. private _textureMatrix;
  54432. /**
  54433. * The texture URL.
  54434. */
  54435. url: string;
  54436. /**
  54437. * Empty line regex stored for GC.
  54438. */
  54439. private static _noneEmptyLineRegex;
  54440. private _engine;
  54441. /**
  54442. * Instantiates a ColorGradingTexture from the following parameters.
  54443. *
  54444. * @param url The location of the color gradind data (currently only supporting 3dl)
  54445. * @param scene The scene the texture will be used in
  54446. */
  54447. constructor(url: string, scene: Scene);
  54448. /**
  54449. * Returns the texture matrix used in most of the material.
  54450. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54451. */
  54452. getTextureMatrix(): Matrix;
  54453. /**
  54454. * Occurs when the file being loaded is a .3dl LUT file.
  54455. */
  54456. private load3dlTexture;
  54457. /**
  54458. * Starts the loading process of the texture.
  54459. */
  54460. private loadTexture;
  54461. /**
  54462. * Clones the color gradind texture.
  54463. */
  54464. clone(): ColorGradingTexture;
  54465. /**
  54466. * Called during delayed load for textures.
  54467. */
  54468. delayLoad(): void;
  54469. /**
  54470. * Parses a color grading texture serialized by Babylon.
  54471. * @param parsedTexture The texture information being parsedTexture
  54472. * @param scene The scene to load the texture in
  54473. * @param rootUrl The root url of the data assets to load
  54474. * @return A color gradind texture
  54475. */
  54476. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54477. /**
  54478. * Serializes the LUT texture to json format.
  54479. */
  54480. serialize(): any;
  54481. }
  54482. }
  54483. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54485. import { Scene } from "babylonjs/scene";
  54486. import { Nullable } from "babylonjs/types";
  54487. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54488. /**
  54489. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54490. */
  54491. export class EquiRectangularCubeTexture extends BaseTexture {
  54492. /** The six faces of the cube. */
  54493. private static _FacesMapping;
  54494. private _noMipmap;
  54495. private _onLoad;
  54496. private _onError;
  54497. /** The size of the cubemap. */
  54498. private _size;
  54499. /** The buffer of the image. */
  54500. private _buffer;
  54501. /** The width of the input image. */
  54502. private _width;
  54503. /** The height of the input image. */
  54504. private _height;
  54505. /** The URL to the image. */
  54506. url: string;
  54507. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54508. coordinatesMode: number;
  54509. /**
  54510. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54511. * @param url The location of the image
  54512. * @param scene The scene the texture will be used in
  54513. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54514. * @param noMipmap Forces to not generate the mipmap if true
  54515. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54516. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54517. * @param onLoad — defines a callback called when texture is loaded
  54518. * @param onError — defines a callback called if there is an error
  54519. */
  54520. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54521. /**
  54522. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54523. */
  54524. private loadImage;
  54525. /**
  54526. * Convert the image buffer into a cubemap and create a CubeTexture.
  54527. */
  54528. private loadTexture;
  54529. /**
  54530. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54531. * @param buffer The ArrayBuffer that should be converted.
  54532. * @returns The buffer as Float32Array.
  54533. */
  54534. private getFloat32ArrayFromArrayBuffer;
  54535. /**
  54536. * Get the current class name of the texture useful for serialization or dynamic coding.
  54537. * @returns "EquiRectangularCubeTexture"
  54538. */
  54539. getClassName(): string;
  54540. /**
  54541. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54542. * @returns A clone of the current EquiRectangularCubeTexture.
  54543. */
  54544. clone(): EquiRectangularCubeTexture;
  54545. }
  54546. }
  54547. declare module "babylonjs/Misc/tga" {
  54548. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54549. /**
  54550. * Based on jsTGALoader - Javascript loader for TGA file
  54551. * By Vincent Thibault
  54552. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54553. */
  54554. export class TGATools {
  54555. private static _TYPE_INDEXED;
  54556. private static _TYPE_RGB;
  54557. private static _TYPE_GREY;
  54558. private static _TYPE_RLE_INDEXED;
  54559. private static _TYPE_RLE_RGB;
  54560. private static _TYPE_RLE_GREY;
  54561. private static _ORIGIN_MASK;
  54562. private static _ORIGIN_SHIFT;
  54563. private static _ORIGIN_BL;
  54564. private static _ORIGIN_BR;
  54565. private static _ORIGIN_UL;
  54566. private static _ORIGIN_UR;
  54567. /**
  54568. * Gets the header of a TGA file
  54569. * @param data defines the TGA data
  54570. * @returns the header
  54571. */
  54572. static GetTGAHeader(data: Uint8Array): any;
  54573. /**
  54574. * Uploads TGA content to a Babylon Texture
  54575. * @hidden
  54576. */
  54577. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54578. /** @hidden */
  54579. 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;
  54580. /** @hidden */
  54581. 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;
  54582. /** @hidden */
  54583. 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;
  54584. /** @hidden */
  54585. 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;
  54586. /** @hidden */
  54587. 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;
  54588. /** @hidden */
  54589. 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;
  54590. }
  54591. }
  54592. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54593. import { Nullable } from "babylonjs/types";
  54594. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54595. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54596. /**
  54597. * Implementation of the TGA Texture Loader.
  54598. * @hidden
  54599. */
  54600. export class _TGATextureLoader implements IInternalTextureLoader {
  54601. /**
  54602. * Defines wether the loader supports cascade loading the different faces.
  54603. */
  54604. readonly supportCascades: boolean;
  54605. /**
  54606. * This returns if the loader support the current file information.
  54607. * @param extension defines the file extension of the file being loaded
  54608. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54609. * @param fallback defines the fallback internal texture if any
  54610. * @param isBase64 defines whether the texture is encoded as a base64
  54611. * @param isBuffer defines whether the texture data are stored as a buffer
  54612. * @returns true if the loader can load the specified file
  54613. */
  54614. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54615. /**
  54616. * Transform the url before loading if required.
  54617. * @param rootUrl the url of the texture
  54618. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54619. * @returns the transformed texture
  54620. */
  54621. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54622. /**
  54623. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54624. * @param rootUrl the url of the texture
  54625. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54626. * @returns the fallback texture
  54627. */
  54628. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54629. /**
  54630. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54631. * @param data contains the texture data
  54632. * @param texture defines the BabylonJS internal texture
  54633. * @param createPolynomials will be true if polynomials have been requested
  54634. * @param onLoad defines the callback to trigger once the texture is ready
  54635. * @param onError defines the callback to trigger in case of error
  54636. */
  54637. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54638. /**
  54639. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54640. * @param data contains the texture data
  54641. * @param texture defines the BabylonJS internal texture
  54642. * @param callback defines the method to call once ready to upload
  54643. */
  54644. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54645. }
  54646. }
  54647. declare module "babylonjs/Misc/basis" {
  54648. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54649. /**
  54650. * Info about the .basis files
  54651. */
  54652. class BasisFileInfo {
  54653. /**
  54654. * If the file has alpha
  54655. */
  54656. hasAlpha: boolean;
  54657. /**
  54658. * Info about each image of the basis file
  54659. */
  54660. images: Array<{
  54661. levels: Array<{
  54662. width: number;
  54663. height: number;
  54664. transcodedPixels: ArrayBufferView;
  54665. }>;
  54666. }>;
  54667. }
  54668. /**
  54669. * Result of transcoding a basis file
  54670. */
  54671. class TranscodeResult {
  54672. /**
  54673. * Info about the .basis file
  54674. */
  54675. fileInfo: BasisFileInfo;
  54676. /**
  54677. * Format to use when loading the file
  54678. */
  54679. format: number;
  54680. }
  54681. /**
  54682. * Configuration options for the Basis transcoder
  54683. */
  54684. export class BasisTranscodeConfiguration {
  54685. /**
  54686. * Supported compression formats used to determine the supported output format of the transcoder
  54687. */
  54688. supportedCompressionFormats?: {
  54689. /**
  54690. * etc1 compression format
  54691. */
  54692. etc1?: boolean;
  54693. /**
  54694. * s3tc compression format
  54695. */
  54696. s3tc?: boolean;
  54697. /**
  54698. * pvrtc compression format
  54699. */
  54700. pvrtc?: boolean;
  54701. /**
  54702. * etc2 compression format
  54703. */
  54704. etc2?: boolean;
  54705. };
  54706. /**
  54707. * If mipmap levels should be loaded for transcoded images (Default: true)
  54708. */
  54709. loadMipmapLevels?: boolean;
  54710. /**
  54711. * Index of a single image to load (Default: all images)
  54712. */
  54713. loadSingleImage?: number;
  54714. }
  54715. /**
  54716. * Used to load .Basis files
  54717. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54718. */
  54719. export class BasisTools {
  54720. private static _IgnoreSupportedFormats;
  54721. /**
  54722. * URL to use when loading the basis transcoder
  54723. */
  54724. static JSModuleURL: string;
  54725. /**
  54726. * URL to use when loading the wasm module for the transcoder
  54727. */
  54728. static WasmModuleURL: string;
  54729. /**
  54730. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54731. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54732. * @returns internal format corresponding to the Basis format
  54733. */
  54734. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54735. private static _WorkerPromise;
  54736. private static _Worker;
  54737. private static _actionId;
  54738. private static _CreateWorkerAsync;
  54739. /**
  54740. * Transcodes a loaded image file to compressed pixel data
  54741. * @param imageData image data to transcode
  54742. * @param config configuration options for the transcoding
  54743. * @returns a promise resulting in the transcoded image
  54744. */
  54745. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54746. /**
  54747. * Loads a texture from the transcode result
  54748. * @param texture texture load to
  54749. * @param transcodeResult the result of transcoding the basis file to load from
  54750. */
  54751. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54752. }
  54753. }
  54754. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54755. import { Nullable } from "babylonjs/types";
  54756. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54757. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54758. /**
  54759. * Loader for .basis file format
  54760. */
  54761. export class _BasisTextureLoader implements IInternalTextureLoader {
  54762. /**
  54763. * Defines whether the loader supports cascade loading the different faces.
  54764. */
  54765. readonly supportCascades: boolean;
  54766. /**
  54767. * This returns if the loader support the current file information.
  54768. * @param extension defines the file extension of the file being loaded
  54769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54770. * @param fallback defines the fallback internal texture if any
  54771. * @param isBase64 defines whether the texture is encoded as a base64
  54772. * @param isBuffer defines whether the texture data are stored as a buffer
  54773. * @returns true if the loader can load the specified file
  54774. */
  54775. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54776. /**
  54777. * Transform the url before loading if required.
  54778. * @param rootUrl the url of the texture
  54779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54780. * @returns the transformed texture
  54781. */
  54782. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54783. /**
  54784. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54785. * @param rootUrl the url of the texture
  54786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54787. * @returns the fallback texture
  54788. */
  54789. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54790. /**
  54791. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54792. * @param data contains the texture data
  54793. * @param texture defines the BabylonJS internal texture
  54794. * @param createPolynomials will be true if polynomials have been requested
  54795. * @param onLoad defines the callback to trigger once the texture is ready
  54796. * @param onError defines the callback to trigger in case of error
  54797. */
  54798. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54799. /**
  54800. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54801. * @param data contains the texture data
  54802. * @param texture defines the BabylonJS internal texture
  54803. * @param callback defines the method to call once ready to upload
  54804. */
  54805. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54806. }
  54807. }
  54808. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54809. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54810. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54811. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54812. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54813. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54814. }
  54815. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54816. import { Scene } from "babylonjs/scene";
  54817. import { Texture } from "babylonjs/Materials/Textures/texture";
  54818. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54819. /**
  54820. * 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.
  54821. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54822. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54823. */
  54824. export class CustomProceduralTexture extends ProceduralTexture {
  54825. private _animate;
  54826. private _time;
  54827. private _config;
  54828. private _texturePath;
  54829. /**
  54830. * Instantiates a new Custom Procedural Texture.
  54831. * 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.
  54832. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54833. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54834. * @param name Define the name of the texture
  54835. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54836. * @param size Define the size of the texture to create
  54837. * @param scene Define the scene the texture belongs to
  54838. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54839. * @param generateMipMaps Define if the texture should creates mip maps or not
  54840. */
  54841. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54842. private _loadJson;
  54843. /**
  54844. * Is the texture ready to be used ? (rendered at least once)
  54845. * @returns true if ready, otherwise, false.
  54846. */
  54847. isReady(): boolean;
  54848. /**
  54849. * Render the texture to its associated render target.
  54850. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54851. */
  54852. render(useCameraPostProcess?: boolean): void;
  54853. /**
  54854. * Update the list of dependant textures samplers in the shader.
  54855. */
  54856. updateTextures(): void;
  54857. /**
  54858. * Update the uniform values of the procedural texture in the shader.
  54859. */
  54860. updateShaderUniforms(): void;
  54861. /**
  54862. * Define if the texture animates or not.
  54863. */
  54864. animate: boolean;
  54865. }
  54866. }
  54867. declare module "babylonjs/Shaders/noise.fragment" {
  54868. /** @hidden */
  54869. export var noisePixelShader: {
  54870. name: string;
  54871. shader: string;
  54872. };
  54873. }
  54874. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54875. import { Nullable } from "babylonjs/types";
  54876. import { Scene } from "babylonjs/scene";
  54877. import { Texture } from "babylonjs/Materials/Textures/texture";
  54878. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54879. import "babylonjs/Shaders/noise.fragment";
  54880. /**
  54881. * Class used to generate noise procedural textures
  54882. */
  54883. export class NoiseProceduralTexture extends ProceduralTexture {
  54884. private _time;
  54885. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54886. brightness: number;
  54887. /** Defines the number of octaves to process */
  54888. octaves: number;
  54889. /** Defines the level of persistence (0.8 by default) */
  54890. persistence: number;
  54891. /** Gets or sets animation speed factor (default is 1) */
  54892. animationSpeedFactor: number;
  54893. /**
  54894. * Creates a new NoiseProceduralTexture
  54895. * @param name defines the name fo the texture
  54896. * @param size defines the size of the texture (default is 256)
  54897. * @param scene defines the hosting scene
  54898. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54899. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54900. */
  54901. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54902. private _updateShaderUniforms;
  54903. protected _getDefines(): string;
  54904. /** Generate the current state of the procedural texture */
  54905. render(useCameraPostProcess?: boolean): void;
  54906. /**
  54907. * Serializes this noise procedural texture
  54908. * @returns a serialized noise procedural texture object
  54909. */
  54910. serialize(): any;
  54911. /**
  54912. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54913. * @param parsedTexture defines parsed texture data
  54914. * @param scene defines the current scene
  54915. * @param rootUrl defines the root URL containing noise procedural texture information
  54916. * @returns a parsed NoiseProceduralTexture
  54917. */
  54918. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54919. }
  54920. }
  54921. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54922. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54923. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54924. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54925. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54926. }
  54927. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54928. import { Nullable } from "babylonjs/types";
  54929. import { Scene } from "babylonjs/scene";
  54930. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54931. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54932. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54933. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54934. /**
  54935. * Raw cube texture where the raw buffers are passed in
  54936. */
  54937. export class RawCubeTexture extends CubeTexture {
  54938. /**
  54939. * Creates a cube texture where the raw buffers are passed in.
  54940. * @param scene defines the scene the texture is attached to
  54941. * @param data defines the array of data to use to create each face
  54942. * @param size defines the size of the textures
  54943. * @param format defines the format of the data
  54944. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54945. * @param generateMipMaps defines if the engine should generate the mip levels
  54946. * @param invertY defines if data must be stored with Y axis inverted
  54947. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54948. * @param compression defines the compression used (null by default)
  54949. */
  54950. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54951. /**
  54952. * Updates the raw cube texture.
  54953. * @param data defines the data to store
  54954. * @param format defines the data format
  54955. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54956. * @param invertY defines if data must be stored with Y axis inverted
  54957. * @param compression defines the compression used (null by default)
  54958. * @param level defines which level of the texture to update
  54959. */
  54960. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54961. /**
  54962. * Updates a raw cube texture with RGBD encoded data.
  54963. * @param data defines the array of data [mipmap][face] to use to create each face
  54964. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54965. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54966. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54967. * @returns a promsie that resolves when the operation is complete
  54968. */
  54969. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54970. /**
  54971. * Clones the raw cube texture.
  54972. * @return a new cube texture
  54973. */
  54974. clone(): CubeTexture;
  54975. /** @hidden */
  54976. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54977. }
  54978. }
  54979. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54980. import { Scene } from "babylonjs/scene";
  54981. import { Texture } from "babylonjs/Materials/Textures/texture";
  54982. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54983. /**
  54984. * Class used to store 3D textures containing user data
  54985. */
  54986. export class RawTexture3D extends Texture {
  54987. /** Gets or sets the texture format to use */
  54988. format: number;
  54989. private _engine;
  54990. /**
  54991. * Create a new RawTexture3D
  54992. * @param data defines the data of the texture
  54993. * @param width defines the width of the texture
  54994. * @param height defines the height of the texture
  54995. * @param depth defines the depth of the texture
  54996. * @param format defines the texture format to use
  54997. * @param scene defines the hosting scene
  54998. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54999. * @param invertY defines if texture must be stored with Y axis inverted
  55000. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55001. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55002. */
  55003. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55004. /** Gets or sets the texture format to use */
  55005. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55006. /**
  55007. * Update the texture with new data
  55008. * @param data defines the data to store in the texture
  55009. */
  55010. update(data: ArrayBufferView): void;
  55011. }
  55012. }
  55013. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55014. import { Scene } from "babylonjs/scene";
  55015. import { Plane } from "babylonjs/Maths/math.plane";
  55016. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55017. /**
  55018. * Creates a refraction texture used by refraction channel of the standard material.
  55019. * It is like a mirror but to see through a material.
  55020. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55021. */
  55022. export class RefractionTexture extends RenderTargetTexture {
  55023. /**
  55024. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55025. * 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.
  55026. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55027. */
  55028. refractionPlane: Plane;
  55029. /**
  55030. * Define how deep under the surface we should see.
  55031. */
  55032. depth: number;
  55033. /**
  55034. * Creates a refraction texture used by refraction channel of the standard material.
  55035. * It is like a mirror but to see through a material.
  55036. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55037. * @param name Define the texture name
  55038. * @param size Define the size of the underlying texture
  55039. * @param scene Define the scene the refraction belongs to
  55040. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55041. */
  55042. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55043. /**
  55044. * Clone the refraction texture.
  55045. * @returns the cloned texture
  55046. */
  55047. clone(): RefractionTexture;
  55048. /**
  55049. * Serialize the texture to a JSON representation you could use in Parse later on
  55050. * @returns the serialized JSON representation
  55051. */
  55052. serialize(): any;
  55053. }
  55054. }
  55055. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55056. import { Nullable } from "babylonjs/types";
  55057. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55058. import { Matrix } from "babylonjs/Maths/math.vector";
  55059. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55060. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55061. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55062. import { Scene } from "babylonjs/scene";
  55063. /**
  55064. * Defines the options related to the creation of an HtmlElementTexture
  55065. */
  55066. export interface IHtmlElementTextureOptions {
  55067. /**
  55068. * Defines wether mip maps should be created or not.
  55069. */
  55070. generateMipMaps?: boolean;
  55071. /**
  55072. * Defines the sampling mode of the texture.
  55073. */
  55074. samplingMode?: number;
  55075. /**
  55076. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55077. */
  55078. engine: Nullable<ThinEngine>;
  55079. /**
  55080. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55081. */
  55082. scene: Nullable<Scene>;
  55083. }
  55084. /**
  55085. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55086. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55087. * is automatically managed.
  55088. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55089. * in your application.
  55090. *
  55091. * As the update is not automatic, you need to call them manually.
  55092. */
  55093. export class HtmlElementTexture extends BaseTexture {
  55094. /**
  55095. * The texture URL.
  55096. */
  55097. element: HTMLVideoElement | HTMLCanvasElement;
  55098. private static readonly DefaultOptions;
  55099. private _textureMatrix;
  55100. private _engine;
  55101. private _isVideo;
  55102. private _generateMipMaps;
  55103. private _samplingMode;
  55104. /**
  55105. * Instantiates a HtmlElementTexture from the following parameters.
  55106. *
  55107. * @param name Defines the name of the texture
  55108. * @param element Defines the video or canvas the texture is filled with
  55109. * @param options Defines the other none mandatory texture creation options
  55110. */
  55111. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55112. private _createInternalTexture;
  55113. /**
  55114. * Returns the texture matrix used in most of the material.
  55115. */
  55116. getTextureMatrix(): Matrix;
  55117. /**
  55118. * Updates the content of the texture.
  55119. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55120. */
  55121. update(invertY?: Nullable<boolean>): void;
  55122. }
  55123. }
  55124. declare module "babylonjs/Materials/Textures/index" {
  55125. export * from "babylonjs/Materials/Textures/baseTexture";
  55126. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55127. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55128. export * from "babylonjs/Materials/Textures/cubeTexture";
  55129. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55130. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55131. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55132. export * from "babylonjs/Materials/Textures/internalTexture";
  55133. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55134. export * from "babylonjs/Materials/Textures/Loaders/index";
  55135. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55136. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55137. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55138. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55139. export * from "babylonjs/Materials/Textures/rawTexture";
  55140. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55141. export * from "babylonjs/Materials/Textures/refractionTexture";
  55142. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55143. export * from "babylonjs/Materials/Textures/texture";
  55144. export * from "babylonjs/Materials/Textures/videoTexture";
  55145. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55146. }
  55147. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55148. /**
  55149. * Enum used to define the target of a block
  55150. */
  55151. export enum NodeMaterialBlockTargets {
  55152. /** Vertex shader */
  55153. Vertex = 1,
  55154. /** Fragment shader */
  55155. Fragment = 2,
  55156. /** Neutral */
  55157. Neutral = 4,
  55158. /** Vertex and Fragment */
  55159. VertexAndFragment = 3
  55160. }
  55161. }
  55162. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55163. /**
  55164. * Defines the kind of connection point for node based material
  55165. */
  55166. export enum NodeMaterialBlockConnectionPointTypes {
  55167. /** Float */
  55168. Float = 1,
  55169. /** Int */
  55170. Int = 2,
  55171. /** Vector2 */
  55172. Vector2 = 4,
  55173. /** Vector3 */
  55174. Vector3 = 8,
  55175. /** Vector4 */
  55176. Vector4 = 16,
  55177. /** Color3 */
  55178. Color3 = 32,
  55179. /** Color4 */
  55180. Color4 = 64,
  55181. /** Matrix */
  55182. Matrix = 128,
  55183. /** Detect type based on connection */
  55184. AutoDetect = 1024,
  55185. /** Output type that will be defined by input type */
  55186. BasedOnInput = 2048
  55187. }
  55188. }
  55189. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55190. /**
  55191. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55192. */
  55193. export enum NodeMaterialBlockConnectionPointMode {
  55194. /** Value is an uniform */
  55195. Uniform = 0,
  55196. /** Value is a mesh attribute */
  55197. Attribute = 1,
  55198. /** Value is a varying between vertex and fragment shaders */
  55199. Varying = 2,
  55200. /** Mode is undefined */
  55201. Undefined = 3
  55202. }
  55203. }
  55204. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55205. /**
  55206. * Enum used to define system values e.g. values automatically provided by the system
  55207. */
  55208. export enum NodeMaterialSystemValues {
  55209. /** World */
  55210. World = 1,
  55211. /** View */
  55212. View = 2,
  55213. /** Projection */
  55214. Projection = 3,
  55215. /** ViewProjection */
  55216. ViewProjection = 4,
  55217. /** WorldView */
  55218. WorldView = 5,
  55219. /** WorldViewProjection */
  55220. WorldViewProjection = 6,
  55221. /** CameraPosition */
  55222. CameraPosition = 7,
  55223. /** Fog Color */
  55224. FogColor = 8,
  55225. /** Delta time */
  55226. DeltaTime = 9
  55227. }
  55228. }
  55229. declare module "babylonjs/Materials/Node/Enums/index" {
  55230. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55231. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55232. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55233. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55234. }
  55235. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55237. /**
  55238. * Root class for all node material optimizers
  55239. */
  55240. export class NodeMaterialOptimizer {
  55241. /**
  55242. * Function used to optimize a NodeMaterial graph
  55243. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55244. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55245. */
  55246. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55247. }
  55248. }
  55249. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55250. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55251. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55252. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55253. import { Scene } from "babylonjs/scene";
  55254. /**
  55255. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55256. */
  55257. export class TransformBlock extends NodeMaterialBlock {
  55258. /**
  55259. * Defines the value to use to complement W value to transform it to a Vector4
  55260. */
  55261. complementW: number;
  55262. /**
  55263. * Defines the value to use to complement z value to transform it to a Vector4
  55264. */
  55265. complementZ: number;
  55266. /**
  55267. * Creates a new TransformBlock
  55268. * @param name defines the block name
  55269. */
  55270. constructor(name: string);
  55271. /**
  55272. * Gets the current class name
  55273. * @returns the class name
  55274. */
  55275. getClassName(): string;
  55276. /**
  55277. * Gets the vector input
  55278. */
  55279. readonly vector: NodeMaterialConnectionPoint;
  55280. /**
  55281. * Gets the output component
  55282. */
  55283. readonly output: NodeMaterialConnectionPoint;
  55284. /**
  55285. * Gets the matrix transform input
  55286. */
  55287. readonly transform: NodeMaterialConnectionPoint;
  55288. protected _buildBlock(state: NodeMaterialBuildState): this;
  55289. serialize(): any;
  55290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55291. protected _dumpPropertiesCode(): string;
  55292. }
  55293. }
  55294. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55298. /**
  55299. * Block used to output the vertex position
  55300. */
  55301. export class VertexOutputBlock extends NodeMaterialBlock {
  55302. /**
  55303. * Creates a new VertexOutputBlock
  55304. * @param name defines the block name
  55305. */
  55306. constructor(name: string);
  55307. /**
  55308. * Gets the current class name
  55309. * @returns the class name
  55310. */
  55311. getClassName(): string;
  55312. /**
  55313. * Gets the vector input component
  55314. */
  55315. readonly vector: NodeMaterialConnectionPoint;
  55316. protected _buildBlock(state: NodeMaterialBuildState): this;
  55317. }
  55318. }
  55319. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55323. /**
  55324. * Block used to output the final color
  55325. */
  55326. export class FragmentOutputBlock extends NodeMaterialBlock {
  55327. /**
  55328. * Create a new FragmentOutputBlock
  55329. * @param name defines the block name
  55330. */
  55331. constructor(name: string);
  55332. /**
  55333. * Gets the current class name
  55334. * @returns the class name
  55335. */
  55336. getClassName(): string;
  55337. /**
  55338. * Gets the rgba input component
  55339. */
  55340. readonly rgba: NodeMaterialConnectionPoint;
  55341. /**
  55342. * Gets the rgb input component
  55343. */
  55344. readonly rgb: NodeMaterialConnectionPoint;
  55345. /**
  55346. * Gets the a input component
  55347. */
  55348. readonly a: NodeMaterialConnectionPoint;
  55349. protected _buildBlock(state: NodeMaterialBuildState): this;
  55350. }
  55351. }
  55352. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55353. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55354. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55355. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55356. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55358. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55359. import { Effect } from "babylonjs/Materials/effect";
  55360. import { Mesh } from "babylonjs/Meshes/mesh";
  55361. import { Nullable } from "babylonjs/types";
  55362. import { Scene } from "babylonjs/scene";
  55363. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55364. /**
  55365. * Block used to read a reflection texture from a sampler
  55366. */
  55367. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55368. private _define3DName;
  55369. private _defineCubicName;
  55370. private _defineExplicitName;
  55371. private _defineProjectionName;
  55372. private _defineLocalCubicName;
  55373. private _defineSphericalName;
  55374. private _definePlanarName;
  55375. private _defineEquirectangularName;
  55376. private _defineMirroredEquirectangularFixedName;
  55377. private _defineEquirectangularFixedName;
  55378. private _defineSkyboxName;
  55379. private _cubeSamplerName;
  55380. private _2DSamplerName;
  55381. private _positionUVWName;
  55382. private _directionWName;
  55383. private _reflectionCoordsName;
  55384. private _reflection2DCoordsName;
  55385. private _reflectionColorName;
  55386. private _reflectionMatrixName;
  55387. /**
  55388. * Gets or sets the texture associated with the node
  55389. */
  55390. texture: Nullable<BaseTexture>;
  55391. /**
  55392. * Create a new TextureBlock
  55393. * @param name defines the block name
  55394. */
  55395. constructor(name: string);
  55396. /**
  55397. * Gets the current class name
  55398. * @returns the class name
  55399. */
  55400. getClassName(): string;
  55401. /**
  55402. * Gets the world position input component
  55403. */
  55404. readonly position: NodeMaterialConnectionPoint;
  55405. /**
  55406. * Gets the world position input component
  55407. */
  55408. readonly worldPosition: NodeMaterialConnectionPoint;
  55409. /**
  55410. * Gets the world normal input component
  55411. */
  55412. readonly worldNormal: NodeMaterialConnectionPoint;
  55413. /**
  55414. * Gets the world input component
  55415. */
  55416. readonly world: NodeMaterialConnectionPoint;
  55417. /**
  55418. * Gets the camera (or eye) position component
  55419. */
  55420. readonly cameraPosition: NodeMaterialConnectionPoint;
  55421. /**
  55422. * Gets the view input component
  55423. */
  55424. readonly view: NodeMaterialConnectionPoint;
  55425. /**
  55426. * Gets the rgb output component
  55427. */
  55428. readonly rgb: NodeMaterialConnectionPoint;
  55429. /**
  55430. * Gets the r output component
  55431. */
  55432. readonly r: NodeMaterialConnectionPoint;
  55433. /**
  55434. * Gets the g output component
  55435. */
  55436. readonly g: NodeMaterialConnectionPoint;
  55437. /**
  55438. * Gets the b output component
  55439. */
  55440. readonly b: NodeMaterialConnectionPoint;
  55441. autoConfigure(material: NodeMaterial): void;
  55442. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55443. isReady(): boolean;
  55444. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55445. private _injectVertexCode;
  55446. private _writeOutput;
  55447. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55448. serialize(): any;
  55449. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55450. }
  55451. }
  55452. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55454. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55455. import { Scene } from "babylonjs/scene";
  55456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55457. import { Matrix } from "babylonjs/Maths/math.vector";
  55458. import { Mesh } from "babylonjs/Meshes/mesh";
  55459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55460. import { Observable } from "babylonjs/Misc/observable";
  55461. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55462. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55463. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55464. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55465. import { Nullable } from "babylonjs/types";
  55466. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55467. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55468. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55469. /**
  55470. * Interface used to configure the node material editor
  55471. */
  55472. export interface INodeMaterialEditorOptions {
  55473. /** Define the URl to load node editor script */
  55474. editorURL?: string;
  55475. }
  55476. /** @hidden */
  55477. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55478. /** BONES */
  55479. NUM_BONE_INFLUENCERS: number;
  55480. BonesPerMesh: number;
  55481. BONETEXTURE: boolean;
  55482. /** MORPH TARGETS */
  55483. MORPHTARGETS: boolean;
  55484. MORPHTARGETS_NORMAL: boolean;
  55485. MORPHTARGETS_TANGENT: boolean;
  55486. MORPHTARGETS_UV: boolean;
  55487. NUM_MORPH_INFLUENCERS: number;
  55488. /** IMAGE PROCESSING */
  55489. IMAGEPROCESSING: boolean;
  55490. VIGNETTE: boolean;
  55491. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55492. VIGNETTEBLENDMODEOPAQUE: boolean;
  55493. TONEMAPPING: boolean;
  55494. TONEMAPPING_ACES: boolean;
  55495. CONTRAST: boolean;
  55496. EXPOSURE: boolean;
  55497. COLORCURVES: boolean;
  55498. COLORGRADING: boolean;
  55499. COLORGRADING3D: boolean;
  55500. SAMPLER3DGREENDEPTH: boolean;
  55501. SAMPLER3DBGRMAP: boolean;
  55502. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55503. /** MISC. */
  55504. BUMPDIRECTUV: number;
  55505. constructor();
  55506. setValue(name: string, value: boolean): void;
  55507. }
  55508. /**
  55509. * Class used to configure NodeMaterial
  55510. */
  55511. export interface INodeMaterialOptions {
  55512. /**
  55513. * Defines if blocks should emit comments
  55514. */
  55515. emitComments: boolean;
  55516. }
  55517. /**
  55518. * Class used to create a node based material built by assembling shader blocks
  55519. */
  55520. export class NodeMaterial extends PushMaterial {
  55521. private static _BuildIdGenerator;
  55522. private _options;
  55523. private _vertexCompilationState;
  55524. private _fragmentCompilationState;
  55525. private _sharedData;
  55526. private _buildId;
  55527. private _buildWasSuccessful;
  55528. private _cachedWorldViewMatrix;
  55529. private _cachedWorldViewProjectionMatrix;
  55530. private _optimizers;
  55531. private _animationFrame;
  55532. /** Define the URl to load node editor script */
  55533. static EditorURL: string;
  55534. private BJSNODEMATERIALEDITOR;
  55535. /** Get the inspector from bundle or global */
  55536. private _getGlobalNodeMaterialEditor;
  55537. /**
  55538. * 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)
  55539. */
  55540. ignoreAlpha: boolean;
  55541. /**
  55542. * Defines the maximum number of lights that can be used in the material
  55543. */
  55544. maxSimultaneousLights: number;
  55545. /**
  55546. * Observable raised when the material is built
  55547. */
  55548. onBuildObservable: Observable<NodeMaterial>;
  55549. /**
  55550. * Gets or sets the root nodes of the material vertex shader
  55551. */
  55552. _vertexOutputNodes: NodeMaterialBlock[];
  55553. /**
  55554. * Gets or sets the root nodes of the material fragment (pixel) shader
  55555. */
  55556. _fragmentOutputNodes: NodeMaterialBlock[];
  55557. /** Gets or sets options to control the node material overall behavior */
  55558. options: INodeMaterialOptions;
  55559. /**
  55560. * Default configuration related to image processing available in the standard Material.
  55561. */
  55562. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55563. /**
  55564. * Gets the image processing configuration used either in this material.
  55565. */
  55566. /**
  55567. * Sets the Default image processing configuration used either in the this material.
  55568. *
  55569. * If sets to null, the scene one is in use.
  55570. */
  55571. imageProcessingConfiguration: ImageProcessingConfiguration;
  55572. /**
  55573. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55574. */
  55575. attachedBlocks: NodeMaterialBlock[];
  55576. /**
  55577. * Create a new node based material
  55578. * @param name defines the material name
  55579. * @param scene defines the hosting scene
  55580. * @param options defines creation option
  55581. */
  55582. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55583. /**
  55584. * Gets the current class name of the material e.g. "NodeMaterial"
  55585. * @returns the class name
  55586. */
  55587. getClassName(): string;
  55588. /**
  55589. * Keep track of the image processing observer to allow dispose and replace.
  55590. */
  55591. private _imageProcessingObserver;
  55592. /**
  55593. * Attaches a new image processing configuration to the Standard Material.
  55594. * @param configuration
  55595. */
  55596. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55597. /**
  55598. * Get a block by its name
  55599. * @param name defines the name of the block to retrieve
  55600. * @returns the required block or null if not found
  55601. */
  55602. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55603. /**
  55604. * Get a block by its name
  55605. * @param predicate defines the predicate used to find the good candidate
  55606. * @returns the required block or null if not found
  55607. */
  55608. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55609. /**
  55610. * Get an input block by its name
  55611. * @param predicate defines the predicate used to find the good candidate
  55612. * @returns the required input block or null if not found
  55613. */
  55614. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55615. /**
  55616. * Gets the list of input blocks attached to this material
  55617. * @returns an array of InputBlocks
  55618. */
  55619. getInputBlocks(): InputBlock[];
  55620. /**
  55621. * Adds a new optimizer to the list of optimizers
  55622. * @param optimizer defines the optimizers to add
  55623. * @returns the current material
  55624. */
  55625. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55626. /**
  55627. * Remove an optimizer from the list of optimizers
  55628. * @param optimizer defines the optimizers to remove
  55629. * @returns the current material
  55630. */
  55631. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55632. /**
  55633. * Add a new block to the list of output nodes
  55634. * @param node defines the node to add
  55635. * @returns the current material
  55636. */
  55637. addOutputNode(node: NodeMaterialBlock): this;
  55638. /**
  55639. * Remove a block from the list of root nodes
  55640. * @param node defines the node to remove
  55641. * @returns the current material
  55642. */
  55643. removeOutputNode(node: NodeMaterialBlock): this;
  55644. private _addVertexOutputNode;
  55645. private _removeVertexOutputNode;
  55646. private _addFragmentOutputNode;
  55647. private _removeFragmentOutputNode;
  55648. /**
  55649. * Specifies if the material will require alpha blending
  55650. * @returns a boolean specifying if alpha blending is needed
  55651. */
  55652. needAlphaBlending(): boolean;
  55653. /**
  55654. * Specifies if this material should be rendered in alpha test mode
  55655. * @returns a boolean specifying if an alpha test is needed.
  55656. */
  55657. needAlphaTesting(): boolean;
  55658. private _initializeBlock;
  55659. private _resetDualBlocks;
  55660. /**
  55661. * Build the material and generates the inner effect
  55662. * @param verbose defines if the build should log activity
  55663. */
  55664. build(verbose?: boolean): void;
  55665. /**
  55666. * Runs an otpimization phase to try to improve the shader code
  55667. */
  55668. optimize(): void;
  55669. private _prepareDefinesForAttributes;
  55670. /**
  55671. * Get if the submesh is ready to be used and all its information available.
  55672. * Child classes can use it to update shaders
  55673. * @param mesh defines the mesh to check
  55674. * @param subMesh defines which submesh to check
  55675. * @param useInstances specifies that instances should be used
  55676. * @returns a boolean indicating that the submesh is ready or not
  55677. */
  55678. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55679. /**
  55680. * Get a string representing the shaders built by the current node graph
  55681. */
  55682. readonly compiledShaders: string;
  55683. /**
  55684. * Binds the world matrix to the material
  55685. * @param world defines the world transformation matrix
  55686. */
  55687. bindOnlyWorldMatrix(world: Matrix): void;
  55688. /**
  55689. * Binds the submesh to this material by preparing the effect and shader to draw
  55690. * @param world defines the world transformation matrix
  55691. * @param mesh defines the mesh containing the submesh
  55692. * @param subMesh defines the submesh to bind the material to
  55693. */
  55694. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55695. /**
  55696. * Gets the active textures from the material
  55697. * @returns an array of textures
  55698. */
  55699. getActiveTextures(): BaseTexture[];
  55700. /**
  55701. * Gets the list of texture blocks
  55702. * @returns an array of texture blocks
  55703. */
  55704. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55705. /**
  55706. * Specifies if the material uses a texture
  55707. * @param texture defines the texture to check against the material
  55708. * @returns a boolean specifying if the material uses the texture
  55709. */
  55710. hasTexture(texture: BaseTexture): boolean;
  55711. /**
  55712. * Disposes the material
  55713. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55714. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55715. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55716. */
  55717. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55718. /** Creates the node editor window. */
  55719. private _createNodeEditor;
  55720. /**
  55721. * Launch the node material editor
  55722. * @param config Define the configuration of the editor
  55723. * @return a promise fulfilled when the node editor is visible
  55724. */
  55725. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55726. /**
  55727. * Clear the current material
  55728. */
  55729. clear(): void;
  55730. /**
  55731. * Clear the current material and set it to a default state
  55732. */
  55733. setToDefault(): void;
  55734. /**
  55735. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55736. * @param url defines the url to load from
  55737. * @returns a promise that will fullfil when the material is fully loaded
  55738. */
  55739. loadAsync(url: string): Promise<void>;
  55740. private _gatherBlocks;
  55741. /**
  55742. * Generate a string containing the code declaration required to create an equivalent of this material
  55743. * @returns a string
  55744. */
  55745. generateCode(): string;
  55746. /**
  55747. * Serializes this material in a JSON representation
  55748. * @returns the serialized material object
  55749. */
  55750. serialize(): any;
  55751. private _restoreConnections;
  55752. /**
  55753. * Clear the current graph and load a new one from a serialization object
  55754. * @param source defines the JSON representation of the material
  55755. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55756. */
  55757. loadFromSerialization(source: any, rootUrl?: string): void;
  55758. /**
  55759. * Creates a node material from parsed material data
  55760. * @param source defines the JSON representation of the material
  55761. * @param scene defines the hosting scene
  55762. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55763. * @returns a new node material
  55764. */
  55765. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55766. /**
  55767. * Creates a new node material set to default basic configuration
  55768. * @param name defines the name of the material
  55769. * @param scene defines the hosting scene
  55770. * @returns a new NodeMaterial
  55771. */
  55772. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55773. }
  55774. }
  55775. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55776. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55777. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55778. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55779. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55781. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55782. import { Effect } from "babylonjs/Materials/effect";
  55783. import { Mesh } from "babylonjs/Meshes/mesh";
  55784. import { Nullable } from "babylonjs/types";
  55785. import { Texture } from "babylonjs/Materials/Textures/texture";
  55786. import { Scene } from "babylonjs/scene";
  55787. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55788. /**
  55789. * Block used to read a texture from a sampler
  55790. */
  55791. export class TextureBlock extends NodeMaterialBlock {
  55792. private _defineName;
  55793. private _linearDefineName;
  55794. private _samplerName;
  55795. private _transformedUVName;
  55796. private _textureTransformName;
  55797. private _textureInfoName;
  55798. private _mainUVName;
  55799. private _mainUVDefineName;
  55800. /**
  55801. * Gets or sets the texture associated with the node
  55802. */
  55803. texture: Nullable<Texture>;
  55804. /**
  55805. * Create a new TextureBlock
  55806. * @param name defines the block name
  55807. */
  55808. constructor(name: string);
  55809. /**
  55810. * Gets the current class name
  55811. * @returns the class name
  55812. */
  55813. getClassName(): string;
  55814. /**
  55815. * Gets the uv input component
  55816. */
  55817. readonly uv: NodeMaterialConnectionPoint;
  55818. /**
  55819. * Gets the rgba output component
  55820. */
  55821. readonly rgba: NodeMaterialConnectionPoint;
  55822. /**
  55823. * Gets the rgb output component
  55824. */
  55825. readonly rgb: NodeMaterialConnectionPoint;
  55826. /**
  55827. * Gets the r output component
  55828. */
  55829. readonly r: NodeMaterialConnectionPoint;
  55830. /**
  55831. * Gets the g output component
  55832. */
  55833. readonly g: NodeMaterialConnectionPoint;
  55834. /**
  55835. * Gets the b output component
  55836. */
  55837. readonly b: NodeMaterialConnectionPoint;
  55838. /**
  55839. * Gets the a output component
  55840. */
  55841. readonly a: NodeMaterialConnectionPoint;
  55842. readonly target: NodeMaterialBlockTargets;
  55843. autoConfigure(material: NodeMaterial): void;
  55844. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55845. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55846. isReady(): boolean;
  55847. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55848. private readonly _isMixed;
  55849. private _injectVertexCode;
  55850. private _writeOutput;
  55851. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55852. protected _dumpPropertiesCode(): string;
  55853. serialize(): any;
  55854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55855. }
  55856. }
  55857. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55858. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55859. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55860. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55861. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55862. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55863. import { Scene } from "babylonjs/scene";
  55864. /**
  55865. * Class used to store shared data between 2 NodeMaterialBuildState
  55866. */
  55867. export class NodeMaterialBuildStateSharedData {
  55868. /**
  55869. * Gets the list of emitted varyings
  55870. */
  55871. temps: string[];
  55872. /**
  55873. * Gets the list of emitted varyings
  55874. */
  55875. varyings: string[];
  55876. /**
  55877. * Gets the varying declaration string
  55878. */
  55879. varyingDeclaration: string;
  55880. /**
  55881. * Input blocks
  55882. */
  55883. inputBlocks: InputBlock[];
  55884. /**
  55885. * Input blocks
  55886. */
  55887. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55888. /**
  55889. * Bindable blocks (Blocks that need to set data to the effect)
  55890. */
  55891. bindableBlocks: NodeMaterialBlock[];
  55892. /**
  55893. * List of blocks that can provide a compilation fallback
  55894. */
  55895. blocksWithFallbacks: NodeMaterialBlock[];
  55896. /**
  55897. * List of blocks that can provide a define update
  55898. */
  55899. blocksWithDefines: NodeMaterialBlock[];
  55900. /**
  55901. * List of blocks that can provide a repeatable content
  55902. */
  55903. repeatableContentBlocks: NodeMaterialBlock[];
  55904. /**
  55905. * List of blocks that can provide a dynamic list of uniforms
  55906. */
  55907. dynamicUniformBlocks: NodeMaterialBlock[];
  55908. /**
  55909. * List of blocks that can block the isReady function for the material
  55910. */
  55911. blockingBlocks: NodeMaterialBlock[];
  55912. /**
  55913. * Gets the list of animated inputs
  55914. */
  55915. animatedInputs: InputBlock[];
  55916. /**
  55917. * Build Id used to avoid multiple recompilations
  55918. */
  55919. buildId: number;
  55920. /** List of emitted variables */
  55921. variableNames: {
  55922. [key: string]: number;
  55923. };
  55924. /** List of emitted defines */
  55925. defineNames: {
  55926. [key: string]: number;
  55927. };
  55928. /** Should emit comments? */
  55929. emitComments: boolean;
  55930. /** Emit build activity */
  55931. verbose: boolean;
  55932. /** Gets or sets the hosting scene */
  55933. scene: Scene;
  55934. /**
  55935. * Gets the compilation hints emitted at compilation time
  55936. */
  55937. hints: {
  55938. needWorldViewMatrix: boolean;
  55939. needWorldViewProjectionMatrix: boolean;
  55940. needAlphaBlending: boolean;
  55941. needAlphaTesting: boolean;
  55942. };
  55943. /**
  55944. * List of compilation checks
  55945. */
  55946. checks: {
  55947. emitVertex: boolean;
  55948. emitFragment: boolean;
  55949. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55950. };
  55951. /** Creates a new shared data */
  55952. constructor();
  55953. /**
  55954. * Emits console errors and exceptions if there is a failing check
  55955. */
  55956. emitErrors(): void;
  55957. }
  55958. }
  55959. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55960. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55961. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55962. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55963. /**
  55964. * Class used to store node based material build state
  55965. */
  55966. export class NodeMaterialBuildState {
  55967. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55968. supportUniformBuffers: boolean;
  55969. /**
  55970. * Gets the list of emitted attributes
  55971. */
  55972. attributes: string[];
  55973. /**
  55974. * Gets the list of emitted uniforms
  55975. */
  55976. uniforms: string[];
  55977. /**
  55978. * Gets the list of emitted constants
  55979. */
  55980. constants: string[];
  55981. /**
  55982. * Gets the list of emitted samplers
  55983. */
  55984. samplers: string[];
  55985. /**
  55986. * Gets the list of emitted functions
  55987. */
  55988. functions: {
  55989. [key: string]: string;
  55990. };
  55991. /**
  55992. * Gets the list of emitted extensions
  55993. */
  55994. extensions: {
  55995. [key: string]: string;
  55996. };
  55997. /**
  55998. * Gets the target of the compilation state
  55999. */
  56000. target: NodeMaterialBlockTargets;
  56001. /**
  56002. * Gets the list of emitted counters
  56003. */
  56004. counters: {
  56005. [key: string]: number;
  56006. };
  56007. /**
  56008. * Shared data between multiple NodeMaterialBuildState instances
  56009. */
  56010. sharedData: NodeMaterialBuildStateSharedData;
  56011. /** @hidden */
  56012. _vertexState: NodeMaterialBuildState;
  56013. /** @hidden */
  56014. _attributeDeclaration: string;
  56015. /** @hidden */
  56016. _uniformDeclaration: string;
  56017. /** @hidden */
  56018. _constantDeclaration: string;
  56019. /** @hidden */
  56020. _samplerDeclaration: string;
  56021. /** @hidden */
  56022. _varyingTransfer: string;
  56023. private _repeatableContentAnchorIndex;
  56024. /** @hidden */
  56025. _builtCompilationString: string;
  56026. /**
  56027. * Gets the emitted compilation strings
  56028. */
  56029. compilationString: string;
  56030. /**
  56031. * Finalize the compilation strings
  56032. * @param state defines the current compilation state
  56033. */
  56034. finalize(state: NodeMaterialBuildState): void;
  56035. /** @hidden */
  56036. readonly _repeatableContentAnchor: string;
  56037. /** @hidden */
  56038. _getFreeVariableName(prefix: string): string;
  56039. /** @hidden */
  56040. _getFreeDefineName(prefix: string): string;
  56041. /** @hidden */
  56042. _excludeVariableName(name: string): void;
  56043. /** @hidden */
  56044. _emit2DSampler(name: string): void;
  56045. /** @hidden */
  56046. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56047. /** @hidden */
  56048. _emitExtension(name: string, extension: string): void;
  56049. /** @hidden */
  56050. _emitFunction(name: string, code: string, comments: string): void;
  56051. /** @hidden */
  56052. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56053. replaceStrings?: {
  56054. search: RegExp;
  56055. replace: string;
  56056. }[];
  56057. repeatKey?: string;
  56058. }): string;
  56059. /** @hidden */
  56060. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56061. repeatKey?: string;
  56062. removeAttributes?: boolean;
  56063. removeUniforms?: boolean;
  56064. removeVaryings?: boolean;
  56065. removeIfDef?: boolean;
  56066. replaceStrings?: {
  56067. search: RegExp;
  56068. replace: string;
  56069. }[];
  56070. }, storeKey?: string): void;
  56071. /** @hidden */
  56072. _registerTempVariable(name: string): boolean;
  56073. /** @hidden */
  56074. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56075. /** @hidden */
  56076. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56077. /** @hidden */
  56078. _emitFloat(value: number): string;
  56079. }
  56080. }
  56081. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56082. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56084. import { Nullable } from "babylonjs/types";
  56085. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56086. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56087. import { Effect } from "babylonjs/Materials/effect";
  56088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56089. import { Mesh } from "babylonjs/Meshes/mesh";
  56090. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56091. import { Scene } from "babylonjs/scene";
  56092. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56093. /**
  56094. * Defines a block that can be used inside a node based material
  56095. */
  56096. export class NodeMaterialBlock {
  56097. private _buildId;
  56098. private _buildTarget;
  56099. private _target;
  56100. private _isFinalMerger;
  56101. private _isInput;
  56102. /** @hidden */
  56103. _codeVariableName: string;
  56104. /** @hidden */
  56105. _inputs: NodeMaterialConnectionPoint[];
  56106. /** @hidden */
  56107. _outputs: NodeMaterialConnectionPoint[];
  56108. /** @hidden */
  56109. _preparationId: number;
  56110. /**
  56111. * Gets or sets the name of the block
  56112. */
  56113. name: string;
  56114. /**
  56115. * Gets or sets the unique id of the node
  56116. */
  56117. uniqueId: number;
  56118. /**
  56119. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56120. */
  56121. readonly isFinalMerger: boolean;
  56122. /**
  56123. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56124. */
  56125. readonly isInput: boolean;
  56126. /**
  56127. * Gets or sets the build Id
  56128. */
  56129. buildId: number;
  56130. /**
  56131. * Gets or sets the target of the block
  56132. */
  56133. target: NodeMaterialBlockTargets;
  56134. /**
  56135. * Gets the list of input points
  56136. */
  56137. readonly inputs: NodeMaterialConnectionPoint[];
  56138. /** Gets the list of output points */
  56139. readonly outputs: NodeMaterialConnectionPoint[];
  56140. /**
  56141. * Find an input by its name
  56142. * @param name defines the name of the input to look for
  56143. * @returns the input or null if not found
  56144. */
  56145. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56146. /**
  56147. * Find an output by its name
  56148. * @param name defines the name of the outputto look for
  56149. * @returns the output or null if not found
  56150. */
  56151. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56152. /**
  56153. * Creates a new NodeMaterialBlock
  56154. * @param name defines the block name
  56155. * @param target defines the target of that block (Vertex by default)
  56156. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56157. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56158. */
  56159. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56160. /**
  56161. * Initialize the block and prepare the context for build
  56162. * @param state defines the state that will be used for the build
  56163. */
  56164. initialize(state: NodeMaterialBuildState): void;
  56165. /**
  56166. * Bind data to effect. Will only be called for blocks with isBindable === true
  56167. * @param effect defines the effect to bind data to
  56168. * @param nodeMaterial defines the hosting NodeMaterial
  56169. * @param mesh defines the mesh that will be rendered
  56170. */
  56171. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56172. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56173. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56174. protected _writeFloat(value: number): string;
  56175. /**
  56176. * Gets the current class name e.g. "NodeMaterialBlock"
  56177. * @returns the class name
  56178. */
  56179. getClassName(): string;
  56180. /**
  56181. * Register a new input. Must be called inside a block constructor
  56182. * @param name defines the connection point name
  56183. * @param type defines the connection point type
  56184. * @param isOptional defines a boolean indicating that this input can be omitted
  56185. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56186. * @returns the current block
  56187. */
  56188. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56189. /**
  56190. * Register a new output. Must be called inside a block constructor
  56191. * @param name defines the connection point name
  56192. * @param type defines the connection point type
  56193. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56194. * @returns the current block
  56195. */
  56196. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56197. /**
  56198. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56199. * @param forOutput defines an optional connection point to check compatibility with
  56200. * @returns the first available input or null
  56201. */
  56202. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56203. /**
  56204. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56205. * @param forBlock defines an optional block to check compatibility with
  56206. * @returns the first available input or null
  56207. */
  56208. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56209. /**
  56210. * Gets the sibling of the given output
  56211. * @param current defines the current output
  56212. * @returns the next output in the list or null
  56213. */
  56214. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56215. /**
  56216. * Connect current block with another block
  56217. * @param other defines the block to connect with
  56218. * @param options define the various options to help pick the right connections
  56219. * @returns the current block
  56220. */
  56221. connectTo(other: NodeMaterialBlock, options?: {
  56222. input?: string;
  56223. output?: string;
  56224. outputSwizzle?: string;
  56225. }): this | undefined;
  56226. protected _buildBlock(state: NodeMaterialBuildState): void;
  56227. /**
  56228. * Add uniforms, samplers and uniform buffers at compilation time
  56229. * @param state defines the state to update
  56230. * @param nodeMaterial defines the node material requesting the update
  56231. * @param defines defines the material defines to update
  56232. * @param uniformBuffers defines the list of uniform buffer names
  56233. */
  56234. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56235. /**
  56236. * Add potential fallbacks if shader compilation fails
  56237. * @param mesh defines the mesh to be rendered
  56238. * @param fallbacks defines the current prioritized list of fallbacks
  56239. */
  56240. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56241. /**
  56242. * Initialize defines for shader compilation
  56243. * @param mesh defines the mesh to be rendered
  56244. * @param nodeMaterial defines the node material requesting the update
  56245. * @param defines defines the material defines to update
  56246. * @param useInstances specifies that instances should be used
  56247. */
  56248. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56249. /**
  56250. * Update defines for shader compilation
  56251. * @param mesh defines the mesh to be rendered
  56252. * @param nodeMaterial defines the node material requesting the update
  56253. * @param defines defines the material defines to update
  56254. * @param useInstances specifies that instances should be used
  56255. */
  56256. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56257. /**
  56258. * Lets the block try to connect some inputs automatically
  56259. * @param material defines the hosting NodeMaterial
  56260. */
  56261. autoConfigure(material: NodeMaterial): void;
  56262. /**
  56263. * Function called when a block is declared as repeatable content generator
  56264. * @param vertexShaderState defines the current compilation state for the vertex shader
  56265. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56266. * @param mesh defines the mesh to be rendered
  56267. * @param defines defines the material defines to update
  56268. */
  56269. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56270. /**
  56271. * Checks if the block is ready
  56272. * @param mesh defines the mesh to be rendered
  56273. * @param nodeMaterial defines the node material requesting the update
  56274. * @param defines defines the material defines to update
  56275. * @param useInstances specifies that instances should be used
  56276. * @returns true if the block is ready
  56277. */
  56278. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56279. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56280. private _processBuild;
  56281. /**
  56282. * Compile the current node and generate the shader code
  56283. * @param state defines the current compilation state (uniforms, samplers, current string)
  56284. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56285. * @returns true if already built
  56286. */
  56287. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56288. protected _inputRename(name: string): string;
  56289. protected _outputRename(name: string): string;
  56290. protected _dumpPropertiesCode(): string;
  56291. /** @hidden */
  56292. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56293. /**
  56294. * Clone the current block to a new identical block
  56295. * @param scene defines the hosting scene
  56296. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56297. * @returns a copy of the current block
  56298. */
  56299. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56300. /**
  56301. * Serializes this block in a JSON representation
  56302. * @returns the serialized block object
  56303. */
  56304. serialize(): any;
  56305. /** @hidden */
  56306. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56307. }
  56308. }
  56309. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56310. /**
  56311. * Enum defining the type of animations supported by InputBlock
  56312. */
  56313. export enum AnimatedInputBlockTypes {
  56314. /** No animation */
  56315. None = 0,
  56316. /** Time based animation. Will only work for floats */
  56317. Time = 1
  56318. }
  56319. }
  56320. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56322. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56323. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56324. import { Nullable } from "babylonjs/types";
  56325. import { Effect } from "babylonjs/Materials/effect";
  56326. import { Matrix } from "babylonjs/Maths/math.vector";
  56327. import { Scene } from "babylonjs/scene";
  56328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56330. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56331. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56332. /**
  56333. * Block used to expose an input value
  56334. */
  56335. export class InputBlock extends NodeMaterialBlock {
  56336. private _mode;
  56337. private _associatedVariableName;
  56338. private _storedValue;
  56339. private _valueCallback;
  56340. private _type;
  56341. private _animationType;
  56342. /** Gets or set a value used to limit the range of float values */
  56343. min: number;
  56344. /** Gets or set a value used to limit the range of float values */
  56345. max: number;
  56346. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56347. matrixMode: number;
  56348. /** @hidden */
  56349. _systemValue: Nullable<NodeMaterialSystemValues>;
  56350. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56351. visibleInInspector: boolean;
  56352. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56353. isConstant: boolean;
  56354. /**
  56355. * Gets or sets the connection point type (default is float)
  56356. */
  56357. readonly type: NodeMaterialBlockConnectionPointTypes;
  56358. /**
  56359. * Creates a new InputBlock
  56360. * @param name defines the block name
  56361. * @param target defines the target of that block (Vertex by default)
  56362. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56363. */
  56364. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56365. /**
  56366. * Gets the output component
  56367. */
  56368. readonly output: NodeMaterialConnectionPoint;
  56369. /**
  56370. * Set the source of this connection point to a vertex attribute
  56371. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56372. * @returns the current connection point
  56373. */
  56374. setAsAttribute(attributeName?: string): InputBlock;
  56375. /**
  56376. * Set the source of this connection point to a system value
  56377. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56378. * @returns the current connection point
  56379. */
  56380. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56381. /**
  56382. * Gets or sets the value of that point.
  56383. * Please note that this value will be ignored if valueCallback is defined
  56384. */
  56385. value: any;
  56386. /**
  56387. * Gets or sets a callback used to get the value of that point.
  56388. * Please note that setting this value will force the connection point to ignore the value property
  56389. */
  56390. valueCallback: () => any;
  56391. /**
  56392. * Gets or sets the associated variable name in the shader
  56393. */
  56394. associatedVariableName: string;
  56395. /** Gets or sets the type of animation applied to the input */
  56396. animationType: AnimatedInputBlockTypes;
  56397. /**
  56398. * Gets a boolean indicating that this connection point not defined yet
  56399. */
  56400. readonly isUndefined: boolean;
  56401. /**
  56402. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56403. * In this case the connection point name must be the name of the uniform to use.
  56404. * Can only be set on inputs
  56405. */
  56406. isUniform: boolean;
  56407. /**
  56408. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56409. * In this case the connection point name must be the name of the attribute to use
  56410. * Can only be set on inputs
  56411. */
  56412. isAttribute: boolean;
  56413. /**
  56414. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56415. * Can only be set on exit points
  56416. */
  56417. isVarying: boolean;
  56418. /**
  56419. * Gets a boolean indicating that the current connection point is a system value
  56420. */
  56421. readonly isSystemValue: boolean;
  56422. /**
  56423. * Gets or sets the current well known value or null if not defined as a system value
  56424. */
  56425. systemValue: Nullable<NodeMaterialSystemValues>;
  56426. /**
  56427. * Gets the current class name
  56428. * @returns the class name
  56429. */
  56430. getClassName(): string;
  56431. /**
  56432. * Animate the input if animationType !== None
  56433. * @param scene defines the rendering scene
  56434. */
  56435. animate(scene: Scene): void;
  56436. private _emitDefine;
  56437. initialize(state: NodeMaterialBuildState): void;
  56438. /**
  56439. * Set the input block to its default value (based on its type)
  56440. */
  56441. setDefaultValue(): void;
  56442. private _emitConstant;
  56443. private _emit;
  56444. /** @hidden */
  56445. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56446. /** @hidden */
  56447. _transmit(effect: Effect, scene: Scene): void;
  56448. protected _buildBlock(state: NodeMaterialBuildState): void;
  56449. protected _dumpPropertiesCode(): string;
  56450. serialize(): any;
  56451. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56452. }
  56453. }
  56454. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56455. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56456. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56457. import { Nullable } from "babylonjs/types";
  56458. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56459. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56460. /**
  56461. * Defines a connection point for a block
  56462. */
  56463. export class NodeMaterialConnectionPoint {
  56464. /** @hidden */
  56465. _ownerBlock: NodeMaterialBlock;
  56466. /** @hidden */
  56467. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56468. private _endpoints;
  56469. private _associatedVariableName;
  56470. /** @hidden */
  56471. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56472. /** @hidden */
  56473. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56474. private _type;
  56475. /** @hidden */
  56476. _enforceAssociatedVariableName: boolean;
  56477. /**
  56478. * Gets or sets the additional types supported by this connection point
  56479. */
  56480. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56481. /**
  56482. * Gets or sets the additional types excluded by this connection point
  56483. */
  56484. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56485. /**
  56486. * Gets or sets the associated variable name in the shader
  56487. */
  56488. associatedVariableName: string;
  56489. /**
  56490. * Gets or sets the connection point type (default is float)
  56491. */
  56492. type: NodeMaterialBlockConnectionPointTypes;
  56493. /**
  56494. * Gets or sets the connection point name
  56495. */
  56496. name: string;
  56497. /**
  56498. * Gets or sets a boolean indicating that this connection point can be omitted
  56499. */
  56500. isOptional: boolean;
  56501. /**
  56502. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56503. */
  56504. define: string;
  56505. /** @hidden */
  56506. _prioritizeVertex: boolean;
  56507. private _target;
  56508. /** Gets or sets the target of that connection point */
  56509. target: NodeMaterialBlockTargets;
  56510. /**
  56511. * Gets a boolean indicating that the current point is connected
  56512. */
  56513. readonly isConnected: boolean;
  56514. /**
  56515. * Gets a boolean indicating that the current point is connected to an input block
  56516. */
  56517. readonly isConnectedToInputBlock: boolean;
  56518. /**
  56519. * Gets a the connected input block (if any)
  56520. */
  56521. readonly connectInputBlock: Nullable<InputBlock>;
  56522. /** Get the other side of the connection (if any) */
  56523. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56524. /** Get the block that owns this connection point */
  56525. readonly ownerBlock: NodeMaterialBlock;
  56526. /** Get the block connected on the other side of this connection (if any) */
  56527. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56528. /** Get the block connected on the endpoints of this connection (if any) */
  56529. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56530. /** Gets the list of connected endpoints */
  56531. readonly endpoints: NodeMaterialConnectionPoint[];
  56532. /** Gets a boolean indicating if that output point is connected to at least one input */
  56533. readonly hasEndpoints: boolean;
  56534. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56535. readonly isConnectedInVertexShader: boolean;
  56536. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56537. readonly isConnectedInFragmentShader: boolean;
  56538. /**
  56539. * Creates a new connection point
  56540. * @param name defines the connection point name
  56541. * @param ownerBlock defines the block hosting this connection point
  56542. */
  56543. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56544. /**
  56545. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56546. * @returns the class name
  56547. */
  56548. getClassName(): string;
  56549. /**
  56550. * Gets an boolean indicating if the current point can be connected to another point
  56551. * @param connectionPoint defines the other connection point
  56552. * @returns true if the connection is possible
  56553. */
  56554. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56555. /**
  56556. * Connect this point to another connection point
  56557. * @param connectionPoint defines the other connection point
  56558. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56559. * @returns the current connection point
  56560. */
  56561. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56562. /**
  56563. * Disconnect this point from one of his endpoint
  56564. * @param endpoint defines the other connection point
  56565. * @returns the current connection point
  56566. */
  56567. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56568. /**
  56569. * Serializes this point in a JSON representation
  56570. * @returns the serialized point object
  56571. */
  56572. serialize(): any;
  56573. }
  56574. }
  56575. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56576. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56577. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56579. import { Mesh } from "babylonjs/Meshes/mesh";
  56580. import { Effect } from "babylonjs/Materials/effect";
  56581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56582. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56583. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56584. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56585. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56586. /**
  56587. * Block used to add support for vertex skinning (bones)
  56588. */
  56589. export class BonesBlock extends NodeMaterialBlock {
  56590. /**
  56591. * Creates a new BonesBlock
  56592. * @param name defines the block name
  56593. */
  56594. constructor(name: string);
  56595. /**
  56596. * Initialize the block and prepare the context for build
  56597. * @param state defines the state that will be used for the build
  56598. */
  56599. initialize(state: NodeMaterialBuildState): void;
  56600. /**
  56601. * Gets the current class name
  56602. * @returns the class name
  56603. */
  56604. getClassName(): string;
  56605. /**
  56606. * Gets the matrix indices input component
  56607. */
  56608. readonly matricesIndices: NodeMaterialConnectionPoint;
  56609. /**
  56610. * Gets the matrix weights input component
  56611. */
  56612. readonly matricesWeights: NodeMaterialConnectionPoint;
  56613. /**
  56614. * Gets the extra matrix indices input component
  56615. */
  56616. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56617. /**
  56618. * Gets the extra matrix weights input component
  56619. */
  56620. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56621. /**
  56622. * Gets the world input component
  56623. */
  56624. readonly world: NodeMaterialConnectionPoint;
  56625. /**
  56626. * Gets the output component
  56627. */
  56628. readonly output: NodeMaterialConnectionPoint;
  56629. autoConfigure(material: NodeMaterial): void;
  56630. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56631. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56633. protected _buildBlock(state: NodeMaterialBuildState): this;
  56634. }
  56635. }
  56636. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56637. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56639. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56641. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56642. /**
  56643. * Block used to add support for instances
  56644. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56645. */
  56646. export class InstancesBlock extends NodeMaterialBlock {
  56647. /**
  56648. * Creates a new InstancesBlock
  56649. * @param name defines the block name
  56650. */
  56651. constructor(name: string);
  56652. /**
  56653. * Gets the current class name
  56654. * @returns the class name
  56655. */
  56656. getClassName(): string;
  56657. /**
  56658. * Gets the first world row input component
  56659. */
  56660. readonly world0: NodeMaterialConnectionPoint;
  56661. /**
  56662. * Gets the second world row input component
  56663. */
  56664. readonly world1: NodeMaterialConnectionPoint;
  56665. /**
  56666. * Gets the third world row input component
  56667. */
  56668. readonly world2: NodeMaterialConnectionPoint;
  56669. /**
  56670. * Gets the forth world row input component
  56671. */
  56672. readonly world3: NodeMaterialConnectionPoint;
  56673. /**
  56674. * Gets the world input component
  56675. */
  56676. readonly world: NodeMaterialConnectionPoint;
  56677. /**
  56678. * Gets the output component
  56679. */
  56680. readonly output: NodeMaterialConnectionPoint;
  56681. autoConfigure(material: NodeMaterial): void;
  56682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56683. protected _buildBlock(state: NodeMaterialBuildState): this;
  56684. }
  56685. }
  56686. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56691. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56692. import { Effect } from "babylonjs/Materials/effect";
  56693. import { Mesh } from "babylonjs/Meshes/mesh";
  56694. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56695. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56696. /**
  56697. * Block used to add morph targets support to vertex shader
  56698. */
  56699. export class MorphTargetsBlock extends NodeMaterialBlock {
  56700. private _repeatableContentAnchor;
  56701. private _repeatebleContentGenerated;
  56702. /**
  56703. * Create a new MorphTargetsBlock
  56704. * @param name defines the block name
  56705. */
  56706. constructor(name: string);
  56707. /**
  56708. * Gets the current class name
  56709. * @returns the class name
  56710. */
  56711. getClassName(): string;
  56712. /**
  56713. * Gets the position input component
  56714. */
  56715. readonly position: NodeMaterialConnectionPoint;
  56716. /**
  56717. * Gets the normal input component
  56718. */
  56719. readonly normal: NodeMaterialConnectionPoint;
  56720. /**
  56721. * Gets the tangent input component
  56722. */
  56723. readonly tangent: NodeMaterialConnectionPoint;
  56724. /**
  56725. * Gets the tangent input component
  56726. */
  56727. readonly uv: NodeMaterialConnectionPoint;
  56728. /**
  56729. * Gets the position output component
  56730. */
  56731. readonly positionOutput: NodeMaterialConnectionPoint;
  56732. /**
  56733. * Gets the normal output component
  56734. */
  56735. readonly normalOutput: NodeMaterialConnectionPoint;
  56736. /**
  56737. * Gets the tangent output component
  56738. */
  56739. readonly tangentOutput: NodeMaterialConnectionPoint;
  56740. /**
  56741. * Gets the tangent output component
  56742. */
  56743. readonly uvOutput: NodeMaterialConnectionPoint;
  56744. initialize(state: NodeMaterialBuildState): void;
  56745. autoConfigure(material: NodeMaterial): void;
  56746. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56747. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56748. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56749. protected _buildBlock(state: NodeMaterialBuildState): this;
  56750. }
  56751. }
  56752. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56756. import { Nullable } from "babylonjs/types";
  56757. import { Scene } from "babylonjs/scene";
  56758. import { Effect } from "babylonjs/Materials/effect";
  56759. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56760. import { Mesh } from "babylonjs/Meshes/mesh";
  56761. import { Light } from "babylonjs/Lights/light";
  56762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56763. /**
  56764. * Block used to get data information from a light
  56765. */
  56766. export class LightInformationBlock extends NodeMaterialBlock {
  56767. private _lightDataUniformName;
  56768. private _lightColorUniformName;
  56769. private _lightTypeDefineName;
  56770. /**
  56771. * Gets or sets the light associated with this block
  56772. */
  56773. light: Nullable<Light>;
  56774. /**
  56775. * Creates a new LightInformationBlock
  56776. * @param name defines the block name
  56777. */
  56778. constructor(name: string);
  56779. /**
  56780. * Gets the current class name
  56781. * @returns the class name
  56782. */
  56783. getClassName(): string;
  56784. /**
  56785. * Gets the world position input component
  56786. */
  56787. readonly worldPosition: NodeMaterialConnectionPoint;
  56788. /**
  56789. * Gets the direction output component
  56790. */
  56791. readonly direction: NodeMaterialConnectionPoint;
  56792. /**
  56793. * Gets the direction output component
  56794. */
  56795. readonly color: NodeMaterialConnectionPoint;
  56796. /**
  56797. * Gets the direction output component
  56798. */
  56799. readonly intensity: NodeMaterialConnectionPoint;
  56800. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56801. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56802. protected _buildBlock(state: NodeMaterialBuildState): this;
  56803. serialize(): any;
  56804. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56805. }
  56806. }
  56807. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56808. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56809. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56810. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56811. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56812. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56813. }
  56814. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56819. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56820. import { Effect } from "babylonjs/Materials/effect";
  56821. import { Mesh } from "babylonjs/Meshes/mesh";
  56822. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56823. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56824. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56825. /**
  56826. * Block used to add image processing support to fragment shader
  56827. */
  56828. export class ImageProcessingBlock extends NodeMaterialBlock {
  56829. /**
  56830. * Create a new ImageProcessingBlock
  56831. * @param name defines the block name
  56832. */
  56833. constructor(name: string);
  56834. /**
  56835. * Gets the current class name
  56836. * @returns the class name
  56837. */
  56838. getClassName(): string;
  56839. /**
  56840. * Gets the color input component
  56841. */
  56842. readonly color: NodeMaterialConnectionPoint;
  56843. /**
  56844. * Gets the output component
  56845. */
  56846. readonly output: NodeMaterialConnectionPoint;
  56847. /**
  56848. * Initialize the block and prepare the context for build
  56849. * @param state defines the state that will be used for the build
  56850. */
  56851. initialize(state: NodeMaterialBuildState): void;
  56852. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56853. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56854. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56855. protected _buildBlock(state: NodeMaterialBuildState): this;
  56856. }
  56857. }
  56858. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56859. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56860. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56862. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56864. import { Effect } from "babylonjs/Materials/effect";
  56865. import { Mesh } from "babylonjs/Meshes/mesh";
  56866. import { Scene } from "babylonjs/scene";
  56867. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56868. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56869. /**
  56870. * Block used to pertub normals based on a normal map
  56871. */
  56872. export class PerturbNormalBlock extends NodeMaterialBlock {
  56873. private _tangentSpaceParameterName;
  56874. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56875. invertX: boolean;
  56876. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56877. invertY: boolean;
  56878. /**
  56879. * Create a new PerturbNormalBlock
  56880. * @param name defines the block name
  56881. */
  56882. constructor(name: string);
  56883. /**
  56884. * Gets the current class name
  56885. * @returns the class name
  56886. */
  56887. getClassName(): string;
  56888. /**
  56889. * Gets the world position input component
  56890. */
  56891. readonly worldPosition: NodeMaterialConnectionPoint;
  56892. /**
  56893. * Gets the world normal input component
  56894. */
  56895. readonly worldNormal: NodeMaterialConnectionPoint;
  56896. /**
  56897. * Gets the uv input component
  56898. */
  56899. readonly uv: NodeMaterialConnectionPoint;
  56900. /**
  56901. * Gets the normal map color input component
  56902. */
  56903. readonly normalMapColor: NodeMaterialConnectionPoint;
  56904. /**
  56905. * Gets the strength input component
  56906. */
  56907. readonly strength: NodeMaterialConnectionPoint;
  56908. /**
  56909. * Gets the output component
  56910. */
  56911. readonly output: NodeMaterialConnectionPoint;
  56912. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56913. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56914. autoConfigure(material: NodeMaterial): void;
  56915. protected _buildBlock(state: NodeMaterialBuildState): this;
  56916. protected _dumpPropertiesCode(): string;
  56917. serialize(): any;
  56918. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56919. }
  56920. }
  56921. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56925. /**
  56926. * Block used to discard a pixel if a value is smaller than a cutoff
  56927. */
  56928. export class DiscardBlock extends NodeMaterialBlock {
  56929. /**
  56930. * Create a new DiscardBlock
  56931. * @param name defines the block name
  56932. */
  56933. constructor(name: string);
  56934. /**
  56935. * Gets the current class name
  56936. * @returns the class name
  56937. */
  56938. getClassName(): string;
  56939. /**
  56940. * Gets the color input component
  56941. */
  56942. readonly value: NodeMaterialConnectionPoint;
  56943. /**
  56944. * Gets the cutoff input component
  56945. */
  56946. readonly cutoff: NodeMaterialConnectionPoint;
  56947. protected _buildBlock(state: NodeMaterialBuildState): this;
  56948. }
  56949. }
  56950. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56951. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56952. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56953. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56954. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56955. }
  56956. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56959. import { Mesh } from "babylonjs/Meshes/mesh";
  56960. import { Effect } from "babylonjs/Materials/effect";
  56961. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56963. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56964. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56965. /**
  56966. * Block used to add support for scene fog
  56967. */
  56968. export class FogBlock extends NodeMaterialBlock {
  56969. private _fogDistanceName;
  56970. private _fogParameters;
  56971. /**
  56972. * Create a new FogBlock
  56973. * @param name defines the block name
  56974. */
  56975. constructor(name: string);
  56976. /**
  56977. * Gets the current class name
  56978. * @returns the class name
  56979. */
  56980. getClassName(): string;
  56981. /**
  56982. * Gets the world position input component
  56983. */
  56984. readonly worldPosition: NodeMaterialConnectionPoint;
  56985. /**
  56986. * Gets the view input component
  56987. */
  56988. readonly view: NodeMaterialConnectionPoint;
  56989. /**
  56990. * Gets the color input component
  56991. */
  56992. readonly input: NodeMaterialConnectionPoint;
  56993. /**
  56994. * Gets the fog color input component
  56995. */
  56996. readonly fogColor: NodeMaterialConnectionPoint;
  56997. /**
  56998. * Gets the output component
  56999. */
  57000. readonly output: NodeMaterialConnectionPoint;
  57001. autoConfigure(material: NodeMaterial): void;
  57002. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57003. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57004. protected _buildBlock(state: NodeMaterialBuildState): this;
  57005. }
  57006. }
  57007. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57010. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57012. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57013. import { Effect } from "babylonjs/Materials/effect";
  57014. import { Mesh } from "babylonjs/Meshes/mesh";
  57015. import { Light } from "babylonjs/Lights/light";
  57016. import { Nullable } from "babylonjs/types";
  57017. import { Scene } from "babylonjs/scene";
  57018. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57019. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57020. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57021. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57022. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57023. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57024. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57025. /**
  57026. * Block used to add light in the fragment shader
  57027. */
  57028. export class LightBlock extends NodeMaterialBlock {
  57029. private _lightId;
  57030. /**
  57031. * Gets or sets the light associated with this block
  57032. */
  57033. light: Nullable<Light>;
  57034. /**
  57035. * Create a new LightBlock
  57036. * @param name defines the block name
  57037. */
  57038. constructor(name: string);
  57039. /**
  57040. * Gets the current class name
  57041. * @returns the class name
  57042. */
  57043. getClassName(): string;
  57044. /**
  57045. * Gets the world position input component
  57046. */
  57047. readonly worldPosition: NodeMaterialConnectionPoint;
  57048. /**
  57049. * Gets the world normal input component
  57050. */
  57051. readonly worldNormal: NodeMaterialConnectionPoint;
  57052. /**
  57053. * Gets the camera (or eye) position component
  57054. */
  57055. readonly cameraPosition: NodeMaterialConnectionPoint;
  57056. /**
  57057. * Gets the glossiness component
  57058. */
  57059. readonly glossiness: NodeMaterialConnectionPoint;
  57060. /**
  57061. * Gets the glossinness power component
  57062. */
  57063. readonly glossPower: NodeMaterialConnectionPoint;
  57064. /**
  57065. * Gets the diffuse color component
  57066. */
  57067. readonly diffuseColor: NodeMaterialConnectionPoint;
  57068. /**
  57069. * Gets the specular color component
  57070. */
  57071. readonly specularColor: NodeMaterialConnectionPoint;
  57072. /**
  57073. * Gets the diffuse output component
  57074. */
  57075. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57076. /**
  57077. * Gets the specular output component
  57078. */
  57079. readonly specularOutput: NodeMaterialConnectionPoint;
  57080. autoConfigure(material: NodeMaterial): void;
  57081. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57082. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57083. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57084. private _injectVertexCode;
  57085. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57086. serialize(): any;
  57087. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57088. }
  57089. }
  57090. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57091. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57092. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57093. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57094. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57095. }
  57096. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57097. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57098. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57099. }
  57100. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57104. /**
  57105. * Block used to multiply 2 values
  57106. */
  57107. export class MultiplyBlock extends NodeMaterialBlock {
  57108. /**
  57109. * Creates a new MultiplyBlock
  57110. * @param name defines the block name
  57111. */
  57112. constructor(name: string);
  57113. /**
  57114. * Gets the current class name
  57115. * @returns the class name
  57116. */
  57117. getClassName(): string;
  57118. /**
  57119. * Gets the left operand input component
  57120. */
  57121. readonly left: NodeMaterialConnectionPoint;
  57122. /**
  57123. * Gets the right operand input component
  57124. */
  57125. readonly right: NodeMaterialConnectionPoint;
  57126. /**
  57127. * Gets the output component
  57128. */
  57129. readonly output: NodeMaterialConnectionPoint;
  57130. protected _buildBlock(state: NodeMaterialBuildState): this;
  57131. }
  57132. }
  57133. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57134. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57135. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57137. /**
  57138. * Block used to add 2 vectors
  57139. */
  57140. export class AddBlock extends NodeMaterialBlock {
  57141. /**
  57142. * Creates a new AddBlock
  57143. * @param name defines the block name
  57144. */
  57145. constructor(name: string);
  57146. /**
  57147. * Gets the current class name
  57148. * @returns the class name
  57149. */
  57150. getClassName(): string;
  57151. /**
  57152. * Gets the left operand input component
  57153. */
  57154. readonly left: NodeMaterialConnectionPoint;
  57155. /**
  57156. * Gets the right operand input component
  57157. */
  57158. readonly right: NodeMaterialConnectionPoint;
  57159. /**
  57160. * Gets the output component
  57161. */
  57162. readonly output: NodeMaterialConnectionPoint;
  57163. protected _buildBlock(state: NodeMaterialBuildState): this;
  57164. }
  57165. }
  57166. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57167. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57169. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57170. /**
  57171. * Block used to scale a vector by a float
  57172. */
  57173. export class ScaleBlock extends NodeMaterialBlock {
  57174. /**
  57175. * Creates a new ScaleBlock
  57176. * @param name defines the block name
  57177. */
  57178. constructor(name: string);
  57179. /**
  57180. * Gets the current class name
  57181. * @returns the class name
  57182. */
  57183. getClassName(): string;
  57184. /**
  57185. * Gets the input component
  57186. */
  57187. readonly input: NodeMaterialConnectionPoint;
  57188. /**
  57189. * Gets the factor input component
  57190. */
  57191. readonly factor: NodeMaterialConnectionPoint;
  57192. /**
  57193. * Gets the output component
  57194. */
  57195. readonly output: NodeMaterialConnectionPoint;
  57196. protected _buildBlock(state: NodeMaterialBuildState): this;
  57197. }
  57198. }
  57199. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57203. import { Scene } from "babylonjs/scene";
  57204. /**
  57205. * Block used to clamp a float
  57206. */
  57207. export class ClampBlock extends NodeMaterialBlock {
  57208. /** Gets or sets the minimum range */
  57209. minimum: number;
  57210. /** Gets or sets the maximum range */
  57211. maximum: number;
  57212. /**
  57213. * Creates a new ClampBlock
  57214. * @param name defines the block name
  57215. */
  57216. constructor(name: string);
  57217. /**
  57218. * Gets the current class name
  57219. * @returns the class name
  57220. */
  57221. getClassName(): string;
  57222. /**
  57223. * Gets the value input component
  57224. */
  57225. readonly value: NodeMaterialConnectionPoint;
  57226. /**
  57227. * Gets the output component
  57228. */
  57229. readonly output: NodeMaterialConnectionPoint;
  57230. protected _buildBlock(state: NodeMaterialBuildState): this;
  57231. protected _dumpPropertiesCode(): string;
  57232. serialize(): any;
  57233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57234. }
  57235. }
  57236. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57237. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57238. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57239. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57240. /**
  57241. * Block used to apply a cross product between 2 vectors
  57242. */
  57243. export class CrossBlock extends NodeMaterialBlock {
  57244. /**
  57245. * Creates a new CrossBlock
  57246. * @param name defines the block name
  57247. */
  57248. constructor(name: string);
  57249. /**
  57250. * Gets the current class name
  57251. * @returns the class name
  57252. */
  57253. getClassName(): string;
  57254. /**
  57255. * Gets the left operand input component
  57256. */
  57257. readonly left: NodeMaterialConnectionPoint;
  57258. /**
  57259. * Gets the right operand input component
  57260. */
  57261. readonly right: NodeMaterialConnectionPoint;
  57262. /**
  57263. * Gets the output component
  57264. */
  57265. readonly output: NodeMaterialConnectionPoint;
  57266. protected _buildBlock(state: NodeMaterialBuildState): this;
  57267. }
  57268. }
  57269. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57273. /**
  57274. * Block used to apply a dot product between 2 vectors
  57275. */
  57276. export class DotBlock extends NodeMaterialBlock {
  57277. /**
  57278. * Creates a new DotBlock
  57279. * @param name defines the block name
  57280. */
  57281. constructor(name: string);
  57282. /**
  57283. * Gets the current class name
  57284. * @returns the class name
  57285. */
  57286. getClassName(): string;
  57287. /**
  57288. * Gets the left operand input component
  57289. */
  57290. readonly left: NodeMaterialConnectionPoint;
  57291. /**
  57292. * Gets the right operand input component
  57293. */
  57294. readonly right: NodeMaterialConnectionPoint;
  57295. /**
  57296. * Gets the output component
  57297. */
  57298. readonly output: NodeMaterialConnectionPoint;
  57299. protected _buildBlock(state: NodeMaterialBuildState): this;
  57300. }
  57301. }
  57302. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57303. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57304. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57305. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57306. import { Vector2 } from "babylonjs/Maths/math.vector";
  57307. import { Scene } from "babylonjs/scene";
  57308. /**
  57309. * Block used to remap a float from a range to a new one
  57310. */
  57311. export class RemapBlock extends NodeMaterialBlock {
  57312. /**
  57313. * Gets or sets the source range
  57314. */
  57315. sourceRange: Vector2;
  57316. /**
  57317. * Gets or sets the target range
  57318. */
  57319. targetRange: Vector2;
  57320. /**
  57321. * Creates a new RemapBlock
  57322. * @param name defines the block name
  57323. */
  57324. constructor(name: string);
  57325. /**
  57326. * Gets the current class name
  57327. * @returns the class name
  57328. */
  57329. getClassName(): string;
  57330. /**
  57331. * Gets the input component
  57332. */
  57333. readonly input: NodeMaterialConnectionPoint;
  57334. /**
  57335. * Gets the source min input component
  57336. */
  57337. readonly sourceMin: NodeMaterialConnectionPoint;
  57338. /**
  57339. * Gets the source max input component
  57340. */
  57341. readonly sourceMax: NodeMaterialConnectionPoint;
  57342. /**
  57343. * Gets the target min input component
  57344. */
  57345. readonly targetMin: NodeMaterialConnectionPoint;
  57346. /**
  57347. * Gets the target max input component
  57348. */
  57349. readonly targetMax: NodeMaterialConnectionPoint;
  57350. /**
  57351. * Gets the output component
  57352. */
  57353. readonly output: NodeMaterialConnectionPoint;
  57354. protected _buildBlock(state: NodeMaterialBuildState): this;
  57355. protected _dumpPropertiesCode(): string;
  57356. serialize(): any;
  57357. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57358. }
  57359. }
  57360. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57364. /**
  57365. * Block used to normalize a vector
  57366. */
  57367. export class NormalizeBlock extends NodeMaterialBlock {
  57368. /**
  57369. * Creates a new NormalizeBlock
  57370. * @param name defines the block name
  57371. */
  57372. constructor(name: string);
  57373. /**
  57374. * Gets the current class name
  57375. * @returns the class name
  57376. */
  57377. getClassName(): string;
  57378. /**
  57379. * Gets the input component
  57380. */
  57381. readonly input: NodeMaterialConnectionPoint;
  57382. /**
  57383. * Gets the output component
  57384. */
  57385. readonly output: NodeMaterialConnectionPoint;
  57386. protected _buildBlock(state: NodeMaterialBuildState): this;
  57387. }
  57388. }
  57389. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57390. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57391. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57392. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57393. import { Scene } from "babylonjs/scene";
  57394. /**
  57395. * Operations supported by the Trigonometry block
  57396. */
  57397. export enum TrigonometryBlockOperations {
  57398. /** Cos */
  57399. Cos = 0,
  57400. /** Sin */
  57401. Sin = 1,
  57402. /** Abs */
  57403. Abs = 2,
  57404. /** Exp */
  57405. Exp = 3,
  57406. /** Exp2 */
  57407. Exp2 = 4,
  57408. /** Round */
  57409. Round = 5,
  57410. /** Floor */
  57411. Floor = 6,
  57412. /** Ceiling */
  57413. Ceiling = 7,
  57414. /** Square root */
  57415. Sqrt = 8,
  57416. /** Log */
  57417. Log = 9,
  57418. /** Tangent */
  57419. Tan = 10,
  57420. /** Arc tangent */
  57421. ArcTan = 11,
  57422. /** Arc cosinus */
  57423. ArcCos = 12,
  57424. /** Arc sinus */
  57425. ArcSin = 13,
  57426. /** Fraction */
  57427. Fract = 14,
  57428. /** Sign */
  57429. Sign = 15,
  57430. /** To radians (from degrees) */
  57431. Radians = 16,
  57432. /** To degrees (from radians) */
  57433. Degrees = 17
  57434. }
  57435. /**
  57436. * Block used to apply trigonometry operation to floats
  57437. */
  57438. export class TrigonometryBlock extends NodeMaterialBlock {
  57439. /**
  57440. * Gets or sets the operation applied by the block
  57441. */
  57442. operation: TrigonometryBlockOperations;
  57443. /**
  57444. * Creates a new TrigonometryBlock
  57445. * @param name defines the block name
  57446. */
  57447. constructor(name: string);
  57448. /**
  57449. * Gets the current class name
  57450. * @returns the class name
  57451. */
  57452. getClassName(): string;
  57453. /**
  57454. * Gets the input component
  57455. */
  57456. readonly input: NodeMaterialConnectionPoint;
  57457. /**
  57458. * Gets the output component
  57459. */
  57460. readonly output: NodeMaterialConnectionPoint;
  57461. protected _buildBlock(state: NodeMaterialBuildState): this;
  57462. serialize(): any;
  57463. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57464. }
  57465. }
  57466. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57470. /**
  57471. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57472. */
  57473. export class ColorMergerBlock extends NodeMaterialBlock {
  57474. /**
  57475. * Create a new ColorMergerBlock
  57476. * @param name defines the block name
  57477. */
  57478. constructor(name: string);
  57479. /**
  57480. * Gets the current class name
  57481. * @returns the class name
  57482. */
  57483. getClassName(): string;
  57484. /**
  57485. * Gets the r component (input)
  57486. */
  57487. readonly r: NodeMaterialConnectionPoint;
  57488. /**
  57489. * Gets the g component (input)
  57490. */
  57491. readonly g: NodeMaterialConnectionPoint;
  57492. /**
  57493. * Gets the b component (input)
  57494. */
  57495. readonly b: NodeMaterialConnectionPoint;
  57496. /**
  57497. * Gets the a component (input)
  57498. */
  57499. readonly a: NodeMaterialConnectionPoint;
  57500. /**
  57501. * Gets the rgba component (output)
  57502. */
  57503. readonly rgba: NodeMaterialConnectionPoint;
  57504. /**
  57505. * Gets the rgb component (output)
  57506. */
  57507. readonly rgb: NodeMaterialConnectionPoint;
  57508. protected _buildBlock(state: NodeMaterialBuildState): this;
  57509. }
  57510. }
  57511. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57514. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57515. /**
  57516. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57517. */
  57518. export class VectorMergerBlock extends NodeMaterialBlock {
  57519. /**
  57520. * Create a new VectorMergerBlock
  57521. * @param name defines the block name
  57522. */
  57523. constructor(name: string);
  57524. /**
  57525. * Gets the current class name
  57526. * @returns the class name
  57527. */
  57528. getClassName(): string;
  57529. /**
  57530. * Gets the x component (input)
  57531. */
  57532. readonly x: NodeMaterialConnectionPoint;
  57533. /**
  57534. * Gets the y component (input)
  57535. */
  57536. readonly y: NodeMaterialConnectionPoint;
  57537. /**
  57538. * Gets the z component (input)
  57539. */
  57540. readonly z: NodeMaterialConnectionPoint;
  57541. /**
  57542. * Gets the w component (input)
  57543. */
  57544. readonly w: NodeMaterialConnectionPoint;
  57545. /**
  57546. * Gets the xyzw component (output)
  57547. */
  57548. readonly xyzw: NodeMaterialConnectionPoint;
  57549. /**
  57550. * Gets the xyz component (output)
  57551. */
  57552. readonly xyz: NodeMaterialConnectionPoint;
  57553. /**
  57554. * Gets the xy component (output)
  57555. */
  57556. readonly xy: NodeMaterialConnectionPoint;
  57557. protected _buildBlock(state: NodeMaterialBuildState): this;
  57558. }
  57559. }
  57560. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57564. /**
  57565. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57566. */
  57567. export class ColorSplitterBlock extends NodeMaterialBlock {
  57568. /**
  57569. * Create a new ColorSplitterBlock
  57570. * @param name defines the block name
  57571. */
  57572. constructor(name: string);
  57573. /**
  57574. * Gets the current class name
  57575. * @returns the class name
  57576. */
  57577. getClassName(): string;
  57578. /**
  57579. * Gets the rgba component (input)
  57580. */
  57581. readonly rgba: NodeMaterialConnectionPoint;
  57582. /**
  57583. * Gets the rgb component (input)
  57584. */
  57585. readonly rgbIn: NodeMaterialConnectionPoint;
  57586. /**
  57587. * Gets the rgb component (output)
  57588. */
  57589. readonly rgbOut: NodeMaterialConnectionPoint;
  57590. /**
  57591. * Gets the r component (output)
  57592. */
  57593. readonly r: NodeMaterialConnectionPoint;
  57594. /**
  57595. * Gets the g component (output)
  57596. */
  57597. readonly g: NodeMaterialConnectionPoint;
  57598. /**
  57599. * Gets the b component (output)
  57600. */
  57601. readonly b: NodeMaterialConnectionPoint;
  57602. /**
  57603. * Gets the a component (output)
  57604. */
  57605. readonly a: NodeMaterialConnectionPoint;
  57606. protected _inputRename(name: string): string;
  57607. protected _outputRename(name: string): string;
  57608. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57609. }
  57610. }
  57611. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57615. /**
  57616. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57617. */
  57618. export class VectorSplitterBlock extends NodeMaterialBlock {
  57619. /**
  57620. * Create a new VectorSplitterBlock
  57621. * @param name defines the block name
  57622. */
  57623. constructor(name: string);
  57624. /**
  57625. * Gets the current class name
  57626. * @returns the class name
  57627. */
  57628. getClassName(): string;
  57629. /**
  57630. * Gets the xyzw component (input)
  57631. */
  57632. readonly xyzw: NodeMaterialConnectionPoint;
  57633. /**
  57634. * Gets the xyz component (input)
  57635. */
  57636. readonly xyzIn: NodeMaterialConnectionPoint;
  57637. /**
  57638. * Gets the xy component (input)
  57639. */
  57640. readonly xyIn: NodeMaterialConnectionPoint;
  57641. /**
  57642. * Gets the xyz component (output)
  57643. */
  57644. readonly xyzOut: NodeMaterialConnectionPoint;
  57645. /**
  57646. * Gets the xy component (output)
  57647. */
  57648. readonly xyOut: NodeMaterialConnectionPoint;
  57649. /**
  57650. * Gets the x component (output)
  57651. */
  57652. readonly x: NodeMaterialConnectionPoint;
  57653. /**
  57654. * Gets the y component (output)
  57655. */
  57656. readonly y: NodeMaterialConnectionPoint;
  57657. /**
  57658. * Gets the z component (output)
  57659. */
  57660. readonly z: NodeMaterialConnectionPoint;
  57661. /**
  57662. * Gets the w component (output)
  57663. */
  57664. readonly w: NodeMaterialConnectionPoint;
  57665. protected _inputRename(name: string): string;
  57666. protected _outputRename(name: string): string;
  57667. protected _buildBlock(state: NodeMaterialBuildState): this;
  57668. }
  57669. }
  57670. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57671. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57672. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57673. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57674. /**
  57675. * Block used to lerp between 2 values
  57676. */
  57677. export class LerpBlock extends NodeMaterialBlock {
  57678. /**
  57679. * Creates a new LerpBlock
  57680. * @param name defines the block name
  57681. */
  57682. constructor(name: string);
  57683. /**
  57684. * Gets the current class name
  57685. * @returns the class name
  57686. */
  57687. getClassName(): string;
  57688. /**
  57689. * Gets the left operand input component
  57690. */
  57691. readonly left: NodeMaterialConnectionPoint;
  57692. /**
  57693. * Gets the right operand input component
  57694. */
  57695. readonly right: NodeMaterialConnectionPoint;
  57696. /**
  57697. * Gets the gradient operand input component
  57698. */
  57699. readonly gradient: NodeMaterialConnectionPoint;
  57700. /**
  57701. * Gets the output component
  57702. */
  57703. readonly output: NodeMaterialConnectionPoint;
  57704. protected _buildBlock(state: NodeMaterialBuildState): this;
  57705. }
  57706. }
  57707. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57711. /**
  57712. * Block used to divide 2 vectors
  57713. */
  57714. export class DivideBlock extends NodeMaterialBlock {
  57715. /**
  57716. * Creates a new DivideBlock
  57717. * @param name defines the block name
  57718. */
  57719. constructor(name: string);
  57720. /**
  57721. * Gets the current class name
  57722. * @returns the class name
  57723. */
  57724. getClassName(): string;
  57725. /**
  57726. * Gets the left operand input component
  57727. */
  57728. readonly left: NodeMaterialConnectionPoint;
  57729. /**
  57730. * Gets the right operand input component
  57731. */
  57732. readonly right: NodeMaterialConnectionPoint;
  57733. /**
  57734. * Gets the output component
  57735. */
  57736. readonly output: NodeMaterialConnectionPoint;
  57737. protected _buildBlock(state: NodeMaterialBuildState): this;
  57738. }
  57739. }
  57740. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57742. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57743. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57744. /**
  57745. * Block used to subtract 2 vectors
  57746. */
  57747. export class SubtractBlock extends NodeMaterialBlock {
  57748. /**
  57749. * Creates a new SubtractBlock
  57750. * @param name defines the block name
  57751. */
  57752. constructor(name: string);
  57753. /**
  57754. * Gets the current class name
  57755. * @returns the class name
  57756. */
  57757. getClassName(): string;
  57758. /**
  57759. * Gets the left operand input component
  57760. */
  57761. readonly left: NodeMaterialConnectionPoint;
  57762. /**
  57763. * Gets the right operand input component
  57764. */
  57765. readonly right: NodeMaterialConnectionPoint;
  57766. /**
  57767. * Gets the output component
  57768. */
  57769. readonly output: NodeMaterialConnectionPoint;
  57770. protected _buildBlock(state: NodeMaterialBuildState): this;
  57771. }
  57772. }
  57773. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57774. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57777. /**
  57778. * Block used to step a value
  57779. */
  57780. export class StepBlock extends NodeMaterialBlock {
  57781. /**
  57782. * Creates a new StepBlock
  57783. * @param name defines the block name
  57784. */
  57785. constructor(name: string);
  57786. /**
  57787. * Gets the current class name
  57788. * @returns the class name
  57789. */
  57790. getClassName(): string;
  57791. /**
  57792. * Gets the value operand input component
  57793. */
  57794. readonly value: NodeMaterialConnectionPoint;
  57795. /**
  57796. * Gets the edge operand input component
  57797. */
  57798. readonly edge: NodeMaterialConnectionPoint;
  57799. /**
  57800. * Gets the output component
  57801. */
  57802. readonly output: NodeMaterialConnectionPoint;
  57803. protected _buildBlock(state: NodeMaterialBuildState): this;
  57804. }
  57805. }
  57806. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57807. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57809. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57810. /**
  57811. * Block used to get the opposite (1 - x) of a value
  57812. */
  57813. export class OneMinusBlock extends NodeMaterialBlock {
  57814. /**
  57815. * Creates a new OneMinusBlock
  57816. * @param name defines the block name
  57817. */
  57818. constructor(name: string);
  57819. /**
  57820. * Gets the current class name
  57821. * @returns the class name
  57822. */
  57823. getClassName(): string;
  57824. /**
  57825. * Gets the input component
  57826. */
  57827. readonly input: NodeMaterialConnectionPoint;
  57828. /**
  57829. * Gets the output component
  57830. */
  57831. readonly output: NodeMaterialConnectionPoint;
  57832. protected _buildBlock(state: NodeMaterialBuildState): this;
  57833. }
  57834. }
  57835. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57839. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57840. /**
  57841. * Block used to get the view direction
  57842. */
  57843. export class ViewDirectionBlock extends NodeMaterialBlock {
  57844. /**
  57845. * Creates a new ViewDirectionBlock
  57846. * @param name defines the block name
  57847. */
  57848. constructor(name: string);
  57849. /**
  57850. * Gets the current class name
  57851. * @returns the class name
  57852. */
  57853. getClassName(): string;
  57854. /**
  57855. * Gets the world position component
  57856. */
  57857. readonly worldPosition: NodeMaterialConnectionPoint;
  57858. /**
  57859. * Gets the camera position component
  57860. */
  57861. readonly cameraPosition: NodeMaterialConnectionPoint;
  57862. /**
  57863. * Gets the output component
  57864. */
  57865. readonly output: NodeMaterialConnectionPoint;
  57866. autoConfigure(material: NodeMaterial): void;
  57867. protected _buildBlock(state: NodeMaterialBuildState): this;
  57868. }
  57869. }
  57870. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57871. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57872. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57873. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57874. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57875. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57876. /**
  57877. * Block used to compute fresnel value
  57878. */
  57879. export class FresnelBlock extends NodeMaterialBlock {
  57880. /**
  57881. * Create a new FresnelBlock
  57882. * @param name defines the block name
  57883. */
  57884. constructor(name: string);
  57885. /**
  57886. * Gets the current class name
  57887. * @returns the class name
  57888. */
  57889. getClassName(): string;
  57890. /**
  57891. * Gets the world normal input component
  57892. */
  57893. readonly worldNormal: NodeMaterialConnectionPoint;
  57894. /**
  57895. * Gets the view direction input component
  57896. */
  57897. readonly viewDirection: NodeMaterialConnectionPoint;
  57898. /**
  57899. * Gets the bias input component
  57900. */
  57901. readonly bias: NodeMaterialConnectionPoint;
  57902. /**
  57903. * Gets the camera (or eye) position component
  57904. */
  57905. readonly power: NodeMaterialConnectionPoint;
  57906. /**
  57907. * Gets the fresnel output component
  57908. */
  57909. readonly fresnel: NodeMaterialConnectionPoint;
  57910. autoConfigure(material: NodeMaterial): void;
  57911. protected _buildBlock(state: NodeMaterialBuildState): this;
  57912. }
  57913. }
  57914. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57918. /**
  57919. * Block used to get the max of 2 values
  57920. */
  57921. export class MaxBlock extends NodeMaterialBlock {
  57922. /**
  57923. * Creates a new MaxBlock
  57924. * @param name defines the block name
  57925. */
  57926. constructor(name: string);
  57927. /**
  57928. * Gets the current class name
  57929. * @returns the class name
  57930. */
  57931. getClassName(): string;
  57932. /**
  57933. * Gets the left operand input component
  57934. */
  57935. readonly left: NodeMaterialConnectionPoint;
  57936. /**
  57937. * Gets the right operand input component
  57938. */
  57939. readonly right: NodeMaterialConnectionPoint;
  57940. /**
  57941. * Gets the output component
  57942. */
  57943. readonly output: NodeMaterialConnectionPoint;
  57944. protected _buildBlock(state: NodeMaterialBuildState): this;
  57945. }
  57946. }
  57947. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57948. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57949. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57950. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57951. /**
  57952. * Block used to get the min of 2 values
  57953. */
  57954. export class MinBlock extends NodeMaterialBlock {
  57955. /**
  57956. * Creates a new MinBlock
  57957. * @param name defines the block name
  57958. */
  57959. constructor(name: string);
  57960. /**
  57961. * Gets the current class name
  57962. * @returns the class name
  57963. */
  57964. getClassName(): string;
  57965. /**
  57966. * Gets the left operand input component
  57967. */
  57968. readonly left: NodeMaterialConnectionPoint;
  57969. /**
  57970. * Gets the right operand input component
  57971. */
  57972. readonly right: NodeMaterialConnectionPoint;
  57973. /**
  57974. * Gets the output component
  57975. */
  57976. readonly output: NodeMaterialConnectionPoint;
  57977. protected _buildBlock(state: NodeMaterialBuildState): this;
  57978. }
  57979. }
  57980. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57982. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57983. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57984. /**
  57985. * Block used to get the distance between 2 values
  57986. */
  57987. export class DistanceBlock extends NodeMaterialBlock {
  57988. /**
  57989. * Creates a new DistanceBlock
  57990. * @param name defines the block name
  57991. */
  57992. constructor(name: string);
  57993. /**
  57994. * Gets the current class name
  57995. * @returns the class name
  57996. */
  57997. getClassName(): string;
  57998. /**
  57999. * Gets the left operand input component
  58000. */
  58001. readonly left: NodeMaterialConnectionPoint;
  58002. /**
  58003. * Gets the right operand input component
  58004. */
  58005. readonly right: NodeMaterialConnectionPoint;
  58006. /**
  58007. * Gets the output component
  58008. */
  58009. readonly output: NodeMaterialConnectionPoint;
  58010. protected _buildBlock(state: NodeMaterialBuildState): this;
  58011. }
  58012. }
  58013. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58017. /**
  58018. * Block used to get the length of a vector
  58019. */
  58020. export class LengthBlock extends NodeMaterialBlock {
  58021. /**
  58022. * Creates a new LengthBlock
  58023. * @param name defines the block name
  58024. */
  58025. constructor(name: string);
  58026. /**
  58027. * Gets the current class name
  58028. * @returns the class name
  58029. */
  58030. getClassName(): string;
  58031. /**
  58032. * Gets the value input component
  58033. */
  58034. readonly value: NodeMaterialConnectionPoint;
  58035. /**
  58036. * Gets the output component
  58037. */
  58038. readonly output: NodeMaterialConnectionPoint;
  58039. protected _buildBlock(state: NodeMaterialBuildState): this;
  58040. }
  58041. }
  58042. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58046. /**
  58047. * Block used to get negative version of a value (i.e. x * -1)
  58048. */
  58049. export class NegateBlock extends NodeMaterialBlock {
  58050. /**
  58051. * Creates a new NegateBlock
  58052. * @param name defines the block name
  58053. */
  58054. constructor(name: string);
  58055. /**
  58056. * Gets the current class name
  58057. * @returns the class name
  58058. */
  58059. getClassName(): string;
  58060. /**
  58061. * Gets the value input component
  58062. */
  58063. readonly value: NodeMaterialConnectionPoint;
  58064. /**
  58065. * Gets the output component
  58066. */
  58067. readonly output: NodeMaterialConnectionPoint;
  58068. protected _buildBlock(state: NodeMaterialBuildState): this;
  58069. }
  58070. }
  58071. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58075. /**
  58076. * Block used to get the value of the first parameter raised to the power of the second
  58077. */
  58078. export class PowBlock extends NodeMaterialBlock {
  58079. /**
  58080. * Creates a new PowBlock
  58081. * @param name defines the block name
  58082. */
  58083. constructor(name: string);
  58084. /**
  58085. * Gets the current class name
  58086. * @returns the class name
  58087. */
  58088. getClassName(): string;
  58089. /**
  58090. * Gets the value operand input component
  58091. */
  58092. readonly value: NodeMaterialConnectionPoint;
  58093. /**
  58094. * Gets the power operand input component
  58095. */
  58096. readonly power: NodeMaterialConnectionPoint;
  58097. /**
  58098. * Gets the output component
  58099. */
  58100. readonly output: NodeMaterialConnectionPoint;
  58101. protected _buildBlock(state: NodeMaterialBuildState): this;
  58102. }
  58103. }
  58104. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58108. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58109. /**
  58110. * Block used to get a random number
  58111. */
  58112. export class RandomNumberBlock extends NodeMaterialBlock {
  58113. /**
  58114. * Creates a new RandomNumberBlock
  58115. * @param name defines the block name
  58116. */
  58117. constructor(name: string);
  58118. /**
  58119. * Gets the current class name
  58120. * @returns the class name
  58121. */
  58122. getClassName(): string;
  58123. /**
  58124. * Gets the seed input component
  58125. */
  58126. readonly seed: NodeMaterialConnectionPoint;
  58127. /**
  58128. * Gets the output component
  58129. */
  58130. readonly output: NodeMaterialConnectionPoint;
  58131. protected _buildBlock(state: NodeMaterialBuildState): this;
  58132. }
  58133. }
  58134. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58135. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58137. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58138. /**
  58139. * Block used to compute arc tangent of 2 values
  58140. */
  58141. export class ArcTan2Block extends NodeMaterialBlock {
  58142. /**
  58143. * Creates a new ArcTan2Block
  58144. * @param name defines the block name
  58145. */
  58146. constructor(name: string);
  58147. /**
  58148. * Gets the current class name
  58149. * @returns the class name
  58150. */
  58151. getClassName(): string;
  58152. /**
  58153. * Gets the x operand input component
  58154. */
  58155. readonly x: NodeMaterialConnectionPoint;
  58156. /**
  58157. * Gets the y operand input component
  58158. */
  58159. readonly y: NodeMaterialConnectionPoint;
  58160. /**
  58161. * Gets the output component
  58162. */
  58163. readonly output: NodeMaterialConnectionPoint;
  58164. protected _buildBlock(state: NodeMaterialBuildState): this;
  58165. }
  58166. }
  58167. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58171. /**
  58172. * Block used to smooth step a value
  58173. */
  58174. export class SmoothStepBlock extends NodeMaterialBlock {
  58175. /**
  58176. * Creates a new SmoothStepBlock
  58177. * @param name defines the block name
  58178. */
  58179. constructor(name: string);
  58180. /**
  58181. * Gets the current class name
  58182. * @returns the class name
  58183. */
  58184. getClassName(): string;
  58185. /**
  58186. * Gets the value operand input component
  58187. */
  58188. readonly value: NodeMaterialConnectionPoint;
  58189. /**
  58190. * Gets the first edge operand input component
  58191. */
  58192. readonly edge0: NodeMaterialConnectionPoint;
  58193. /**
  58194. * Gets the second edge operand input component
  58195. */
  58196. readonly edge1: NodeMaterialConnectionPoint;
  58197. /**
  58198. * Gets the output component
  58199. */
  58200. readonly output: NodeMaterialConnectionPoint;
  58201. protected _buildBlock(state: NodeMaterialBuildState): this;
  58202. }
  58203. }
  58204. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58206. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58207. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58208. /**
  58209. * Block used to get the reciprocal (1 / x) of a value
  58210. */
  58211. export class ReciprocalBlock extends NodeMaterialBlock {
  58212. /**
  58213. * Creates a new ReciprocalBlock
  58214. * @param name defines the block name
  58215. */
  58216. constructor(name: string);
  58217. /**
  58218. * Gets the current class name
  58219. * @returns the class name
  58220. */
  58221. getClassName(): string;
  58222. /**
  58223. * Gets the input component
  58224. */
  58225. readonly input: NodeMaterialConnectionPoint;
  58226. /**
  58227. * Gets the output component
  58228. */
  58229. readonly output: NodeMaterialConnectionPoint;
  58230. protected _buildBlock(state: NodeMaterialBuildState): this;
  58231. }
  58232. }
  58233. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58237. /**
  58238. * Block used to replace a color by another one
  58239. */
  58240. export class ReplaceColorBlock extends NodeMaterialBlock {
  58241. /**
  58242. * Creates a new ReplaceColorBlock
  58243. * @param name defines the block name
  58244. */
  58245. constructor(name: string);
  58246. /**
  58247. * Gets the current class name
  58248. * @returns the class name
  58249. */
  58250. getClassName(): string;
  58251. /**
  58252. * Gets the value input component
  58253. */
  58254. readonly value: NodeMaterialConnectionPoint;
  58255. /**
  58256. * Gets the reference input component
  58257. */
  58258. readonly reference: NodeMaterialConnectionPoint;
  58259. /**
  58260. * Gets the distance input component
  58261. */
  58262. readonly distance: NodeMaterialConnectionPoint;
  58263. /**
  58264. * Gets the replacement input component
  58265. */
  58266. readonly replacement: NodeMaterialConnectionPoint;
  58267. /**
  58268. * Gets the output component
  58269. */
  58270. readonly output: NodeMaterialConnectionPoint;
  58271. protected _buildBlock(state: NodeMaterialBuildState): this;
  58272. }
  58273. }
  58274. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58278. /**
  58279. * Block used to posterize a value
  58280. * @see https://en.wikipedia.org/wiki/Posterization
  58281. */
  58282. export class PosterizeBlock extends NodeMaterialBlock {
  58283. /**
  58284. * Creates a new PosterizeBlock
  58285. * @param name defines the block name
  58286. */
  58287. constructor(name: string);
  58288. /**
  58289. * Gets the current class name
  58290. * @returns the class name
  58291. */
  58292. getClassName(): string;
  58293. /**
  58294. * Gets the value input component
  58295. */
  58296. readonly value: NodeMaterialConnectionPoint;
  58297. /**
  58298. * Gets the steps input component
  58299. */
  58300. readonly steps: NodeMaterialConnectionPoint;
  58301. /**
  58302. * Gets the output component
  58303. */
  58304. readonly output: NodeMaterialConnectionPoint;
  58305. protected _buildBlock(state: NodeMaterialBuildState): this;
  58306. }
  58307. }
  58308. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58309. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58310. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58311. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58312. import { Scene } from "babylonjs/scene";
  58313. /**
  58314. * Operations supported by the Wave block
  58315. */
  58316. export enum WaveBlockKind {
  58317. /** SawTooth */
  58318. SawTooth = 0,
  58319. /** Square */
  58320. Square = 1,
  58321. /** Triangle */
  58322. Triangle = 2
  58323. }
  58324. /**
  58325. * Block used to apply wave operation to floats
  58326. */
  58327. export class WaveBlock extends NodeMaterialBlock {
  58328. /**
  58329. * Gets or sets the kibnd of wave to be applied by the block
  58330. */
  58331. kind: WaveBlockKind;
  58332. /**
  58333. * Creates a new WaveBlock
  58334. * @param name defines the block name
  58335. */
  58336. constructor(name: string);
  58337. /**
  58338. * Gets the current class name
  58339. * @returns the class name
  58340. */
  58341. getClassName(): string;
  58342. /**
  58343. * Gets the input component
  58344. */
  58345. readonly input: NodeMaterialConnectionPoint;
  58346. /**
  58347. * Gets the output component
  58348. */
  58349. readonly output: NodeMaterialConnectionPoint;
  58350. protected _buildBlock(state: NodeMaterialBuildState): this;
  58351. serialize(): any;
  58352. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58353. }
  58354. }
  58355. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58359. import { Color3 } from "babylonjs/Maths/math.color";
  58360. import { Scene } from "babylonjs/scene";
  58361. /**
  58362. * Class used to store a color step for the GradientBlock
  58363. */
  58364. export class GradientBlockColorStep {
  58365. /**
  58366. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58367. */
  58368. step: number;
  58369. /**
  58370. * Gets or sets the color associated with this step
  58371. */
  58372. color: Color3;
  58373. /**
  58374. * Creates a new GradientBlockColorStep
  58375. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58376. * @param color defines the color associated with this step
  58377. */
  58378. constructor(
  58379. /**
  58380. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58381. */
  58382. step: number,
  58383. /**
  58384. * Gets or sets the color associated with this step
  58385. */
  58386. color: Color3);
  58387. }
  58388. /**
  58389. * Block used to return a color from a gradient based on an input value between 0 and 1
  58390. */
  58391. export class GradientBlock extends NodeMaterialBlock {
  58392. /**
  58393. * Gets or sets the list of color steps
  58394. */
  58395. colorSteps: GradientBlockColorStep[];
  58396. /**
  58397. * Creates a new GradientBlock
  58398. * @param name defines the block name
  58399. */
  58400. constructor(name: string);
  58401. /**
  58402. * Gets the current class name
  58403. * @returns the class name
  58404. */
  58405. getClassName(): string;
  58406. /**
  58407. * Gets the gradient input component
  58408. */
  58409. readonly gradient: NodeMaterialConnectionPoint;
  58410. /**
  58411. * Gets the output component
  58412. */
  58413. readonly output: NodeMaterialConnectionPoint;
  58414. private _writeColorConstant;
  58415. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58416. serialize(): any;
  58417. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58418. protected _dumpPropertiesCode(): string;
  58419. }
  58420. }
  58421. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58425. /**
  58426. * Block used to normalize lerp between 2 values
  58427. */
  58428. export class NLerpBlock extends NodeMaterialBlock {
  58429. /**
  58430. * Creates a new NLerpBlock
  58431. * @param name defines the block name
  58432. */
  58433. constructor(name: string);
  58434. /**
  58435. * Gets the current class name
  58436. * @returns the class name
  58437. */
  58438. getClassName(): string;
  58439. /**
  58440. * Gets the left operand input component
  58441. */
  58442. readonly left: NodeMaterialConnectionPoint;
  58443. /**
  58444. * Gets the right operand input component
  58445. */
  58446. readonly right: NodeMaterialConnectionPoint;
  58447. /**
  58448. * Gets the gradient operand input component
  58449. */
  58450. readonly gradient: NodeMaterialConnectionPoint;
  58451. /**
  58452. * Gets the output component
  58453. */
  58454. readonly output: NodeMaterialConnectionPoint;
  58455. protected _buildBlock(state: NodeMaterialBuildState): this;
  58456. }
  58457. }
  58458. declare module "babylonjs/Materials/Node/Blocks/index" {
  58459. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58460. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58461. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58462. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58463. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58464. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58465. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58466. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58467. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58468. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58469. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58470. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58471. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58472. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58473. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58474. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58475. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58476. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58477. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58478. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58479. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58480. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58481. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58482. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58483. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58484. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58485. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58486. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58487. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58488. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58489. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58490. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58491. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58492. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58493. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58494. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58495. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58496. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58497. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58498. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58499. }
  58500. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58501. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58502. }
  58503. declare module "babylonjs/Materials/Node/index" {
  58504. export * from "babylonjs/Materials/Node/Enums/index";
  58505. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58506. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58507. export * from "babylonjs/Materials/Node/nodeMaterial";
  58508. export * from "babylonjs/Materials/Node/Blocks/index";
  58509. export * from "babylonjs/Materials/Node/Optimizers/index";
  58510. }
  58511. declare module "babylonjs/Materials/effectRenderer" {
  58512. import { Nullable } from "babylonjs/types";
  58513. import { Texture } from "babylonjs/Materials/Textures/texture";
  58514. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58515. import { Viewport } from "babylonjs/Maths/math.viewport";
  58516. import { Observable } from "babylonjs/Misc/observable";
  58517. import { Effect } from "babylonjs/Materials/effect";
  58518. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58519. import "babylonjs/Shaders/postprocess.vertex";
  58520. /**
  58521. * Effect Render Options
  58522. */
  58523. export interface IEffectRendererOptions {
  58524. /**
  58525. * Defines the vertices positions.
  58526. */
  58527. positions?: number[];
  58528. /**
  58529. * Defines the indices.
  58530. */
  58531. indices?: number[];
  58532. }
  58533. /**
  58534. * Helper class to render one or more effects
  58535. */
  58536. export class EffectRenderer {
  58537. private engine;
  58538. private static _DefaultOptions;
  58539. private _vertexBuffers;
  58540. private _indexBuffer;
  58541. private _ringBufferIndex;
  58542. private _ringScreenBuffer;
  58543. private _fullscreenViewport;
  58544. private _getNextFrameBuffer;
  58545. /**
  58546. * Creates an effect renderer
  58547. * @param engine the engine to use for rendering
  58548. * @param options defines the options of the effect renderer
  58549. */
  58550. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58551. /**
  58552. * Sets the current viewport in normalized coordinates 0-1
  58553. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58554. */
  58555. setViewport(viewport?: Viewport): void;
  58556. /**
  58557. * Binds the embedded attributes buffer to the effect.
  58558. * @param effect Defines the effect to bind the attributes for
  58559. */
  58560. bindBuffers(effect: Effect): void;
  58561. /**
  58562. * Sets the current effect wrapper to use during draw.
  58563. * The effect needs to be ready before calling this api.
  58564. * This also sets the default full screen position attribute.
  58565. * @param effectWrapper Defines the effect to draw with
  58566. */
  58567. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58568. /**
  58569. * Draws a full screen quad.
  58570. */
  58571. draw(): void;
  58572. /**
  58573. * renders one or more effects to a specified texture
  58574. * @param effectWrappers list of effects to renderer
  58575. * @param outputTexture texture to draw to, if null it will render to the screen
  58576. */
  58577. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58578. /**
  58579. * Disposes of the effect renderer
  58580. */
  58581. dispose(): void;
  58582. }
  58583. /**
  58584. * Options to create an EffectWrapper
  58585. */
  58586. interface EffectWrapperCreationOptions {
  58587. /**
  58588. * Engine to use to create the effect
  58589. */
  58590. engine: ThinEngine;
  58591. /**
  58592. * Fragment shader for the effect
  58593. */
  58594. fragmentShader: string;
  58595. /**
  58596. * Vertex shader for the effect
  58597. */
  58598. vertexShader?: string;
  58599. /**
  58600. * Attributes to use in the shader
  58601. */
  58602. attributeNames?: Array<string>;
  58603. /**
  58604. * Uniforms to use in the shader
  58605. */
  58606. uniformNames?: Array<string>;
  58607. /**
  58608. * Texture sampler names to use in the shader
  58609. */
  58610. samplerNames?: Array<string>;
  58611. /**
  58612. * The friendly name of the effect displayed in Spector.
  58613. */
  58614. name?: string;
  58615. }
  58616. /**
  58617. * Wraps an effect to be used for rendering
  58618. */
  58619. export class EffectWrapper {
  58620. /**
  58621. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58622. */
  58623. onApplyObservable: Observable<{}>;
  58624. /**
  58625. * The underlying effect
  58626. */
  58627. effect: Effect;
  58628. /**
  58629. * Creates an effect to be renderer
  58630. * @param creationOptions options to create the effect
  58631. */
  58632. constructor(creationOptions: EffectWrapperCreationOptions);
  58633. /**
  58634. * Disposes of the effect wrapper
  58635. */
  58636. dispose(): void;
  58637. }
  58638. }
  58639. declare module "babylonjs/Materials/index" {
  58640. export * from "babylonjs/Materials/Background/index";
  58641. export * from "babylonjs/Materials/colorCurves";
  58642. export * from "babylonjs/Materials/iEffectFallbacks";
  58643. export * from "babylonjs/Materials/effectFallbacks";
  58644. export * from "babylonjs/Materials/effect";
  58645. export * from "babylonjs/Materials/fresnelParameters";
  58646. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58647. export * from "babylonjs/Materials/material";
  58648. export * from "babylonjs/Materials/materialDefines";
  58649. export * from "babylonjs/Materials/materialHelper";
  58650. export * from "babylonjs/Materials/multiMaterial";
  58651. export * from "babylonjs/Materials/PBR/index";
  58652. export * from "babylonjs/Materials/pushMaterial";
  58653. export * from "babylonjs/Materials/shaderMaterial";
  58654. export * from "babylonjs/Materials/standardMaterial";
  58655. export * from "babylonjs/Materials/Textures/index";
  58656. export * from "babylonjs/Materials/uniformBuffer";
  58657. export * from "babylonjs/Materials/materialFlags";
  58658. export * from "babylonjs/Materials/Node/index";
  58659. export * from "babylonjs/Materials/effectRenderer";
  58660. }
  58661. declare module "babylonjs/Maths/index" {
  58662. export * from "babylonjs/Maths/math.scalar";
  58663. export * from "babylonjs/Maths/math";
  58664. export * from "babylonjs/Maths/sphericalPolynomial";
  58665. }
  58666. declare module "babylonjs/Misc/workerPool" {
  58667. import { IDisposable } from "babylonjs/scene";
  58668. /**
  58669. * Helper class to push actions to a pool of workers.
  58670. */
  58671. export class WorkerPool implements IDisposable {
  58672. private _workerInfos;
  58673. private _pendingActions;
  58674. /**
  58675. * Constructor
  58676. * @param workers Array of workers to use for actions
  58677. */
  58678. constructor(workers: Array<Worker>);
  58679. /**
  58680. * Terminates all workers and clears any pending actions.
  58681. */
  58682. dispose(): void;
  58683. /**
  58684. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58685. * pended until a worker has completed its action.
  58686. * @param action The action to perform. Call onComplete when the action is complete.
  58687. */
  58688. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58689. private _execute;
  58690. }
  58691. }
  58692. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58693. import { IDisposable } from "babylonjs/scene";
  58694. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58695. /**
  58696. * Configuration for Draco compression
  58697. */
  58698. export interface IDracoCompressionConfiguration {
  58699. /**
  58700. * Configuration for the decoder.
  58701. */
  58702. decoder: {
  58703. /**
  58704. * The url to the WebAssembly module.
  58705. */
  58706. wasmUrl?: string;
  58707. /**
  58708. * The url to the WebAssembly binary.
  58709. */
  58710. wasmBinaryUrl?: string;
  58711. /**
  58712. * The url to the fallback JavaScript module.
  58713. */
  58714. fallbackUrl?: string;
  58715. };
  58716. }
  58717. /**
  58718. * Draco compression (https://google.github.io/draco/)
  58719. *
  58720. * This class wraps the Draco module.
  58721. *
  58722. * **Encoder**
  58723. *
  58724. * The encoder is not currently implemented.
  58725. *
  58726. * **Decoder**
  58727. *
  58728. * 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.
  58729. *
  58730. * To update the configuration, use the following code:
  58731. * ```javascript
  58732. * DracoCompression.Configuration = {
  58733. * decoder: {
  58734. * wasmUrl: "<url to the WebAssembly library>",
  58735. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58736. * fallbackUrl: "<url to the fallback JavaScript library>",
  58737. * }
  58738. * };
  58739. * ```
  58740. *
  58741. * 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.
  58742. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58743. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58744. *
  58745. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58746. * ```javascript
  58747. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58748. * ```
  58749. *
  58750. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58751. */
  58752. export class DracoCompression implements IDisposable {
  58753. private _workerPoolPromise?;
  58754. private _decoderModulePromise?;
  58755. /**
  58756. * The configuration. Defaults to the following urls:
  58757. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58758. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58759. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58760. */
  58761. static Configuration: IDracoCompressionConfiguration;
  58762. /**
  58763. * Returns true if the decoder configuration is available.
  58764. */
  58765. static readonly DecoderAvailable: boolean;
  58766. /**
  58767. * Default number of workers to create when creating the draco compression object.
  58768. */
  58769. static DefaultNumWorkers: number;
  58770. private static GetDefaultNumWorkers;
  58771. private static _Default;
  58772. /**
  58773. * Default instance for the draco compression object.
  58774. */
  58775. static readonly Default: DracoCompression;
  58776. /**
  58777. * Constructor
  58778. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58779. */
  58780. constructor(numWorkers?: number);
  58781. /**
  58782. * Stop all async operations and release resources.
  58783. */
  58784. dispose(): void;
  58785. /**
  58786. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58787. * @returns a promise that resolves when ready
  58788. */
  58789. whenReadyAsync(): Promise<void>;
  58790. /**
  58791. * Decode Draco compressed mesh data to vertex data.
  58792. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58793. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58794. * @returns A promise that resolves with the decoded vertex data
  58795. */
  58796. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58797. [kind: string]: number;
  58798. }): Promise<VertexData>;
  58799. }
  58800. }
  58801. declare module "babylonjs/Meshes/Compression/index" {
  58802. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58803. }
  58804. declare module "babylonjs/Meshes/csg" {
  58805. import { Nullable } from "babylonjs/types";
  58806. import { Scene } from "babylonjs/scene";
  58807. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58808. import { Mesh } from "babylonjs/Meshes/mesh";
  58809. import { Material } from "babylonjs/Materials/material";
  58810. /**
  58811. * Class for building Constructive Solid Geometry
  58812. */
  58813. export class CSG {
  58814. private polygons;
  58815. /**
  58816. * The world matrix
  58817. */
  58818. matrix: Matrix;
  58819. /**
  58820. * Stores the position
  58821. */
  58822. position: Vector3;
  58823. /**
  58824. * Stores the rotation
  58825. */
  58826. rotation: Vector3;
  58827. /**
  58828. * Stores the rotation quaternion
  58829. */
  58830. rotationQuaternion: Nullable<Quaternion>;
  58831. /**
  58832. * Stores the scaling vector
  58833. */
  58834. scaling: Vector3;
  58835. /**
  58836. * Convert the Mesh to CSG
  58837. * @param mesh The Mesh to convert to CSG
  58838. * @returns A new CSG from the Mesh
  58839. */
  58840. static FromMesh(mesh: Mesh): CSG;
  58841. /**
  58842. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58843. * @param polygons Polygons used to construct a CSG solid
  58844. */
  58845. private static FromPolygons;
  58846. /**
  58847. * Clones, or makes a deep copy, of the CSG
  58848. * @returns A new CSG
  58849. */
  58850. clone(): CSG;
  58851. /**
  58852. * Unions this CSG with another CSG
  58853. * @param csg The CSG to union against this CSG
  58854. * @returns The unioned CSG
  58855. */
  58856. union(csg: CSG): CSG;
  58857. /**
  58858. * Unions this CSG with another CSG in place
  58859. * @param csg The CSG to union against this CSG
  58860. */
  58861. unionInPlace(csg: CSG): void;
  58862. /**
  58863. * Subtracts this CSG with another CSG
  58864. * @param csg The CSG to subtract against this CSG
  58865. * @returns A new CSG
  58866. */
  58867. subtract(csg: CSG): CSG;
  58868. /**
  58869. * Subtracts this CSG with another CSG in place
  58870. * @param csg The CSG to subtact against this CSG
  58871. */
  58872. subtractInPlace(csg: CSG): void;
  58873. /**
  58874. * Intersect this CSG with another CSG
  58875. * @param csg The CSG to intersect against this CSG
  58876. * @returns A new CSG
  58877. */
  58878. intersect(csg: CSG): CSG;
  58879. /**
  58880. * Intersects this CSG with another CSG in place
  58881. * @param csg The CSG to intersect against this CSG
  58882. */
  58883. intersectInPlace(csg: CSG): void;
  58884. /**
  58885. * Return a new CSG solid with solid and empty space switched. This solid is
  58886. * not modified.
  58887. * @returns A new CSG solid with solid and empty space switched
  58888. */
  58889. inverse(): CSG;
  58890. /**
  58891. * Inverses the CSG in place
  58892. */
  58893. inverseInPlace(): void;
  58894. /**
  58895. * This is used to keep meshes transformations so they can be restored
  58896. * when we build back a Babylon Mesh
  58897. * NB : All CSG operations are performed in world coordinates
  58898. * @param csg The CSG to copy the transform attributes from
  58899. * @returns This CSG
  58900. */
  58901. copyTransformAttributes(csg: CSG): CSG;
  58902. /**
  58903. * Build Raw mesh from CSG
  58904. * Coordinates here are in world space
  58905. * @param name The name of the mesh geometry
  58906. * @param scene The Scene
  58907. * @param keepSubMeshes Specifies if the submeshes should be kept
  58908. * @returns A new Mesh
  58909. */
  58910. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58911. /**
  58912. * Build Mesh from CSG taking material and transforms into account
  58913. * @param name The name of the Mesh
  58914. * @param material The material of the Mesh
  58915. * @param scene The Scene
  58916. * @param keepSubMeshes Specifies if submeshes should be kept
  58917. * @returns The new Mesh
  58918. */
  58919. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58920. }
  58921. }
  58922. declare module "babylonjs/Meshes/trailMesh" {
  58923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58924. import { Mesh } from "babylonjs/Meshes/mesh";
  58925. import { Scene } from "babylonjs/scene";
  58926. /**
  58927. * Class used to create a trail following a mesh
  58928. */
  58929. export class TrailMesh extends Mesh {
  58930. private _generator;
  58931. private _autoStart;
  58932. private _running;
  58933. private _diameter;
  58934. private _length;
  58935. private _sectionPolygonPointsCount;
  58936. private _sectionVectors;
  58937. private _sectionNormalVectors;
  58938. private _beforeRenderObserver;
  58939. /**
  58940. * @constructor
  58941. * @param name The value used by scene.getMeshByName() to do a lookup.
  58942. * @param generator The mesh to generate a trail.
  58943. * @param scene The scene to add this mesh to.
  58944. * @param diameter Diameter of trailing mesh. Default is 1.
  58945. * @param length Length of trailing mesh. Default is 60.
  58946. * @param autoStart Automatically start trailing mesh. Default true.
  58947. */
  58948. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58949. /**
  58950. * "TrailMesh"
  58951. * @returns "TrailMesh"
  58952. */
  58953. getClassName(): string;
  58954. private _createMesh;
  58955. /**
  58956. * Start trailing mesh.
  58957. */
  58958. start(): void;
  58959. /**
  58960. * Stop trailing mesh.
  58961. */
  58962. stop(): void;
  58963. /**
  58964. * Update trailing mesh geometry.
  58965. */
  58966. update(): void;
  58967. /**
  58968. * Returns a new TrailMesh object.
  58969. * @param name is a string, the name given to the new mesh
  58970. * @param newGenerator use new generator object for cloned trail mesh
  58971. * @returns a new mesh
  58972. */
  58973. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58974. /**
  58975. * Serializes this trail mesh
  58976. * @param serializationObject object to write serialization to
  58977. */
  58978. serialize(serializationObject: any): void;
  58979. /**
  58980. * Parses a serialized trail mesh
  58981. * @param parsedMesh the serialized mesh
  58982. * @param scene the scene to create the trail mesh in
  58983. * @returns the created trail mesh
  58984. */
  58985. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58986. }
  58987. }
  58988. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58989. import { Nullable } from "babylonjs/types";
  58990. import { Scene } from "babylonjs/scene";
  58991. import { Vector4 } from "babylonjs/Maths/math.vector";
  58992. import { Color4 } from "babylonjs/Maths/math.color";
  58993. import { Mesh } from "babylonjs/Meshes/mesh";
  58994. /**
  58995. * Class containing static functions to help procedurally build meshes
  58996. */
  58997. export class TiledBoxBuilder {
  58998. /**
  58999. * Creates a box mesh
  59000. * 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)
  59001. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59005. * @param name defines the name of the mesh
  59006. * @param options defines the options used to create the mesh
  59007. * @param scene defines the hosting scene
  59008. * @returns the box mesh
  59009. */
  59010. static CreateTiledBox(name: string, options: {
  59011. pattern?: number;
  59012. width?: number;
  59013. height?: number;
  59014. depth?: number;
  59015. tileSize?: number;
  59016. tileWidth?: number;
  59017. tileHeight?: number;
  59018. alignHorizontal?: number;
  59019. alignVertical?: number;
  59020. faceUV?: Vector4[];
  59021. faceColors?: Color4[];
  59022. sideOrientation?: number;
  59023. updatable?: boolean;
  59024. }, scene?: Nullable<Scene>): Mesh;
  59025. }
  59026. }
  59027. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59028. import { Vector4 } from "babylonjs/Maths/math.vector";
  59029. import { Mesh } from "babylonjs/Meshes/mesh";
  59030. /**
  59031. * Class containing static functions to help procedurally build meshes
  59032. */
  59033. export class TorusKnotBuilder {
  59034. /**
  59035. * Creates a torus knot mesh
  59036. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59037. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59038. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59039. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59043. * @param name defines the name of the mesh
  59044. * @param options defines the options used to create the mesh
  59045. * @param scene defines the hosting scene
  59046. * @returns the torus knot mesh
  59047. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59048. */
  59049. static CreateTorusKnot(name: string, options: {
  59050. radius?: number;
  59051. tube?: number;
  59052. radialSegments?: number;
  59053. tubularSegments?: number;
  59054. p?: number;
  59055. q?: number;
  59056. updatable?: boolean;
  59057. sideOrientation?: number;
  59058. frontUVs?: Vector4;
  59059. backUVs?: Vector4;
  59060. }, scene: any): Mesh;
  59061. }
  59062. }
  59063. declare module "babylonjs/Meshes/polygonMesh" {
  59064. import { Scene } from "babylonjs/scene";
  59065. import { Vector2 } from "babylonjs/Maths/math.vector";
  59066. import { Mesh } from "babylonjs/Meshes/mesh";
  59067. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59068. import { Path2 } from "babylonjs/Maths/math.path";
  59069. /**
  59070. * Polygon
  59071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59072. */
  59073. export class Polygon {
  59074. /**
  59075. * Creates a rectangle
  59076. * @param xmin bottom X coord
  59077. * @param ymin bottom Y coord
  59078. * @param xmax top X coord
  59079. * @param ymax top Y coord
  59080. * @returns points that make the resulting rectation
  59081. */
  59082. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59083. /**
  59084. * Creates a circle
  59085. * @param radius radius of circle
  59086. * @param cx scale in x
  59087. * @param cy scale in y
  59088. * @param numberOfSides number of sides that make up the circle
  59089. * @returns points that make the resulting circle
  59090. */
  59091. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59092. /**
  59093. * Creates a polygon from input string
  59094. * @param input Input polygon data
  59095. * @returns the parsed points
  59096. */
  59097. static Parse(input: string): Vector2[];
  59098. /**
  59099. * Starts building a polygon from x and y coordinates
  59100. * @param x x coordinate
  59101. * @param y y coordinate
  59102. * @returns the started path2
  59103. */
  59104. static StartingAt(x: number, y: number): Path2;
  59105. }
  59106. /**
  59107. * Builds a polygon
  59108. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59109. */
  59110. export class PolygonMeshBuilder {
  59111. private _points;
  59112. private _outlinepoints;
  59113. private _holes;
  59114. private _name;
  59115. private _scene;
  59116. private _epoints;
  59117. private _eholes;
  59118. private _addToepoint;
  59119. /**
  59120. * Babylon reference to the earcut plugin.
  59121. */
  59122. bjsEarcut: any;
  59123. /**
  59124. * Creates a PolygonMeshBuilder
  59125. * @param name name of the builder
  59126. * @param contours Path of the polygon
  59127. * @param scene scene to add to when creating the mesh
  59128. * @param earcutInjection can be used to inject your own earcut reference
  59129. */
  59130. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59131. /**
  59132. * Adds a whole within the polygon
  59133. * @param hole Array of points defining the hole
  59134. * @returns this
  59135. */
  59136. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59137. /**
  59138. * Creates the polygon
  59139. * @param updatable If the mesh should be updatable
  59140. * @param depth The depth of the mesh created
  59141. * @returns the created mesh
  59142. */
  59143. build(updatable?: boolean, depth?: number): Mesh;
  59144. /**
  59145. * Creates the polygon
  59146. * @param depth The depth of the mesh created
  59147. * @returns the created VertexData
  59148. */
  59149. buildVertexData(depth?: number): VertexData;
  59150. /**
  59151. * Adds a side to the polygon
  59152. * @param positions points that make the polygon
  59153. * @param normals normals of the polygon
  59154. * @param uvs uvs of the polygon
  59155. * @param indices indices of the polygon
  59156. * @param bounds bounds of the polygon
  59157. * @param points points of the polygon
  59158. * @param depth depth of the polygon
  59159. * @param flip flip of the polygon
  59160. */
  59161. private addSide;
  59162. }
  59163. }
  59164. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59165. import { Scene } from "babylonjs/scene";
  59166. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59167. import { Color4 } from "babylonjs/Maths/math.color";
  59168. import { Mesh } from "babylonjs/Meshes/mesh";
  59169. import { Nullable } from "babylonjs/types";
  59170. /**
  59171. * Class containing static functions to help procedurally build meshes
  59172. */
  59173. export class PolygonBuilder {
  59174. /**
  59175. * Creates a polygon mesh
  59176. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59177. * * 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
  59178. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59181. * * Remember you can only change the shape positions, not their number when updating a polygon
  59182. * @param name defines the name of the mesh
  59183. * @param options defines the options used to create the mesh
  59184. * @param scene defines the hosting scene
  59185. * @param earcutInjection can be used to inject your own earcut reference
  59186. * @returns the polygon mesh
  59187. */
  59188. static CreatePolygon(name: string, options: {
  59189. shape: Vector3[];
  59190. holes?: Vector3[][];
  59191. depth?: number;
  59192. faceUV?: Vector4[];
  59193. faceColors?: Color4[];
  59194. updatable?: boolean;
  59195. sideOrientation?: number;
  59196. frontUVs?: Vector4;
  59197. backUVs?: Vector4;
  59198. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59199. /**
  59200. * Creates an extruded polygon mesh, with depth in the Y direction.
  59201. * * 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)
  59202. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59203. * @param name defines the name of the mesh
  59204. * @param options defines the options used to create the mesh
  59205. * @param scene defines the hosting scene
  59206. * @param earcutInjection can be used to inject your own earcut reference
  59207. * @returns the polygon mesh
  59208. */
  59209. static ExtrudePolygon(name: string, options: {
  59210. shape: Vector3[];
  59211. holes?: Vector3[][];
  59212. depth?: number;
  59213. faceUV?: Vector4[];
  59214. faceColors?: Color4[];
  59215. updatable?: boolean;
  59216. sideOrientation?: number;
  59217. frontUVs?: Vector4;
  59218. backUVs?: Vector4;
  59219. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59220. }
  59221. }
  59222. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59223. import { Scene } from "babylonjs/scene";
  59224. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59225. import { Mesh } from "babylonjs/Meshes/mesh";
  59226. import { Nullable } from "babylonjs/types";
  59227. /**
  59228. * Class containing static functions to help procedurally build meshes
  59229. */
  59230. export class LatheBuilder {
  59231. /**
  59232. * Creates lathe mesh.
  59233. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59234. * * 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
  59235. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59236. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59237. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59238. * * 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
  59239. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59240. * * 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
  59241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59243. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59245. * @param name defines the name of the mesh
  59246. * @param options defines the options used to create the mesh
  59247. * @param scene defines the hosting scene
  59248. * @returns the lathe mesh
  59249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59250. */
  59251. static CreateLathe(name: string, options: {
  59252. shape: Vector3[];
  59253. radius?: number;
  59254. tessellation?: number;
  59255. clip?: number;
  59256. arc?: number;
  59257. closed?: boolean;
  59258. updatable?: boolean;
  59259. sideOrientation?: number;
  59260. frontUVs?: Vector4;
  59261. backUVs?: Vector4;
  59262. cap?: number;
  59263. invertUV?: boolean;
  59264. }, scene?: Nullable<Scene>): Mesh;
  59265. }
  59266. }
  59267. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59268. import { Nullable } from "babylonjs/types";
  59269. import { Scene } from "babylonjs/scene";
  59270. import { Vector4 } from "babylonjs/Maths/math.vector";
  59271. import { Mesh } from "babylonjs/Meshes/mesh";
  59272. /**
  59273. * Class containing static functions to help procedurally build meshes
  59274. */
  59275. export class TiledPlaneBuilder {
  59276. /**
  59277. * Creates a tiled plane mesh
  59278. * * The parameter `pattern` will, depending on value, do nothing or
  59279. * * * flip (reflect about central vertical) alternate tiles across and up
  59280. * * * flip every tile on alternate rows
  59281. * * * rotate (180 degs) alternate tiles across and up
  59282. * * * rotate every tile on alternate rows
  59283. * * * flip and rotate alternate tiles across and up
  59284. * * * flip and rotate every tile on alternate rows
  59285. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59286. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59288. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59289. * * 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)
  59290. * * 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)
  59291. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59292. * @param name defines the name of the mesh
  59293. * @param options defines the options used to create the mesh
  59294. * @param scene defines the hosting scene
  59295. * @returns the box mesh
  59296. */
  59297. static CreateTiledPlane(name: string, options: {
  59298. pattern?: number;
  59299. tileSize?: number;
  59300. tileWidth?: number;
  59301. tileHeight?: number;
  59302. size?: number;
  59303. width?: number;
  59304. height?: number;
  59305. alignHorizontal?: number;
  59306. alignVertical?: number;
  59307. sideOrientation?: number;
  59308. frontUVs?: Vector4;
  59309. backUVs?: Vector4;
  59310. updatable?: boolean;
  59311. }, scene?: Nullable<Scene>): Mesh;
  59312. }
  59313. }
  59314. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59315. import { Nullable } from "babylonjs/types";
  59316. import { Scene } from "babylonjs/scene";
  59317. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59318. import { Mesh } from "babylonjs/Meshes/mesh";
  59319. /**
  59320. * Class containing static functions to help procedurally build meshes
  59321. */
  59322. export class TubeBuilder {
  59323. /**
  59324. * Creates a tube mesh.
  59325. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59326. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59327. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59328. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59329. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59330. * * 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)
  59331. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59332. * * 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
  59333. * * 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
  59334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59336. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59338. * @param name defines the name of the mesh
  59339. * @param options defines the options used to create the mesh
  59340. * @param scene defines the hosting scene
  59341. * @returns the tube mesh
  59342. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59343. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59344. */
  59345. static CreateTube(name: string, options: {
  59346. path: Vector3[];
  59347. radius?: number;
  59348. tessellation?: number;
  59349. radiusFunction?: {
  59350. (i: number, distance: number): number;
  59351. };
  59352. cap?: number;
  59353. arc?: number;
  59354. updatable?: boolean;
  59355. sideOrientation?: number;
  59356. frontUVs?: Vector4;
  59357. backUVs?: Vector4;
  59358. instance?: Mesh;
  59359. invertUV?: boolean;
  59360. }, scene?: Nullable<Scene>): Mesh;
  59361. }
  59362. }
  59363. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59364. import { Scene } from "babylonjs/scene";
  59365. import { Vector4 } from "babylonjs/Maths/math.vector";
  59366. import { Mesh } from "babylonjs/Meshes/mesh";
  59367. import { Nullable } from "babylonjs/types";
  59368. /**
  59369. * Class containing static functions to help procedurally build meshes
  59370. */
  59371. export class IcoSphereBuilder {
  59372. /**
  59373. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59374. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59375. * * 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`)
  59376. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59377. * * 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
  59378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59381. * @param name defines the name of the mesh
  59382. * @param options defines the options used to create the mesh
  59383. * @param scene defines the hosting scene
  59384. * @returns the icosahedron mesh
  59385. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59386. */
  59387. static CreateIcoSphere(name: string, options: {
  59388. radius?: number;
  59389. radiusX?: number;
  59390. radiusY?: number;
  59391. radiusZ?: number;
  59392. flat?: boolean;
  59393. subdivisions?: number;
  59394. sideOrientation?: number;
  59395. frontUVs?: Vector4;
  59396. backUVs?: Vector4;
  59397. updatable?: boolean;
  59398. }, scene?: Nullable<Scene>): Mesh;
  59399. }
  59400. }
  59401. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59402. import { Vector3 } from "babylonjs/Maths/math.vector";
  59403. import { Mesh } from "babylonjs/Meshes/mesh";
  59404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59405. /**
  59406. * Class containing static functions to help procedurally build meshes
  59407. */
  59408. export class DecalBuilder {
  59409. /**
  59410. * Creates a decal mesh.
  59411. * 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
  59412. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59413. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59414. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59415. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59416. * @param name defines the name of the mesh
  59417. * @param sourceMesh defines the mesh where the decal must be applied
  59418. * @param options defines the options used to create the mesh
  59419. * @param scene defines the hosting scene
  59420. * @returns the decal mesh
  59421. * @see https://doc.babylonjs.com/how_to/decals
  59422. */
  59423. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59424. position?: Vector3;
  59425. normal?: Vector3;
  59426. size?: Vector3;
  59427. angle?: number;
  59428. }): Mesh;
  59429. }
  59430. }
  59431. declare module "babylonjs/Meshes/meshBuilder" {
  59432. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59433. import { Nullable } from "babylonjs/types";
  59434. import { Scene } from "babylonjs/scene";
  59435. import { Mesh } from "babylonjs/Meshes/mesh";
  59436. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59437. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59439. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59440. import { Plane } from "babylonjs/Maths/math.plane";
  59441. /**
  59442. * Class containing static functions to help procedurally build meshes
  59443. */
  59444. export class MeshBuilder {
  59445. /**
  59446. * Creates a box mesh
  59447. * * The parameter `size` sets the size (float) of each box side (default 1)
  59448. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59449. * * 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)
  59450. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59454. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59455. * @param name defines the name of the mesh
  59456. * @param options defines the options used to create the mesh
  59457. * @param scene defines the hosting scene
  59458. * @returns the box mesh
  59459. */
  59460. static CreateBox(name: string, options: {
  59461. size?: number;
  59462. width?: number;
  59463. height?: number;
  59464. depth?: number;
  59465. faceUV?: Vector4[];
  59466. faceColors?: Color4[];
  59467. sideOrientation?: number;
  59468. frontUVs?: Vector4;
  59469. backUVs?: Vector4;
  59470. updatable?: boolean;
  59471. }, scene?: Nullable<Scene>): Mesh;
  59472. /**
  59473. * Creates a tiled box mesh
  59474. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59476. * @param name defines the name of the mesh
  59477. * @param options defines the options used to create the mesh
  59478. * @param scene defines the hosting scene
  59479. * @returns the tiled box mesh
  59480. */
  59481. static CreateTiledBox(name: string, options: {
  59482. pattern?: number;
  59483. size?: number;
  59484. width?: number;
  59485. height?: number;
  59486. depth: number;
  59487. tileSize?: number;
  59488. tileWidth?: number;
  59489. tileHeight?: number;
  59490. faceUV?: Vector4[];
  59491. faceColors?: Color4[];
  59492. alignHorizontal?: number;
  59493. alignVertical?: number;
  59494. sideOrientation?: number;
  59495. updatable?: boolean;
  59496. }, scene?: Nullable<Scene>): Mesh;
  59497. /**
  59498. * Creates a sphere mesh
  59499. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59500. * * 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`)
  59501. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59502. * * 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
  59503. * * 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)
  59504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59507. * @param name defines the name of the mesh
  59508. * @param options defines the options used to create the mesh
  59509. * @param scene defines the hosting scene
  59510. * @returns the sphere mesh
  59511. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59512. */
  59513. static CreateSphere(name: string, options: {
  59514. segments?: number;
  59515. diameter?: number;
  59516. diameterX?: number;
  59517. diameterY?: number;
  59518. diameterZ?: number;
  59519. arc?: number;
  59520. slice?: number;
  59521. sideOrientation?: number;
  59522. frontUVs?: Vector4;
  59523. backUVs?: Vector4;
  59524. updatable?: boolean;
  59525. }, scene?: Nullable<Scene>): Mesh;
  59526. /**
  59527. * Creates a plane polygonal mesh. By default, this is a disc
  59528. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59529. * * 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
  59530. * * 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
  59531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59534. * @param name defines the name of the mesh
  59535. * @param options defines the options used to create the mesh
  59536. * @param scene defines the hosting scene
  59537. * @returns the plane polygonal mesh
  59538. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59539. */
  59540. static CreateDisc(name: string, options: {
  59541. radius?: number;
  59542. tessellation?: number;
  59543. arc?: number;
  59544. updatable?: boolean;
  59545. sideOrientation?: number;
  59546. frontUVs?: Vector4;
  59547. backUVs?: Vector4;
  59548. }, scene?: Nullable<Scene>): Mesh;
  59549. /**
  59550. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59551. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59552. * * 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`)
  59553. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59554. * * 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
  59555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59558. * @param name defines the name of the mesh
  59559. * @param options defines the options used to create the mesh
  59560. * @param scene defines the hosting scene
  59561. * @returns the icosahedron mesh
  59562. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59563. */
  59564. static CreateIcoSphere(name: string, options: {
  59565. radius?: number;
  59566. radiusX?: number;
  59567. radiusY?: number;
  59568. radiusZ?: number;
  59569. flat?: boolean;
  59570. subdivisions?: number;
  59571. sideOrientation?: number;
  59572. frontUVs?: Vector4;
  59573. backUVs?: Vector4;
  59574. updatable?: boolean;
  59575. }, scene?: Nullable<Scene>): Mesh;
  59576. /**
  59577. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59578. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59579. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59580. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59581. * * 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
  59582. * * 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
  59583. * * 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
  59584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59587. * * 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
  59588. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59589. * * 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
  59590. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59592. * @param name defines the name of the mesh
  59593. * @param options defines the options used to create the mesh
  59594. * @param scene defines the hosting scene
  59595. * @returns the ribbon mesh
  59596. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59597. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59598. */
  59599. static CreateRibbon(name: string, options: {
  59600. pathArray: Vector3[][];
  59601. closeArray?: boolean;
  59602. closePath?: boolean;
  59603. offset?: number;
  59604. updatable?: boolean;
  59605. sideOrientation?: number;
  59606. frontUVs?: Vector4;
  59607. backUVs?: Vector4;
  59608. instance?: Mesh;
  59609. invertUV?: boolean;
  59610. uvs?: Vector2[];
  59611. colors?: Color4[];
  59612. }, scene?: Nullable<Scene>): Mesh;
  59613. /**
  59614. * Creates a cylinder or a cone mesh
  59615. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59616. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59617. * * 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.
  59618. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59619. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59620. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59621. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59622. * * 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).
  59623. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59624. * * 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).
  59625. * * 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
  59626. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59627. * * 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
  59628. * * 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.
  59629. * * If `enclose` is false, a ring surface is one element.
  59630. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59631. * * 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
  59632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59635. * @param name defines the name of the mesh
  59636. * @param options defines the options used to create the mesh
  59637. * @param scene defines the hosting scene
  59638. * @returns the cylinder mesh
  59639. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59640. */
  59641. static CreateCylinder(name: string, options: {
  59642. height?: number;
  59643. diameterTop?: number;
  59644. diameterBottom?: number;
  59645. diameter?: number;
  59646. tessellation?: number;
  59647. subdivisions?: number;
  59648. arc?: number;
  59649. faceColors?: Color4[];
  59650. faceUV?: Vector4[];
  59651. updatable?: boolean;
  59652. hasRings?: boolean;
  59653. enclose?: boolean;
  59654. cap?: number;
  59655. sideOrientation?: number;
  59656. frontUVs?: Vector4;
  59657. backUVs?: Vector4;
  59658. }, scene?: Nullable<Scene>): Mesh;
  59659. /**
  59660. * Creates a torus mesh
  59661. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59662. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59663. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59667. * @param name defines the name of the mesh
  59668. * @param options defines the options used to create the mesh
  59669. * @param scene defines the hosting scene
  59670. * @returns the torus mesh
  59671. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59672. */
  59673. static CreateTorus(name: string, options: {
  59674. diameter?: number;
  59675. thickness?: number;
  59676. tessellation?: number;
  59677. updatable?: boolean;
  59678. sideOrientation?: number;
  59679. frontUVs?: Vector4;
  59680. backUVs?: Vector4;
  59681. }, scene?: Nullable<Scene>): Mesh;
  59682. /**
  59683. * Creates a torus knot mesh
  59684. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59685. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59686. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59687. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59691. * @param name defines the name of the mesh
  59692. * @param options defines the options used to create the mesh
  59693. * @param scene defines the hosting scene
  59694. * @returns the torus knot mesh
  59695. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59696. */
  59697. static CreateTorusKnot(name: string, options: {
  59698. radius?: number;
  59699. tube?: number;
  59700. radialSegments?: number;
  59701. tubularSegments?: number;
  59702. p?: number;
  59703. q?: number;
  59704. updatable?: boolean;
  59705. sideOrientation?: number;
  59706. frontUVs?: Vector4;
  59707. backUVs?: Vector4;
  59708. }, scene?: Nullable<Scene>): Mesh;
  59709. /**
  59710. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59711. * * 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
  59712. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59713. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59714. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59715. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59716. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59717. * * 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
  59718. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59720. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59721. * @param name defines the name of the new line system
  59722. * @param options defines the options used to create the line system
  59723. * @param scene defines the hosting scene
  59724. * @returns a new line system mesh
  59725. */
  59726. static CreateLineSystem(name: string, options: {
  59727. lines: Vector3[][];
  59728. updatable?: boolean;
  59729. instance?: Nullable<LinesMesh>;
  59730. colors?: Nullable<Color4[][]>;
  59731. useVertexAlpha?: boolean;
  59732. }, scene: Nullable<Scene>): LinesMesh;
  59733. /**
  59734. * Creates a line mesh
  59735. * 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
  59736. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59737. * * The parameter `points` is an array successive Vector3
  59738. * * 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
  59739. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59740. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59741. * * When updating an instance, remember that only point positions can change, not the number of points
  59742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59743. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59744. * @param name defines the name of the new line system
  59745. * @param options defines the options used to create the line system
  59746. * @param scene defines the hosting scene
  59747. * @returns a new line mesh
  59748. */
  59749. static CreateLines(name: string, options: {
  59750. points: Vector3[];
  59751. updatable?: boolean;
  59752. instance?: Nullable<LinesMesh>;
  59753. colors?: Color4[];
  59754. useVertexAlpha?: boolean;
  59755. }, scene?: Nullable<Scene>): LinesMesh;
  59756. /**
  59757. * Creates a dashed line mesh
  59758. * * 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
  59759. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59760. * * The parameter `points` is an array successive Vector3
  59761. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59762. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59763. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59764. * * 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
  59765. * * When updating an instance, remember that only point positions can change, not the number of points
  59766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59767. * @param name defines the name of the mesh
  59768. * @param options defines the options used to create the mesh
  59769. * @param scene defines the hosting scene
  59770. * @returns the dashed line mesh
  59771. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59772. */
  59773. static CreateDashedLines(name: string, options: {
  59774. points: Vector3[];
  59775. dashSize?: number;
  59776. gapSize?: number;
  59777. dashNb?: number;
  59778. updatable?: boolean;
  59779. instance?: LinesMesh;
  59780. }, scene?: Nullable<Scene>): LinesMesh;
  59781. /**
  59782. * 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.
  59783. * * 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.
  59784. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59785. * * 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.
  59786. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59787. * * 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
  59788. * * 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
  59789. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59792. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59794. * @param name defines the name of the mesh
  59795. * @param options defines the options used to create the mesh
  59796. * @param scene defines the hosting scene
  59797. * @returns the extruded shape mesh
  59798. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59799. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59800. */
  59801. static ExtrudeShape(name: string, options: {
  59802. shape: Vector3[];
  59803. path: Vector3[];
  59804. scale?: number;
  59805. rotation?: number;
  59806. cap?: number;
  59807. updatable?: boolean;
  59808. sideOrientation?: number;
  59809. frontUVs?: Vector4;
  59810. backUVs?: Vector4;
  59811. instance?: Mesh;
  59812. invertUV?: boolean;
  59813. }, scene?: Nullable<Scene>): Mesh;
  59814. /**
  59815. * Creates an custom extruded shape mesh.
  59816. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59817. * * 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.
  59818. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59819. * * 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
  59820. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59821. * * 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
  59822. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59823. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59824. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59825. * * 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
  59826. * * 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
  59827. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59830. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59832. * @param name defines the name of the mesh
  59833. * @param options defines the options used to create the mesh
  59834. * @param scene defines the hosting scene
  59835. * @returns the custom extruded shape mesh
  59836. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59837. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59838. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59839. */
  59840. static ExtrudeShapeCustom(name: string, options: {
  59841. shape: Vector3[];
  59842. path: Vector3[];
  59843. scaleFunction?: any;
  59844. rotationFunction?: any;
  59845. ribbonCloseArray?: boolean;
  59846. ribbonClosePath?: boolean;
  59847. cap?: number;
  59848. updatable?: boolean;
  59849. sideOrientation?: number;
  59850. frontUVs?: Vector4;
  59851. backUVs?: Vector4;
  59852. instance?: Mesh;
  59853. invertUV?: boolean;
  59854. }, scene?: Nullable<Scene>): Mesh;
  59855. /**
  59856. * Creates lathe mesh.
  59857. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59858. * * 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
  59859. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59860. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59861. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59862. * * 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
  59863. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59864. * * 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
  59865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59867. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59869. * @param name defines the name of the mesh
  59870. * @param options defines the options used to create the mesh
  59871. * @param scene defines the hosting scene
  59872. * @returns the lathe mesh
  59873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59874. */
  59875. static CreateLathe(name: string, options: {
  59876. shape: Vector3[];
  59877. radius?: number;
  59878. tessellation?: number;
  59879. clip?: number;
  59880. arc?: number;
  59881. closed?: boolean;
  59882. updatable?: boolean;
  59883. sideOrientation?: number;
  59884. frontUVs?: Vector4;
  59885. backUVs?: Vector4;
  59886. cap?: number;
  59887. invertUV?: boolean;
  59888. }, scene?: Nullable<Scene>): Mesh;
  59889. /**
  59890. * Creates a tiled plane mesh
  59891. * * You can set a limited pattern arrangement with the tiles
  59892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59895. * @param name defines the name of the mesh
  59896. * @param options defines the options used to create the mesh
  59897. * @param scene defines the hosting scene
  59898. * @returns the plane mesh
  59899. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59900. */
  59901. static CreateTiledPlane(name: string, options: {
  59902. pattern?: number;
  59903. tileSize?: number;
  59904. tileWidth?: number;
  59905. tileHeight?: number;
  59906. size?: number;
  59907. width?: number;
  59908. height?: number;
  59909. alignHorizontal?: number;
  59910. alignVertical?: number;
  59911. sideOrientation?: number;
  59912. frontUVs?: Vector4;
  59913. backUVs?: Vector4;
  59914. updatable?: boolean;
  59915. }, scene?: Nullable<Scene>): Mesh;
  59916. /**
  59917. * Creates a plane mesh
  59918. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59919. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59920. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59924. * @param name defines the name of the mesh
  59925. * @param options defines the options used to create the mesh
  59926. * @param scene defines the hosting scene
  59927. * @returns the plane mesh
  59928. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59929. */
  59930. static CreatePlane(name: string, options: {
  59931. size?: number;
  59932. width?: number;
  59933. height?: number;
  59934. sideOrientation?: number;
  59935. frontUVs?: Vector4;
  59936. backUVs?: Vector4;
  59937. updatable?: boolean;
  59938. sourcePlane?: Plane;
  59939. }, scene?: Nullable<Scene>): Mesh;
  59940. /**
  59941. * Creates a ground mesh
  59942. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59943. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59945. * @param name defines the name of the mesh
  59946. * @param options defines the options used to create the mesh
  59947. * @param scene defines the hosting scene
  59948. * @returns the ground mesh
  59949. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59950. */
  59951. static CreateGround(name: string, options: {
  59952. width?: number;
  59953. height?: number;
  59954. subdivisions?: number;
  59955. subdivisionsX?: number;
  59956. subdivisionsY?: number;
  59957. updatable?: boolean;
  59958. }, scene?: Nullable<Scene>): Mesh;
  59959. /**
  59960. * Creates a tiled ground mesh
  59961. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59962. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59963. * * 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
  59964. * * 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
  59965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59966. * @param name defines the name of the mesh
  59967. * @param options defines the options used to create the mesh
  59968. * @param scene defines the hosting scene
  59969. * @returns the tiled ground mesh
  59970. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59971. */
  59972. static CreateTiledGround(name: string, options: {
  59973. xmin: number;
  59974. zmin: number;
  59975. xmax: number;
  59976. zmax: number;
  59977. subdivisions?: {
  59978. w: number;
  59979. h: number;
  59980. };
  59981. precision?: {
  59982. w: number;
  59983. h: number;
  59984. };
  59985. updatable?: boolean;
  59986. }, scene?: Nullable<Scene>): Mesh;
  59987. /**
  59988. * Creates a ground mesh from a height map
  59989. * * The parameter `url` sets the URL of the height map image resource.
  59990. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59991. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59992. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59993. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59994. * * 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.
  59995. * * 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).
  59996. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59998. * @param name defines the name of the mesh
  59999. * @param url defines the url to the height map
  60000. * @param options defines the options used to create the mesh
  60001. * @param scene defines the hosting scene
  60002. * @returns the ground mesh
  60003. * @see https://doc.babylonjs.com/babylon101/height_map
  60004. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60005. */
  60006. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60007. width?: number;
  60008. height?: number;
  60009. subdivisions?: number;
  60010. minHeight?: number;
  60011. maxHeight?: number;
  60012. colorFilter?: Color3;
  60013. alphaFilter?: number;
  60014. updatable?: boolean;
  60015. onReady?: (mesh: GroundMesh) => void;
  60016. }, scene?: Nullable<Scene>): GroundMesh;
  60017. /**
  60018. * Creates a polygon mesh
  60019. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60020. * * 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
  60021. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60023. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60024. * * Remember you can only change the shape positions, not their number when updating a polygon
  60025. * @param name defines the name of the mesh
  60026. * @param options defines the options used to create the mesh
  60027. * @param scene defines the hosting scene
  60028. * @param earcutInjection can be used to inject your own earcut reference
  60029. * @returns the polygon mesh
  60030. */
  60031. static CreatePolygon(name: string, options: {
  60032. shape: Vector3[];
  60033. holes?: Vector3[][];
  60034. depth?: number;
  60035. faceUV?: Vector4[];
  60036. faceColors?: Color4[];
  60037. updatable?: boolean;
  60038. sideOrientation?: number;
  60039. frontUVs?: Vector4;
  60040. backUVs?: Vector4;
  60041. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60042. /**
  60043. * Creates an extruded polygon mesh, with depth in the Y direction.
  60044. * * 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)
  60045. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60046. * @param name defines the name of the mesh
  60047. * @param options defines the options used to create the mesh
  60048. * @param scene defines the hosting scene
  60049. * @param earcutInjection can be used to inject your own earcut reference
  60050. * @returns the polygon mesh
  60051. */
  60052. static ExtrudePolygon(name: string, options: {
  60053. shape: Vector3[];
  60054. holes?: Vector3[][];
  60055. depth?: number;
  60056. faceUV?: Vector4[];
  60057. faceColors?: Color4[];
  60058. updatable?: boolean;
  60059. sideOrientation?: number;
  60060. frontUVs?: Vector4;
  60061. backUVs?: Vector4;
  60062. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60063. /**
  60064. * Creates a tube mesh.
  60065. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60066. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60067. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60068. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60069. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60070. * * 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)
  60071. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60072. * * 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
  60073. * * 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
  60074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60076. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60078. * @param name defines the name of the mesh
  60079. * @param options defines the options used to create the mesh
  60080. * @param scene defines the hosting scene
  60081. * @returns the tube mesh
  60082. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60083. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60084. */
  60085. static CreateTube(name: string, options: {
  60086. path: Vector3[];
  60087. radius?: number;
  60088. tessellation?: number;
  60089. radiusFunction?: {
  60090. (i: number, distance: number): number;
  60091. };
  60092. cap?: number;
  60093. arc?: number;
  60094. updatable?: boolean;
  60095. sideOrientation?: number;
  60096. frontUVs?: Vector4;
  60097. backUVs?: Vector4;
  60098. instance?: Mesh;
  60099. invertUV?: boolean;
  60100. }, scene?: Nullable<Scene>): Mesh;
  60101. /**
  60102. * Creates a polyhedron mesh
  60103. * * 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
  60104. * * The parameter `size` (positive float, default 1) sets the polygon size
  60105. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60106. * * 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`
  60107. * * 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
  60108. * * 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)`)
  60109. * * 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
  60110. * * 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
  60111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60114. * @param name defines the name of the mesh
  60115. * @param options defines the options used to create the mesh
  60116. * @param scene defines the hosting scene
  60117. * @returns the polyhedron mesh
  60118. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60119. */
  60120. static CreatePolyhedron(name: string, options: {
  60121. type?: number;
  60122. size?: number;
  60123. sizeX?: number;
  60124. sizeY?: number;
  60125. sizeZ?: number;
  60126. custom?: any;
  60127. faceUV?: Vector4[];
  60128. faceColors?: Color4[];
  60129. flat?: boolean;
  60130. updatable?: boolean;
  60131. sideOrientation?: number;
  60132. frontUVs?: Vector4;
  60133. backUVs?: Vector4;
  60134. }, scene?: Nullable<Scene>): Mesh;
  60135. /**
  60136. * Creates a decal mesh.
  60137. * 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
  60138. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60139. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60140. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60141. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60142. * @param name defines the name of the mesh
  60143. * @param sourceMesh defines the mesh where the decal must be applied
  60144. * @param options defines the options used to create the mesh
  60145. * @param scene defines the hosting scene
  60146. * @returns the decal mesh
  60147. * @see https://doc.babylonjs.com/how_to/decals
  60148. */
  60149. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60150. position?: Vector3;
  60151. normal?: Vector3;
  60152. size?: Vector3;
  60153. angle?: number;
  60154. }): Mesh;
  60155. }
  60156. }
  60157. declare module "babylonjs/Meshes/meshSimplification" {
  60158. import { Mesh } from "babylonjs/Meshes/mesh";
  60159. /**
  60160. * A simplifier interface for future simplification implementations
  60161. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60162. */
  60163. export interface ISimplifier {
  60164. /**
  60165. * Simplification of a given mesh according to the given settings.
  60166. * Since this requires computation, it is assumed that the function runs async.
  60167. * @param settings The settings of the simplification, including quality and distance
  60168. * @param successCallback A callback that will be called after the mesh was simplified.
  60169. * @param errorCallback in case of an error, this callback will be called. optional.
  60170. */
  60171. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60172. }
  60173. /**
  60174. * Expected simplification settings.
  60175. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60176. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60177. */
  60178. export interface ISimplificationSettings {
  60179. /**
  60180. * Gets or sets the expected quality
  60181. */
  60182. quality: number;
  60183. /**
  60184. * Gets or sets the distance when this optimized version should be used
  60185. */
  60186. distance: number;
  60187. /**
  60188. * Gets an already optimized mesh
  60189. */
  60190. optimizeMesh?: boolean;
  60191. }
  60192. /**
  60193. * Class used to specify simplification options
  60194. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60195. */
  60196. export class SimplificationSettings implements ISimplificationSettings {
  60197. /** expected quality */
  60198. quality: number;
  60199. /** distance when this optimized version should be used */
  60200. distance: number;
  60201. /** already optimized mesh */
  60202. optimizeMesh?: boolean | undefined;
  60203. /**
  60204. * Creates a SimplificationSettings
  60205. * @param quality expected quality
  60206. * @param distance distance when this optimized version should be used
  60207. * @param optimizeMesh already optimized mesh
  60208. */
  60209. constructor(
  60210. /** expected quality */
  60211. quality: number,
  60212. /** distance when this optimized version should be used */
  60213. distance: number,
  60214. /** already optimized mesh */
  60215. optimizeMesh?: boolean | undefined);
  60216. }
  60217. /**
  60218. * Interface used to define a simplification task
  60219. */
  60220. export interface ISimplificationTask {
  60221. /**
  60222. * Array of settings
  60223. */
  60224. settings: Array<ISimplificationSettings>;
  60225. /**
  60226. * Simplification type
  60227. */
  60228. simplificationType: SimplificationType;
  60229. /**
  60230. * Mesh to simplify
  60231. */
  60232. mesh: Mesh;
  60233. /**
  60234. * Callback called on success
  60235. */
  60236. successCallback?: () => void;
  60237. /**
  60238. * Defines if parallel processing can be used
  60239. */
  60240. parallelProcessing: boolean;
  60241. }
  60242. /**
  60243. * Queue used to order the simplification tasks
  60244. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60245. */
  60246. export class SimplificationQueue {
  60247. private _simplificationArray;
  60248. /**
  60249. * Gets a boolean indicating that the process is still running
  60250. */
  60251. running: boolean;
  60252. /**
  60253. * Creates a new queue
  60254. */
  60255. constructor();
  60256. /**
  60257. * Adds a new simplification task
  60258. * @param task defines a task to add
  60259. */
  60260. addTask(task: ISimplificationTask): void;
  60261. /**
  60262. * Execute next task
  60263. */
  60264. executeNext(): void;
  60265. /**
  60266. * Execute a simplification task
  60267. * @param task defines the task to run
  60268. */
  60269. runSimplification(task: ISimplificationTask): void;
  60270. private getSimplifier;
  60271. }
  60272. /**
  60273. * The implemented types of simplification
  60274. * At the moment only Quadratic Error Decimation is implemented
  60275. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60276. */
  60277. export enum SimplificationType {
  60278. /** Quadratic error decimation */
  60279. QUADRATIC = 0
  60280. }
  60281. }
  60282. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60283. import { Scene } from "babylonjs/scene";
  60284. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60285. import { ISceneComponent } from "babylonjs/sceneComponent";
  60286. module "babylonjs/scene" {
  60287. interface Scene {
  60288. /** @hidden (Backing field) */
  60289. _simplificationQueue: SimplificationQueue;
  60290. /**
  60291. * Gets or sets the simplification queue attached to the scene
  60292. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60293. */
  60294. simplificationQueue: SimplificationQueue;
  60295. }
  60296. }
  60297. module "babylonjs/Meshes/mesh" {
  60298. interface Mesh {
  60299. /**
  60300. * Simplify the mesh according to the given array of settings.
  60301. * Function will return immediately and will simplify async
  60302. * @param settings a collection of simplification settings
  60303. * @param parallelProcessing should all levels calculate parallel or one after the other
  60304. * @param simplificationType the type of simplification to run
  60305. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60306. * @returns the current mesh
  60307. */
  60308. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60309. }
  60310. }
  60311. /**
  60312. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60313. * created in a scene
  60314. */
  60315. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60316. /**
  60317. * The component name helpfull to identify the component in the list of scene components.
  60318. */
  60319. readonly name: string;
  60320. /**
  60321. * The scene the component belongs to.
  60322. */
  60323. scene: Scene;
  60324. /**
  60325. * Creates a new instance of the component for the given scene
  60326. * @param scene Defines the scene to register the component in
  60327. */
  60328. constructor(scene: Scene);
  60329. /**
  60330. * Registers the component in a given scene
  60331. */
  60332. register(): void;
  60333. /**
  60334. * Rebuilds the elements related to this component in case of
  60335. * context lost for instance.
  60336. */
  60337. rebuild(): void;
  60338. /**
  60339. * Disposes the component and the associated ressources
  60340. */
  60341. dispose(): void;
  60342. private _beforeCameraUpdate;
  60343. }
  60344. }
  60345. declare module "babylonjs/Meshes/Builders/index" {
  60346. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60347. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60348. export * from "babylonjs/Meshes/Builders/discBuilder";
  60349. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60350. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60351. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60352. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60353. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60354. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60355. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60356. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60357. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60358. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60359. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60360. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60361. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60362. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60363. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60364. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60365. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60366. }
  60367. declare module "babylonjs/Meshes/index" {
  60368. export * from "babylonjs/Meshes/abstractMesh";
  60369. export * from "babylonjs/Meshes/buffer";
  60370. export * from "babylonjs/Meshes/Compression/index";
  60371. export * from "babylonjs/Meshes/csg";
  60372. export * from "babylonjs/Meshes/geometry";
  60373. export * from "babylonjs/Meshes/groundMesh";
  60374. export * from "babylonjs/Meshes/trailMesh";
  60375. export * from "babylonjs/Meshes/instancedMesh";
  60376. export * from "babylonjs/Meshes/linesMesh";
  60377. export * from "babylonjs/Meshes/mesh";
  60378. export * from "babylonjs/Meshes/mesh.vertexData";
  60379. export * from "babylonjs/Meshes/meshBuilder";
  60380. export * from "babylonjs/Meshes/meshSimplification";
  60381. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60382. export * from "babylonjs/Meshes/polygonMesh";
  60383. export * from "babylonjs/Meshes/subMesh";
  60384. export * from "babylonjs/Meshes/meshLODLevel";
  60385. export * from "babylonjs/Meshes/transformNode";
  60386. export * from "babylonjs/Meshes/Builders/index";
  60387. export * from "babylonjs/Meshes/dataBuffer";
  60388. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60389. }
  60390. declare module "babylonjs/Morph/index" {
  60391. export * from "babylonjs/Morph/morphTarget";
  60392. export * from "babylonjs/Morph/morphTargetManager";
  60393. }
  60394. declare module "babylonjs/Navigation/INavigationEngine" {
  60395. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60396. import { Vector3 } from "babylonjs/Maths/math";
  60397. import { Mesh } from "babylonjs/Meshes/mesh";
  60398. import { Scene } from "babylonjs/scene";
  60399. /**
  60400. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60401. */
  60402. export interface INavigationEnginePlugin {
  60403. /**
  60404. * plugin name
  60405. */
  60406. name: string;
  60407. /**
  60408. * Creates a navigation mesh
  60409. * @param meshes array of all the geometry used to compute the navigatio mesh
  60410. * @param parameters bunch of parameters used to filter geometry
  60411. */
  60412. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60413. /**
  60414. * Create a navigation mesh debug mesh
  60415. * @param scene is where the mesh will be added
  60416. * @returns debug display mesh
  60417. */
  60418. createDebugNavMesh(scene: Scene): Mesh;
  60419. /**
  60420. * Get a navigation mesh constrained position, closest to the parameter position
  60421. * @param position world position
  60422. * @returns the closest point to position constrained by the navigation mesh
  60423. */
  60424. getClosestPoint(position: Vector3): Vector3;
  60425. /**
  60426. * Get a navigation mesh constrained position, within a particular radius
  60427. * @param position world position
  60428. * @param maxRadius the maximum distance to the constrained world position
  60429. * @returns the closest point to position constrained by the navigation mesh
  60430. */
  60431. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60432. /**
  60433. * Compute the final position from a segment made of destination-position
  60434. * @param position world position
  60435. * @param destination world position
  60436. * @returns the resulting point along the navmesh
  60437. */
  60438. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60439. /**
  60440. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60441. * @param start world position
  60442. * @param end world position
  60443. * @returns array containing world position composing the path
  60444. */
  60445. computePath(start: Vector3, end: Vector3): Vector3[];
  60446. /**
  60447. * If this plugin is supported
  60448. * @returns true if plugin is supported
  60449. */
  60450. isSupported(): boolean;
  60451. /**
  60452. * Create a new Crowd so you can add agents
  60453. * @param maxAgents the maximum agent count in the crowd
  60454. * @param maxAgentRadius the maximum radius an agent can have
  60455. * @param scene to attach the crowd to
  60456. * @returns the crowd you can add agents to
  60457. */
  60458. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60459. /**
  60460. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60461. * The queries will try to find a solution within those bounds
  60462. * default is (1,1,1)
  60463. * @param extent x,y,z value that define the extent around the queries point of reference
  60464. */
  60465. setDefaultQueryExtent(extent: Vector3): void;
  60466. /**
  60467. * Get the Bounding box extent specified by setDefaultQueryExtent
  60468. * @returns the box extent values
  60469. */
  60470. getDefaultQueryExtent(): Vector3;
  60471. /**
  60472. * Release all resources
  60473. */
  60474. dispose(): void;
  60475. }
  60476. /**
  60477. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60478. */
  60479. export interface ICrowd {
  60480. /**
  60481. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60482. * You can attach anything to that node. The node position is updated in the scene update tick.
  60483. * @param pos world position that will be constrained by the navigation mesh
  60484. * @param parameters agent parameters
  60485. * @param transform hooked to the agent that will be update by the scene
  60486. * @returns agent index
  60487. */
  60488. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60489. /**
  60490. * Returns the agent position in world space
  60491. * @param index agent index returned by addAgent
  60492. * @returns world space position
  60493. */
  60494. getAgentPosition(index: number): Vector3;
  60495. /**
  60496. * Gets the agent velocity in world space
  60497. * @param index agent index returned by addAgent
  60498. * @returns world space velocity
  60499. */
  60500. getAgentVelocity(index: number): Vector3;
  60501. /**
  60502. * remove a particular agent previously created
  60503. * @param index agent index returned by addAgent
  60504. */
  60505. removeAgent(index: number): void;
  60506. /**
  60507. * get the list of all agents attached to this crowd
  60508. * @returns list of agent indices
  60509. */
  60510. getAgents(): number[];
  60511. /**
  60512. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60513. * @param deltaTime in seconds
  60514. */
  60515. update(deltaTime: number): void;
  60516. /**
  60517. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60518. * @param index agent index returned by addAgent
  60519. * @param destination targeted world position
  60520. */
  60521. agentGoto(index: number, destination: Vector3): void;
  60522. /**
  60523. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60524. * The queries will try to find a solution within those bounds
  60525. * default is (1,1,1)
  60526. * @param extent x,y,z value that define the extent around the queries point of reference
  60527. */
  60528. setDefaultQueryExtent(extent: Vector3): void;
  60529. /**
  60530. * Get the Bounding box extent specified by setDefaultQueryExtent
  60531. * @returns the box extent values
  60532. */
  60533. getDefaultQueryExtent(): Vector3;
  60534. /**
  60535. * Release all resources
  60536. */
  60537. dispose(): void;
  60538. }
  60539. /**
  60540. * Configures an agent
  60541. */
  60542. export interface IAgentParameters {
  60543. /**
  60544. * Agent radius. [Limit: >= 0]
  60545. */
  60546. radius: number;
  60547. /**
  60548. * Agent height. [Limit: > 0]
  60549. */
  60550. height: number;
  60551. /**
  60552. * Maximum allowed acceleration. [Limit: >= 0]
  60553. */
  60554. maxAcceleration: number;
  60555. /**
  60556. * Maximum allowed speed. [Limit: >= 0]
  60557. */
  60558. maxSpeed: number;
  60559. /**
  60560. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60561. */
  60562. collisionQueryRange: number;
  60563. /**
  60564. * The path visibility optimization range. [Limit: > 0]
  60565. */
  60566. pathOptimizationRange: number;
  60567. /**
  60568. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60569. */
  60570. separationWeight: number;
  60571. }
  60572. /**
  60573. * Configures the navigation mesh creation
  60574. */
  60575. export interface INavMeshParameters {
  60576. /**
  60577. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60578. */
  60579. cs: number;
  60580. /**
  60581. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60582. */
  60583. ch: number;
  60584. /**
  60585. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60586. */
  60587. walkableSlopeAngle: number;
  60588. /**
  60589. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60590. * be considered walkable. [Limit: >= 3] [Units: vx]
  60591. */
  60592. walkableHeight: number;
  60593. /**
  60594. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60595. */
  60596. walkableClimb: number;
  60597. /**
  60598. * The distance to erode/shrink the walkable area of the heightfield away from
  60599. * obstructions. [Limit: >=0] [Units: vx]
  60600. */
  60601. walkableRadius: number;
  60602. /**
  60603. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60604. */
  60605. maxEdgeLen: number;
  60606. /**
  60607. * The maximum distance a simplfied contour's border edges should deviate
  60608. * the original raw contour. [Limit: >=0] [Units: vx]
  60609. */
  60610. maxSimplificationError: number;
  60611. /**
  60612. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60613. */
  60614. minRegionArea: number;
  60615. /**
  60616. * Any regions with a span count smaller than this value will, if possible,
  60617. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60618. */
  60619. mergeRegionArea: number;
  60620. /**
  60621. * The maximum number of vertices allowed for polygons generated during the
  60622. * contour to polygon conversion process. [Limit: >= 3]
  60623. */
  60624. maxVertsPerPoly: number;
  60625. /**
  60626. * Sets the sampling distance to use when generating the detail mesh.
  60627. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60628. */
  60629. detailSampleDist: number;
  60630. /**
  60631. * The maximum distance the detail mesh surface should deviate from heightfield
  60632. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60633. */
  60634. detailSampleMaxError: number;
  60635. }
  60636. }
  60637. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60638. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60639. import { Mesh } from "babylonjs/Meshes/mesh";
  60640. import { Scene } from "babylonjs/scene";
  60641. import { Vector3 } from "babylonjs/Maths/math";
  60642. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60643. /**
  60644. * RecastJS navigation plugin
  60645. */
  60646. export class RecastJSPlugin implements INavigationEnginePlugin {
  60647. /**
  60648. * Reference to the Recast library
  60649. */
  60650. bjsRECAST: any;
  60651. /**
  60652. * plugin name
  60653. */
  60654. name: string;
  60655. /**
  60656. * the first navmesh created. We might extend this to support multiple navmeshes
  60657. */
  60658. navMesh: any;
  60659. /**
  60660. * Initializes the recastJS plugin
  60661. * @param recastInjection can be used to inject your own recast reference
  60662. */
  60663. constructor(recastInjection?: any);
  60664. /**
  60665. * Creates a navigation mesh
  60666. * @param meshes array of all the geometry used to compute the navigatio mesh
  60667. * @param parameters bunch of parameters used to filter geometry
  60668. */
  60669. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60670. /**
  60671. * Create a navigation mesh debug mesh
  60672. * @param scene is where the mesh will be added
  60673. * @returns debug display mesh
  60674. */
  60675. createDebugNavMesh(scene: Scene): Mesh;
  60676. /**
  60677. * Get a navigation mesh constrained position, closest to the parameter position
  60678. * @param position world position
  60679. * @returns the closest point to position constrained by the navigation mesh
  60680. */
  60681. getClosestPoint(position: Vector3): Vector3;
  60682. /**
  60683. * Get a navigation mesh constrained position, within a particular radius
  60684. * @param position world position
  60685. * @param maxRadius the maximum distance to the constrained world position
  60686. * @returns the closest point to position constrained by the navigation mesh
  60687. */
  60688. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60689. /**
  60690. * Compute the final position from a segment made of destination-position
  60691. * @param position world position
  60692. * @param destination world position
  60693. * @returns the resulting point along the navmesh
  60694. */
  60695. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60696. /**
  60697. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60698. * @param start world position
  60699. * @param end world position
  60700. * @returns array containing world position composing the path
  60701. */
  60702. computePath(start: Vector3, end: Vector3): Vector3[];
  60703. /**
  60704. * Create a new Crowd so you can add agents
  60705. * @param maxAgents the maximum agent count in the crowd
  60706. * @param maxAgentRadius the maximum radius an agent can have
  60707. * @param scene to attach the crowd to
  60708. * @returns the crowd you can add agents to
  60709. */
  60710. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60711. /**
  60712. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60713. * The queries will try to find a solution within those bounds
  60714. * default is (1,1,1)
  60715. * @param extent x,y,z value that define the extent around the queries point of reference
  60716. */
  60717. setDefaultQueryExtent(extent: Vector3): void;
  60718. /**
  60719. * Get the Bounding box extent specified by setDefaultQueryExtent
  60720. * @returns the box extent values
  60721. */
  60722. getDefaultQueryExtent(): Vector3;
  60723. /**
  60724. * Disposes
  60725. */
  60726. dispose(): void;
  60727. /**
  60728. * If this plugin is supported
  60729. * @returns true if plugin is supported
  60730. */
  60731. isSupported(): boolean;
  60732. }
  60733. /**
  60734. * Recast detour crowd implementation
  60735. */
  60736. export class RecastJSCrowd implements ICrowd {
  60737. /**
  60738. * Recast/detour plugin
  60739. */
  60740. bjsRECASTPlugin: RecastJSPlugin;
  60741. /**
  60742. * Link to the detour crowd
  60743. */
  60744. recastCrowd: any;
  60745. /**
  60746. * One transform per agent
  60747. */
  60748. transforms: TransformNode[];
  60749. /**
  60750. * All agents created
  60751. */
  60752. agents: number[];
  60753. /**
  60754. * Link to the scene is kept to unregister the crowd from the scene
  60755. */
  60756. private _scene;
  60757. /**
  60758. * Observer for crowd updates
  60759. */
  60760. private _onBeforeAnimationsObserver;
  60761. /**
  60762. * Constructor
  60763. * @param plugin recastJS plugin
  60764. * @param maxAgents the maximum agent count in the crowd
  60765. * @param maxAgentRadius the maximum radius an agent can have
  60766. * @param scene to attach the crowd to
  60767. * @returns the crowd you can add agents to
  60768. */
  60769. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60770. /**
  60771. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60772. * You can attach anything to that node. The node position is updated in the scene update tick.
  60773. * @param pos world position that will be constrained by the navigation mesh
  60774. * @param parameters agent parameters
  60775. * @param transform hooked to the agent that will be update by the scene
  60776. * @returns agent index
  60777. */
  60778. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60779. /**
  60780. * Returns the agent position in world space
  60781. * @param index agent index returned by addAgent
  60782. * @returns world space position
  60783. */
  60784. getAgentPosition(index: number): Vector3;
  60785. /**
  60786. * Returns the agent velocity in world space
  60787. * @param index agent index returned by addAgent
  60788. * @returns world space velocity
  60789. */
  60790. getAgentVelocity(index: number): Vector3;
  60791. /**
  60792. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60793. * @param index agent index returned by addAgent
  60794. * @param destination targeted world position
  60795. */
  60796. agentGoto(index: number, destination: Vector3): void;
  60797. /**
  60798. * remove a particular agent previously created
  60799. * @param index agent index returned by addAgent
  60800. */
  60801. removeAgent(index: number): void;
  60802. /**
  60803. * get the list of all agents attached to this crowd
  60804. * @returns list of agent indices
  60805. */
  60806. getAgents(): number[];
  60807. /**
  60808. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60809. * @param deltaTime in seconds
  60810. */
  60811. update(deltaTime: number): void;
  60812. /**
  60813. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60814. * The queries will try to find a solution within those bounds
  60815. * default is (1,1,1)
  60816. * @param extent x,y,z value that define the extent around the queries point of reference
  60817. */
  60818. setDefaultQueryExtent(extent: Vector3): void;
  60819. /**
  60820. * Get the Bounding box extent specified by setDefaultQueryExtent
  60821. * @returns the box extent values
  60822. */
  60823. getDefaultQueryExtent(): Vector3;
  60824. /**
  60825. * Release all resources
  60826. */
  60827. dispose(): void;
  60828. }
  60829. }
  60830. declare module "babylonjs/Navigation/Plugins/index" {
  60831. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60832. }
  60833. declare module "babylonjs/Navigation/index" {
  60834. export * from "babylonjs/Navigation/INavigationEngine";
  60835. export * from "babylonjs/Navigation/Plugins/index";
  60836. }
  60837. declare module "babylonjs/Offline/database" {
  60838. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60839. /**
  60840. * Class used to enable access to IndexedDB
  60841. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60842. */
  60843. export class Database implements IOfflineProvider {
  60844. private _callbackManifestChecked;
  60845. private _currentSceneUrl;
  60846. private _db;
  60847. private _enableSceneOffline;
  60848. private _enableTexturesOffline;
  60849. private _manifestVersionFound;
  60850. private _mustUpdateRessources;
  60851. private _hasReachedQuota;
  60852. private _isSupported;
  60853. private _idbFactory;
  60854. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60855. private static IsUASupportingBlobStorage;
  60856. /**
  60857. * Gets a boolean indicating if Database storate is enabled (off by default)
  60858. */
  60859. static IDBStorageEnabled: boolean;
  60860. /**
  60861. * Gets a boolean indicating if scene must be saved in the database
  60862. */
  60863. readonly enableSceneOffline: boolean;
  60864. /**
  60865. * Gets a boolean indicating if textures must be saved in the database
  60866. */
  60867. readonly enableTexturesOffline: boolean;
  60868. /**
  60869. * Creates a new Database
  60870. * @param urlToScene defines the url to load the scene
  60871. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60872. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60873. */
  60874. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60875. private static _ParseURL;
  60876. private static _ReturnFullUrlLocation;
  60877. private _checkManifestFile;
  60878. /**
  60879. * Open the database and make it available
  60880. * @param successCallback defines the callback to call on success
  60881. * @param errorCallback defines the callback to call on error
  60882. */
  60883. open(successCallback: () => void, errorCallback: () => void): void;
  60884. /**
  60885. * Loads an image from the database
  60886. * @param url defines the url to load from
  60887. * @param image defines the target DOM image
  60888. */
  60889. loadImage(url: string, image: HTMLImageElement): void;
  60890. private _loadImageFromDBAsync;
  60891. private _saveImageIntoDBAsync;
  60892. private _checkVersionFromDB;
  60893. private _loadVersionFromDBAsync;
  60894. private _saveVersionIntoDBAsync;
  60895. /**
  60896. * Loads a file from database
  60897. * @param url defines the URL to load from
  60898. * @param sceneLoaded defines a callback to call on success
  60899. * @param progressCallBack defines a callback to call when progress changed
  60900. * @param errorCallback defines a callback to call on error
  60901. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60902. */
  60903. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60904. private _loadFileAsync;
  60905. private _saveFileAsync;
  60906. /**
  60907. * Validates if xhr data is correct
  60908. * @param xhr defines the request to validate
  60909. * @param dataType defines the expected data type
  60910. * @returns true if data is correct
  60911. */
  60912. private static _ValidateXHRData;
  60913. }
  60914. }
  60915. declare module "babylonjs/Offline/index" {
  60916. export * from "babylonjs/Offline/database";
  60917. export * from "babylonjs/Offline/IOfflineProvider";
  60918. }
  60919. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60920. /** @hidden */
  60921. export var gpuUpdateParticlesPixelShader: {
  60922. name: string;
  60923. shader: string;
  60924. };
  60925. }
  60926. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60927. /** @hidden */
  60928. export var gpuUpdateParticlesVertexShader: {
  60929. name: string;
  60930. shader: string;
  60931. };
  60932. }
  60933. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60934. /** @hidden */
  60935. export var clipPlaneFragmentDeclaration2: {
  60936. name: string;
  60937. shader: string;
  60938. };
  60939. }
  60940. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60941. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60942. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60943. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60944. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60945. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60946. /** @hidden */
  60947. export var gpuRenderParticlesPixelShader: {
  60948. name: string;
  60949. shader: string;
  60950. };
  60951. }
  60952. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60953. /** @hidden */
  60954. export var clipPlaneVertexDeclaration2: {
  60955. name: string;
  60956. shader: string;
  60957. };
  60958. }
  60959. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60960. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60961. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60962. /** @hidden */
  60963. export var gpuRenderParticlesVertexShader: {
  60964. name: string;
  60965. shader: string;
  60966. };
  60967. }
  60968. declare module "babylonjs/Particles/gpuParticleSystem" {
  60969. import { Nullable } from "babylonjs/types";
  60970. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60971. import { Observable } from "babylonjs/Misc/observable";
  60972. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60973. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60974. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60975. import { Scene, IDisposable } from "babylonjs/scene";
  60976. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60977. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60978. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60979. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60980. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60981. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60982. /**
  60983. * This represents a GPU particle system in Babylon
  60984. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60985. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60986. */
  60987. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60988. /**
  60989. * The layer mask we are rendering the particles through.
  60990. */
  60991. layerMask: number;
  60992. private _capacity;
  60993. private _activeCount;
  60994. private _currentActiveCount;
  60995. private _accumulatedCount;
  60996. private _renderEffect;
  60997. private _updateEffect;
  60998. private _buffer0;
  60999. private _buffer1;
  61000. private _spriteBuffer;
  61001. private _updateVAO;
  61002. private _renderVAO;
  61003. private _targetIndex;
  61004. private _sourceBuffer;
  61005. private _targetBuffer;
  61006. private _engine;
  61007. private _currentRenderId;
  61008. private _started;
  61009. private _stopped;
  61010. private _timeDelta;
  61011. private _randomTexture;
  61012. private _randomTexture2;
  61013. private _attributesStrideSize;
  61014. private _updateEffectOptions;
  61015. private _randomTextureSize;
  61016. private _actualFrame;
  61017. private readonly _rawTextureWidth;
  61018. /**
  61019. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61020. */
  61021. static readonly IsSupported: boolean;
  61022. /**
  61023. * An event triggered when the system is disposed.
  61024. */
  61025. onDisposeObservable: Observable<GPUParticleSystem>;
  61026. /**
  61027. * Gets the maximum number of particles active at the same time.
  61028. * @returns The max number of active particles.
  61029. */
  61030. getCapacity(): number;
  61031. /**
  61032. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61033. * to override the particles.
  61034. */
  61035. forceDepthWrite: boolean;
  61036. /**
  61037. * Gets or set the number of active particles
  61038. */
  61039. activeParticleCount: number;
  61040. private _preWarmDone;
  61041. /**
  61042. * Is this system ready to be used/rendered
  61043. * @return true if the system is ready
  61044. */
  61045. isReady(): boolean;
  61046. /**
  61047. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61048. * @returns True if it has been started, otherwise false.
  61049. */
  61050. isStarted(): boolean;
  61051. /**
  61052. * Starts the particle system and begins to emit
  61053. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61054. */
  61055. start(delay?: number): void;
  61056. /**
  61057. * Stops the particle system.
  61058. */
  61059. stop(): void;
  61060. /**
  61061. * Remove all active particles
  61062. */
  61063. reset(): void;
  61064. /**
  61065. * Returns the string "GPUParticleSystem"
  61066. * @returns a string containing the class name
  61067. */
  61068. getClassName(): string;
  61069. private _colorGradientsTexture;
  61070. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61071. /**
  61072. * Adds a new color gradient
  61073. * @param gradient defines the gradient to use (between 0 and 1)
  61074. * @param color1 defines the color to affect to the specified gradient
  61075. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61076. * @returns the current particle system
  61077. */
  61078. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61079. /**
  61080. * Remove a specific color gradient
  61081. * @param gradient defines the gradient to remove
  61082. * @returns the current particle system
  61083. */
  61084. removeColorGradient(gradient: number): GPUParticleSystem;
  61085. private _angularSpeedGradientsTexture;
  61086. private _sizeGradientsTexture;
  61087. private _velocityGradientsTexture;
  61088. private _limitVelocityGradientsTexture;
  61089. private _dragGradientsTexture;
  61090. private _addFactorGradient;
  61091. /**
  61092. * Adds a new size gradient
  61093. * @param gradient defines the gradient to use (between 0 and 1)
  61094. * @param factor defines the size factor to affect to the specified gradient
  61095. * @returns the current particle system
  61096. */
  61097. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61098. /**
  61099. * Remove a specific size gradient
  61100. * @param gradient defines the gradient to remove
  61101. * @returns the current particle system
  61102. */
  61103. removeSizeGradient(gradient: number): GPUParticleSystem;
  61104. /**
  61105. * Adds a new angular speed gradient
  61106. * @param gradient defines the gradient to use (between 0 and 1)
  61107. * @param factor defines the angular speed to affect to the specified gradient
  61108. * @returns the current particle system
  61109. */
  61110. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61111. /**
  61112. * Remove a specific angular speed gradient
  61113. * @param gradient defines the gradient to remove
  61114. * @returns the current particle system
  61115. */
  61116. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61117. /**
  61118. * Adds a new velocity gradient
  61119. * @param gradient defines the gradient to use (between 0 and 1)
  61120. * @param factor defines the velocity to affect to the specified gradient
  61121. * @returns the current particle system
  61122. */
  61123. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61124. /**
  61125. * Remove a specific velocity gradient
  61126. * @param gradient defines the gradient to remove
  61127. * @returns the current particle system
  61128. */
  61129. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61130. /**
  61131. * Adds a new limit velocity gradient
  61132. * @param gradient defines the gradient to use (between 0 and 1)
  61133. * @param factor defines the limit velocity value to affect to the specified gradient
  61134. * @returns the current particle system
  61135. */
  61136. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61137. /**
  61138. * Remove a specific limit velocity gradient
  61139. * @param gradient defines the gradient to remove
  61140. * @returns the current particle system
  61141. */
  61142. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61143. /**
  61144. * Adds a new drag gradient
  61145. * @param gradient defines the gradient to use (between 0 and 1)
  61146. * @param factor defines the drag value to affect to the specified gradient
  61147. * @returns the current particle system
  61148. */
  61149. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61150. /**
  61151. * Remove a specific drag gradient
  61152. * @param gradient defines the gradient to remove
  61153. * @returns the current particle system
  61154. */
  61155. removeDragGradient(gradient: number): GPUParticleSystem;
  61156. /**
  61157. * Not supported by GPUParticleSystem
  61158. * @param gradient defines the gradient to use (between 0 and 1)
  61159. * @param factor defines the emit rate value to affect to the specified gradient
  61160. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61161. * @returns the current particle system
  61162. */
  61163. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61164. /**
  61165. * Not supported by GPUParticleSystem
  61166. * @param gradient defines the gradient to remove
  61167. * @returns the current particle system
  61168. */
  61169. removeEmitRateGradient(gradient: number): IParticleSystem;
  61170. /**
  61171. * Not supported by GPUParticleSystem
  61172. * @param gradient defines the gradient to use (between 0 and 1)
  61173. * @param factor defines the start size value to affect to the specified gradient
  61174. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61175. * @returns the current particle system
  61176. */
  61177. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61178. /**
  61179. * Not supported by GPUParticleSystem
  61180. * @param gradient defines the gradient to remove
  61181. * @returns the current particle system
  61182. */
  61183. removeStartSizeGradient(gradient: number): IParticleSystem;
  61184. /**
  61185. * Not supported by GPUParticleSystem
  61186. * @param gradient defines the gradient to use (between 0 and 1)
  61187. * @param min defines the color remap minimal range
  61188. * @param max defines the color remap maximal range
  61189. * @returns the current particle system
  61190. */
  61191. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61192. /**
  61193. * Not supported by GPUParticleSystem
  61194. * @param gradient defines the gradient to remove
  61195. * @returns the current particle system
  61196. */
  61197. removeColorRemapGradient(): IParticleSystem;
  61198. /**
  61199. * Not supported by GPUParticleSystem
  61200. * @param gradient defines the gradient to use (between 0 and 1)
  61201. * @param min defines the alpha remap minimal range
  61202. * @param max defines the alpha remap maximal range
  61203. * @returns the current particle system
  61204. */
  61205. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61206. /**
  61207. * Not supported by GPUParticleSystem
  61208. * @param gradient defines the gradient to remove
  61209. * @returns the current particle system
  61210. */
  61211. removeAlphaRemapGradient(): IParticleSystem;
  61212. /**
  61213. * Not supported by GPUParticleSystem
  61214. * @param gradient defines the gradient to use (between 0 and 1)
  61215. * @param color defines the color to affect to the specified gradient
  61216. * @returns the current particle system
  61217. */
  61218. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61219. /**
  61220. * Not supported by GPUParticleSystem
  61221. * @param gradient defines the gradient to remove
  61222. * @returns the current particle system
  61223. */
  61224. removeRampGradient(): IParticleSystem;
  61225. /**
  61226. * Not supported by GPUParticleSystem
  61227. * @returns the list of ramp gradients
  61228. */
  61229. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61230. /**
  61231. * Not supported by GPUParticleSystem
  61232. * Gets or sets a boolean indicating that ramp gradients must be used
  61233. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61234. */
  61235. useRampGradients: boolean;
  61236. /**
  61237. * Not supported by GPUParticleSystem
  61238. * @param gradient defines the gradient to use (between 0 and 1)
  61239. * @param factor defines the life time factor to affect to the specified gradient
  61240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61241. * @returns the current particle system
  61242. */
  61243. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61244. /**
  61245. * Not supported by GPUParticleSystem
  61246. * @param gradient defines the gradient to remove
  61247. * @returns the current particle system
  61248. */
  61249. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61250. /**
  61251. * Instantiates a GPU particle system.
  61252. * 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.
  61253. * @param name The name of the particle system
  61254. * @param options The options used to create the system
  61255. * @param scene The scene the particle system belongs to
  61256. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61257. */
  61258. constructor(name: string, options: Partial<{
  61259. capacity: number;
  61260. randomTextureSize: number;
  61261. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61262. protected _reset(): void;
  61263. private _createUpdateVAO;
  61264. private _createRenderVAO;
  61265. private _initialize;
  61266. /** @hidden */
  61267. _recreateUpdateEffect(): void;
  61268. /** @hidden */
  61269. _recreateRenderEffect(): void;
  61270. /**
  61271. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61272. * @param preWarm defines if we are in the pre-warmimg phase
  61273. */
  61274. animate(preWarm?: boolean): void;
  61275. private _createFactorGradientTexture;
  61276. private _createSizeGradientTexture;
  61277. private _createAngularSpeedGradientTexture;
  61278. private _createVelocityGradientTexture;
  61279. private _createLimitVelocityGradientTexture;
  61280. private _createDragGradientTexture;
  61281. private _createColorGradientTexture;
  61282. /**
  61283. * Renders the particle system in its current state
  61284. * @param preWarm defines if the system should only update the particles but not render them
  61285. * @returns the current number of particles
  61286. */
  61287. render(preWarm?: boolean): number;
  61288. /**
  61289. * Rebuilds the particle system
  61290. */
  61291. rebuild(): void;
  61292. private _releaseBuffers;
  61293. private _releaseVAOs;
  61294. /**
  61295. * Disposes the particle system and free the associated resources
  61296. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61297. */
  61298. dispose(disposeTexture?: boolean): void;
  61299. /**
  61300. * Clones the particle system.
  61301. * @param name The name of the cloned object
  61302. * @param newEmitter The new emitter to use
  61303. * @returns the cloned particle system
  61304. */
  61305. clone(name: string, newEmitter: any): GPUParticleSystem;
  61306. /**
  61307. * Serializes the particle system to a JSON object.
  61308. * @returns the JSON object
  61309. */
  61310. serialize(): any;
  61311. /**
  61312. * Parses a JSON object to create a GPU particle system.
  61313. * @param parsedParticleSystem The JSON object to parse
  61314. * @param scene The scene to create the particle system in
  61315. * @param rootUrl The root url to use to load external dependencies like texture
  61316. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61317. * @returns the parsed GPU particle system
  61318. */
  61319. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61320. }
  61321. }
  61322. declare module "babylonjs/Particles/particleSystemSet" {
  61323. import { Nullable } from "babylonjs/types";
  61324. import { Color3 } from "babylonjs/Maths/math.color";
  61325. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61327. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61328. import { Scene, IDisposable } from "babylonjs/scene";
  61329. /**
  61330. * Represents a set of particle systems working together to create a specific effect
  61331. */
  61332. export class ParticleSystemSet implements IDisposable {
  61333. /**
  61334. * Gets or sets base Assets URL
  61335. */
  61336. static BaseAssetsUrl: string;
  61337. private _emitterCreationOptions;
  61338. private _emitterNode;
  61339. /**
  61340. * Gets the particle system list
  61341. */
  61342. systems: IParticleSystem[];
  61343. /**
  61344. * Gets the emitter node used with this set
  61345. */
  61346. readonly emitterNode: Nullable<TransformNode>;
  61347. /**
  61348. * Creates a new emitter mesh as a sphere
  61349. * @param options defines the options used to create the sphere
  61350. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61351. * @param scene defines the hosting scene
  61352. */
  61353. setEmitterAsSphere(options: {
  61354. diameter: number;
  61355. segments: number;
  61356. color: Color3;
  61357. }, renderingGroupId: number, scene: Scene): void;
  61358. /**
  61359. * Starts all particle systems of the set
  61360. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61361. */
  61362. start(emitter?: AbstractMesh): void;
  61363. /**
  61364. * Release all associated resources
  61365. */
  61366. dispose(): void;
  61367. /**
  61368. * Serialize the set into a JSON compatible object
  61369. * @returns a JSON compatible representation of the set
  61370. */
  61371. serialize(): any;
  61372. /**
  61373. * Parse a new ParticleSystemSet from a serialized source
  61374. * @param data defines a JSON compatible representation of the set
  61375. * @param scene defines the hosting scene
  61376. * @param gpu defines if we want GPU particles or CPU particles
  61377. * @returns a new ParticleSystemSet
  61378. */
  61379. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61380. }
  61381. }
  61382. declare module "babylonjs/Particles/particleHelper" {
  61383. import { Nullable } from "babylonjs/types";
  61384. import { Scene } from "babylonjs/scene";
  61385. import { Vector3 } from "babylonjs/Maths/math.vector";
  61386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61387. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61388. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61389. /**
  61390. * This class is made for on one-liner static method to help creating particle system set.
  61391. */
  61392. export class ParticleHelper {
  61393. /**
  61394. * Gets or sets base Assets URL
  61395. */
  61396. static BaseAssetsUrl: string;
  61397. /**
  61398. * Create a default particle system that you can tweak
  61399. * @param emitter defines the emitter to use
  61400. * @param capacity defines the system capacity (default is 500 particles)
  61401. * @param scene defines the hosting scene
  61402. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61403. * @returns the new Particle system
  61404. */
  61405. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61406. /**
  61407. * This is the main static method (one-liner) of this helper to create different particle systems
  61408. * @param type This string represents the type to the particle system to create
  61409. * @param scene The scene where the particle system should live
  61410. * @param gpu If the system will use gpu
  61411. * @returns the ParticleSystemSet created
  61412. */
  61413. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61414. /**
  61415. * Static function used to export a particle system to a ParticleSystemSet variable.
  61416. * Please note that the emitter shape is not exported
  61417. * @param systems defines the particle systems to export
  61418. * @returns the created particle system set
  61419. */
  61420. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61421. }
  61422. }
  61423. declare module "babylonjs/Particles/particleSystemComponent" {
  61424. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61425. import { Effect } from "babylonjs/Materials/effect";
  61426. import "babylonjs/Shaders/particles.vertex";
  61427. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61428. module "babylonjs/Engines/engine" {
  61429. interface Engine {
  61430. /**
  61431. * Create an effect to use with particle systems.
  61432. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61433. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61434. * @param uniformsNames defines a list of attribute names
  61435. * @param samplers defines an array of string used to represent textures
  61436. * @param defines defines the string containing the defines to use to compile the shaders
  61437. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61438. * @param onCompiled defines a function to call when the effect creation is successful
  61439. * @param onError defines a function to call when the effect creation has failed
  61440. * @returns the new Effect
  61441. */
  61442. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61443. }
  61444. }
  61445. module "babylonjs/Meshes/mesh" {
  61446. interface Mesh {
  61447. /**
  61448. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61449. * @returns an array of IParticleSystem
  61450. */
  61451. getEmittedParticleSystems(): IParticleSystem[];
  61452. /**
  61453. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61454. * @returns an array of IParticleSystem
  61455. */
  61456. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61457. }
  61458. }
  61459. /**
  61460. * @hidden
  61461. */
  61462. export var _IDoNeedToBeInTheBuild: number;
  61463. }
  61464. declare module "babylonjs/Particles/pointsCloudSystem" {
  61465. import { Color4 } from "babylonjs/Maths/math";
  61466. import { Mesh } from "babylonjs/Meshes/mesh";
  61467. import { Scene, IDisposable } from "babylonjs/scene";
  61468. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  61469. /** Defines the 4 color options */
  61470. export enum PointColor {
  61471. /** color value */
  61472. Color = 2,
  61473. /** uv value */
  61474. UV = 1,
  61475. /** random value */
  61476. Random = 0,
  61477. /** stated value */
  61478. Stated = 3
  61479. }
  61480. /**
  61481. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61482. * 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.
  61483. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61484. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61485. *
  61486. * Full documentation here : TO BE ENTERED
  61487. */
  61488. export class PointsCloudSystem implements IDisposable {
  61489. /**
  61490. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61491. * Example : var p = SPS.particles[i];
  61492. */
  61493. particles: CloudPoint[];
  61494. /**
  61495. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61496. */
  61497. nbParticles: number;
  61498. /**
  61499. * This a counter for your own usage. It's not set by any SPS functions.
  61500. */
  61501. counter: number;
  61502. /**
  61503. * The PCS name. This name is also given to the underlying mesh.
  61504. */
  61505. name: string;
  61506. /**
  61507. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61508. */
  61509. mesh: Mesh;
  61510. /**
  61511. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61512. * Please read :
  61513. */
  61514. vars: any;
  61515. /**
  61516. * @hidden
  61517. */
  61518. _size: number;
  61519. private _scene;
  61520. private _promises;
  61521. private _positions;
  61522. private _indices;
  61523. private _normals;
  61524. private _colors;
  61525. private _uvs;
  61526. private _indices32;
  61527. private _positions32;
  61528. private _colors32;
  61529. private _uvs32;
  61530. private _updatable;
  61531. private _isVisibilityBoxLocked;
  61532. private _alwaysVisible;
  61533. private _groups;
  61534. private _groupCounter;
  61535. private _computeParticleColor;
  61536. private _computeParticleTexture;
  61537. private _computeParticleRotation;
  61538. private _computeBoundingBox;
  61539. private _isReady;
  61540. /**
  61541. * Creates a PCS (Points Cloud System) object
  61542. * @param name (String) is the PCS name, this will be the underlying mesh name
  61543. * @param pointSize (number) is the size for each point
  61544. * @param scene (Scene) is the scene in which the PCS is added
  61545. * @param options defines the options of the PCS e.g.
  61546. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61547. */
  61548. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61549. updatable?: boolean;
  61550. });
  61551. /**
  61552. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61553. * If no points were added to the PCS, the returned mesh is just a single point.
  61554. * @returns a promise for the created mesh
  61555. */
  61556. buildMeshAsync(): Promise<Mesh>;
  61557. /**
  61558. * @hidden
  61559. */
  61560. private _buildMesh;
  61561. private _addParticle;
  61562. private _randomUnitVector;
  61563. private _getColorIndicesForCoord;
  61564. private _setPointsColorOrUV;
  61565. private _colorFromTexture;
  61566. private _calculateDensity;
  61567. /**
  61568. * Adds points to the PCS in random positions within a unit sphere
  61569. * @param nb (positive integer) the number of particles to be created from this model
  61570. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61571. * @returns the number of groups in the system
  61572. */
  61573. addPoints(nb: number, pointFunction?: any): number;
  61574. /**
  61575. * Adds points to the PCS from the surface of the model shape
  61576. * @param mesh is any Mesh object that will be used as a surface model for the points
  61577. * @param nb (positive integer) the number of particles to be created from this model
  61578. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61579. * @param color (color3) to be used when colorWith is stated
  61580. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61581. * @returns the number of groups in the system
  61582. */
  61583. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61584. /**
  61585. * Adds points to the PCS inside the model shape
  61586. * @param mesh is any Mesh object that will be used as a surface model for the points
  61587. * @param nb (positive integer) the number of particles to be created from this model
  61588. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  61589. * @param color (color4) to be used when colorWith is stated
  61590. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61591. * @returns the number of groups in the system
  61592. */
  61593. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61594. /**
  61595. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61596. * This method calls `updateParticle()` for each particle of the SPS.
  61597. * For an animated SPS, it is usually called within the render loop.
  61598. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61599. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61600. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61601. * @returns the PCS.
  61602. */
  61603. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61604. /**
  61605. * Disposes the PCS.
  61606. */
  61607. dispose(): void;
  61608. /**
  61609. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61610. * doc :
  61611. * @returns the PCS.
  61612. */
  61613. refreshVisibleSize(): PointsCloudSystem;
  61614. /**
  61615. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61616. * @param size the size (float) of the visibility box
  61617. * note : this doesn't lock the PCS mesh bounding box.
  61618. * doc :
  61619. */
  61620. setVisibilityBox(size: number): void;
  61621. /**
  61622. * Gets whether the PCS is always visible or not
  61623. * doc :
  61624. */
  61625. /**
  61626. * Sets the PCS as always visible or not
  61627. * doc :
  61628. */
  61629. isAlwaysVisible: boolean;
  61630. /**
  61631. * Tells to `setParticles()` to compute the particle rotations or not
  61632. * Default value : false. The PCS is faster when it's set to false
  61633. * Note : particle rotations are only applied to parent particles
  61634. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61635. */
  61636. computeParticleRotation: boolean;
  61637. /**
  61638. * Tells to `setParticles()` to compute the particle colors or not.
  61639. * Default value : true. The PCS is faster when it's set to false.
  61640. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61641. */
  61642. /**
  61643. * Gets if `setParticles()` computes the particle colors or not.
  61644. * Default value : false. The PCS is faster when it's set to false.
  61645. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61646. */
  61647. computeParticleColor: boolean;
  61648. /**
  61649. * Gets if `setParticles()` computes the particle textures or not.
  61650. * Default value : false. The PCS is faster when it's set to false.
  61651. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61652. */
  61653. computeParticleTexture: boolean;
  61654. /**
  61655. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61656. */
  61657. /**
  61658. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61659. */
  61660. computeBoundingBox: boolean;
  61661. /**
  61662. * This function does nothing. It may be overwritten to set all the particle first values.
  61663. * The PCS doesn't call this function, you may have to call it by your own.
  61664. * doc :
  61665. */
  61666. initParticles(): void;
  61667. /**
  61668. * This function does nothing. It may be overwritten to recycle a particle
  61669. * The PCS doesn't call this function, you can to call it
  61670. * doc :
  61671. * @param particle The particle to recycle
  61672. * @returns the recycled particle
  61673. */
  61674. recycleParticle(particle: CloudPoint): CloudPoint;
  61675. /**
  61676. * Updates a particle : this function should be overwritten by the user.
  61677. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61678. * doc :
  61679. * @example : just set a particle position or velocity and recycle conditions
  61680. * @param particle The particle to update
  61681. * @returns the updated particle
  61682. */
  61683. updateParticle(particle: CloudPoint): CloudPoint;
  61684. /**
  61685. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61686. * This does nothing and may be overwritten by the user.
  61687. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61688. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61689. * @param update the boolean update value actually passed to setParticles()
  61690. */
  61691. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61692. /**
  61693. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61694. * This will be passed three parameters.
  61695. * This does nothing and may be overwritten by the user.
  61696. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61697. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61698. * @param update the boolean update value actually passed to setParticles()
  61699. */
  61700. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61701. }
  61702. }
  61703. declare module "babylonjs/Particles/cloudPoint" {
  61704. import { Nullable } from "babylonjs/types";
  61705. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  61706. import { Mesh } from "babylonjs/Meshes/mesh";
  61707. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61708. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  61709. /**
  61710. * Represents one particle of a points cloud system.
  61711. */
  61712. export class CloudPoint {
  61713. /**
  61714. * particle global index
  61715. */
  61716. idx: number;
  61717. /**
  61718. * The color of the particle
  61719. */
  61720. color: Nullable<Color4>;
  61721. /**
  61722. * The world space position of the particle.
  61723. */
  61724. position: Vector3;
  61725. /**
  61726. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61727. */
  61728. rotation: Vector3;
  61729. /**
  61730. * The world space rotation quaternion of the particle.
  61731. */
  61732. rotationQuaternion: Nullable<Quaternion>;
  61733. /**
  61734. * The uv of the particle.
  61735. */
  61736. uv: Nullable<Vector2>;
  61737. /**
  61738. * The current speed of the particle.
  61739. */
  61740. velocity: Vector3;
  61741. /**
  61742. * The pivot point in the particle local space.
  61743. */
  61744. pivot: Vector3;
  61745. /**
  61746. * Must the particle be translated from its pivot point in its local space ?
  61747. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61748. * Default : false
  61749. */
  61750. translateFromPivot: boolean;
  61751. /**
  61752. * Index of this particle in the global "positions" array (Internal use)
  61753. * @hidden
  61754. */
  61755. _pos: number;
  61756. /**
  61757. * @hidden Index of this particle in the global "indices" array (Internal use)
  61758. */
  61759. _ind: number;
  61760. /**
  61761. * Group this particle belongs to
  61762. */
  61763. _group: PointsGroup;
  61764. /**
  61765. * Group id of this particle
  61766. */
  61767. groupId: number;
  61768. /**
  61769. * Index of the particle in its group id (Internal use)
  61770. */
  61771. idxInGroup: number;
  61772. /**
  61773. * @hidden Particle BoundingInfo object (Internal use)
  61774. */
  61775. _boundingInfo: BoundingInfo;
  61776. /**
  61777. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61778. */
  61779. _pcs: PointsCloudSystem;
  61780. /**
  61781. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61782. */
  61783. _stillInvisible: boolean;
  61784. /**
  61785. * @hidden Last computed particle rotation matrix
  61786. */
  61787. _rotationMatrix: number[];
  61788. /**
  61789. * Parent particle Id, if any.
  61790. * Default null.
  61791. */
  61792. parentId: Nullable<number>;
  61793. /**
  61794. * @hidden Internal global position in the PCS.
  61795. */
  61796. _globalPosition: Vector3;
  61797. /**
  61798. * Creates a Point Cloud object.
  61799. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61800. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61801. * @param group (PointsGroup) is the group the particle belongs to
  61802. * @param groupId (integer) is the group identifier in the PCS.
  61803. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61804. * @param pcs defines the PCS it is associated to
  61805. */
  61806. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61807. /**
  61808. * get point size
  61809. */
  61810. /**
  61811. * Set point size
  61812. */
  61813. size: Vector3;
  61814. /**
  61815. * Legacy support, changed quaternion to rotationQuaternion
  61816. */
  61817. /**
  61818. * Legacy support, changed quaternion to rotationQuaternion
  61819. */
  61820. quaternion: Nullable<Quaternion>;
  61821. /**
  61822. * Returns a boolean. True if the particle intersects a mesh, else false
  61823. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  61824. * @param target is the object (point or mesh) what the intersection is computed against
  61825. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  61826. * @returns true if it intersects
  61827. */
  61828. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  61829. /**
  61830. * get the rotation matrix of the particle
  61831. * @hidden
  61832. */
  61833. getRotationMatrix(m: Matrix): void;
  61834. }
  61835. /**
  61836. * Represents a group of points in a points cloud system
  61837. * * PCS internal tool, don't use it manually.
  61838. */
  61839. export class PointsGroup {
  61840. /**
  61841. * The group id
  61842. * @hidden
  61843. */
  61844. groupID: number;
  61845. /**
  61846. * image data for group (internal use)
  61847. * @hidden
  61848. */
  61849. _groupImageData: Nullable<ArrayBufferView>;
  61850. /**
  61851. * Image Width (internal use)
  61852. * @hidden
  61853. */
  61854. _groupImgWidth: number;
  61855. /**
  61856. * Image Height (internal use)
  61857. * @hidden
  61858. */
  61859. _groupImgHeight: number;
  61860. /**
  61861. * Custom position function (internal use)
  61862. * @hidden
  61863. */
  61864. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61865. /**
  61866. * density per facet for surface points
  61867. * @hidden
  61868. */
  61869. _groupDensity: number[];
  61870. /**
  61871. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61872. * PCS internal tool, don't use it manually.
  61873. * @hidden
  61874. */
  61875. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61876. }
  61877. }
  61878. declare module "babylonjs/Particles/index" {
  61879. export * from "babylonjs/Particles/baseParticleSystem";
  61880. export * from "babylonjs/Particles/EmitterTypes/index";
  61881. export * from "babylonjs/Particles/gpuParticleSystem";
  61882. export * from "babylonjs/Particles/IParticleSystem";
  61883. export * from "babylonjs/Particles/particle";
  61884. export * from "babylonjs/Particles/particleHelper";
  61885. export * from "babylonjs/Particles/particleSystem";
  61886. export * from "babylonjs/Particles/particleSystemComponent";
  61887. export * from "babylonjs/Particles/particleSystemSet";
  61888. export * from "babylonjs/Particles/solidParticle";
  61889. export * from "babylonjs/Particles/solidParticleSystem";
  61890. export * from "babylonjs/Particles/cloudPoint";
  61891. export * from "babylonjs/Particles/pointsCloudSystem";
  61892. export * from "babylonjs/Particles/subEmitter";
  61893. }
  61894. declare module "babylonjs/Physics/physicsEngineComponent" {
  61895. import { Nullable } from "babylonjs/types";
  61896. import { Observable, Observer } from "babylonjs/Misc/observable";
  61897. import { Vector3 } from "babylonjs/Maths/math.vector";
  61898. import { Mesh } from "babylonjs/Meshes/mesh";
  61899. import { ISceneComponent } from "babylonjs/sceneComponent";
  61900. import { Scene } from "babylonjs/scene";
  61901. import { Node } from "babylonjs/node";
  61902. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61903. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61904. module "babylonjs/scene" {
  61905. interface Scene {
  61906. /** @hidden (Backing field) */
  61907. _physicsEngine: Nullable<IPhysicsEngine>;
  61908. /**
  61909. * Gets the current physics engine
  61910. * @returns a IPhysicsEngine or null if none attached
  61911. */
  61912. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61913. /**
  61914. * Enables physics to the current scene
  61915. * @param gravity defines the scene's gravity for the physics engine
  61916. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61917. * @return a boolean indicating if the physics engine was initialized
  61918. */
  61919. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61920. /**
  61921. * Disables and disposes the physics engine associated with the scene
  61922. */
  61923. disablePhysicsEngine(): void;
  61924. /**
  61925. * Gets a boolean indicating if there is an active physics engine
  61926. * @returns a boolean indicating if there is an active physics engine
  61927. */
  61928. isPhysicsEnabled(): boolean;
  61929. /**
  61930. * Deletes a physics compound impostor
  61931. * @param compound defines the compound to delete
  61932. */
  61933. deleteCompoundImpostor(compound: any): void;
  61934. /**
  61935. * An event triggered when physic simulation is about to be run
  61936. */
  61937. onBeforePhysicsObservable: Observable<Scene>;
  61938. /**
  61939. * An event triggered when physic simulation has been done
  61940. */
  61941. onAfterPhysicsObservable: Observable<Scene>;
  61942. }
  61943. }
  61944. module "babylonjs/Meshes/abstractMesh" {
  61945. interface AbstractMesh {
  61946. /** @hidden */
  61947. _physicsImpostor: Nullable<PhysicsImpostor>;
  61948. /**
  61949. * Gets or sets impostor used for physic simulation
  61950. * @see http://doc.babylonjs.com/features/physics_engine
  61951. */
  61952. physicsImpostor: Nullable<PhysicsImpostor>;
  61953. /**
  61954. * Gets the current physics impostor
  61955. * @see http://doc.babylonjs.com/features/physics_engine
  61956. * @returns a physics impostor or null
  61957. */
  61958. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61959. /** Apply a physic impulse to the mesh
  61960. * @param force defines the force to apply
  61961. * @param contactPoint defines where to apply the force
  61962. * @returns the current mesh
  61963. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61964. */
  61965. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61966. /**
  61967. * Creates a physic joint between two meshes
  61968. * @param otherMesh defines the other mesh to use
  61969. * @param pivot1 defines the pivot to use on this mesh
  61970. * @param pivot2 defines the pivot to use on the other mesh
  61971. * @param options defines additional options (can be plugin dependent)
  61972. * @returns the current mesh
  61973. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61974. */
  61975. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61976. /** @hidden */
  61977. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61978. }
  61979. }
  61980. /**
  61981. * Defines the physics engine scene component responsible to manage a physics engine
  61982. */
  61983. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61984. /**
  61985. * The component name helpful to identify the component in the list of scene components.
  61986. */
  61987. readonly name: string;
  61988. /**
  61989. * The scene the component belongs to.
  61990. */
  61991. scene: Scene;
  61992. /**
  61993. * Creates a new instance of the component for the given scene
  61994. * @param scene Defines the scene to register the component in
  61995. */
  61996. constructor(scene: Scene);
  61997. /**
  61998. * Registers the component in a given scene
  61999. */
  62000. register(): void;
  62001. /**
  62002. * Rebuilds the elements related to this component in case of
  62003. * context lost for instance.
  62004. */
  62005. rebuild(): void;
  62006. /**
  62007. * Disposes the component and the associated ressources
  62008. */
  62009. dispose(): void;
  62010. }
  62011. }
  62012. declare module "babylonjs/Physics/physicsHelper" {
  62013. import { Nullable } from "babylonjs/types";
  62014. import { Vector3 } from "babylonjs/Maths/math.vector";
  62015. import { Mesh } from "babylonjs/Meshes/mesh";
  62016. import { Scene } from "babylonjs/scene";
  62017. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62018. /**
  62019. * A helper for physics simulations
  62020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62021. */
  62022. export class PhysicsHelper {
  62023. private _scene;
  62024. private _physicsEngine;
  62025. /**
  62026. * Initializes the Physics helper
  62027. * @param scene Babylon.js scene
  62028. */
  62029. constructor(scene: Scene);
  62030. /**
  62031. * Applies a radial explosion impulse
  62032. * @param origin the origin of the explosion
  62033. * @param radiusOrEventOptions the radius or the options of radial explosion
  62034. * @param strength the explosion strength
  62035. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62036. * @returns A physics radial explosion event, or null
  62037. */
  62038. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62039. /**
  62040. * Applies a radial explosion force
  62041. * @param origin the origin of the explosion
  62042. * @param radiusOrEventOptions the radius or the options of radial explosion
  62043. * @param strength the explosion strength
  62044. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62045. * @returns A physics radial explosion event, or null
  62046. */
  62047. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62048. /**
  62049. * Creates a gravitational field
  62050. * @param origin the origin of the explosion
  62051. * @param radiusOrEventOptions the radius or the options of radial explosion
  62052. * @param strength the explosion strength
  62053. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62054. * @returns A physics gravitational field event, or null
  62055. */
  62056. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62057. /**
  62058. * Creates a physics updraft event
  62059. * @param origin the origin of the updraft
  62060. * @param radiusOrEventOptions the radius or the options of the updraft
  62061. * @param strength the strength of the updraft
  62062. * @param height the height of the updraft
  62063. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62064. * @returns A physics updraft event, or null
  62065. */
  62066. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62067. /**
  62068. * Creates a physics vortex event
  62069. * @param origin the of the vortex
  62070. * @param radiusOrEventOptions the radius or the options of the vortex
  62071. * @param strength the strength of the vortex
  62072. * @param height the height of the vortex
  62073. * @returns a Physics vortex event, or null
  62074. * A physics vortex event or null
  62075. */
  62076. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62077. }
  62078. /**
  62079. * Represents a physics radial explosion event
  62080. */
  62081. class PhysicsRadialExplosionEvent {
  62082. private _scene;
  62083. private _options;
  62084. private _sphere;
  62085. private _dataFetched;
  62086. /**
  62087. * Initializes a radial explosioin event
  62088. * @param _scene BabylonJS scene
  62089. * @param _options The options for the vortex event
  62090. */
  62091. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62092. /**
  62093. * Returns the data related to the radial explosion event (sphere).
  62094. * @returns The radial explosion event data
  62095. */
  62096. getData(): PhysicsRadialExplosionEventData;
  62097. /**
  62098. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62099. * @param impostor A physics imposter
  62100. * @param origin the origin of the explosion
  62101. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62102. */
  62103. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62104. /**
  62105. * Triggers affecterd impostors callbacks
  62106. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62107. */
  62108. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62109. /**
  62110. * Disposes the sphere.
  62111. * @param force Specifies if the sphere should be disposed by force
  62112. */
  62113. dispose(force?: boolean): void;
  62114. /*** Helpers ***/
  62115. private _prepareSphere;
  62116. private _intersectsWithSphere;
  62117. }
  62118. /**
  62119. * Represents a gravitational field event
  62120. */
  62121. class PhysicsGravitationalFieldEvent {
  62122. private _physicsHelper;
  62123. private _scene;
  62124. private _origin;
  62125. private _options;
  62126. private _tickCallback;
  62127. private _sphere;
  62128. private _dataFetched;
  62129. /**
  62130. * Initializes the physics gravitational field event
  62131. * @param _physicsHelper A physics helper
  62132. * @param _scene BabylonJS scene
  62133. * @param _origin The origin position of the gravitational field event
  62134. * @param _options The options for the vortex event
  62135. */
  62136. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62137. /**
  62138. * Returns the data related to the gravitational field event (sphere).
  62139. * @returns A gravitational field event
  62140. */
  62141. getData(): PhysicsGravitationalFieldEventData;
  62142. /**
  62143. * Enables the gravitational field.
  62144. */
  62145. enable(): void;
  62146. /**
  62147. * Disables the gravitational field.
  62148. */
  62149. disable(): void;
  62150. /**
  62151. * Disposes the sphere.
  62152. * @param force The force to dispose from the gravitational field event
  62153. */
  62154. dispose(force?: boolean): void;
  62155. private _tick;
  62156. }
  62157. /**
  62158. * Represents a physics updraft event
  62159. */
  62160. class PhysicsUpdraftEvent {
  62161. private _scene;
  62162. private _origin;
  62163. private _options;
  62164. private _physicsEngine;
  62165. private _originTop;
  62166. private _originDirection;
  62167. private _tickCallback;
  62168. private _cylinder;
  62169. private _cylinderPosition;
  62170. private _dataFetched;
  62171. /**
  62172. * Initializes the physics updraft event
  62173. * @param _scene BabylonJS scene
  62174. * @param _origin The origin position of the updraft
  62175. * @param _options The options for the updraft event
  62176. */
  62177. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62178. /**
  62179. * Returns the data related to the updraft event (cylinder).
  62180. * @returns A physics updraft event
  62181. */
  62182. getData(): PhysicsUpdraftEventData;
  62183. /**
  62184. * Enables the updraft.
  62185. */
  62186. enable(): void;
  62187. /**
  62188. * Disables the updraft.
  62189. */
  62190. disable(): void;
  62191. /**
  62192. * Disposes the cylinder.
  62193. * @param force Specifies if the updraft should be disposed by force
  62194. */
  62195. dispose(force?: boolean): void;
  62196. private getImpostorHitData;
  62197. private _tick;
  62198. /*** Helpers ***/
  62199. private _prepareCylinder;
  62200. private _intersectsWithCylinder;
  62201. }
  62202. /**
  62203. * Represents a physics vortex event
  62204. */
  62205. class PhysicsVortexEvent {
  62206. private _scene;
  62207. private _origin;
  62208. private _options;
  62209. private _physicsEngine;
  62210. private _originTop;
  62211. private _tickCallback;
  62212. private _cylinder;
  62213. private _cylinderPosition;
  62214. private _dataFetched;
  62215. /**
  62216. * Initializes the physics vortex event
  62217. * @param _scene The BabylonJS scene
  62218. * @param _origin The origin position of the vortex
  62219. * @param _options The options for the vortex event
  62220. */
  62221. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62222. /**
  62223. * Returns the data related to the vortex event (cylinder).
  62224. * @returns The physics vortex event data
  62225. */
  62226. getData(): PhysicsVortexEventData;
  62227. /**
  62228. * Enables the vortex.
  62229. */
  62230. enable(): void;
  62231. /**
  62232. * Disables the cortex.
  62233. */
  62234. disable(): void;
  62235. /**
  62236. * Disposes the sphere.
  62237. * @param force
  62238. */
  62239. dispose(force?: boolean): void;
  62240. private getImpostorHitData;
  62241. private _tick;
  62242. /*** Helpers ***/
  62243. private _prepareCylinder;
  62244. private _intersectsWithCylinder;
  62245. }
  62246. /**
  62247. * Options fot the radial explosion event
  62248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62249. */
  62250. export class PhysicsRadialExplosionEventOptions {
  62251. /**
  62252. * The radius of the sphere for the radial explosion.
  62253. */
  62254. radius: number;
  62255. /**
  62256. * The strenth of the explosion.
  62257. */
  62258. strength: number;
  62259. /**
  62260. * The strenght of the force in correspondence to the distance of the affected object
  62261. */
  62262. falloff: PhysicsRadialImpulseFalloff;
  62263. /**
  62264. * Sphere options for the radial explosion.
  62265. */
  62266. sphere: {
  62267. segments: number;
  62268. diameter: number;
  62269. };
  62270. /**
  62271. * Sphere options for the radial explosion.
  62272. */
  62273. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62274. }
  62275. /**
  62276. * Options fot the updraft event
  62277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62278. */
  62279. export class PhysicsUpdraftEventOptions {
  62280. /**
  62281. * The radius of the cylinder for the vortex
  62282. */
  62283. radius: number;
  62284. /**
  62285. * The strenth of the updraft.
  62286. */
  62287. strength: number;
  62288. /**
  62289. * The height of the cylinder for the updraft.
  62290. */
  62291. height: number;
  62292. /**
  62293. * The mode for the the updraft.
  62294. */
  62295. updraftMode: PhysicsUpdraftMode;
  62296. }
  62297. /**
  62298. * Options fot the vortex event
  62299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62300. */
  62301. export class PhysicsVortexEventOptions {
  62302. /**
  62303. * The radius of the cylinder for the vortex
  62304. */
  62305. radius: number;
  62306. /**
  62307. * The strenth of the vortex.
  62308. */
  62309. strength: number;
  62310. /**
  62311. * The height of the cylinder for the vortex.
  62312. */
  62313. height: number;
  62314. /**
  62315. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62316. */
  62317. centripetalForceThreshold: number;
  62318. /**
  62319. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62320. */
  62321. centripetalForceMultiplier: number;
  62322. /**
  62323. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62324. */
  62325. centrifugalForceMultiplier: number;
  62326. /**
  62327. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62328. */
  62329. updraftForceMultiplier: number;
  62330. }
  62331. /**
  62332. * The strenght of the force in correspondence to the distance of the affected object
  62333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62334. */
  62335. export enum PhysicsRadialImpulseFalloff {
  62336. /** Defines that impulse is constant in strength across it's whole radius */
  62337. Constant = 0,
  62338. /** Defines that impulse gets weaker if it's further from the origin */
  62339. Linear = 1
  62340. }
  62341. /**
  62342. * The strength of the force in correspondence to the distance of the affected object
  62343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62344. */
  62345. export enum PhysicsUpdraftMode {
  62346. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62347. Center = 0,
  62348. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62349. Perpendicular = 1
  62350. }
  62351. /**
  62352. * Interface for a physics hit data
  62353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62354. */
  62355. export interface PhysicsHitData {
  62356. /**
  62357. * The force applied at the contact point
  62358. */
  62359. force: Vector3;
  62360. /**
  62361. * The contact point
  62362. */
  62363. contactPoint: Vector3;
  62364. /**
  62365. * The distance from the origin to the contact point
  62366. */
  62367. distanceFromOrigin: number;
  62368. }
  62369. /**
  62370. * Interface for radial explosion event data
  62371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62372. */
  62373. export interface PhysicsRadialExplosionEventData {
  62374. /**
  62375. * A sphere used for the radial explosion event
  62376. */
  62377. sphere: Mesh;
  62378. }
  62379. /**
  62380. * Interface for gravitational field event data
  62381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62382. */
  62383. export interface PhysicsGravitationalFieldEventData {
  62384. /**
  62385. * A sphere mesh used for the gravitational field event
  62386. */
  62387. sphere: Mesh;
  62388. }
  62389. /**
  62390. * Interface for updraft event data
  62391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62392. */
  62393. export interface PhysicsUpdraftEventData {
  62394. /**
  62395. * A cylinder used for the updraft event
  62396. */
  62397. cylinder: Mesh;
  62398. }
  62399. /**
  62400. * Interface for vortex event data
  62401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62402. */
  62403. export interface PhysicsVortexEventData {
  62404. /**
  62405. * A cylinder used for the vortex event
  62406. */
  62407. cylinder: Mesh;
  62408. }
  62409. /**
  62410. * Interface for an affected physics impostor
  62411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62412. */
  62413. export interface PhysicsAffectedImpostorWithData {
  62414. /**
  62415. * The impostor affected by the effect
  62416. */
  62417. impostor: PhysicsImpostor;
  62418. /**
  62419. * The data about the hit/horce from the explosion
  62420. */
  62421. hitData: PhysicsHitData;
  62422. }
  62423. }
  62424. declare module "babylonjs/Physics/Plugins/index" {
  62425. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62426. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62427. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  62428. }
  62429. declare module "babylonjs/Physics/index" {
  62430. export * from "babylonjs/Physics/IPhysicsEngine";
  62431. export * from "babylonjs/Physics/physicsEngine";
  62432. export * from "babylonjs/Physics/physicsEngineComponent";
  62433. export * from "babylonjs/Physics/physicsHelper";
  62434. export * from "babylonjs/Physics/physicsImpostor";
  62435. export * from "babylonjs/Physics/physicsJoint";
  62436. export * from "babylonjs/Physics/Plugins/index";
  62437. }
  62438. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  62439. /** @hidden */
  62440. export var blackAndWhitePixelShader: {
  62441. name: string;
  62442. shader: string;
  62443. };
  62444. }
  62445. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  62446. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62447. import { Camera } from "babylonjs/Cameras/camera";
  62448. import { Engine } from "babylonjs/Engines/engine";
  62449. import "babylonjs/Shaders/blackAndWhite.fragment";
  62450. /**
  62451. * Post process used to render in black and white
  62452. */
  62453. export class BlackAndWhitePostProcess extends PostProcess {
  62454. /**
  62455. * Linear about to convert he result to black and white (default: 1)
  62456. */
  62457. degree: number;
  62458. /**
  62459. * Creates a black and white post process
  62460. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62461. * @param name The name of the effect.
  62462. * @param options The required width/height ratio to downsize to before computing the render pass.
  62463. * @param camera The camera to apply the render pass to.
  62464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62465. * @param engine The engine which the post process will be applied. (default: current engine)
  62466. * @param reusable If the post process can be reused on the same frame. (default: false)
  62467. */
  62468. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62469. }
  62470. }
  62471. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  62472. import { Nullable } from "babylonjs/types";
  62473. import { Camera } from "babylonjs/Cameras/camera";
  62474. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62475. import { Engine } from "babylonjs/Engines/engine";
  62476. /**
  62477. * This represents a set of one or more post processes in Babylon.
  62478. * A post process can be used to apply a shader to a texture after it is rendered.
  62479. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62480. */
  62481. export class PostProcessRenderEffect {
  62482. private _postProcesses;
  62483. private _getPostProcesses;
  62484. private _singleInstance;
  62485. private _cameras;
  62486. private _indicesForCamera;
  62487. /**
  62488. * Name of the effect
  62489. * @hidden
  62490. */
  62491. _name: string;
  62492. /**
  62493. * Instantiates a post process render effect.
  62494. * A post process can be used to apply a shader to a texture after it is rendered.
  62495. * @param engine The engine the effect is tied to
  62496. * @param name The name of the effect
  62497. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62498. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62499. */
  62500. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62501. /**
  62502. * Checks if all the post processes in the effect are supported.
  62503. */
  62504. readonly isSupported: boolean;
  62505. /**
  62506. * Updates the current state of the effect
  62507. * @hidden
  62508. */
  62509. _update(): void;
  62510. /**
  62511. * Attaches the effect on cameras
  62512. * @param cameras The camera to attach to.
  62513. * @hidden
  62514. */
  62515. _attachCameras(cameras: Camera): void;
  62516. /**
  62517. * Attaches the effect on cameras
  62518. * @param cameras The camera to attach to.
  62519. * @hidden
  62520. */
  62521. _attachCameras(cameras: Camera[]): void;
  62522. /**
  62523. * Detaches the effect on cameras
  62524. * @param cameras The camera to detatch from.
  62525. * @hidden
  62526. */
  62527. _detachCameras(cameras: Camera): void;
  62528. /**
  62529. * Detatches the effect on cameras
  62530. * @param cameras The camera to detatch from.
  62531. * @hidden
  62532. */
  62533. _detachCameras(cameras: Camera[]): void;
  62534. /**
  62535. * Enables the effect on given cameras
  62536. * @param cameras The camera to enable.
  62537. * @hidden
  62538. */
  62539. _enable(cameras: Camera): void;
  62540. /**
  62541. * Enables the effect on given cameras
  62542. * @param cameras The camera to enable.
  62543. * @hidden
  62544. */
  62545. _enable(cameras: Nullable<Camera[]>): void;
  62546. /**
  62547. * Disables the effect on the given cameras
  62548. * @param cameras The camera to disable.
  62549. * @hidden
  62550. */
  62551. _disable(cameras: Camera): void;
  62552. /**
  62553. * Disables the effect on the given cameras
  62554. * @param cameras The camera to disable.
  62555. * @hidden
  62556. */
  62557. _disable(cameras: Nullable<Camera[]>): void;
  62558. /**
  62559. * Gets a list of the post processes contained in the effect.
  62560. * @param camera The camera to get the post processes on.
  62561. * @returns The list of the post processes in the effect.
  62562. */
  62563. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62564. }
  62565. }
  62566. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  62567. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62568. /** @hidden */
  62569. export var extractHighlightsPixelShader: {
  62570. name: string;
  62571. shader: string;
  62572. };
  62573. }
  62574. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  62575. import { Nullable } from "babylonjs/types";
  62576. import { Camera } from "babylonjs/Cameras/camera";
  62577. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62578. import { Engine } from "babylonjs/Engines/engine";
  62579. import "babylonjs/Shaders/extractHighlights.fragment";
  62580. /**
  62581. * 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.
  62582. */
  62583. export class ExtractHighlightsPostProcess extends PostProcess {
  62584. /**
  62585. * The luminance threshold, pixels below this value will be set to black.
  62586. */
  62587. threshold: number;
  62588. /** @hidden */
  62589. _exposure: number;
  62590. /**
  62591. * Post process which has the input texture to be used when performing highlight extraction
  62592. * @hidden
  62593. */
  62594. _inputPostProcess: Nullable<PostProcess>;
  62595. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62596. }
  62597. }
  62598. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62599. /** @hidden */
  62600. export var bloomMergePixelShader: {
  62601. name: string;
  62602. shader: string;
  62603. };
  62604. }
  62605. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62606. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62607. import { Nullable } from "babylonjs/types";
  62608. import { Engine } from "babylonjs/Engines/engine";
  62609. import { Camera } from "babylonjs/Cameras/camera";
  62610. import "babylonjs/Shaders/bloomMerge.fragment";
  62611. /**
  62612. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62613. */
  62614. export class BloomMergePostProcess extends PostProcess {
  62615. /** Weight of the bloom to be added to the original input. */
  62616. weight: number;
  62617. /**
  62618. * Creates a new instance of @see BloomMergePostProcess
  62619. * @param name The name of the effect.
  62620. * @param originalFromInput Post process which's input will be used for the merge.
  62621. * @param blurred Blurred highlights post process which's output will be used.
  62622. * @param weight Weight of the bloom to be added to the original input.
  62623. * @param options The required width/height ratio to downsize to before computing the render pass.
  62624. * @param camera The camera to apply the render pass to.
  62625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62626. * @param engine The engine which the post process will be applied. (default: current engine)
  62627. * @param reusable If the post process can be reused on the same frame. (default: false)
  62628. * @param textureType Type of textures used when performing the post process. (default: 0)
  62629. * @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)
  62630. */
  62631. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62632. /** Weight of the bloom to be added to the original input. */
  62633. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62634. }
  62635. }
  62636. declare module "babylonjs/PostProcesses/bloomEffect" {
  62637. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62638. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62639. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62640. import { Camera } from "babylonjs/Cameras/camera";
  62641. import { Scene } from "babylonjs/scene";
  62642. /**
  62643. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62644. */
  62645. export class BloomEffect extends PostProcessRenderEffect {
  62646. private bloomScale;
  62647. /**
  62648. * @hidden Internal
  62649. */
  62650. _effects: Array<PostProcess>;
  62651. /**
  62652. * @hidden Internal
  62653. */
  62654. _downscale: ExtractHighlightsPostProcess;
  62655. private _blurX;
  62656. private _blurY;
  62657. private _merge;
  62658. /**
  62659. * The luminance threshold to find bright areas of the image to bloom.
  62660. */
  62661. threshold: number;
  62662. /**
  62663. * The strength of the bloom.
  62664. */
  62665. weight: number;
  62666. /**
  62667. * Specifies the size of the bloom blur kernel, relative to the final output size
  62668. */
  62669. kernel: number;
  62670. /**
  62671. * Creates a new instance of @see BloomEffect
  62672. * @param scene The scene the effect belongs to.
  62673. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62674. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62675. * @param bloomWeight The the strength of bloom.
  62676. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62677. * @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)
  62678. */
  62679. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62680. /**
  62681. * Disposes each of the internal effects for a given camera.
  62682. * @param camera The camera to dispose the effect on.
  62683. */
  62684. disposeEffects(camera: Camera): void;
  62685. /**
  62686. * @hidden Internal
  62687. */
  62688. _updateEffects(): void;
  62689. /**
  62690. * Internal
  62691. * @returns if all the contained post processes are ready.
  62692. * @hidden
  62693. */
  62694. _isReady(): boolean;
  62695. }
  62696. }
  62697. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62698. /** @hidden */
  62699. export var chromaticAberrationPixelShader: {
  62700. name: string;
  62701. shader: string;
  62702. };
  62703. }
  62704. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62705. import { Vector2 } from "babylonjs/Maths/math.vector";
  62706. import { Nullable } from "babylonjs/types";
  62707. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62708. import { Camera } from "babylonjs/Cameras/camera";
  62709. import { Engine } from "babylonjs/Engines/engine";
  62710. import "babylonjs/Shaders/chromaticAberration.fragment";
  62711. /**
  62712. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62713. */
  62714. export class ChromaticAberrationPostProcess extends PostProcess {
  62715. /**
  62716. * The amount of seperation of rgb channels (default: 30)
  62717. */
  62718. aberrationAmount: number;
  62719. /**
  62720. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62721. */
  62722. radialIntensity: number;
  62723. /**
  62724. * 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))
  62725. */
  62726. direction: Vector2;
  62727. /**
  62728. * 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))
  62729. */
  62730. centerPosition: Vector2;
  62731. /**
  62732. * Creates a new instance ChromaticAberrationPostProcess
  62733. * @param name The name of the effect.
  62734. * @param screenWidth The width of the screen to apply the effect on.
  62735. * @param screenHeight The height of the screen to apply the effect on.
  62736. * @param options The required width/height ratio to downsize to before computing the render pass.
  62737. * @param camera The camera to apply the render pass to.
  62738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62739. * @param engine The engine which the post process will be applied. (default: current engine)
  62740. * @param reusable If the post process can be reused on the same frame. (default: false)
  62741. * @param textureType Type of textures used when performing the post process. (default: 0)
  62742. * @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)
  62743. */
  62744. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62745. }
  62746. }
  62747. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62748. /** @hidden */
  62749. export var circleOfConfusionPixelShader: {
  62750. name: string;
  62751. shader: string;
  62752. };
  62753. }
  62754. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62755. import { Nullable } from "babylonjs/types";
  62756. import { Engine } from "babylonjs/Engines/engine";
  62757. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62758. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62759. import { Camera } from "babylonjs/Cameras/camera";
  62760. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62761. /**
  62762. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62763. */
  62764. export class CircleOfConfusionPostProcess extends PostProcess {
  62765. /**
  62766. * 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.
  62767. */
  62768. lensSize: number;
  62769. /**
  62770. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62771. */
  62772. fStop: number;
  62773. /**
  62774. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62775. */
  62776. focusDistance: number;
  62777. /**
  62778. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62779. */
  62780. focalLength: number;
  62781. private _depthTexture;
  62782. /**
  62783. * Creates a new instance CircleOfConfusionPostProcess
  62784. * @param name The name of the effect.
  62785. * @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.
  62786. * @param options The required width/height ratio to downsize to before computing the render pass.
  62787. * @param camera The camera to apply the render pass to.
  62788. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62789. * @param engine The engine which the post process will be applied. (default: current engine)
  62790. * @param reusable If the post process can be reused on the same frame. (default: false)
  62791. * @param textureType Type of textures used when performing the post process. (default: 0)
  62792. * @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)
  62793. */
  62794. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62795. /**
  62796. * 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.
  62797. */
  62798. depthTexture: RenderTargetTexture;
  62799. }
  62800. }
  62801. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62802. /** @hidden */
  62803. export var colorCorrectionPixelShader: {
  62804. name: string;
  62805. shader: string;
  62806. };
  62807. }
  62808. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62809. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62810. import { Engine } from "babylonjs/Engines/engine";
  62811. import { Camera } from "babylonjs/Cameras/camera";
  62812. import "babylonjs/Shaders/colorCorrection.fragment";
  62813. /**
  62814. *
  62815. * This post-process allows the modification of rendered colors by using
  62816. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62817. *
  62818. * The object needs to be provided an url to a texture containing the color
  62819. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62820. * Use an image editing software to tweak the LUT to match your needs.
  62821. *
  62822. * For an example of a color LUT, see here:
  62823. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62824. * For explanations on color grading, see here:
  62825. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62826. *
  62827. */
  62828. export class ColorCorrectionPostProcess extends PostProcess {
  62829. private _colorTableTexture;
  62830. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62831. }
  62832. }
  62833. declare module "babylonjs/Shaders/convolution.fragment" {
  62834. /** @hidden */
  62835. export var convolutionPixelShader: {
  62836. name: string;
  62837. shader: string;
  62838. };
  62839. }
  62840. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62841. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62842. import { Nullable } from "babylonjs/types";
  62843. import { Camera } from "babylonjs/Cameras/camera";
  62844. import { Engine } from "babylonjs/Engines/engine";
  62845. import "babylonjs/Shaders/convolution.fragment";
  62846. /**
  62847. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62848. * input texture to perform effects such as edge detection or sharpening
  62849. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62850. */
  62851. export class ConvolutionPostProcess extends PostProcess {
  62852. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62853. kernel: number[];
  62854. /**
  62855. * Creates a new instance ConvolutionPostProcess
  62856. * @param name The name of the effect.
  62857. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62858. * @param options The required width/height ratio to downsize to before computing the render pass.
  62859. * @param camera The camera to apply the render pass to.
  62860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62861. * @param engine The engine which the post process will be applied. (default: current engine)
  62862. * @param reusable If the post process can be reused on the same frame. (default: false)
  62863. * @param textureType Type of textures used when performing the post process. (default: 0)
  62864. */
  62865. constructor(name: string,
  62866. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62867. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62868. /**
  62869. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62870. */
  62871. static EdgeDetect0Kernel: number[];
  62872. /**
  62873. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62874. */
  62875. static EdgeDetect1Kernel: number[];
  62876. /**
  62877. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62878. */
  62879. static EdgeDetect2Kernel: number[];
  62880. /**
  62881. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62882. */
  62883. static SharpenKernel: number[];
  62884. /**
  62885. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62886. */
  62887. static EmbossKernel: number[];
  62888. /**
  62889. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62890. */
  62891. static GaussianKernel: number[];
  62892. }
  62893. }
  62894. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62895. import { Nullable } from "babylonjs/types";
  62896. import { Vector2 } from "babylonjs/Maths/math.vector";
  62897. import { Camera } from "babylonjs/Cameras/camera";
  62898. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62899. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62900. import { Engine } from "babylonjs/Engines/engine";
  62901. import { Scene } from "babylonjs/scene";
  62902. /**
  62903. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62904. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62905. * based on samples that have a large difference in distance than the center pixel.
  62906. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62907. */
  62908. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62909. direction: Vector2;
  62910. /**
  62911. * Creates a new instance CircleOfConfusionPostProcess
  62912. * @param name The name of the effect.
  62913. * @param scene The scene the effect belongs to.
  62914. * @param direction The direction the blur should be applied.
  62915. * @param kernel The size of the kernel used to blur.
  62916. * @param options The required width/height ratio to downsize to before computing the render pass.
  62917. * @param camera The camera to apply the render pass to.
  62918. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62919. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62921. * @param engine The engine which the post process will be applied. (default: current engine)
  62922. * @param reusable If the post process can be reused on the same frame. (default: false)
  62923. * @param textureType Type of textures used when performing the post process. (default: 0)
  62924. * @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)
  62925. */
  62926. 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);
  62927. }
  62928. }
  62929. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62930. /** @hidden */
  62931. export var depthOfFieldMergePixelShader: {
  62932. name: string;
  62933. shader: string;
  62934. };
  62935. }
  62936. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62937. import { Nullable } from "babylonjs/types";
  62938. import { Camera } from "babylonjs/Cameras/camera";
  62939. import { Effect } from "babylonjs/Materials/effect";
  62940. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62941. import { Engine } from "babylonjs/Engines/engine";
  62942. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62943. /**
  62944. * Options to be set when merging outputs from the default pipeline.
  62945. */
  62946. export class DepthOfFieldMergePostProcessOptions {
  62947. /**
  62948. * The original image to merge on top of
  62949. */
  62950. originalFromInput: PostProcess;
  62951. /**
  62952. * Parameters to perform the merge of the depth of field effect
  62953. */
  62954. depthOfField?: {
  62955. circleOfConfusion: PostProcess;
  62956. blurSteps: Array<PostProcess>;
  62957. };
  62958. /**
  62959. * Parameters to perform the merge of bloom effect
  62960. */
  62961. bloom?: {
  62962. blurred: PostProcess;
  62963. weight: number;
  62964. };
  62965. }
  62966. /**
  62967. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62968. */
  62969. export class DepthOfFieldMergePostProcess extends PostProcess {
  62970. private blurSteps;
  62971. /**
  62972. * Creates a new instance of DepthOfFieldMergePostProcess
  62973. * @param name The name of the effect.
  62974. * @param originalFromInput Post process which's input will be used for the merge.
  62975. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62976. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62977. * @param options The required width/height ratio to downsize to before computing the render pass.
  62978. * @param camera The camera to apply the render pass to.
  62979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62980. * @param engine The engine which the post process will be applied. (default: current engine)
  62981. * @param reusable If the post process can be reused on the same frame. (default: false)
  62982. * @param textureType Type of textures used when performing the post process. (default: 0)
  62983. * @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)
  62984. */
  62985. 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);
  62986. /**
  62987. * Updates the effect with the current post process compile time values and recompiles the shader.
  62988. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62989. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62990. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62991. * @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
  62992. * @param onCompiled Called when the shader has been compiled.
  62993. * @param onError Called if there is an error when compiling a shader.
  62994. */
  62995. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62996. }
  62997. }
  62998. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62999. import { Nullable } from "babylonjs/types";
  63000. import { Camera } from "babylonjs/Cameras/camera";
  63001. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63002. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63003. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63004. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63005. import { Scene } from "babylonjs/scene";
  63006. /**
  63007. * Specifies the level of max blur that should be applied when using the depth of field effect
  63008. */
  63009. export enum DepthOfFieldEffectBlurLevel {
  63010. /**
  63011. * Subtle blur
  63012. */
  63013. Low = 0,
  63014. /**
  63015. * Medium blur
  63016. */
  63017. Medium = 1,
  63018. /**
  63019. * Large blur
  63020. */
  63021. High = 2
  63022. }
  63023. /**
  63024. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63025. */
  63026. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63027. private _circleOfConfusion;
  63028. /**
  63029. * @hidden Internal, blurs from high to low
  63030. */
  63031. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63032. private _depthOfFieldBlurY;
  63033. private _dofMerge;
  63034. /**
  63035. * @hidden Internal post processes in depth of field effect
  63036. */
  63037. _effects: Array<PostProcess>;
  63038. /**
  63039. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63040. */
  63041. focalLength: number;
  63042. /**
  63043. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63044. */
  63045. fStop: number;
  63046. /**
  63047. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63048. */
  63049. focusDistance: number;
  63050. /**
  63051. * 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.
  63052. */
  63053. lensSize: number;
  63054. /**
  63055. * Creates a new instance DepthOfFieldEffect
  63056. * @param scene The scene the effect belongs to.
  63057. * @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.
  63058. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63059. * @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)
  63060. */
  63061. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63062. /**
  63063. * Get the current class name of the current effet
  63064. * @returns "DepthOfFieldEffect"
  63065. */
  63066. getClassName(): string;
  63067. /**
  63068. * 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.
  63069. */
  63070. depthTexture: RenderTargetTexture;
  63071. /**
  63072. * Disposes each of the internal effects for a given camera.
  63073. * @param camera The camera to dispose the effect on.
  63074. */
  63075. disposeEffects(camera: Camera): void;
  63076. /**
  63077. * @hidden Internal
  63078. */
  63079. _updateEffects(): void;
  63080. /**
  63081. * Internal
  63082. * @returns if all the contained post processes are ready.
  63083. * @hidden
  63084. */
  63085. _isReady(): boolean;
  63086. }
  63087. }
  63088. declare module "babylonjs/Shaders/displayPass.fragment" {
  63089. /** @hidden */
  63090. export var displayPassPixelShader: {
  63091. name: string;
  63092. shader: string;
  63093. };
  63094. }
  63095. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63096. import { Nullable } from "babylonjs/types";
  63097. import { Camera } from "babylonjs/Cameras/camera";
  63098. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63099. import { Engine } from "babylonjs/Engines/engine";
  63100. import "babylonjs/Shaders/displayPass.fragment";
  63101. /**
  63102. * DisplayPassPostProcess which produces an output the same as it's input
  63103. */
  63104. export class DisplayPassPostProcess extends PostProcess {
  63105. /**
  63106. * Creates the DisplayPassPostProcess
  63107. * @param name The name of the effect.
  63108. * @param options The required width/height ratio to downsize to before computing the render pass.
  63109. * @param camera The camera to apply the render pass to.
  63110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63111. * @param engine The engine which the post process will be applied. (default: current engine)
  63112. * @param reusable If the post process can be reused on the same frame. (default: false)
  63113. */
  63114. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63115. }
  63116. }
  63117. declare module "babylonjs/Shaders/filter.fragment" {
  63118. /** @hidden */
  63119. export var filterPixelShader: {
  63120. name: string;
  63121. shader: string;
  63122. };
  63123. }
  63124. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63125. import { Nullable } from "babylonjs/types";
  63126. import { Matrix } from "babylonjs/Maths/math.vector";
  63127. import { Camera } from "babylonjs/Cameras/camera";
  63128. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63129. import { Engine } from "babylonjs/Engines/engine";
  63130. import "babylonjs/Shaders/filter.fragment";
  63131. /**
  63132. * Applies a kernel filter to the image
  63133. */
  63134. export class FilterPostProcess extends PostProcess {
  63135. /** The matrix to be applied to the image */
  63136. kernelMatrix: Matrix;
  63137. /**
  63138. *
  63139. * @param name The name of the effect.
  63140. * @param kernelMatrix The matrix to be applied to the image
  63141. * @param options The required width/height ratio to downsize to before computing the render pass.
  63142. * @param camera The camera to apply the render pass to.
  63143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63144. * @param engine The engine which the post process will be applied. (default: current engine)
  63145. * @param reusable If the post process can be reused on the same frame. (default: false)
  63146. */
  63147. constructor(name: string,
  63148. /** The matrix to be applied to the image */
  63149. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63150. }
  63151. }
  63152. declare module "babylonjs/Shaders/fxaa.fragment" {
  63153. /** @hidden */
  63154. export var fxaaPixelShader: {
  63155. name: string;
  63156. shader: string;
  63157. };
  63158. }
  63159. declare module "babylonjs/Shaders/fxaa.vertex" {
  63160. /** @hidden */
  63161. export var fxaaVertexShader: {
  63162. name: string;
  63163. shader: string;
  63164. };
  63165. }
  63166. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63167. import { Nullable } from "babylonjs/types";
  63168. import { Camera } from "babylonjs/Cameras/camera";
  63169. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63170. import { Engine } from "babylonjs/Engines/engine";
  63171. import "babylonjs/Shaders/fxaa.fragment";
  63172. import "babylonjs/Shaders/fxaa.vertex";
  63173. /**
  63174. * Fxaa post process
  63175. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63176. */
  63177. export class FxaaPostProcess extends PostProcess {
  63178. /** @hidden */
  63179. texelWidth: number;
  63180. /** @hidden */
  63181. texelHeight: number;
  63182. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63183. private _getDefines;
  63184. }
  63185. }
  63186. declare module "babylonjs/Shaders/grain.fragment" {
  63187. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63188. /** @hidden */
  63189. export var grainPixelShader: {
  63190. name: string;
  63191. shader: string;
  63192. };
  63193. }
  63194. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63195. import { Nullable } from "babylonjs/types";
  63196. import { Camera } from "babylonjs/Cameras/camera";
  63197. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63198. import { Engine } from "babylonjs/Engines/engine";
  63199. import "babylonjs/Shaders/grain.fragment";
  63200. /**
  63201. * The GrainPostProcess adds noise to the image at mid luminance levels
  63202. */
  63203. export class GrainPostProcess extends PostProcess {
  63204. /**
  63205. * The intensity of the grain added (default: 30)
  63206. */
  63207. intensity: number;
  63208. /**
  63209. * If the grain should be randomized on every frame
  63210. */
  63211. animated: boolean;
  63212. /**
  63213. * Creates a new instance of @see GrainPostProcess
  63214. * @param name The name of the effect.
  63215. * @param options The required width/height ratio to downsize to before computing the render pass.
  63216. * @param camera The camera to apply the render pass to.
  63217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63218. * @param engine The engine which the post process will be applied. (default: current engine)
  63219. * @param reusable If the post process can be reused on the same frame. (default: false)
  63220. * @param textureType Type of textures used when performing the post process. (default: 0)
  63221. * @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)
  63222. */
  63223. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63224. }
  63225. }
  63226. declare module "babylonjs/Shaders/highlights.fragment" {
  63227. /** @hidden */
  63228. export var highlightsPixelShader: {
  63229. name: string;
  63230. shader: string;
  63231. };
  63232. }
  63233. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63234. import { Nullable } from "babylonjs/types";
  63235. import { Camera } from "babylonjs/Cameras/camera";
  63236. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63237. import { Engine } from "babylonjs/Engines/engine";
  63238. import "babylonjs/Shaders/highlights.fragment";
  63239. /**
  63240. * Extracts highlights from the image
  63241. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63242. */
  63243. export class HighlightsPostProcess extends PostProcess {
  63244. /**
  63245. * Extracts highlights from the image
  63246. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63247. * @param name The name of the effect.
  63248. * @param options The required width/height ratio to downsize to before computing the render pass.
  63249. * @param camera The camera to apply the render pass to.
  63250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63251. * @param engine The engine which the post process will be applied. (default: current engine)
  63252. * @param reusable If the post process can be reused on the same frame. (default: false)
  63253. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63254. */
  63255. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63256. }
  63257. }
  63258. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63259. /** @hidden */
  63260. export var mrtFragmentDeclaration: {
  63261. name: string;
  63262. shader: string;
  63263. };
  63264. }
  63265. declare module "babylonjs/Shaders/geometry.fragment" {
  63266. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63267. /** @hidden */
  63268. export var geometryPixelShader: {
  63269. name: string;
  63270. shader: string;
  63271. };
  63272. }
  63273. declare module "babylonjs/Shaders/geometry.vertex" {
  63274. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63275. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63276. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63277. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63278. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63279. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63280. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63281. /** @hidden */
  63282. export var geometryVertexShader: {
  63283. name: string;
  63284. shader: string;
  63285. };
  63286. }
  63287. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63288. import { Matrix } from "babylonjs/Maths/math.vector";
  63289. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63290. import { Mesh } from "babylonjs/Meshes/mesh";
  63291. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63292. import { Effect } from "babylonjs/Materials/effect";
  63293. import { Scene } from "babylonjs/scene";
  63294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63295. import "babylonjs/Shaders/geometry.fragment";
  63296. import "babylonjs/Shaders/geometry.vertex";
  63297. /** @hidden */
  63298. interface ISavedTransformationMatrix {
  63299. world: Matrix;
  63300. viewProjection: Matrix;
  63301. }
  63302. /**
  63303. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63304. */
  63305. export class GeometryBufferRenderer {
  63306. /**
  63307. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63308. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63309. */
  63310. static readonly POSITION_TEXTURE_TYPE: number;
  63311. /**
  63312. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63313. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63314. */
  63315. static readonly VELOCITY_TEXTURE_TYPE: number;
  63316. /**
  63317. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63318. * in order to compute objects velocities when enableVelocity is set to "true"
  63319. * @hidden
  63320. */
  63321. _previousTransformationMatrices: {
  63322. [index: number]: ISavedTransformationMatrix;
  63323. };
  63324. /**
  63325. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63326. * in order to compute objects velocities when enableVelocity is set to "true"
  63327. * @hidden
  63328. */
  63329. _previousBonesTransformationMatrices: {
  63330. [index: number]: Float32Array;
  63331. };
  63332. /**
  63333. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63334. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63335. */
  63336. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63337. private _scene;
  63338. private _multiRenderTarget;
  63339. private _ratio;
  63340. private _enablePosition;
  63341. private _enableVelocity;
  63342. private _positionIndex;
  63343. private _velocityIndex;
  63344. protected _effect: Effect;
  63345. protected _cachedDefines: string;
  63346. /**
  63347. * Set the render list (meshes to be rendered) used in the G buffer.
  63348. */
  63349. renderList: Mesh[];
  63350. /**
  63351. * Gets wether or not G buffer are supported by the running hardware.
  63352. * This requires draw buffer supports
  63353. */
  63354. readonly isSupported: boolean;
  63355. /**
  63356. * Returns the index of the given texture type in the G-Buffer textures array
  63357. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63358. * @returns the index of the given texture type in the G-Buffer textures array
  63359. */
  63360. getTextureIndex(textureType: number): number;
  63361. /**
  63362. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63363. */
  63364. /**
  63365. * Sets whether or not objects positions are enabled for the G buffer.
  63366. */
  63367. enablePosition: boolean;
  63368. /**
  63369. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63370. */
  63371. /**
  63372. * Sets wether or not objects velocities are enabled for the G buffer.
  63373. */
  63374. enableVelocity: boolean;
  63375. /**
  63376. * Gets the scene associated with the buffer.
  63377. */
  63378. readonly scene: Scene;
  63379. /**
  63380. * Gets the ratio used by the buffer during its creation.
  63381. * How big is the buffer related to the main canvas.
  63382. */
  63383. readonly ratio: number;
  63384. /** @hidden */
  63385. static _SceneComponentInitialization: (scene: Scene) => void;
  63386. /**
  63387. * Creates a new G Buffer for the scene
  63388. * @param scene The scene the buffer belongs to
  63389. * @param ratio How big is the buffer related to the main canvas.
  63390. */
  63391. constructor(scene: Scene, ratio?: number);
  63392. /**
  63393. * Checks wether everything is ready to render a submesh to the G buffer.
  63394. * @param subMesh the submesh to check readiness for
  63395. * @param useInstances is the mesh drawn using instance or not
  63396. * @returns true if ready otherwise false
  63397. */
  63398. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63399. /**
  63400. * Gets the current underlying G Buffer.
  63401. * @returns the buffer
  63402. */
  63403. getGBuffer(): MultiRenderTarget;
  63404. /**
  63405. * Gets the number of samples used to render the buffer (anti aliasing).
  63406. */
  63407. /**
  63408. * Sets the number of samples used to render the buffer (anti aliasing).
  63409. */
  63410. samples: number;
  63411. /**
  63412. * Disposes the renderer and frees up associated resources.
  63413. */
  63414. dispose(): void;
  63415. protected _createRenderTargets(): void;
  63416. private _copyBonesTransformationMatrices;
  63417. }
  63418. }
  63419. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63420. import { Nullable } from "babylonjs/types";
  63421. import { Scene } from "babylonjs/scene";
  63422. import { ISceneComponent } from "babylonjs/sceneComponent";
  63423. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63424. module "babylonjs/scene" {
  63425. interface Scene {
  63426. /** @hidden (Backing field) */
  63427. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63428. /**
  63429. * Gets or Sets the current geometry buffer associated to the scene.
  63430. */
  63431. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63432. /**
  63433. * Enables a GeometryBufferRender and associates it with the scene
  63434. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63435. * @returns the GeometryBufferRenderer
  63436. */
  63437. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63438. /**
  63439. * Disables the GeometryBufferRender associated with the scene
  63440. */
  63441. disableGeometryBufferRenderer(): void;
  63442. }
  63443. }
  63444. /**
  63445. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63446. * in several rendering techniques.
  63447. */
  63448. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63449. /**
  63450. * The component name helpful to identify the component in the list of scene components.
  63451. */
  63452. readonly name: string;
  63453. /**
  63454. * The scene the component belongs to.
  63455. */
  63456. scene: Scene;
  63457. /**
  63458. * Creates a new instance of the component for the given scene
  63459. * @param scene Defines the scene to register the component in
  63460. */
  63461. constructor(scene: Scene);
  63462. /**
  63463. * Registers the component in a given scene
  63464. */
  63465. register(): void;
  63466. /**
  63467. * Rebuilds the elements related to this component in case of
  63468. * context lost for instance.
  63469. */
  63470. rebuild(): void;
  63471. /**
  63472. * Disposes the component and the associated ressources
  63473. */
  63474. dispose(): void;
  63475. private _gatherRenderTargets;
  63476. }
  63477. }
  63478. declare module "babylonjs/Shaders/motionBlur.fragment" {
  63479. /** @hidden */
  63480. export var motionBlurPixelShader: {
  63481. name: string;
  63482. shader: string;
  63483. };
  63484. }
  63485. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  63486. import { Nullable } from "babylonjs/types";
  63487. import { Camera } from "babylonjs/Cameras/camera";
  63488. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63489. import { Scene } from "babylonjs/scene";
  63490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63491. import "babylonjs/Animations/animatable";
  63492. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63493. import "babylonjs/Shaders/motionBlur.fragment";
  63494. import { Engine } from "babylonjs/Engines/engine";
  63495. /**
  63496. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63497. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63498. * As an example, all you have to do is to create the post-process:
  63499. * var mb = new BABYLON.MotionBlurPostProcess(
  63500. * 'mb', // The name of the effect.
  63501. * scene, // The scene containing the objects to blur according to their velocity.
  63502. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63503. * camera // The camera to apply the render pass to.
  63504. * );
  63505. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63506. */
  63507. export class MotionBlurPostProcess extends PostProcess {
  63508. /**
  63509. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63510. */
  63511. motionStrength: number;
  63512. /**
  63513. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63514. */
  63515. /**
  63516. * Sets the number of iterations to be used for motion blur quality
  63517. */
  63518. motionBlurSamples: number;
  63519. private _motionBlurSamples;
  63520. private _geometryBufferRenderer;
  63521. /**
  63522. * Creates a new instance MotionBlurPostProcess
  63523. * @param name The name of the effect.
  63524. * @param scene The scene containing the objects to blur according to their velocity.
  63525. * @param options The required width/height ratio to downsize to before computing the render pass.
  63526. * @param camera The camera to apply the render pass to.
  63527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63528. * @param engine The engine which the post process will be applied. (default: current engine)
  63529. * @param reusable If the post process can be reused on the same frame. (default: false)
  63530. * @param textureType Type of textures used when performing the post process. (default: 0)
  63531. * @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)
  63532. */
  63533. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63534. /**
  63535. * Excludes the given skinned mesh from computing bones velocities.
  63536. * 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.
  63537. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63538. */
  63539. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63540. /**
  63541. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63542. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63543. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63544. */
  63545. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63546. /**
  63547. * Disposes the post process.
  63548. * @param camera The camera to dispose the post process on.
  63549. */
  63550. dispose(camera?: Camera): void;
  63551. }
  63552. }
  63553. declare module "babylonjs/Shaders/refraction.fragment" {
  63554. /** @hidden */
  63555. export var refractionPixelShader: {
  63556. name: string;
  63557. shader: string;
  63558. };
  63559. }
  63560. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  63561. import { Color3 } from "babylonjs/Maths/math.color";
  63562. import { Camera } from "babylonjs/Cameras/camera";
  63563. import { Texture } from "babylonjs/Materials/Textures/texture";
  63564. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63565. import { Engine } from "babylonjs/Engines/engine";
  63566. import "babylonjs/Shaders/refraction.fragment";
  63567. /**
  63568. * Post process which applies a refractin texture
  63569. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63570. */
  63571. export class RefractionPostProcess extends PostProcess {
  63572. /** the base color of the refraction (used to taint the rendering) */
  63573. color: Color3;
  63574. /** simulated refraction depth */
  63575. depth: number;
  63576. /** the coefficient of the base color (0 to remove base color tainting) */
  63577. colorLevel: number;
  63578. private _refTexture;
  63579. private _ownRefractionTexture;
  63580. /**
  63581. * Gets or sets the refraction texture
  63582. * Please note that you are responsible for disposing the texture if you set it manually
  63583. */
  63584. refractionTexture: Texture;
  63585. /**
  63586. * Initializes the RefractionPostProcess
  63587. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63588. * @param name The name of the effect.
  63589. * @param refractionTextureUrl Url of the refraction texture to use
  63590. * @param color the base color of the refraction (used to taint the rendering)
  63591. * @param depth simulated refraction depth
  63592. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63593. * @param camera The camera to apply the render pass to.
  63594. * @param options The required width/height ratio to downsize to before computing the render pass.
  63595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63596. * @param engine The engine which the post process will be applied. (default: current engine)
  63597. * @param reusable If the post process can be reused on the same frame. (default: false)
  63598. */
  63599. constructor(name: string, refractionTextureUrl: string,
  63600. /** the base color of the refraction (used to taint the rendering) */
  63601. color: Color3,
  63602. /** simulated refraction depth */
  63603. depth: number,
  63604. /** the coefficient of the base color (0 to remove base color tainting) */
  63605. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63606. /**
  63607. * Disposes of the post process
  63608. * @param camera Camera to dispose post process on
  63609. */
  63610. dispose(camera: Camera): void;
  63611. }
  63612. }
  63613. declare module "babylonjs/Shaders/sharpen.fragment" {
  63614. /** @hidden */
  63615. export var sharpenPixelShader: {
  63616. name: string;
  63617. shader: string;
  63618. };
  63619. }
  63620. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63621. import { Nullable } from "babylonjs/types";
  63622. import { Camera } from "babylonjs/Cameras/camera";
  63623. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63624. import "babylonjs/Shaders/sharpen.fragment";
  63625. import { Engine } from "babylonjs/Engines/engine";
  63626. /**
  63627. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63628. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63629. */
  63630. export class SharpenPostProcess extends PostProcess {
  63631. /**
  63632. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63633. */
  63634. colorAmount: number;
  63635. /**
  63636. * How much sharpness should be applied (default: 0.3)
  63637. */
  63638. edgeAmount: number;
  63639. /**
  63640. * Creates a new instance ConvolutionPostProcess
  63641. * @param name The name of the effect.
  63642. * @param options The required width/height ratio to downsize to before computing the render pass.
  63643. * @param camera The camera to apply the render pass to.
  63644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63645. * @param engine The engine which the post process will be applied. (default: current engine)
  63646. * @param reusable If the post process can be reused on the same frame. (default: false)
  63647. * @param textureType Type of textures used when performing the post process. (default: 0)
  63648. * @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)
  63649. */
  63650. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63651. }
  63652. }
  63653. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63654. import { Nullable } from "babylonjs/types";
  63655. import { Camera } from "babylonjs/Cameras/camera";
  63656. import { Engine } from "babylonjs/Engines/engine";
  63657. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63658. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63659. /**
  63660. * PostProcessRenderPipeline
  63661. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63662. */
  63663. export class PostProcessRenderPipeline {
  63664. private engine;
  63665. private _renderEffects;
  63666. private _renderEffectsForIsolatedPass;
  63667. /**
  63668. * List of inspectable custom properties (used by the Inspector)
  63669. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63670. */
  63671. inspectableCustomProperties: IInspectable[];
  63672. /**
  63673. * @hidden
  63674. */
  63675. protected _cameras: Camera[];
  63676. /** @hidden */
  63677. _name: string;
  63678. /**
  63679. * Gets pipeline name
  63680. */
  63681. readonly name: string;
  63682. /**
  63683. * Initializes a PostProcessRenderPipeline
  63684. * @param engine engine to add the pipeline to
  63685. * @param name name of the pipeline
  63686. */
  63687. constructor(engine: Engine, name: string);
  63688. /**
  63689. * Gets the class name
  63690. * @returns "PostProcessRenderPipeline"
  63691. */
  63692. getClassName(): string;
  63693. /**
  63694. * If all the render effects in the pipeline are supported
  63695. */
  63696. readonly isSupported: boolean;
  63697. /**
  63698. * Adds an effect to the pipeline
  63699. * @param renderEffect the effect to add
  63700. */
  63701. addEffect(renderEffect: PostProcessRenderEffect): void;
  63702. /** @hidden */
  63703. _rebuild(): void;
  63704. /** @hidden */
  63705. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63706. /** @hidden */
  63707. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63708. /** @hidden */
  63709. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63710. /** @hidden */
  63711. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63712. /** @hidden */
  63713. _attachCameras(cameras: Camera, unique: boolean): void;
  63714. /** @hidden */
  63715. _attachCameras(cameras: Camera[], unique: boolean): void;
  63716. /** @hidden */
  63717. _detachCameras(cameras: Camera): void;
  63718. /** @hidden */
  63719. _detachCameras(cameras: Nullable<Camera[]>): void;
  63720. /** @hidden */
  63721. _update(): void;
  63722. /** @hidden */
  63723. _reset(): void;
  63724. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63725. /**
  63726. * Disposes of the pipeline
  63727. */
  63728. dispose(): void;
  63729. }
  63730. }
  63731. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63732. import { Camera } from "babylonjs/Cameras/camera";
  63733. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63734. /**
  63735. * PostProcessRenderPipelineManager class
  63736. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63737. */
  63738. export class PostProcessRenderPipelineManager {
  63739. private _renderPipelines;
  63740. /**
  63741. * Initializes a PostProcessRenderPipelineManager
  63742. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63743. */
  63744. constructor();
  63745. /**
  63746. * Gets the list of supported render pipelines
  63747. */
  63748. readonly supportedPipelines: PostProcessRenderPipeline[];
  63749. /**
  63750. * Adds a pipeline to the manager
  63751. * @param renderPipeline The pipeline to add
  63752. */
  63753. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63754. /**
  63755. * Attaches a camera to the pipeline
  63756. * @param renderPipelineName The name of the pipeline to attach to
  63757. * @param cameras the camera to attach
  63758. * @param unique if the camera can be attached multiple times to the pipeline
  63759. */
  63760. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63761. /**
  63762. * Detaches a camera from the pipeline
  63763. * @param renderPipelineName The name of the pipeline to detach from
  63764. * @param cameras the camera to detach
  63765. */
  63766. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63767. /**
  63768. * Enables an effect by name on a pipeline
  63769. * @param renderPipelineName the name of the pipeline to enable the effect in
  63770. * @param renderEffectName the name of the effect to enable
  63771. * @param cameras the cameras that the effect should be enabled on
  63772. */
  63773. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63774. /**
  63775. * Disables an effect by name on a pipeline
  63776. * @param renderPipelineName the name of the pipeline to disable the effect in
  63777. * @param renderEffectName the name of the effect to disable
  63778. * @param cameras the cameras that the effect should be disabled on
  63779. */
  63780. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63781. /**
  63782. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63783. */
  63784. update(): void;
  63785. /** @hidden */
  63786. _rebuild(): void;
  63787. /**
  63788. * Disposes of the manager and pipelines
  63789. */
  63790. dispose(): void;
  63791. }
  63792. }
  63793. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63794. import { ISceneComponent } from "babylonjs/sceneComponent";
  63795. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63796. import { Scene } from "babylonjs/scene";
  63797. module "babylonjs/scene" {
  63798. interface Scene {
  63799. /** @hidden (Backing field) */
  63800. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63801. /**
  63802. * Gets the postprocess render pipeline manager
  63803. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63804. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63805. */
  63806. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63807. }
  63808. }
  63809. /**
  63810. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63811. */
  63812. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63813. /**
  63814. * The component name helpfull to identify the component in the list of scene components.
  63815. */
  63816. readonly name: string;
  63817. /**
  63818. * The scene the component belongs to.
  63819. */
  63820. scene: Scene;
  63821. /**
  63822. * Creates a new instance of the component for the given scene
  63823. * @param scene Defines the scene to register the component in
  63824. */
  63825. constructor(scene: Scene);
  63826. /**
  63827. * Registers the component in a given scene
  63828. */
  63829. register(): void;
  63830. /**
  63831. * Rebuilds the elements related to this component in case of
  63832. * context lost for instance.
  63833. */
  63834. rebuild(): void;
  63835. /**
  63836. * Disposes the component and the associated ressources
  63837. */
  63838. dispose(): void;
  63839. private _gatherRenderTargets;
  63840. }
  63841. }
  63842. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63843. import { Nullable } from "babylonjs/types";
  63844. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63845. import { Camera } from "babylonjs/Cameras/camera";
  63846. import { IDisposable } from "babylonjs/scene";
  63847. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63848. import { Scene } from "babylonjs/scene";
  63849. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63850. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63851. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63852. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63853. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63854. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63855. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63856. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63857. import { Animation } from "babylonjs/Animations/animation";
  63858. /**
  63859. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63860. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63861. */
  63862. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63863. private _scene;
  63864. private _camerasToBeAttached;
  63865. /**
  63866. * ID of the sharpen post process,
  63867. */
  63868. private readonly SharpenPostProcessId;
  63869. /**
  63870. * @ignore
  63871. * ID of the image processing post process;
  63872. */
  63873. readonly ImageProcessingPostProcessId: string;
  63874. /**
  63875. * @ignore
  63876. * ID of the Fast Approximate Anti-Aliasing post process;
  63877. */
  63878. readonly FxaaPostProcessId: string;
  63879. /**
  63880. * ID of the chromatic aberration post process,
  63881. */
  63882. private readonly ChromaticAberrationPostProcessId;
  63883. /**
  63884. * ID of the grain post process
  63885. */
  63886. private readonly GrainPostProcessId;
  63887. /**
  63888. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63889. */
  63890. sharpen: SharpenPostProcess;
  63891. private _sharpenEffect;
  63892. private bloom;
  63893. /**
  63894. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63895. */
  63896. depthOfField: DepthOfFieldEffect;
  63897. /**
  63898. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63899. */
  63900. fxaa: FxaaPostProcess;
  63901. /**
  63902. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63903. */
  63904. imageProcessing: ImageProcessingPostProcess;
  63905. /**
  63906. * Chromatic aberration post process which will shift rgb colors in the image
  63907. */
  63908. chromaticAberration: ChromaticAberrationPostProcess;
  63909. private _chromaticAberrationEffect;
  63910. /**
  63911. * Grain post process which add noise to the image
  63912. */
  63913. grain: GrainPostProcess;
  63914. private _grainEffect;
  63915. /**
  63916. * Glow post process which adds a glow to emissive areas of the image
  63917. */
  63918. private _glowLayer;
  63919. /**
  63920. * Animations which can be used to tweak settings over a period of time
  63921. */
  63922. animations: Animation[];
  63923. private _imageProcessingConfigurationObserver;
  63924. private _sharpenEnabled;
  63925. private _bloomEnabled;
  63926. private _depthOfFieldEnabled;
  63927. private _depthOfFieldBlurLevel;
  63928. private _fxaaEnabled;
  63929. private _imageProcessingEnabled;
  63930. private _defaultPipelineTextureType;
  63931. private _bloomScale;
  63932. private _chromaticAberrationEnabled;
  63933. private _grainEnabled;
  63934. private _buildAllowed;
  63935. /**
  63936. * Gets active scene
  63937. */
  63938. readonly scene: Scene;
  63939. /**
  63940. * Enable or disable the sharpen process from the pipeline
  63941. */
  63942. sharpenEnabled: boolean;
  63943. private _resizeObserver;
  63944. private _hardwareScaleLevel;
  63945. private _bloomKernel;
  63946. /**
  63947. * Specifies the size of the bloom blur kernel, relative to the final output size
  63948. */
  63949. bloomKernel: number;
  63950. /**
  63951. * Specifies the weight of the bloom in the final rendering
  63952. */
  63953. private _bloomWeight;
  63954. /**
  63955. * Specifies the luma threshold for the area that will be blurred by the bloom
  63956. */
  63957. private _bloomThreshold;
  63958. private _hdr;
  63959. /**
  63960. * The strength of the bloom.
  63961. */
  63962. bloomWeight: number;
  63963. /**
  63964. * The strength of the bloom.
  63965. */
  63966. bloomThreshold: number;
  63967. /**
  63968. * The scale of the bloom, lower value will provide better performance.
  63969. */
  63970. bloomScale: number;
  63971. /**
  63972. * Enable or disable the bloom from the pipeline
  63973. */
  63974. bloomEnabled: boolean;
  63975. private _rebuildBloom;
  63976. /**
  63977. * If the depth of field is enabled.
  63978. */
  63979. depthOfFieldEnabled: boolean;
  63980. /**
  63981. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63982. */
  63983. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63984. /**
  63985. * If the anti aliasing is enabled.
  63986. */
  63987. fxaaEnabled: boolean;
  63988. private _samples;
  63989. /**
  63990. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63991. */
  63992. samples: number;
  63993. /**
  63994. * If image processing is enabled.
  63995. */
  63996. imageProcessingEnabled: boolean;
  63997. /**
  63998. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63999. */
  64000. glowLayerEnabled: boolean;
  64001. /**
  64002. * Gets the glow layer (or null if not defined)
  64003. */
  64004. readonly glowLayer: Nullable<GlowLayer>;
  64005. /**
  64006. * Enable or disable the chromaticAberration process from the pipeline
  64007. */
  64008. chromaticAberrationEnabled: boolean;
  64009. /**
  64010. * Enable or disable the grain process from the pipeline
  64011. */
  64012. grainEnabled: boolean;
  64013. /**
  64014. * @constructor
  64015. * @param name - The rendering pipeline name (default: "")
  64016. * @param hdr - If high dynamic range textures should be used (default: true)
  64017. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64018. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64019. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64020. */
  64021. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64022. /**
  64023. * Get the class name
  64024. * @returns "DefaultRenderingPipeline"
  64025. */
  64026. getClassName(): string;
  64027. /**
  64028. * Force the compilation of the entire pipeline.
  64029. */
  64030. prepare(): void;
  64031. private _hasCleared;
  64032. private _prevPostProcess;
  64033. private _prevPrevPostProcess;
  64034. private _setAutoClearAndTextureSharing;
  64035. private _depthOfFieldSceneObserver;
  64036. private _buildPipeline;
  64037. private _disposePostProcesses;
  64038. /**
  64039. * Adds a camera to the pipeline
  64040. * @param camera the camera to be added
  64041. */
  64042. addCamera(camera: Camera): void;
  64043. /**
  64044. * Removes a camera from the pipeline
  64045. * @param camera the camera to remove
  64046. */
  64047. removeCamera(camera: Camera): void;
  64048. /**
  64049. * Dispose of the pipeline and stop all post processes
  64050. */
  64051. dispose(): void;
  64052. /**
  64053. * Serialize the rendering pipeline (Used when exporting)
  64054. * @returns the serialized object
  64055. */
  64056. serialize(): any;
  64057. /**
  64058. * Parse the serialized pipeline
  64059. * @param source Source pipeline.
  64060. * @param scene The scene to load the pipeline to.
  64061. * @param rootUrl The URL of the serialized pipeline.
  64062. * @returns An instantiated pipeline from the serialized object.
  64063. */
  64064. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64065. }
  64066. }
  64067. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64068. /** @hidden */
  64069. export var lensHighlightsPixelShader: {
  64070. name: string;
  64071. shader: string;
  64072. };
  64073. }
  64074. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64075. /** @hidden */
  64076. export var depthOfFieldPixelShader: {
  64077. name: string;
  64078. shader: string;
  64079. };
  64080. }
  64081. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64082. import { Camera } from "babylonjs/Cameras/camera";
  64083. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64084. import { Scene } from "babylonjs/scene";
  64085. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64086. import "babylonjs/Shaders/chromaticAberration.fragment";
  64087. import "babylonjs/Shaders/lensHighlights.fragment";
  64088. import "babylonjs/Shaders/depthOfField.fragment";
  64089. /**
  64090. * BABYLON.JS Chromatic Aberration GLSL Shader
  64091. * Author: Olivier Guyot
  64092. * Separates very slightly R, G and B colors on the edges of the screen
  64093. * Inspired by Francois Tarlier & Martins Upitis
  64094. */
  64095. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64096. /**
  64097. * @ignore
  64098. * The chromatic aberration PostProcess id in the pipeline
  64099. */
  64100. LensChromaticAberrationEffect: string;
  64101. /**
  64102. * @ignore
  64103. * The highlights enhancing PostProcess id in the pipeline
  64104. */
  64105. HighlightsEnhancingEffect: string;
  64106. /**
  64107. * @ignore
  64108. * The depth-of-field PostProcess id in the pipeline
  64109. */
  64110. LensDepthOfFieldEffect: string;
  64111. private _scene;
  64112. private _depthTexture;
  64113. private _grainTexture;
  64114. private _chromaticAberrationPostProcess;
  64115. private _highlightsPostProcess;
  64116. private _depthOfFieldPostProcess;
  64117. private _edgeBlur;
  64118. private _grainAmount;
  64119. private _chromaticAberration;
  64120. private _distortion;
  64121. private _highlightsGain;
  64122. private _highlightsThreshold;
  64123. private _dofDistance;
  64124. private _dofAperture;
  64125. private _dofDarken;
  64126. private _dofPentagon;
  64127. private _blurNoise;
  64128. /**
  64129. * @constructor
  64130. *
  64131. * Effect parameters are as follow:
  64132. * {
  64133. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64134. * edge_blur: number; // from 0 to x (1 for realism)
  64135. * distortion: number; // from 0 to x (1 for realism)
  64136. * grain_amount: number; // from 0 to 1
  64137. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64138. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64139. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64140. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64141. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64142. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64143. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64144. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64145. * }
  64146. * Note: if an effect parameter is unset, effect is disabled
  64147. *
  64148. * @param name The rendering pipeline name
  64149. * @param parameters - An object containing all parameters (see above)
  64150. * @param scene The scene linked to this pipeline
  64151. * @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)
  64152. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64153. */
  64154. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64155. /**
  64156. * Get the class name
  64157. * @returns "LensRenderingPipeline"
  64158. */
  64159. getClassName(): string;
  64160. /**
  64161. * Gets associated scene
  64162. */
  64163. readonly scene: Scene;
  64164. /**
  64165. * Gets or sets the edge blur
  64166. */
  64167. edgeBlur: number;
  64168. /**
  64169. * Gets or sets the grain amount
  64170. */
  64171. grainAmount: number;
  64172. /**
  64173. * Gets or sets the chromatic aberration amount
  64174. */
  64175. chromaticAberration: number;
  64176. /**
  64177. * Gets or sets the depth of field aperture
  64178. */
  64179. dofAperture: number;
  64180. /**
  64181. * Gets or sets the edge distortion
  64182. */
  64183. edgeDistortion: number;
  64184. /**
  64185. * Gets or sets the depth of field distortion
  64186. */
  64187. dofDistortion: number;
  64188. /**
  64189. * Gets or sets the darken out of focus amount
  64190. */
  64191. darkenOutOfFocus: number;
  64192. /**
  64193. * Gets or sets a boolean indicating if blur noise is enabled
  64194. */
  64195. blurNoise: boolean;
  64196. /**
  64197. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64198. */
  64199. pentagonBokeh: boolean;
  64200. /**
  64201. * Gets or sets the highlight grain amount
  64202. */
  64203. highlightsGain: number;
  64204. /**
  64205. * Gets or sets the highlight threshold
  64206. */
  64207. highlightsThreshold: number;
  64208. /**
  64209. * Sets the amount of blur at the edges
  64210. * @param amount blur amount
  64211. */
  64212. setEdgeBlur(amount: number): void;
  64213. /**
  64214. * Sets edge blur to 0
  64215. */
  64216. disableEdgeBlur(): void;
  64217. /**
  64218. * Sets the amout of grain
  64219. * @param amount Amount of grain
  64220. */
  64221. setGrainAmount(amount: number): void;
  64222. /**
  64223. * Set grain amount to 0
  64224. */
  64225. disableGrain(): void;
  64226. /**
  64227. * Sets the chromatic aberration amount
  64228. * @param amount amount of chromatic aberration
  64229. */
  64230. setChromaticAberration(amount: number): void;
  64231. /**
  64232. * Sets chromatic aberration amount to 0
  64233. */
  64234. disableChromaticAberration(): void;
  64235. /**
  64236. * Sets the EdgeDistortion amount
  64237. * @param amount amount of EdgeDistortion
  64238. */
  64239. setEdgeDistortion(amount: number): void;
  64240. /**
  64241. * Sets edge distortion to 0
  64242. */
  64243. disableEdgeDistortion(): void;
  64244. /**
  64245. * Sets the FocusDistance amount
  64246. * @param amount amount of FocusDistance
  64247. */
  64248. setFocusDistance(amount: number): void;
  64249. /**
  64250. * Disables depth of field
  64251. */
  64252. disableDepthOfField(): void;
  64253. /**
  64254. * Sets the Aperture amount
  64255. * @param amount amount of Aperture
  64256. */
  64257. setAperture(amount: number): void;
  64258. /**
  64259. * Sets the DarkenOutOfFocus amount
  64260. * @param amount amount of DarkenOutOfFocus
  64261. */
  64262. setDarkenOutOfFocus(amount: number): void;
  64263. private _pentagonBokehIsEnabled;
  64264. /**
  64265. * Creates a pentagon bokeh effect
  64266. */
  64267. enablePentagonBokeh(): void;
  64268. /**
  64269. * Disables the pentagon bokeh effect
  64270. */
  64271. disablePentagonBokeh(): void;
  64272. /**
  64273. * Enables noise blur
  64274. */
  64275. enableNoiseBlur(): void;
  64276. /**
  64277. * Disables noise blur
  64278. */
  64279. disableNoiseBlur(): void;
  64280. /**
  64281. * Sets the HighlightsGain amount
  64282. * @param amount amount of HighlightsGain
  64283. */
  64284. setHighlightsGain(amount: number): void;
  64285. /**
  64286. * Sets the HighlightsThreshold amount
  64287. * @param amount amount of HighlightsThreshold
  64288. */
  64289. setHighlightsThreshold(amount: number): void;
  64290. /**
  64291. * Disables highlights
  64292. */
  64293. disableHighlights(): void;
  64294. /**
  64295. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64296. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64297. */
  64298. dispose(disableDepthRender?: boolean): void;
  64299. private _createChromaticAberrationPostProcess;
  64300. private _createHighlightsPostProcess;
  64301. private _createDepthOfFieldPostProcess;
  64302. private _createGrainTexture;
  64303. }
  64304. }
  64305. declare module "babylonjs/Shaders/ssao2.fragment" {
  64306. /** @hidden */
  64307. export var ssao2PixelShader: {
  64308. name: string;
  64309. shader: string;
  64310. };
  64311. }
  64312. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64313. /** @hidden */
  64314. export var ssaoCombinePixelShader: {
  64315. name: string;
  64316. shader: string;
  64317. };
  64318. }
  64319. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64320. import { Camera } from "babylonjs/Cameras/camera";
  64321. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64322. import { Scene } from "babylonjs/scene";
  64323. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64324. import "babylonjs/Shaders/ssao2.fragment";
  64325. import "babylonjs/Shaders/ssaoCombine.fragment";
  64326. /**
  64327. * Render pipeline to produce ssao effect
  64328. */
  64329. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64330. /**
  64331. * @ignore
  64332. * The PassPostProcess id in the pipeline that contains the original scene color
  64333. */
  64334. SSAOOriginalSceneColorEffect: string;
  64335. /**
  64336. * @ignore
  64337. * The SSAO PostProcess id in the pipeline
  64338. */
  64339. SSAORenderEffect: string;
  64340. /**
  64341. * @ignore
  64342. * The horizontal blur PostProcess id in the pipeline
  64343. */
  64344. SSAOBlurHRenderEffect: string;
  64345. /**
  64346. * @ignore
  64347. * The vertical blur PostProcess id in the pipeline
  64348. */
  64349. SSAOBlurVRenderEffect: string;
  64350. /**
  64351. * @ignore
  64352. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64353. */
  64354. SSAOCombineRenderEffect: string;
  64355. /**
  64356. * The output strength of the SSAO post-process. Default value is 1.0.
  64357. */
  64358. totalStrength: number;
  64359. /**
  64360. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64361. */
  64362. maxZ: number;
  64363. /**
  64364. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64365. */
  64366. minZAspect: number;
  64367. private _samples;
  64368. /**
  64369. * Number of samples used for the SSAO calculations. Default value is 8
  64370. */
  64371. samples: number;
  64372. private _textureSamples;
  64373. /**
  64374. * Number of samples to use for antialiasing
  64375. */
  64376. textureSamples: number;
  64377. /**
  64378. * Ratio object used for SSAO ratio and blur ratio
  64379. */
  64380. private _ratio;
  64381. /**
  64382. * Dynamically generated sphere sampler.
  64383. */
  64384. private _sampleSphere;
  64385. /**
  64386. * Blur filter offsets
  64387. */
  64388. private _samplerOffsets;
  64389. private _expensiveBlur;
  64390. /**
  64391. * If bilateral blur should be used
  64392. */
  64393. expensiveBlur: boolean;
  64394. /**
  64395. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64396. */
  64397. radius: number;
  64398. /**
  64399. * The base color of the SSAO post-process
  64400. * The final result is "base + ssao" between [0, 1]
  64401. */
  64402. base: number;
  64403. /**
  64404. * Support test.
  64405. */
  64406. static readonly IsSupported: boolean;
  64407. private _scene;
  64408. private _depthTexture;
  64409. private _normalTexture;
  64410. private _randomTexture;
  64411. private _originalColorPostProcess;
  64412. private _ssaoPostProcess;
  64413. private _blurHPostProcess;
  64414. private _blurVPostProcess;
  64415. private _ssaoCombinePostProcess;
  64416. private _firstUpdate;
  64417. /**
  64418. * Gets active scene
  64419. */
  64420. readonly scene: Scene;
  64421. /**
  64422. * @constructor
  64423. * @param name The rendering pipeline name
  64424. * @param scene The scene linked to this pipeline
  64425. * @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 }
  64426. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64427. */
  64428. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64429. /**
  64430. * Get the class name
  64431. * @returns "SSAO2RenderingPipeline"
  64432. */
  64433. getClassName(): string;
  64434. /**
  64435. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64436. */
  64437. dispose(disableGeometryBufferRenderer?: boolean): void;
  64438. private _createBlurPostProcess;
  64439. /** @hidden */
  64440. _rebuild(): void;
  64441. private _bits;
  64442. private _radicalInverse_VdC;
  64443. private _hammersley;
  64444. private _hemisphereSample_uniform;
  64445. private _generateHemisphere;
  64446. private _createSSAOPostProcess;
  64447. private _createSSAOCombinePostProcess;
  64448. private _createRandomTexture;
  64449. /**
  64450. * Serialize the rendering pipeline (Used when exporting)
  64451. * @returns the serialized object
  64452. */
  64453. serialize(): any;
  64454. /**
  64455. * Parse the serialized pipeline
  64456. * @param source Source pipeline.
  64457. * @param scene The scene to load the pipeline to.
  64458. * @param rootUrl The URL of the serialized pipeline.
  64459. * @returns An instantiated pipeline from the serialized object.
  64460. */
  64461. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  64462. }
  64463. }
  64464. declare module "babylonjs/Shaders/ssao.fragment" {
  64465. /** @hidden */
  64466. export var ssaoPixelShader: {
  64467. name: string;
  64468. shader: string;
  64469. };
  64470. }
  64471. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  64472. import { Camera } from "babylonjs/Cameras/camera";
  64473. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64474. import { Scene } from "babylonjs/scene";
  64475. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64476. import "babylonjs/Shaders/ssao.fragment";
  64477. import "babylonjs/Shaders/ssaoCombine.fragment";
  64478. /**
  64479. * Render pipeline to produce ssao effect
  64480. */
  64481. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  64482. /**
  64483. * @ignore
  64484. * The PassPostProcess id in the pipeline that contains the original scene color
  64485. */
  64486. SSAOOriginalSceneColorEffect: string;
  64487. /**
  64488. * @ignore
  64489. * The SSAO PostProcess id in the pipeline
  64490. */
  64491. SSAORenderEffect: string;
  64492. /**
  64493. * @ignore
  64494. * The horizontal blur PostProcess id in the pipeline
  64495. */
  64496. SSAOBlurHRenderEffect: string;
  64497. /**
  64498. * @ignore
  64499. * The vertical blur PostProcess id in the pipeline
  64500. */
  64501. SSAOBlurVRenderEffect: string;
  64502. /**
  64503. * @ignore
  64504. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64505. */
  64506. SSAOCombineRenderEffect: string;
  64507. /**
  64508. * The output strength of the SSAO post-process. Default value is 1.0.
  64509. */
  64510. totalStrength: number;
  64511. /**
  64512. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64513. */
  64514. radius: number;
  64515. /**
  64516. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64517. * Must not be equal to fallOff and superior to fallOff.
  64518. * Default value is 0.0075
  64519. */
  64520. area: number;
  64521. /**
  64522. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64523. * Must not be equal to area and inferior to area.
  64524. * Default value is 0.000001
  64525. */
  64526. fallOff: number;
  64527. /**
  64528. * The base color of the SSAO post-process
  64529. * The final result is "base + ssao" between [0, 1]
  64530. */
  64531. base: number;
  64532. private _scene;
  64533. private _depthTexture;
  64534. private _randomTexture;
  64535. private _originalColorPostProcess;
  64536. private _ssaoPostProcess;
  64537. private _blurHPostProcess;
  64538. private _blurVPostProcess;
  64539. private _ssaoCombinePostProcess;
  64540. private _firstUpdate;
  64541. /**
  64542. * Gets active scene
  64543. */
  64544. readonly scene: Scene;
  64545. /**
  64546. * @constructor
  64547. * @param name - The rendering pipeline name
  64548. * @param scene - The scene linked to this pipeline
  64549. * @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 }
  64550. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64551. */
  64552. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64553. /**
  64554. * Get the class name
  64555. * @returns "SSAORenderingPipeline"
  64556. */
  64557. getClassName(): string;
  64558. /**
  64559. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64560. */
  64561. dispose(disableDepthRender?: boolean): void;
  64562. private _createBlurPostProcess;
  64563. /** @hidden */
  64564. _rebuild(): void;
  64565. private _createSSAOPostProcess;
  64566. private _createSSAOCombinePostProcess;
  64567. private _createRandomTexture;
  64568. }
  64569. }
  64570. declare module "babylonjs/Shaders/standard.fragment" {
  64571. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64572. /** @hidden */
  64573. export var standardPixelShader: {
  64574. name: string;
  64575. shader: string;
  64576. };
  64577. }
  64578. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64579. import { Nullable } from "babylonjs/types";
  64580. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64581. import { Camera } from "babylonjs/Cameras/camera";
  64582. import { Texture } from "babylonjs/Materials/Textures/texture";
  64583. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64584. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64585. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64586. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64587. import { IDisposable } from "babylonjs/scene";
  64588. import { SpotLight } from "babylonjs/Lights/spotLight";
  64589. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64590. import { Scene } from "babylonjs/scene";
  64591. import { Animation } from "babylonjs/Animations/animation";
  64592. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64593. import "babylonjs/Shaders/standard.fragment";
  64594. /**
  64595. * Standard rendering pipeline
  64596. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64597. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64598. */
  64599. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64600. /**
  64601. * Public members
  64602. */
  64603. /**
  64604. * Post-process which contains the original scene color before the pipeline applies all the effects
  64605. */
  64606. originalPostProcess: Nullable<PostProcess>;
  64607. /**
  64608. * Post-process used to down scale an image x4
  64609. */
  64610. downSampleX4PostProcess: Nullable<PostProcess>;
  64611. /**
  64612. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64613. */
  64614. brightPassPostProcess: Nullable<PostProcess>;
  64615. /**
  64616. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64617. */
  64618. blurHPostProcesses: PostProcess[];
  64619. /**
  64620. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64621. */
  64622. blurVPostProcesses: PostProcess[];
  64623. /**
  64624. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64625. */
  64626. textureAdderPostProcess: Nullable<PostProcess>;
  64627. /**
  64628. * Post-process used to create volumetric lighting effect
  64629. */
  64630. volumetricLightPostProcess: Nullable<PostProcess>;
  64631. /**
  64632. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64633. */
  64634. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64635. /**
  64636. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64637. */
  64638. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64639. /**
  64640. * Post-process used to merge the volumetric light effect and the real scene color
  64641. */
  64642. volumetricLightMergePostProces: Nullable<PostProcess>;
  64643. /**
  64644. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64645. */
  64646. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64647. /**
  64648. * Base post-process used to calculate the average luminance of the final image for HDR
  64649. */
  64650. luminancePostProcess: Nullable<PostProcess>;
  64651. /**
  64652. * Post-processes used to create down sample post-processes in order to get
  64653. * the average luminance of the final image for HDR
  64654. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64655. */
  64656. luminanceDownSamplePostProcesses: PostProcess[];
  64657. /**
  64658. * Post-process used to create a HDR effect (light adaptation)
  64659. */
  64660. hdrPostProcess: Nullable<PostProcess>;
  64661. /**
  64662. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64663. */
  64664. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64665. /**
  64666. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64667. */
  64668. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64669. /**
  64670. * Post-process used to merge the final HDR post-process and the real scene color
  64671. */
  64672. hdrFinalPostProcess: Nullable<PostProcess>;
  64673. /**
  64674. * Post-process used to create a lens flare effect
  64675. */
  64676. lensFlarePostProcess: Nullable<PostProcess>;
  64677. /**
  64678. * Post-process that merges the result of the lens flare post-process and the real scene color
  64679. */
  64680. lensFlareComposePostProcess: Nullable<PostProcess>;
  64681. /**
  64682. * Post-process used to create a motion blur effect
  64683. */
  64684. motionBlurPostProcess: Nullable<PostProcess>;
  64685. /**
  64686. * Post-process used to create a depth of field effect
  64687. */
  64688. depthOfFieldPostProcess: Nullable<PostProcess>;
  64689. /**
  64690. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64691. */
  64692. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64693. /**
  64694. * Represents the brightness threshold in order to configure the illuminated surfaces
  64695. */
  64696. brightThreshold: number;
  64697. /**
  64698. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64699. */
  64700. blurWidth: number;
  64701. /**
  64702. * Sets if the blur for highlighted surfaces must be only horizontal
  64703. */
  64704. horizontalBlur: boolean;
  64705. /**
  64706. * Gets the overall exposure used by the pipeline
  64707. */
  64708. /**
  64709. * Sets the overall exposure used by the pipeline
  64710. */
  64711. exposure: number;
  64712. /**
  64713. * Texture used typically to simulate "dirty" on camera lens
  64714. */
  64715. lensTexture: Nullable<Texture>;
  64716. /**
  64717. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64718. */
  64719. volumetricLightCoefficient: number;
  64720. /**
  64721. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64722. */
  64723. volumetricLightPower: number;
  64724. /**
  64725. * Used the set the blur intensity to smooth the volumetric lights
  64726. */
  64727. volumetricLightBlurScale: number;
  64728. /**
  64729. * Light (spot or directional) used to generate the volumetric lights rays
  64730. * The source light must have a shadow generate so the pipeline can get its
  64731. * depth map
  64732. */
  64733. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64734. /**
  64735. * For eye adaptation, represents the minimum luminance the eye can see
  64736. */
  64737. hdrMinimumLuminance: number;
  64738. /**
  64739. * For eye adaptation, represents the decrease luminance speed
  64740. */
  64741. hdrDecreaseRate: number;
  64742. /**
  64743. * For eye adaptation, represents the increase luminance speed
  64744. */
  64745. hdrIncreaseRate: number;
  64746. /**
  64747. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64748. */
  64749. /**
  64750. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64751. */
  64752. hdrAutoExposure: boolean;
  64753. /**
  64754. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64755. */
  64756. lensColorTexture: Nullable<Texture>;
  64757. /**
  64758. * The overall strengh for the lens flare effect
  64759. */
  64760. lensFlareStrength: number;
  64761. /**
  64762. * Dispersion coefficient for lens flare ghosts
  64763. */
  64764. lensFlareGhostDispersal: number;
  64765. /**
  64766. * Main lens flare halo width
  64767. */
  64768. lensFlareHaloWidth: number;
  64769. /**
  64770. * Based on the lens distortion effect, defines how much the lens flare result
  64771. * is distorted
  64772. */
  64773. lensFlareDistortionStrength: number;
  64774. /**
  64775. * Configures the blur intensity used for for lens flare (halo)
  64776. */
  64777. lensFlareBlurWidth: number;
  64778. /**
  64779. * Lens star texture must be used to simulate rays on the flares and is available
  64780. * in the documentation
  64781. */
  64782. lensStarTexture: Nullable<Texture>;
  64783. /**
  64784. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64785. * flare effect by taking account of the dirt texture
  64786. */
  64787. lensFlareDirtTexture: Nullable<Texture>;
  64788. /**
  64789. * Represents the focal length for the depth of field effect
  64790. */
  64791. depthOfFieldDistance: number;
  64792. /**
  64793. * Represents the blur intensity for the blurred part of the depth of field effect
  64794. */
  64795. depthOfFieldBlurWidth: number;
  64796. /**
  64797. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64798. */
  64799. /**
  64800. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64801. */
  64802. motionStrength: number;
  64803. /**
  64804. * Gets wether or not the motion blur post-process is object based or screen based.
  64805. */
  64806. /**
  64807. * Sets wether or not the motion blur post-process should be object based or screen based
  64808. */
  64809. objectBasedMotionBlur: boolean;
  64810. /**
  64811. * List of animations for the pipeline (IAnimatable implementation)
  64812. */
  64813. animations: Animation[];
  64814. /**
  64815. * Private members
  64816. */
  64817. private _scene;
  64818. private _currentDepthOfFieldSource;
  64819. private _basePostProcess;
  64820. private _fixedExposure;
  64821. private _currentExposure;
  64822. private _hdrAutoExposure;
  64823. private _hdrCurrentLuminance;
  64824. private _motionStrength;
  64825. private _isObjectBasedMotionBlur;
  64826. private _floatTextureType;
  64827. private _camerasToBeAttached;
  64828. private _ratio;
  64829. private _bloomEnabled;
  64830. private _depthOfFieldEnabled;
  64831. private _vlsEnabled;
  64832. private _lensFlareEnabled;
  64833. private _hdrEnabled;
  64834. private _motionBlurEnabled;
  64835. private _fxaaEnabled;
  64836. private _motionBlurSamples;
  64837. private _volumetricLightStepsCount;
  64838. private _samples;
  64839. /**
  64840. * @ignore
  64841. * Specifies if the bloom pipeline is enabled
  64842. */
  64843. BloomEnabled: boolean;
  64844. /**
  64845. * @ignore
  64846. * Specifies if the depth of field pipeline is enabed
  64847. */
  64848. DepthOfFieldEnabled: boolean;
  64849. /**
  64850. * @ignore
  64851. * Specifies if the lens flare pipeline is enabed
  64852. */
  64853. LensFlareEnabled: boolean;
  64854. /**
  64855. * @ignore
  64856. * Specifies if the HDR pipeline is enabled
  64857. */
  64858. HDREnabled: boolean;
  64859. /**
  64860. * @ignore
  64861. * Specifies if the volumetric lights scattering effect is enabled
  64862. */
  64863. VLSEnabled: boolean;
  64864. /**
  64865. * @ignore
  64866. * Specifies if the motion blur effect is enabled
  64867. */
  64868. MotionBlurEnabled: boolean;
  64869. /**
  64870. * Specifies if anti-aliasing is enabled
  64871. */
  64872. fxaaEnabled: boolean;
  64873. /**
  64874. * Specifies the number of steps used to calculate the volumetric lights
  64875. * Typically in interval [50, 200]
  64876. */
  64877. volumetricLightStepsCount: number;
  64878. /**
  64879. * Specifies the number of samples used for the motion blur effect
  64880. * Typically in interval [16, 64]
  64881. */
  64882. motionBlurSamples: number;
  64883. /**
  64884. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64885. */
  64886. samples: number;
  64887. /**
  64888. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64889. * @constructor
  64890. * @param name The rendering pipeline name
  64891. * @param scene The scene linked to this pipeline
  64892. * @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)
  64893. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64894. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64895. */
  64896. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64897. private _buildPipeline;
  64898. private _createDownSampleX4PostProcess;
  64899. private _createBrightPassPostProcess;
  64900. private _createBlurPostProcesses;
  64901. private _createTextureAdderPostProcess;
  64902. private _createVolumetricLightPostProcess;
  64903. private _createLuminancePostProcesses;
  64904. private _createHdrPostProcess;
  64905. private _createLensFlarePostProcess;
  64906. private _createDepthOfFieldPostProcess;
  64907. private _createMotionBlurPostProcess;
  64908. private _getDepthTexture;
  64909. private _disposePostProcesses;
  64910. /**
  64911. * Dispose of the pipeline and stop all post processes
  64912. */
  64913. dispose(): void;
  64914. /**
  64915. * Serialize the rendering pipeline (Used when exporting)
  64916. * @returns the serialized object
  64917. */
  64918. serialize(): any;
  64919. /**
  64920. * Parse the serialized pipeline
  64921. * @param source Source pipeline.
  64922. * @param scene The scene to load the pipeline to.
  64923. * @param rootUrl The URL of the serialized pipeline.
  64924. * @returns An instantiated pipeline from the serialized object.
  64925. */
  64926. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64927. /**
  64928. * Luminance steps
  64929. */
  64930. static LuminanceSteps: number;
  64931. }
  64932. }
  64933. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64934. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64935. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64936. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64937. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64938. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64939. }
  64940. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64941. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64942. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64943. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64944. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64945. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64946. }
  64947. declare module "babylonjs/Shaders/tonemap.fragment" {
  64948. /** @hidden */
  64949. export var tonemapPixelShader: {
  64950. name: string;
  64951. shader: string;
  64952. };
  64953. }
  64954. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64955. import { Camera } from "babylonjs/Cameras/camera";
  64956. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64957. import "babylonjs/Shaders/tonemap.fragment";
  64958. import { Engine } from "babylonjs/Engines/engine";
  64959. /** Defines operator used for tonemapping */
  64960. export enum TonemappingOperator {
  64961. /** Hable */
  64962. Hable = 0,
  64963. /** Reinhard */
  64964. Reinhard = 1,
  64965. /** HejiDawson */
  64966. HejiDawson = 2,
  64967. /** Photographic */
  64968. Photographic = 3
  64969. }
  64970. /**
  64971. * Defines a post process to apply tone mapping
  64972. */
  64973. export class TonemapPostProcess extends PostProcess {
  64974. private _operator;
  64975. /** Defines the required exposure adjustement */
  64976. exposureAdjustment: number;
  64977. /**
  64978. * Creates a new TonemapPostProcess
  64979. * @param name defines the name of the postprocess
  64980. * @param _operator defines the operator to use
  64981. * @param exposureAdjustment defines the required exposure adjustement
  64982. * @param camera defines the camera to use (can be null)
  64983. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64984. * @param engine defines the hosting engine (can be ignore if camera is set)
  64985. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64986. */
  64987. constructor(name: string, _operator: TonemappingOperator,
  64988. /** Defines the required exposure adjustement */
  64989. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64990. }
  64991. }
  64992. declare module "babylonjs/Shaders/depth.vertex" {
  64993. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64994. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64995. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64996. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64997. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64998. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64999. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65000. /** @hidden */
  65001. export var depthVertexShader: {
  65002. name: string;
  65003. shader: string;
  65004. };
  65005. }
  65006. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65007. /** @hidden */
  65008. export var volumetricLightScatteringPixelShader: {
  65009. name: string;
  65010. shader: string;
  65011. };
  65012. }
  65013. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65014. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65015. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65016. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65017. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65018. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65019. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65020. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65021. /** @hidden */
  65022. export var volumetricLightScatteringPassVertexShader: {
  65023. name: string;
  65024. shader: string;
  65025. };
  65026. }
  65027. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65028. /** @hidden */
  65029. export var volumetricLightScatteringPassPixelShader: {
  65030. name: string;
  65031. shader: string;
  65032. };
  65033. }
  65034. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65035. import { Vector3 } from "babylonjs/Maths/math.vector";
  65036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65037. import { Mesh } from "babylonjs/Meshes/mesh";
  65038. import { Camera } from "babylonjs/Cameras/camera";
  65039. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65040. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65041. import { Scene } from "babylonjs/scene";
  65042. import "babylonjs/Meshes/Builders/planeBuilder";
  65043. import "babylonjs/Shaders/depth.vertex";
  65044. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65045. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65046. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65047. import { Engine } from "babylonjs/Engines/engine";
  65048. /**
  65049. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65050. */
  65051. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65052. private _volumetricLightScatteringPass;
  65053. private _volumetricLightScatteringRTT;
  65054. private _viewPort;
  65055. private _screenCoordinates;
  65056. private _cachedDefines;
  65057. /**
  65058. * If not undefined, the mesh position is computed from the attached node position
  65059. */
  65060. attachedNode: {
  65061. position: Vector3;
  65062. };
  65063. /**
  65064. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65065. */
  65066. customMeshPosition: Vector3;
  65067. /**
  65068. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65069. */
  65070. useCustomMeshPosition: boolean;
  65071. /**
  65072. * If the post-process should inverse the light scattering direction
  65073. */
  65074. invert: boolean;
  65075. /**
  65076. * The internal mesh used by the post-process
  65077. */
  65078. mesh: Mesh;
  65079. /**
  65080. * @hidden
  65081. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65082. */
  65083. useDiffuseColor: boolean;
  65084. /**
  65085. * Array containing the excluded meshes not rendered in the internal pass
  65086. */
  65087. excludedMeshes: AbstractMesh[];
  65088. /**
  65089. * Controls the overall intensity of the post-process
  65090. */
  65091. exposure: number;
  65092. /**
  65093. * Dissipates each sample's contribution in range [0, 1]
  65094. */
  65095. decay: number;
  65096. /**
  65097. * Controls the overall intensity of each sample
  65098. */
  65099. weight: number;
  65100. /**
  65101. * Controls the density of each sample
  65102. */
  65103. density: number;
  65104. /**
  65105. * @constructor
  65106. * @param name The post-process name
  65107. * @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)
  65108. * @param camera The camera that the post-process will be attached to
  65109. * @param mesh The mesh used to create the light scattering
  65110. * @param samples The post-process quality, default 100
  65111. * @param samplingModeThe post-process filtering mode
  65112. * @param engine The babylon engine
  65113. * @param reusable If the post-process is reusable
  65114. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65115. */
  65116. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65117. /**
  65118. * Returns the string "VolumetricLightScatteringPostProcess"
  65119. * @returns "VolumetricLightScatteringPostProcess"
  65120. */
  65121. getClassName(): string;
  65122. private _isReady;
  65123. /**
  65124. * Sets the new light position for light scattering effect
  65125. * @param position The new custom light position
  65126. */
  65127. setCustomMeshPosition(position: Vector3): void;
  65128. /**
  65129. * Returns the light position for light scattering effect
  65130. * @return Vector3 The custom light position
  65131. */
  65132. getCustomMeshPosition(): Vector3;
  65133. /**
  65134. * Disposes the internal assets and detaches the post-process from the camera
  65135. */
  65136. dispose(camera: Camera): void;
  65137. /**
  65138. * Returns the render target texture used by the post-process
  65139. * @return the render target texture used by the post-process
  65140. */
  65141. getPass(): RenderTargetTexture;
  65142. private _meshExcluded;
  65143. private _createPass;
  65144. private _updateMeshScreenCoordinates;
  65145. /**
  65146. * Creates a default mesh for the Volumeric Light Scattering post-process
  65147. * @param name The mesh name
  65148. * @param scene The scene where to create the mesh
  65149. * @return the default mesh
  65150. */
  65151. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65152. }
  65153. }
  65154. declare module "babylonjs/PostProcesses/index" {
  65155. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65156. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65157. export * from "babylonjs/PostProcesses/bloomEffect";
  65158. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65159. export * from "babylonjs/PostProcesses/blurPostProcess";
  65160. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65161. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65162. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65163. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65164. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65165. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65166. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65167. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65168. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65169. export * from "babylonjs/PostProcesses/filterPostProcess";
  65170. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65171. export * from "babylonjs/PostProcesses/grainPostProcess";
  65172. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65173. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65174. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65175. export * from "babylonjs/PostProcesses/passPostProcess";
  65176. export * from "babylonjs/PostProcesses/postProcess";
  65177. export * from "babylonjs/PostProcesses/postProcessManager";
  65178. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65179. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65180. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65181. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65182. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65183. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65184. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65185. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65186. }
  65187. declare module "babylonjs/Probes/index" {
  65188. export * from "babylonjs/Probes/reflectionProbe";
  65189. }
  65190. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65191. import { Scene } from "babylonjs/scene";
  65192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65193. import { SmartArray } from "babylonjs/Misc/smartArray";
  65194. import { ISceneComponent } from "babylonjs/sceneComponent";
  65195. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65196. import "babylonjs/Meshes/Builders/boxBuilder";
  65197. import "babylonjs/Shaders/color.fragment";
  65198. import "babylonjs/Shaders/color.vertex";
  65199. import { Color3 } from "babylonjs/Maths/math.color";
  65200. module "babylonjs/scene" {
  65201. interface Scene {
  65202. /** @hidden (Backing field) */
  65203. _boundingBoxRenderer: BoundingBoxRenderer;
  65204. /** @hidden (Backing field) */
  65205. _forceShowBoundingBoxes: boolean;
  65206. /**
  65207. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65208. */
  65209. forceShowBoundingBoxes: boolean;
  65210. /**
  65211. * Gets the bounding box renderer associated with the scene
  65212. * @returns a BoundingBoxRenderer
  65213. */
  65214. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65215. }
  65216. }
  65217. module "babylonjs/Meshes/abstractMesh" {
  65218. interface AbstractMesh {
  65219. /** @hidden (Backing field) */
  65220. _showBoundingBox: boolean;
  65221. /**
  65222. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65223. */
  65224. showBoundingBox: boolean;
  65225. }
  65226. }
  65227. /**
  65228. * Component responsible of rendering the bounding box of the meshes in a scene.
  65229. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65230. */
  65231. export class BoundingBoxRenderer implements ISceneComponent {
  65232. /**
  65233. * The component name helpfull to identify the component in the list of scene components.
  65234. */
  65235. readonly name: string;
  65236. /**
  65237. * The scene the component belongs to.
  65238. */
  65239. scene: Scene;
  65240. /**
  65241. * Color of the bounding box lines placed in front of an object
  65242. */
  65243. frontColor: Color3;
  65244. /**
  65245. * Color of the bounding box lines placed behind an object
  65246. */
  65247. backColor: Color3;
  65248. /**
  65249. * Defines if the renderer should show the back lines or not
  65250. */
  65251. showBackLines: boolean;
  65252. /**
  65253. * @hidden
  65254. */
  65255. renderList: SmartArray<BoundingBox>;
  65256. private _colorShader;
  65257. private _vertexBuffers;
  65258. private _indexBuffer;
  65259. private _fillIndexBuffer;
  65260. private _fillIndexData;
  65261. /**
  65262. * Instantiates a new bounding box renderer in a scene.
  65263. * @param scene the scene the renderer renders in
  65264. */
  65265. constructor(scene: Scene);
  65266. /**
  65267. * Registers the component in a given scene
  65268. */
  65269. register(): void;
  65270. private _evaluateSubMesh;
  65271. private _activeMesh;
  65272. private _prepareRessources;
  65273. private _createIndexBuffer;
  65274. /**
  65275. * Rebuilds the elements related to this component in case of
  65276. * context lost for instance.
  65277. */
  65278. rebuild(): void;
  65279. /**
  65280. * @hidden
  65281. */
  65282. reset(): void;
  65283. /**
  65284. * Render the bounding boxes of a specific rendering group
  65285. * @param renderingGroupId defines the rendering group to render
  65286. */
  65287. render(renderingGroupId: number): void;
  65288. /**
  65289. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65290. * @param mesh Define the mesh to render the occlusion bounding box for
  65291. */
  65292. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65293. /**
  65294. * Dispose and release the resources attached to this renderer.
  65295. */
  65296. dispose(): void;
  65297. }
  65298. }
  65299. declare module "babylonjs/Shaders/depth.fragment" {
  65300. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65301. /** @hidden */
  65302. export var depthPixelShader: {
  65303. name: string;
  65304. shader: string;
  65305. };
  65306. }
  65307. declare module "babylonjs/Rendering/depthRenderer" {
  65308. import { Nullable } from "babylonjs/types";
  65309. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65310. import { Scene } from "babylonjs/scene";
  65311. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65312. import { Camera } from "babylonjs/Cameras/camera";
  65313. import "babylonjs/Shaders/depth.fragment";
  65314. import "babylonjs/Shaders/depth.vertex";
  65315. /**
  65316. * This represents a depth renderer in Babylon.
  65317. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65318. */
  65319. export class DepthRenderer {
  65320. private _scene;
  65321. private _depthMap;
  65322. private _effect;
  65323. private readonly _storeNonLinearDepth;
  65324. private readonly _clearColor;
  65325. /** Get if the depth renderer is using packed depth or not */
  65326. readonly isPacked: boolean;
  65327. private _cachedDefines;
  65328. private _camera;
  65329. /**
  65330. * Specifiess that the depth renderer will only be used within
  65331. * the camera it is created for.
  65332. * This can help forcing its rendering during the camera processing.
  65333. */
  65334. useOnlyInActiveCamera: boolean;
  65335. /** @hidden */
  65336. static _SceneComponentInitialization: (scene: Scene) => void;
  65337. /**
  65338. * Instantiates a depth renderer
  65339. * @param scene The scene the renderer belongs to
  65340. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65341. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65342. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65343. */
  65344. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65345. /**
  65346. * Creates the depth rendering effect and checks if the effect is ready.
  65347. * @param subMesh The submesh to be used to render the depth map of
  65348. * @param useInstances If multiple world instances should be used
  65349. * @returns if the depth renderer is ready to render the depth map
  65350. */
  65351. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65352. /**
  65353. * Gets the texture which the depth map will be written to.
  65354. * @returns The depth map texture
  65355. */
  65356. getDepthMap(): RenderTargetTexture;
  65357. /**
  65358. * Disposes of the depth renderer.
  65359. */
  65360. dispose(): void;
  65361. }
  65362. }
  65363. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65364. import { Nullable } from "babylonjs/types";
  65365. import { Scene } from "babylonjs/scene";
  65366. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65367. import { Camera } from "babylonjs/Cameras/camera";
  65368. import { ISceneComponent } from "babylonjs/sceneComponent";
  65369. module "babylonjs/scene" {
  65370. interface Scene {
  65371. /** @hidden (Backing field) */
  65372. _depthRenderer: {
  65373. [id: string]: DepthRenderer;
  65374. };
  65375. /**
  65376. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65377. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65378. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65379. * @returns the created depth renderer
  65380. */
  65381. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65382. /**
  65383. * Disables a depth renderer for a given camera
  65384. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65385. */
  65386. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65387. }
  65388. }
  65389. /**
  65390. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65391. * in several rendering techniques.
  65392. */
  65393. export class DepthRendererSceneComponent implements ISceneComponent {
  65394. /**
  65395. * The component name helpfull to identify the component in the list of scene components.
  65396. */
  65397. readonly name: string;
  65398. /**
  65399. * The scene the component belongs to.
  65400. */
  65401. scene: Scene;
  65402. /**
  65403. * Creates a new instance of the component for the given scene
  65404. * @param scene Defines the scene to register the component in
  65405. */
  65406. constructor(scene: Scene);
  65407. /**
  65408. * Registers the component in a given scene
  65409. */
  65410. register(): void;
  65411. /**
  65412. * Rebuilds the elements related to this component in case of
  65413. * context lost for instance.
  65414. */
  65415. rebuild(): void;
  65416. /**
  65417. * Disposes the component and the associated ressources
  65418. */
  65419. dispose(): void;
  65420. private _gatherRenderTargets;
  65421. private _gatherActiveCameraRenderTargets;
  65422. }
  65423. }
  65424. declare module "babylonjs/Shaders/outline.fragment" {
  65425. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65426. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  65427. /** @hidden */
  65428. export var outlinePixelShader: {
  65429. name: string;
  65430. shader: string;
  65431. };
  65432. }
  65433. declare module "babylonjs/Shaders/outline.vertex" {
  65434. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65435. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65437. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65438. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65439. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65440. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65441. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65442. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  65443. /** @hidden */
  65444. export var outlineVertexShader: {
  65445. name: string;
  65446. shader: string;
  65447. };
  65448. }
  65449. declare module "babylonjs/Rendering/outlineRenderer" {
  65450. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65451. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  65452. import { Scene } from "babylonjs/scene";
  65453. import { ISceneComponent } from "babylonjs/sceneComponent";
  65454. import "babylonjs/Shaders/outline.fragment";
  65455. import "babylonjs/Shaders/outline.vertex";
  65456. module "babylonjs/scene" {
  65457. interface Scene {
  65458. /** @hidden */
  65459. _outlineRenderer: OutlineRenderer;
  65460. /**
  65461. * Gets the outline renderer associated with the scene
  65462. * @returns a OutlineRenderer
  65463. */
  65464. getOutlineRenderer(): OutlineRenderer;
  65465. }
  65466. }
  65467. module "babylonjs/Meshes/abstractMesh" {
  65468. interface AbstractMesh {
  65469. /** @hidden (Backing field) */
  65470. _renderOutline: boolean;
  65471. /**
  65472. * Gets or sets a boolean indicating if the outline must be rendered as well
  65473. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  65474. */
  65475. renderOutline: boolean;
  65476. /** @hidden (Backing field) */
  65477. _renderOverlay: boolean;
  65478. /**
  65479. * Gets or sets a boolean indicating if the overlay must be rendered as well
  65480. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  65481. */
  65482. renderOverlay: boolean;
  65483. }
  65484. }
  65485. /**
  65486. * This class is responsible to draw bothe outline/overlay of meshes.
  65487. * It should not be used directly but through the available method on mesh.
  65488. */
  65489. export class OutlineRenderer implements ISceneComponent {
  65490. /**
  65491. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  65492. */
  65493. private static _StencilReference;
  65494. /**
  65495. * The name of the component. Each component must have a unique name.
  65496. */
  65497. name: string;
  65498. /**
  65499. * The scene the component belongs to.
  65500. */
  65501. scene: Scene;
  65502. /**
  65503. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  65504. */
  65505. zOffset: number;
  65506. private _engine;
  65507. private _effect;
  65508. private _cachedDefines;
  65509. private _savedDepthWrite;
  65510. /**
  65511. * Instantiates a new outline renderer. (There could be only one per scene).
  65512. * @param scene Defines the scene it belongs to
  65513. */
  65514. constructor(scene: Scene);
  65515. /**
  65516. * Register the component to one instance of a scene.
  65517. */
  65518. register(): void;
  65519. /**
  65520. * Rebuilds the elements related to this component in case of
  65521. * context lost for instance.
  65522. */
  65523. rebuild(): void;
  65524. /**
  65525. * Disposes the component and the associated ressources.
  65526. */
  65527. dispose(): void;
  65528. /**
  65529. * Renders the outline in the canvas.
  65530. * @param subMesh Defines the sumesh to render
  65531. * @param batch Defines the batch of meshes in case of instances
  65532. * @param useOverlay Defines if the rendering is for the overlay or the outline
  65533. */
  65534. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  65535. /**
  65536. * Returns whether or not the outline renderer is ready for a given submesh.
  65537. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  65538. * @param subMesh Defines the submesh to check readyness for
  65539. * @param useInstances Defines wheter wee are trying to render instances or not
  65540. * @returns true if ready otherwise false
  65541. */
  65542. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65543. private _beforeRenderingMesh;
  65544. private _afterRenderingMesh;
  65545. }
  65546. }
  65547. declare module "babylonjs/Rendering/index" {
  65548. export * from "babylonjs/Rendering/boundingBoxRenderer";
  65549. export * from "babylonjs/Rendering/depthRenderer";
  65550. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  65551. export * from "babylonjs/Rendering/edgesRenderer";
  65552. export * from "babylonjs/Rendering/geometryBufferRenderer";
  65553. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65554. export * from "babylonjs/Rendering/outlineRenderer";
  65555. export * from "babylonjs/Rendering/renderingGroup";
  65556. export * from "babylonjs/Rendering/renderingManager";
  65557. export * from "babylonjs/Rendering/utilityLayerRenderer";
  65558. }
  65559. declare module "babylonjs/Sprites/spritePackedManager" {
  65560. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  65561. import { Scene } from "babylonjs/scene";
  65562. /**
  65563. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65564. * @see http://doc.babylonjs.com/babylon101/sprites
  65565. */
  65566. export class SpritePackedManager extends SpriteManager {
  65567. /** defines the packed manager's name */
  65568. name: string;
  65569. /**
  65570. * Creates a new sprite manager from a packed sprite sheet
  65571. * @param name defines the manager's name
  65572. * @param imgUrl defines the sprite sheet url
  65573. * @param capacity defines the maximum allowed number of sprites
  65574. * @param scene defines the hosting scene
  65575. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65576. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65577. * @param samplingMode defines the smapling mode to use with spritesheet
  65578. * @param fromPacked set to true; do not alter
  65579. */
  65580. constructor(
  65581. /** defines the packed manager's name */
  65582. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65583. }
  65584. }
  65585. declare module "babylonjs/Sprites/index" {
  65586. export * from "babylonjs/Sprites/sprite";
  65587. export * from "babylonjs/Sprites/spriteManager";
  65588. export * from "babylonjs/Sprites/spritePackedManager";
  65589. export * from "babylonjs/Sprites/spriteSceneComponent";
  65590. }
  65591. declare module "babylonjs/States/index" {
  65592. export * from "babylonjs/States/alphaCullingState";
  65593. export * from "babylonjs/States/depthCullingState";
  65594. export * from "babylonjs/States/stencilState";
  65595. }
  65596. declare module "babylonjs/Misc/assetsManager" {
  65597. import { Scene } from "babylonjs/scene";
  65598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65599. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65600. import { Skeleton } from "babylonjs/Bones/skeleton";
  65601. import { Observable } from "babylonjs/Misc/observable";
  65602. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65603. import { Texture } from "babylonjs/Materials/Textures/texture";
  65604. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65605. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65606. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65607. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65608. /**
  65609. * Defines the list of states available for a task inside a AssetsManager
  65610. */
  65611. export enum AssetTaskState {
  65612. /**
  65613. * Initialization
  65614. */
  65615. INIT = 0,
  65616. /**
  65617. * Running
  65618. */
  65619. RUNNING = 1,
  65620. /**
  65621. * Done
  65622. */
  65623. DONE = 2,
  65624. /**
  65625. * Error
  65626. */
  65627. ERROR = 3
  65628. }
  65629. /**
  65630. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65631. */
  65632. export abstract class AbstractAssetTask {
  65633. /**
  65634. * Task name
  65635. */ name: string;
  65636. /**
  65637. * Callback called when the task is successful
  65638. */
  65639. onSuccess: (task: any) => void;
  65640. /**
  65641. * Callback called when the task is not successful
  65642. */
  65643. onError: (task: any, message?: string, exception?: any) => void;
  65644. /**
  65645. * Creates a new AssetsManager
  65646. * @param name defines the name of the task
  65647. */
  65648. constructor(
  65649. /**
  65650. * Task name
  65651. */ name: string);
  65652. private _isCompleted;
  65653. private _taskState;
  65654. private _errorObject;
  65655. /**
  65656. * Get if the task is completed
  65657. */
  65658. readonly isCompleted: boolean;
  65659. /**
  65660. * Gets the current state of the task
  65661. */
  65662. readonly taskState: AssetTaskState;
  65663. /**
  65664. * Gets the current error object (if task is in error)
  65665. */
  65666. readonly errorObject: {
  65667. message?: string;
  65668. exception?: any;
  65669. };
  65670. /**
  65671. * Internal only
  65672. * @hidden
  65673. */
  65674. _setErrorObject(message?: string, exception?: any): void;
  65675. /**
  65676. * Execute the current task
  65677. * @param scene defines the scene where you want your assets to be loaded
  65678. * @param onSuccess is a callback called when the task is successfully executed
  65679. * @param onError is a callback called if an error occurs
  65680. */
  65681. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65682. /**
  65683. * Execute the current task
  65684. * @param scene defines the scene where you want your assets to be loaded
  65685. * @param onSuccess is a callback called when the task is successfully executed
  65686. * @param onError is a callback called if an error occurs
  65687. */
  65688. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65689. /**
  65690. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65691. * This can be used with failed tasks that have the reason for failure fixed.
  65692. */
  65693. reset(): void;
  65694. private onErrorCallback;
  65695. private onDoneCallback;
  65696. }
  65697. /**
  65698. * Define the interface used by progress events raised during assets loading
  65699. */
  65700. export interface IAssetsProgressEvent {
  65701. /**
  65702. * Defines the number of remaining tasks to process
  65703. */
  65704. remainingCount: number;
  65705. /**
  65706. * Defines the total number of tasks
  65707. */
  65708. totalCount: number;
  65709. /**
  65710. * Defines the task that was just processed
  65711. */
  65712. task: AbstractAssetTask;
  65713. }
  65714. /**
  65715. * Class used to share progress information about assets loading
  65716. */
  65717. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65718. /**
  65719. * Defines the number of remaining tasks to process
  65720. */
  65721. remainingCount: number;
  65722. /**
  65723. * Defines the total number of tasks
  65724. */
  65725. totalCount: number;
  65726. /**
  65727. * Defines the task that was just processed
  65728. */
  65729. task: AbstractAssetTask;
  65730. /**
  65731. * Creates a AssetsProgressEvent
  65732. * @param remainingCount defines the number of remaining tasks to process
  65733. * @param totalCount defines the total number of tasks
  65734. * @param task defines the task that was just processed
  65735. */
  65736. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65737. }
  65738. /**
  65739. * Define a task used by AssetsManager to load meshes
  65740. */
  65741. export class MeshAssetTask extends AbstractAssetTask {
  65742. /**
  65743. * Defines the name of the task
  65744. */
  65745. name: string;
  65746. /**
  65747. * Defines the list of mesh's names you want to load
  65748. */
  65749. meshesNames: any;
  65750. /**
  65751. * Defines the root url to use as a base to load your meshes and associated resources
  65752. */
  65753. rootUrl: string;
  65754. /**
  65755. * Defines the filename of the scene to load from
  65756. */
  65757. sceneFilename: string;
  65758. /**
  65759. * Gets the list of loaded meshes
  65760. */
  65761. loadedMeshes: Array<AbstractMesh>;
  65762. /**
  65763. * Gets the list of loaded particle systems
  65764. */
  65765. loadedParticleSystems: Array<IParticleSystem>;
  65766. /**
  65767. * Gets the list of loaded skeletons
  65768. */
  65769. loadedSkeletons: Array<Skeleton>;
  65770. /**
  65771. * Gets the list of loaded animation groups
  65772. */
  65773. loadedAnimationGroups: Array<AnimationGroup>;
  65774. /**
  65775. * Callback called when the task is successful
  65776. */
  65777. onSuccess: (task: MeshAssetTask) => void;
  65778. /**
  65779. * Callback called when the task is successful
  65780. */
  65781. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65782. /**
  65783. * Creates a new MeshAssetTask
  65784. * @param name defines the name of the task
  65785. * @param meshesNames defines the list of mesh's names you want to load
  65786. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65787. * @param sceneFilename defines the filename of the scene to load from
  65788. */
  65789. constructor(
  65790. /**
  65791. * Defines the name of the task
  65792. */
  65793. name: string,
  65794. /**
  65795. * Defines the list of mesh's names you want to load
  65796. */
  65797. meshesNames: any,
  65798. /**
  65799. * Defines the root url to use as a base to load your meshes and associated resources
  65800. */
  65801. rootUrl: string,
  65802. /**
  65803. * Defines the filename of the scene to load from
  65804. */
  65805. sceneFilename: string);
  65806. /**
  65807. * Execute the current task
  65808. * @param scene defines the scene where you want your assets to be loaded
  65809. * @param onSuccess is a callback called when the task is successfully executed
  65810. * @param onError is a callback called if an error occurs
  65811. */
  65812. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65813. }
  65814. /**
  65815. * Define a task used by AssetsManager to load text content
  65816. */
  65817. export class TextFileAssetTask extends AbstractAssetTask {
  65818. /**
  65819. * Defines the name of the task
  65820. */
  65821. name: string;
  65822. /**
  65823. * Defines the location of the file to load
  65824. */
  65825. url: string;
  65826. /**
  65827. * Gets the loaded text string
  65828. */
  65829. text: string;
  65830. /**
  65831. * Callback called when the task is successful
  65832. */
  65833. onSuccess: (task: TextFileAssetTask) => void;
  65834. /**
  65835. * Callback called when the task is successful
  65836. */
  65837. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65838. /**
  65839. * Creates a new TextFileAssetTask object
  65840. * @param name defines the name of the task
  65841. * @param url defines the location of the file to load
  65842. */
  65843. constructor(
  65844. /**
  65845. * Defines the name of the task
  65846. */
  65847. name: string,
  65848. /**
  65849. * Defines the location of the file to load
  65850. */
  65851. url: string);
  65852. /**
  65853. * Execute the current task
  65854. * @param scene defines the scene where you want your assets to be loaded
  65855. * @param onSuccess is a callback called when the task is successfully executed
  65856. * @param onError is a callback called if an error occurs
  65857. */
  65858. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65859. }
  65860. /**
  65861. * Define a task used by AssetsManager to load binary data
  65862. */
  65863. export class BinaryFileAssetTask extends AbstractAssetTask {
  65864. /**
  65865. * Defines the name of the task
  65866. */
  65867. name: string;
  65868. /**
  65869. * Defines the location of the file to load
  65870. */
  65871. url: string;
  65872. /**
  65873. * Gets the lodaded data (as an array buffer)
  65874. */
  65875. data: ArrayBuffer;
  65876. /**
  65877. * Callback called when the task is successful
  65878. */
  65879. onSuccess: (task: BinaryFileAssetTask) => void;
  65880. /**
  65881. * Callback called when the task is successful
  65882. */
  65883. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65884. /**
  65885. * Creates a new BinaryFileAssetTask object
  65886. * @param name defines the name of the new task
  65887. * @param url defines the location of the file to load
  65888. */
  65889. constructor(
  65890. /**
  65891. * Defines the name of the task
  65892. */
  65893. name: string,
  65894. /**
  65895. * Defines the location of the file to load
  65896. */
  65897. url: string);
  65898. /**
  65899. * Execute the current task
  65900. * @param scene defines the scene where you want your assets to be loaded
  65901. * @param onSuccess is a callback called when the task is successfully executed
  65902. * @param onError is a callback called if an error occurs
  65903. */
  65904. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65905. }
  65906. /**
  65907. * Define a task used by AssetsManager to load images
  65908. */
  65909. export class ImageAssetTask extends AbstractAssetTask {
  65910. /**
  65911. * Defines the name of the task
  65912. */
  65913. name: string;
  65914. /**
  65915. * Defines the location of the image to load
  65916. */
  65917. url: string;
  65918. /**
  65919. * Gets the loaded images
  65920. */
  65921. image: HTMLImageElement;
  65922. /**
  65923. * Callback called when the task is successful
  65924. */
  65925. onSuccess: (task: ImageAssetTask) => void;
  65926. /**
  65927. * Callback called when the task is successful
  65928. */
  65929. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65930. /**
  65931. * Creates a new ImageAssetTask
  65932. * @param name defines the name of the task
  65933. * @param url defines the location of the image to load
  65934. */
  65935. constructor(
  65936. /**
  65937. * Defines the name of the task
  65938. */
  65939. name: string,
  65940. /**
  65941. * Defines the location of the image to load
  65942. */
  65943. url: string);
  65944. /**
  65945. * Execute the current task
  65946. * @param scene defines the scene where you want your assets to be loaded
  65947. * @param onSuccess is a callback called when the task is successfully executed
  65948. * @param onError is a callback called if an error occurs
  65949. */
  65950. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65951. }
  65952. /**
  65953. * Defines the interface used by texture loading tasks
  65954. */
  65955. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65956. /**
  65957. * Gets the loaded texture
  65958. */
  65959. texture: TEX;
  65960. }
  65961. /**
  65962. * Define a task used by AssetsManager to load 2D textures
  65963. */
  65964. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65965. /**
  65966. * Defines the name of the task
  65967. */
  65968. name: string;
  65969. /**
  65970. * Defines the location of the file to load
  65971. */
  65972. url: string;
  65973. /**
  65974. * Defines if mipmap should not be generated (default is false)
  65975. */
  65976. noMipmap?: boolean | undefined;
  65977. /**
  65978. * Defines if texture must be inverted on Y axis (default is false)
  65979. */
  65980. invertY?: boolean | undefined;
  65981. /**
  65982. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65983. */
  65984. samplingMode: number;
  65985. /**
  65986. * Gets the loaded texture
  65987. */
  65988. texture: Texture;
  65989. /**
  65990. * Callback called when the task is successful
  65991. */
  65992. onSuccess: (task: TextureAssetTask) => void;
  65993. /**
  65994. * Callback called when the task is successful
  65995. */
  65996. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65997. /**
  65998. * Creates a new TextureAssetTask object
  65999. * @param name defines the name of the task
  66000. * @param url defines the location of the file to load
  66001. * @param noMipmap defines if mipmap should not be generated (default is false)
  66002. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66003. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66004. */
  66005. constructor(
  66006. /**
  66007. * Defines the name of the task
  66008. */
  66009. name: string,
  66010. /**
  66011. * Defines the location of the file to load
  66012. */
  66013. url: string,
  66014. /**
  66015. * Defines if mipmap should not be generated (default is false)
  66016. */
  66017. noMipmap?: boolean | undefined,
  66018. /**
  66019. * Defines if texture must be inverted on Y axis (default is false)
  66020. */
  66021. invertY?: boolean | undefined,
  66022. /**
  66023. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66024. */
  66025. samplingMode?: number);
  66026. /**
  66027. * Execute the current task
  66028. * @param scene defines the scene where you want your assets to be loaded
  66029. * @param onSuccess is a callback called when the task is successfully executed
  66030. * @param onError is a callback called if an error occurs
  66031. */
  66032. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66033. }
  66034. /**
  66035. * Define a task used by AssetsManager to load cube textures
  66036. */
  66037. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66038. /**
  66039. * Defines the name of the task
  66040. */
  66041. name: string;
  66042. /**
  66043. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66044. */
  66045. url: string;
  66046. /**
  66047. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66048. */
  66049. extensions?: string[] | undefined;
  66050. /**
  66051. * Defines if mipmaps should not be generated (default is false)
  66052. */
  66053. noMipmap?: boolean | undefined;
  66054. /**
  66055. * Defines the explicit list of files (undefined by default)
  66056. */
  66057. files?: string[] | undefined;
  66058. /**
  66059. * Gets the loaded texture
  66060. */
  66061. texture: CubeTexture;
  66062. /**
  66063. * Callback called when the task is successful
  66064. */
  66065. onSuccess: (task: CubeTextureAssetTask) => void;
  66066. /**
  66067. * Callback called when the task is successful
  66068. */
  66069. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66070. /**
  66071. * Creates a new CubeTextureAssetTask
  66072. * @param name defines the name of the task
  66073. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66074. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66075. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66076. * @param files defines the explicit list of files (undefined by default)
  66077. */
  66078. constructor(
  66079. /**
  66080. * Defines the name of the task
  66081. */
  66082. name: string,
  66083. /**
  66084. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66085. */
  66086. url: string,
  66087. /**
  66088. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66089. */
  66090. extensions?: string[] | undefined,
  66091. /**
  66092. * Defines if mipmaps should not be generated (default is false)
  66093. */
  66094. noMipmap?: boolean | undefined,
  66095. /**
  66096. * Defines the explicit list of files (undefined by default)
  66097. */
  66098. files?: string[] | undefined);
  66099. /**
  66100. * Execute the current task
  66101. * @param scene defines the scene where you want your assets to be loaded
  66102. * @param onSuccess is a callback called when the task is successfully executed
  66103. * @param onError is a callback called if an error occurs
  66104. */
  66105. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66106. }
  66107. /**
  66108. * Define a task used by AssetsManager to load HDR cube textures
  66109. */
  66110. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66111. /**
  66112. * Defines the name of the task
  66113. */
  66114. name: string;
  66115. /**
  66116. * Defines the location of the file to load
  66117. */
  66118. url: string;
  66119. /**
  66120. * Defines the desired size (the more it increases the longer the generation will be)
  66121. */
  66122. size: number;
  66123. /**
  66124. * Defines if mipmaps should not be generated (default is false)
  66125. */
  66126. noMipmap: boolean;
  66127. /**
  66128. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66129. */
  66130. generateHarmonics: boolean;
  66131. /**
  66132. * 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)
  66133. */
  66134. gammaSpace: boolean;
  66135. /**
  66136. * Internal Use Only
  66137. */
  66138. reserved: boolean;
  66139. /**
  66140. * Gets the loaded texture
  66141. */
  66142. texture: HDRCubeTexture;
  66143. /**
  66144. * Callback called when the task is successful
  66145. */
  66146. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66147. /**
  66148. * Callback called when the task is successful
  66149. */
  66150. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66151. /**
  66152. * Creates a new HDRCubeTextureAssetTask object
  66153. * @param name defines the name of the task
  66154. * @param url defines the location of the file to load
  66155. * @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.
  66156. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66157. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66158. * @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)
  66159. * @param reserved Internal use only
  66160. */
  66161. constructor(
  66162. /**
  66163. * Defines the name of the task
  66164. */
  66165. name: string,
  66166. /**
  66167. * Defines the location of the file to load
  66168. */
  66169. url: string,
  66170. /**
  66171. * Defines the desired size (the more it increases the longer the generation will be)
  66172. */
  66173. size: number,
  66174. /**
  66175. * Defines if mipmaps should not be generated (default is false)
  66176. */
  66177. noMipmap?: boolean,
  66178. /**
  66179. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66180. */
  66181. generateHarmonics?: boolean,
  66182. /**
  66183. * 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)
  66184. */
  66185. gammaSpace?: boolean,
  66186. /**
  66187. * Internal Use Only
  66188. */
  66189. reserved?: boolean);
  66190. /**
  66191. * Execute the current task
  66192. * @param scene defines the scene where you want your assets to be loaded
  66193. * @param onSuccess is a callback called when the task is successfully executed
  66194. * @param onError is a callback called if an error occurs
  66195. */
  66196. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66197. }
  66198. /**
  66199. * Define a task used by AssetsManager to load Equirectangular cube textures
  66200. */
  66201. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66202. /**
  66203. * Defines the name of the task
  66204. */
  66205. name: string;
  66206. /**
  66207. * Defines the location of the file to load
  66208. */
  66209. url: string;
  66210. /**
  66211. * Defines the desired size (the more it increases the longer the generation will be)
  66212. */
  66213. size: number;
  66214. /**
  66215. * Defines if mipmaps should not be generated (default is false)
  66216. */
  66217. noMipmap: boolean;
  66218. /**
  66219. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66220. * but the standard material would require them in Gamma space) (default is true)
  66221. */
  66222. gammaSpace: boolean;
  66223. /**
  66224. * Gets the loaded texture
  66225. */
  66226. texture: EquiRectangularCubeTexture;
  66227. /**
  66228. * Callback called when the task is successful
  66229. */
  66230. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66231. /**
  66232. * Callback called when the task is successful
  66233. */
  66234. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66235. /**
  66236. * Creates a new EquiRectangularCubeTextureAssetTask object
  66237. * @param name defines the name of the task
  66238. * @param url defines the location of the file to load
  66239. * @param size defines the desired size (the more it increases the longer the generation will be)
  66240. * If the size is omitted this implies you are using a preprocessed cubemap.
  66241. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66242. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66243. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66244. * (default is true)
  66245. */
  66246. constructor(
  66247. /**
  66248. * Defines the name of the task
  66249. */
  66250. name: string,
  66251. /**
  66252. * Defines the location of the file to load
  66253. */
  66254. url: string,
  66255. /**
  66256. * Defines the desired size (the more it increases the longer the generation will be)
  66257. */
  66258. size: number,
  66259. /**
  66260. * Defines if mipmaps should not be generated (default is false)
  66261. */
  66262. noMipmap?: boolean,
  66263. /**
  66264. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66265. * but the standard material would require them in Gamma space) (default is true)
  66266. */
  66267. gammaSpace?: boolean);
  66268. /**
  66269. * Execute the current task
  66270. * @param scene defines the scene where you want your assets to be loaded
  66271. * @param onSuccess is a callback called when the task is successfully executed
  66272. * @param onError is a callback called if an error occurs
  66273. */
  66274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66275. }
  66276. /**
  66277. * This class can be used to easily import assets into a scene
  66278. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66279. */
  66280. export class AssetsManager {
  66281. private _scene;
  66282. private _isLoading;
  66283. protected _tasks: AbstractAssetTask[];
  66284. protected _waitingTasksCount: number;
  66285. protected _totalTasksCount: number;
  66286. /**
  66287. * Callback called when all tasks are processed
  66288. */
  66289. onFinish: (tasks: AbstractAssetTask[]) => void;
  66290. /**
  66291. * Callback called when a task is successful
  66292. */
  66293. onTaskSuccess: (task: AbstractAssetTask) => void;
  66294. /**
  66295. * Callback called when a task had an error
  66296. */
  66297. onTaskError: (task: AbstractAssetTask) => void;
  66298. /**
  66299. * Callback called when a task is done (whatever the result is)
  66300. */
  66301. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66302. /**
  66303. * Observable called when all tasks are processed
  66304. */
  66305. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66306. /**
  66307. * Observable called when a task had an error
  66308. */
  66309. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66310. /**
  66311. * Observable called when all tasks were executed
  66312. */
  66313. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66314. /**
  66315. * Observable called when a task is done (whatever the result is)
  66316. */
  66317. onProgressObservable: Observable<IAssetsProgressEvent>;
  66318. /**
  66319. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66320. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66321. */
  66322. useDefaultLoadingScreen: boolean;
  66323. /**
  66324. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66325. * when all assets have been downloaded.
  66326. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66327. */
  66328. autoHideLoadingUI: boolean;
  66329. /**
  66330. * Creates a new AssetsManager
  66331. * @param scene defines the scene to work on
  66332. */
  66333. constructor(scene: Scene);
  66334. /**
  66335. * Add a MeshAssetTask to the list of active tasks
  66336. * @param taskName defines the name of the new task
  66337. * @param meshesNames defines the name of meshes to load
  66338. * @param rootUrl defines the root url to use to locate files
  66339. * @param sceneFilename defines the filename of the scene file
  66340. * @returns a new MeshAssetTask object
  66341. */
  66342. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66343. /**
  66344. * Add a TextFileAssetTask to the list of active tasks
  66345. * @param taskName defines the name of the new task
  66346. * @param url defines the url of the file to load
  66347. * @returns a new TextFileAssetTask object
  66348. */
  66349. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66350. /**
  66351. * Add a BinaryFileAssetTask to the list of active tasks
  66352. * @param taskName defines the name of the new task
  66353. * @param url defines the url of the file to load
  66354. * @returns a new BinaryFileAssetTask object
  66355. */
  66356. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66357. /**
  66358. * Add a ImageAssetTask to the list of active tasks
  66359. * @param taskName defines the name of the new task
  66360. * @param url defines the url of the file to load
  66361. * @returns a new ImageAssetTask object
  66362. */
  66363. addImageTask(taskName: string, url: string): ImageAssetTask;
  66364. /**
  66365. * Add a TextureAssetTask to the list of active tasks
  66366. * @param taskName defines the name of the new task
  66367. * @param url defines the url of the file to load
  66368. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66369. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66370. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66371. * @returns a new TextureAssetTask object
  66372. */
  66373. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66374. /**
  66375. * Add a CubeTextureAssetTask to the list of active tasks
  66376. * @param taskName defines the name of the new task
  66377. * @param url defines the url of the file to load
  66378. * @param extensions defines the extension to use to load the cube map (can be null)
  66379. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66380. * @param files defines the list of files to load (can be null)
  66381. * @returns a new CubeTextureAssetTask object
  66382. */
  66383. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66384. /**
  66385. *
  66386. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66387. * @param taskName defines the name of the new task
  66388. * @param url defines the url of the file to load
  66389. * @param size defines the size you want for the cubemap (can be null)
  66390. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66391. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66392. * @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)
  66393. * @param reserved Internal use only
  66394. * @returns a new HDRCubeTextureAssetTask object
  66395. */
  66396. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66397. /**
  66398. *
  66399. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66400. * @param taskName defines the name of the new task
  66401. * @param url defines the url of the file to load
  66402. * @param size defines the size you want for the cubemap (can be null)
  66403. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66404. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66405. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66406. * @returns a new EquiRectangularCubeTextureAssetTask object
  66407. */
  66408. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66409. /**
  66410. * Remove a task from the assets manager.
  66411. * @param task the task to remove
  66412. */
  66413. removeTask(task: AbstractAssetTask): void;
  66414. private _decreaseWaitingTasksCount;
  66415. private _runTask;
  66416. /**
  66417. * Reset the AssetsManager and remove all tasks
  66418. * @return the current instance of the AssetsManager
  66419. */
  66420. reset(): AssetsManager;
  66421. /**
  66422. * Start the loading process
  66423. * @return the current instance of the AssetsManager
  66424. */
  66425. load(): AssetsManager;
  66426. /**
  66427. * Start the loading process as an async operation
  66428. * @return a promise returning the list of failed tasks
  66429. */
  66430. loadAsync(): Promise<void>;
  66431. }
  66432. }
  66433. declare module "babylonjs/Misc/deferred" {
  66434. /**
  66435. * Wrapper class for promise with external resolve and reject.
  66436. */
  66437. export class Deferred<T> {
  66438. /**
  66439. * The promise associated with this deferred object.
  66440. */
  66441. readonly promise: Promise<T>;
  66442. private _resolve;
  66443. private _reject;
  66444. /**
  66445. * The resolve method of the promise associated with this deferred object.
  66446. */
  66447. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  66448. /**
  66449. * The reject method of the promise associated with this deferred object.
  66450. */
  66451. readonly reject: (reason?: any) => void;
  66452. /**
  66453. * Constructor for this deferred object.
  66454. */
  66455. constructor();
  66456. }
  66457. }
  66458. declare module "babylonjs/Misc/meshExploder" {
  66459. import { Mesh } from "babylonjs/Meshes/mesh";
  66460. /**
  66461. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66462. */
  66463. export class MeshExploder {
  66464. private _centerMesh;
  66465. private _meshes;
  66466. private _meshesOrigins;
  66467. private _toCenterVectors;
  66468. private _scaledDirection;
  66469. private _newPosition;
  66470. private _centerPosition;
  66471. /**
  66472. * Explodes meshes from a center mesh.
  66473. * @param meshes The meshes to explode.
  66474. * @param centerMesh The mesh to be center of explosion.
  66475. */
  66476. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66477. private _setCenterMesh;
  66478. /**
  66479. * Get class name
  66480. * @returns "MeshExploder"
  66481. */
  66482. getClassName(): string;
  66483. /**
  66484. * "Exploded meshes"
  66485. * @returns Array of meshes with the centerMesh at index 0.
  66486. */
  66487. getMeshes(): Array<Mesh>;
  66488. /**
  66489. * Explodes meshes giving a specific direction
  66490. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66491. */
  66492. explode(direction?: number): void;
  66493. }
  66494. }
  66495. declare module "babylonjs/Misc/filesInput" {
  66496. import { Engine } from "babylonjs/Engines/engine";
  66497. import { Scene } from "babylonjs/scene";
  66498. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  66499. /**
  66500. * Class used to help managing file picking and drag'n'drop
  66501. */
  66502. export class FilesInput {
  66503. /**
  66504. * List of files ready to be loaded
  66505. */
  66506. static readonly FilesToLoad: {
  66507. [key: string]: File;
  66508. };
  66509. /**
  66510. * Callback called when a file is processed
  66511. */
  66512. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66513. private _engine;
  66514. private _currentScene;
  66515. private _sceneLoadedCallback;
  66516. private _progressCallback;
  66517. private _additionalRenderLoopLogicCallback;
  66518. private _textureLoadingCallback;
  66519. private _startingProcessingFilesCallback;
  66520. private _onReloadCallback;
  66521. private _errorCallback;
  66522. private _elementToMonitor;
  66523. private _sceneFileToLoad;
  66524. private _filesToLoad;
  66525. /**
  66526. * Creates a new FilesInput
  66527. * @param engine defines the rendering engine
  66528. * @param scene defines the hosting scene
  66529. * @param sceneLoadedCallback callback called when scene is loaded
  66530. * @param progressCallback callback called to track progress
  66531. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66532. * @param textureLoadingCallback callback called when a texture is loading
  66533. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66534. * @param onReloadCallback callback called when a reload is requested
  66535. * @param errorCallback callback call if an error occurs
  66536. */
  66537. 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);
  66538. private _dragEnterHandler;
  66539. private _dragOverHandler;
  66540. private _dropHandler;
  66541. /**
  66542. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66543. * @param elementToMonitor defines the DOM element to track
  66544. */
  66545. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66546. /**
  66547. * Release all associated resources
  66548. */
  66549. dispose(): void;
  66550. private renderFunction;
  66551. private drag;
  66552. private drop;
  66553. private _traverseFolder;
  66554. private _processFiles;
  66555. /**
  66556. * Load files from a drop event
  66557. * @param event defines the drop event to use as source
  66558. */
  66559. loadFiles(event: any): void;
  66560. private _processReload;
  66561. /**
  66562. * Reload the current scene from the loaded files
  66563. */
  66564. reload(): void;
  66565. }
  66566. }
  66567. declare module "babylonjs/Misc/HighDynamicRange/index" {
  66568. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  66569. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  66570. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  66571. }
  66572. declare module "babylonjs/Misc/sceneOptimizer" {
  66573. import { Scene, IDisposable } from "babylonjs/scene";
  66574. import { Observable } from "babylonjs/Misc/observable";
  66575. /**
  66576. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66577. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66578. */
  66579. export class SceneOptimization {
  66580. /**
  66581. * Defines the priority of this optimization (0 by default which means first in the list)
  66582. */
  66583. priority: number;
  66584. /**
  66585. * Gets a string describing the action executed by the current optimization
  66586. * @returns description string
  66587. */
  66588. getDescription(): string;
  66589. /**
  66590. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66591. * @param scene defines the current scene where to apply this optimization
  66592. * @param optimizer defines the current optimizer
  66593. * @returns true if everything that can be done was applied
  66594. */
  66595. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66596. /**
  66597. * Creates the SceneOptimization object
  66598. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66599. * @param desc defines the description associated with the optimization
  66600. */
  66601. constructor(
  66602. /**
  66603. * Defines the priority of this optimization (0 by default which means first in the list)
  66604. */
  66605. priority?: number);
  66606. }
  66607. /**
  66608. * Defines an optimization used to reduce the size of render target textures
  66609. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66610. */
  66611. export class TextureOptimization extends SceneOptimization {
  66612. /**
  66613. * Defines the priority of this optimization (0 by default which means first in the list)
  66614. */
  66615. priority: number;
  66616. /**
  66617. * 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
  66618. */
  66619. maximumSize: number;
  66620. /**
  66621. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66622. */
  66623. step: number;
  66624. /**
  66625. * Gets a string describing the action executed by the current optimization
  66626. * @returns description string
  66627. */
  66628. getDescription(): string;
  66629. /**
  66630. * Creates the TextureOptimization object
  66631. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66632. * @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
  66633. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66634. */
  66635. constructor(
  66636. /**
  66637. * Defines the priority of this optimization (0 by default which means first in the list)
  66638. */
  66639. priority?: number,
  66640. /**
  66641. * 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
  66642. */
  66643. maximumSize?: number,
  66644. /**
  66645. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66646. */
  66647. step?: number);
  66648. /**
  66649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66650. * @param scene defines the current scene where to apply this optimization
  66651. * @param optimizer defines the current optimizer
  66652. * @returns true if everything that can be done was applied
  66653. */
  66654. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66655. }
  66656. /**
  66657. * Defines an optimization used to increase or decrease the rendering resolution
  66658. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66659. */
  66660. export class HardwareScalingOptimization extends SceneOptimization {
  66661. /**
  66662. * Defines the priority of this optimization (0 by default which means first in the list)
  66663. */
  66664. priority: number;
  66665. /**
  66666. * Defines the maximum scale to use (2 by default)
  66667. */
  66668. maximumScale: number;
  66669. /**
  66670. * Defines the step to use between two passes (0.5 by default)
  66671. */
  66672. step: number;
  66673. private _currentScale;
  66674. private _directionOffset;
  66675. /**
  66676. * Gets a string describing the action executed by the current optimization
  66677. * @return description string
  66678. */
  66679. getDescription(): string;
  66680. /**
  66681. * Creates the HardwareScalingOptimization object
  66682. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66683. * @param maximumScale defines the maximum scale to use (2 by default)
  66684. * @param step defines the step to use between two passes (0.5 by default)
  66685. */
  66686. constructor(
  66687. /**
  66688. * Defines the priority of this optimization (0 by default which means first in the list)
  66689. */
  66690. priority?: number,
  66691. /**
  66692. * Defines the maximum scale to use (2 by default)
  66693. */
  66694. maximumScale?: number,
  66695. /**
  66696. * Defines the step to use between two passes (0.5 by default)
  66697. */
  66698. step?: number);
  66699. /**
  66700. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66701. * @param scene defines the current scene where to apply this optimization
  66702. * @param optimizer defines the current optimizer
  66703. * @returns true if everything that can be done was applied
  66704. */
  66705. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66706. }
  66707. /**
  66708. * Defines an optimization used to remove shadows
  66709. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66710. */
  66711. export class ShadowsOptimization extends SceneOptimization {
  66712. /**
  66713. * Gets a string describing the action executed by the current optimization
  66714. * @return description string
  66715. */
  66716. getDescription(): string;
  66717. /**
  66718. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66719. * @param scene defines the current scene where to apply this optimization
  66720. * @param optimizer defines the current optimizer
  66721. * @returns true if everything that can be done was applied
  66722. */
  66723. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66724. }
  66725. /**
  66726. * Defines an optimization used to turn post-processes off
  66727. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66728. */
  66729. export class PostProcessesOptimization extends SceneOptimization {
  66730. /**
  66731. * Gets a string describing the action executed by the current optimization
  66732. * @return description string
  66733. */
  66734. getDescription(): string;
  66735. /**
  66736. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66737. * @param scene defines the current scene where to apply this optimization
  66738. * @param optimizer defines the current optimizer
  66739. * @returns true if everything that can be done was applied
  66740. */
  66741. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66742. }
  66743. /**
  66744. * Defines an optimization used to turn lens flares off
  66745. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66746. */
  66747. export class LensFlaresOptimization extends SceneOptimization {
  66748. /**
  66749. * Gets a string describing the action executed by the current optimization
  66750. * @return description string
  66751. */
  66752. getDescription(): string;
  66753. /**
  66754. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66755. * @param scene defines the current scene where to apply this optimization
  66756. * @param optimizer defines the current optimizer
  66757. * @returns true if everything that can be done was applied
  66758. */
  66759. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66760. }
  66761. /**
  66762. * Defines an optimization based on user defined callback.
  66763. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66764. */
  66765. export class CustomOptimization extends SceneOptimization {
  66766. /**
  66767. * Callback called to apply the custom optimization.
  66768. */
  66769. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66770. /**
  66771. * Callback called to get custom description
  66772. */
  66773. onGetDescription: () => string;
  66774. /**
  66775. * Gets a string describing the action executed by the current optimization
  66776. * @returns description string
  66777. */
  66778. getDescription(): string;
  66779. /**
  66780. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66781. * @param scene defines the current scene where to apply this optimization
  66782. * @param optimizer defines the current optimizer
  66783. * @returns true if everything that can be done was applied
  66784. */
  66785. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66786. }
  66787. /**
  66788. * Defines an optimization used to turn particles off
  66789. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66790. */
  66791. export class ParticlesOptimization extends SceneOptimization {
  66792. /**
  66793. * Gets a string describing the action executed by the current optimization
  66794. * @return description string
  66795. */
  66796. getDescription(): string;
  66797. /**
  66798. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66799. * @param scene defines the current scene where to apply this optimization
  66800. * @param optimizer defines the current optimizer
  66801. * @returns true if everything that can be done was applied
  66802. */
  66803. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66804. }
  66805. /**
  66806. * Defines an optimization used to turn render targets off
  66807. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66808. */
  66809. export class RenderTargetsOptimization extends SceneOptimization {
  66810. /**
  66811. * Gets a string describing the action executed by the current optimization
  66812. * @return description string
  66813. */
  66814. getDescription(): string;
  66815. /**
  66816. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66817. * @param scene defines the current scene where to apply this optimization
  66818. * @param optimizer defines the current optimizer
  66819. * @returns true if everything that can be done was applied
  66820. */
  66821. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66822. }
  66823. /**
  66824. * Defines an optimization used to merge meshes with compatible materials
  66825. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66826. */
  66827. export class MergeMeshesOptimization extends SceneOptimization {
  66828. private static _UpdateSelectionTree;
  66829. /**
  66830. * Gets or sets a boolean which defines if optimization octree has to be updated
  66831. */
  66832. /**
  66833. * Gets or sets a boolean which defines if optimization octree has to be updated
  66834. */
  66835. static UpdateSelectionTree: boolean;
  66836. /**
  66837. * Gets a string describing the action executed by the current optimization
  66838. * @return description string
  66839. */
  66840. getDescription(): string;
  66841. private _canBeMerged;
  66842. /**
  66843. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66844. * @param scene defines the current scene where to apply this optimization
  66845. * @param optimizer defines the current optimizer
  66846. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66847. * @returns true if everything that can be done was applied
  66848. */
  66849. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66850. }
  66851. /**
  66852. * Defines a list of options used by SceneOptimizer
  66853. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66854. */
  66855. export class SceneOptimizerOptions {
  66856. /**
  66857. * Defines the target frame rate to reach (60 by default)
  66858. */
  66859. targetFrameRate: number;
  66860. /**
  66861. * Defines the interval between two checkes (2000ms by default)
  66862. */
  66863. trackerDuration: number;
  66864. /**
  66865. * Gets the list of optimizations to apply
  66866. */
  66867. optimizations: SceneOptimization[];
  66868. /**
  66869. * Creates a new list of options used by SceneOptimizer
  66870. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66871. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66872. */
  66873. constructor(
  66874. /**
  66875. * Defines the target frame rate to reach (60 by default)
  66876. */
  66877. targetFrameRate?: number,
  66878. /**
  66879. * Defines the interval between two checkes (2000ms by default)
  66880. */
  66881. trackerDuration?: number);
  66882. /**
  66883. * Add a new optimization
  66884. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66885. * @returns the current SceneOptimizerOptions
  66886. */
  66887. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66888. /**
  66889. * Add a new custom optimization
  66890. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66891. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66892. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66893. * @returns the current SceneOptimizerOptions
  66894. */
  66895. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66896. /**
  66897. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66898. * @param targetFrameRate defines the target frame rate (60 by default)
  66899. * @returns a SceneOptimizerOptions object
  66900. */
  66901. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66902. /**
  66903. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66904. * @param targetFrameRate defines the target frame rate (60 by default)
  66905. * @returns a SceneOptimizerOptions object
  66906. */
  66907. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66908. /**
  66909. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66910. * @param targetFrameRate defines the target frame rate (60 by default)
  66911. * @returns a SceneOptimizerOptions object
  66912. */
  66913. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66914. }
  66915. /**
  66916. * Class used to run optimizations in order to reach a target frame rate
  66917. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66918. */
  66919. export class SceneOptimizer implements IDisposable {
  66920. private _isRunning;
  66921. private _options;
  66922. private _scene;
  66923. private _currentPriorityLevel;
  66924. private _targetFrameRate;
  66925. private _trackerDuration;
  66926. private _currentFrameRate;
  66927. private _sceneDisposeObserver;
  66928. private _improvementMode;
  66929. /**
  66930. * Defines an observable called when the optimizer reaches the target frame rate
  66931. */
  66932. onSuccessObservable: Observable<SceneOptimizer>;
  66933. /**
  66934. * Defines an observable called when the optimizer enables an optimization
  66935. */
  66936. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66937. /**
  66938. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66939. */
  66940. onFailureObservable: Observable<SceneOptimizer>;
  66941. /**
  66942. * Gets a boolean indicating if the optimizer is in improvement mode
  66943. */
  66944. readonly isInImprovementMode: boolean;
  66945. /**
  66946. * Gets the current priority level (0 at start)
  66947. */
  66948. readonly currentPriorityLevel: number;
  66949. /**
  66950. * Gets the current frame rate checked by the SceneOptimizer
  66951. */
  66952. readonly currentFrameRate: number;
  66953. /**
  66954. * Gets or sets the current target frame rate (60 by default)
  66955. */
  66956. /**
  66957. * Gets or sets the current target frame rate (60 by default)
  66958. */
  66959. targetFrameRate: number;
  66960. /**
  66961. * Gets or sets the current interval between two checks (every 2000ms by default)
  66962. */
  66963. /**
  66964. * Gets or sets the current interval between two checks (every 2000ms by default)
  66965. */
  66966. trackerDuration: number;
  66967. /**
  66968. * Gets the list of active optimizations
  66969. */
  66970. readonly optimizations: SceneOptimization[];
  66971. /**
  66972. * Creates a new SceneOptimizer
  66973. * @param scene defines the scene to work on
  66974. * @param options defines the options to use with the SceneOptimizer
  66975. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66976. * @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)
  66977. */
  66978. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66979. /**
  66980. * Stops the current optimizer
  66981. */
  66982. stop(): void;
  66983. /**
  66984. * Reset the optimizer to initial step (current priority level = 0)
  66985. */
  66986. reset(): void;
  66987. /**
  66988. * Start the optimizer. By default it will try to reach a specific framerate
  66989. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66990. */
  66991. start(): void;
  66992. private _checkCurrentState;
  66993. /**
  66994. * Release all resources
  66995. */
  66996. dispose(): void;
  66997. /**
  66998. * Helper function to create a SceneOptimizer with one single line of code
  66999. * @param scene defines the scene to work on
  67000. * @param options defines the options to use with the SceneOptimizer
  67001. * @param onSuccess defines a callback to call on success
  67002. * @param onFailure defines a callback to call on failure
  67003. * @returns the new SceneOptimizer object
  67004. */
  67005. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67006. }
  67007. }
  67008. declare module "babylonjs/Misc/sceneSerializer" {
  67009. import { Scene } from "babylonjs/scene";
  67010. /**
  67011. * Class used to serialize a scene into a string
  67012. */
  67013. export class SceneSerializer {
  67014. /**
  67015. * Clear cache used by a previous serialization
  67016. */
  67017. static ClearCache(): void;
  67018. /**
  67019. * Serialize a scene into a JSON compatible object
  67020. * @param scene defines the scene to serialize
  67021. * @returns a JSON compatible object
  67022. */
  67023. static Serialize(scene: Scene): any;
  67024. /**
  67025. * Serialize a mesh into a JSON compatible object
  67026. * @param toSerialize defines the mesh to serialize
  67027. * @param withParents defines if parents must be serialized as well
  67028. * @param withChildren defines if children must be serialized as well
  67029. * @returns a JSON compatible object
  67030. */
  67031. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67032. }
  67033. }
  67034. declare module "babylonjs/Misc/textureTools" {
  67035. import { Texture } from "babylonjs/Materials/Textures/texture";
  67036. /**
  67037. * Class used to host texture specific utilities
  67038. */
  67039. export class TextureTools {
  67040. /**
  67041. * Uses the GPU to create a copy texture rescaled at a given size
  67042. * @param texture Texture to copy from
  67043. * @param width defines the desired width
  67044. * @param height defines the desired height
  67045. * @param useBilinearMode defines if bilinear mode has to be used
  67046. * @return the generated texture
  67047. */
  67048. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67049. }
  67050. }
  67051. declare module "babylonjs/Misc/videoRecorder" {
  67052. import { Nullable } from "babylonjs/types";
  67053. import { Engine } from "babylonjs/Engines/engine";
  67054. /**
  67055. * This represents the different options available for the video capture.
  67056. */
  67057. export interface VideoRecorderOptions {
  67058. /** Defines the mime type of the video. */
  67059. mimeType: string;
  67060. /** Defines the FPS the video should be recorded at. */
  67061. fps: number;
  67062. /** Defines the chunk size for the recording data. */
  67063. recordChunckSize: number;
  67064. /** The audio tracks to attach to the recording. */
  67065. audioTracks?: MediaStreamTrack[];
  67066. }
  67067. /**
  67068. * This can help with recording videos from BabylonJS.
  67069. * This is based on the available WebRTC functionalities of the browser.
  67070. *
  67071. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67072. */
  67073. export class VideoRecorder {
  67074. private static readonly _defaultOptions;
  67075. /**
  67076. * Returns whether or not the VideoRecorder is available in your browser.
  67077. * @param engine Defines the Babylon Engine.
  67078. * @returns true if supported otherwise false.
  67079. */
  67080. static IsSupported(engine: Engine): boolean;
  67081. private readonly _options;
  67082. private _canvas;
  67083. private _mediaRecorder;
  67084. private _recordedChunks;
  67085. private _fileName;
  67086. private _resolve;
  67087. private _reject;
  67088. /**
  67089. * True when a recording is already in progress.
  67090. */
  67091. readonly isRecording: boolean;
  67092. /**
  67093. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67094. * @param engine Defines the BabylonJS Engine you wish to record.
  67095. * @param options Defines options that can be used to customize the capture.
  67096. */
  67097. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67098. /**
  67099. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67100. */
  67101. stopRecording(): void;
  67102. /**
  67103. * Starts recording the canvas for a max duration specified in parameters.
  67104. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67105. * If null no automatic download will start and you can rely on the promise to get the data back.
  67106. * @param maxDuration Defines the maximum recording time in seconds.
  67107. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67108. * @return A promise callback at the end of the recording with the video data in Blob.
  67109. */
  67110. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67111. /**
  67112. * Releases internal resources used during the recording.
  67113. */
  67114. dispose(): void;
  67115. private _handleDataAvailable;
  67116. private _handleError;
  67117. private _handleStop;
  67118. }
  67119. }
  67120. declare module "babylonjs/Misc/screenshotTools" {
  67121. import { Camera } from "babylonjs/Cameras/camera";
  67122. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67123. import { Engine } from "babylonjs/Engines/engine";
  67124. /**
  67125. * Class containing a set of static utilities functions for screenshots
  67126. */
  67127. export class ScreenshotTools {
  67128. /**
  67129. * Captures a screenshot of the current rendering
  67130. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67131. * @param engine defines the rendering engine
  67132. * @param camera defines the source camera
  67133. * @param size This parameter can be set to a single number or to an object with the
  67134. * following (optional) properties: precision, width, height. If a single number is passed,
  67135. * it will be used for both width and height. If an object is passed, the screenshot size
  67136. * will be derived from the parameters. The precision property is a multiplier allowing
  67137. * rendering at a higher or lower resolution
  67138. * @param successCallback defines the callback receives a single parameter which contains the
  67139. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67140. * src parameter of an <img> to display it
  67141. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67142. * Check your browser for supported MIME types
  67143. */
  67144. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67145. /**
  67146. * Captures a screenshot of the current rendering
  67147. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67148. * @param engine defines the rendering engine
  67149. * @param camera defines the source camera
  67150. * @param size This parameter can be set to a single number or to an object with the
  67151. * following (optional) properties: precision, width, height. If a single number is passed,
  67152. * it will be used for both width and height. If an object is passed, the screenshot size
  67153. * will be derived from the parameters. The precision property is a multiplier allowing
  67154. * rendering at a higher or lower resolution
  67155. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67156. * Check your browser for supported MIME types
  67157. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67158. * to the src parameter of an <img> to display it
  67159. */
  67160. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67161. /**
  67162. * Generates an image screenshot from the specified camera.
  67163. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67164. * @param engine The engine to use for rendering
  67165. * @param camera The camera to use for rendering
  67166. * @param size This parameter can be set to a single number or to an object with the
  67167. * following (optional) properties: precision, width, height. If a single number is passed,
  67168. * it will be used for both width and height. If an object is passed, the screenshot size
  67169. * will be derived from the parameters. The precision property is a multiplier allowing
  67170. * rendering at a higher or lower resolution
  67171. * @param successCallback The callback receives a single parameter which contains the
  67172. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67173. * src parameter of an <img> to display it
  67174. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67175. * Check your browser for supported MIME types
  67176. * @param samples Texture samples (default: 1)
  67177. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67178. * @param fileName A name for for the downloaded file.
  67179. */
  67180. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67181. /**
  67182. * Generates an image screenshot from the specified camera.
  67183. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67184. * @param engine The engine to use for rendering
  67185. * @param camera The camera to use for rendering
  67186. * @param size This parameter can be set to a single number or to an object with the
  67187. * following (optional) properties: precision, width, height. If a single number is passed,
  67188. * it will be used for both width and height. If an object is passed, the screenshot size
  67189. * will be derived from the parameters. The precision property is a multiplier allowing
  67190. * rendering at a higher or lower resolution
  67191. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67192. * Check your browser for supported MIME types
  67193. * @param samples Texture samples (default: 1)
  67194. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67195. * @param fileName A name for for the downloaded file.
  67196. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67197. * to the src parameter of an <img> to display it
  67198. */
  67199. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67200. /**
  67201. * Gets height and width for screenshot size
  67202. * @private
  67203. */
  67204. private static _getScreenshotSize;
  67205. }
  67206. }
  67207. declare module "babylonjs/Misc/index" {
  67208. export * from "babylonjs/Misc/andOrNotEvaluator";
  67209. export * from "babylonjs/Misc/assetsManager";
  67210. export * from "babylonjs/Misc/dds";
  67211. export * from "babylonjs/Misc/decorators";
  67212. export * from "babylonjs/Misc/deferred";
  67213. export * from "babylonjs/Misc/environmentTextureTools";
  67214. export * from "babylonjs/Misc/meshExploder";
  67215. export * from "babylonjs/Misc/filesInput";
  67216. export * from "babylonjs/Misc/HighDynamicRange/index";
  67217. export * from "babylonjs/Misc/khronosTextureContainer";
  67218. export * from "babylonjs/Misc/observable";
  67219. export * from "babylonjs/Misc/performanceMonitor";
  67220. export * from "babylonjs/Misc/promise";
  67221. export * from "babylonjs/Misc/sceneOptimizer";
  67222. export * from "babylonjs/Misc/sceneSerializer";
  67223. export * from "babylonjs/Misc/smartArray";
  67224. export * from "babylonjs/Misc/stringDictionary";
  67225. export * from "babylonjs/Misc/tags";
  67226. export * from "babylonjs/Misc/textureTools";
  67227. export * from "babylonjs/Misc/tga";
  67228. export * from "babylonjs/Misc/tools";
  67229. export * from "babylonjs/Misc/videoRecorder";
  67230. export * from "babylonjs/Misc/virtualJoystick";
  67231. export * from "babylonjs/Misc/workerPool";
  67232. export * from "babylonjs/Misc/logger";
  67233. export * from "babylonjs/Misc/typeStore";
  67234. export * from "babylonjs/Misc/filesInputStore";
  67235. export * from "babylonjs/Misc/deepCopier";
  67236. export * from "babylonjs/Misc/pivotTools";
  67237. export * from "babylonjs/Misc/precisionDate";
  67238. export * from "babylonjs/Misc/screenshotTools";
  67239. export * from "babylonjs/Misc/typeStore";
  67240. export * from "babylonjs/Misc/webRequest";
  67241. export * from "babylonjs/Misc/iInspectable";
  67242. export * from "babylonjs/Misc/brdfTextureTools";
  67243. export * from "babylonjs/Misc/rgbdTextureTools";
  67244. export * from "babylonjs/Misc/gradients";
  67245. export * from "babylonjs/Misc/perfCounter";
  67246. export * from "babylonjs/Misc/fileRequest";
  67247. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67248. export * from "babylonjs/Misc/retryStrategy";
  67249. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67250. export * from "babylonjs/Misc/canvasGenerator";
  67251. export * from "babylonjs/Misc/fileTools";
  67252. export * from "babylonjs/Misc/stringTools";
  67253. }
  67254. declare module "babylonjs/index" {
  67255. export * from "babylonjs/abstractScene";
  67256. export * from "babylonjs/Actions/index";
  67257. export * from "babylonjs/Animations/index";
  67258. export * from "babylonjs/assetContainer";
  67259. export * from "babylonjs/Audio/index";
  67260. export * from "babylonjs/Behaviors/index";
  67261. export * from "babylonjs/Bones/index";
  67262. export * from "babylonjs/Cameras/index";
  67263. export * from "babylonjs/Collisions/index";
  67264. export * from "babylonjs/Culling/index";
  67265. export * from "babylonjs/Debug/index";
  67266. export * from "babylonjs/Engines/index";
  67267. export * from "babylonjs/Events/index";
  67268. export * from "babylonjs/Gamepads/index";
  67269. export * from "babylonjs/Gizmos/index";
  67270. export * from "babylonjs/Helpers/index";
  67271. export * from "babylonjs/Instrumentation/index";
  67272. export * from "babylonjs/Layers/index";
  67273. export * from "babylonjs/LensFlares/index";
  67274. export * from "babylonjs/Lights/index";
  67275. export * from "babylonjs/Loading/index";
  67276. export * from "babylonjs/Materials/index";
  67277. export * from "babylonjs/Maths/index";
  67278. export * from "babylonjs/Meshes/index";
  67279. export * from "babylonjs/Morph/index";
  67280. export * from "babylonjs/Navigation/index";
  67281. export * from "babylonjs/node";
  67282. export * from "babylonjs/Offline/index";
  67283. export * from "babylonjs/Particles/index";
  67284. export * from "babylonjs/Physics/index";
  67285. export * from "babylonjs/PostProcesses/index";
  67286. export * from "babylonjs/Probes/index";
  67287. export * from "babylonjs/Rendering/index";
  67288. export * from "babylonjs/scene";
  67289. export * from "babylonjs/sceneComponent";
  67290. export * from "babylonjs/Sprites/index";
  67291. export * from "babylonjs/States/index";
  67292. export * from "babylonjs/Misc/index";
  67293. export * from "babylonjs/types";
  67294. }
  67295. declare module "babylonjs/Animations/pathCursor" {
  67296. import { Vector3 } from "babylonjs/Maths/math.vector";
  67297. import { Path2 } from "babylonjs/Maths/math.path";
  67298. /**
  67299. * A cursor which tracks a point on a path
  67300. */
  67301. export class PathCursor {
  67302. private path;
  67303. /**
  67304. * Stores path cursor callbacks for when an onchange event is triggered
  67305. */
  67306. private _onchange;
  67307. /**
  67308. * The value of the path cursor
  67309. */
  67310. value: number;
  67311. /**
  67312. * The animation array of the path cursor
  67313. */
  67314. animations: Animation[];
  67315. /**
  67316. * Initializes the path cursor
  67317. * @param path The path to track
  67318. */
  67319. constructor(path: Path2);
  67320. /**
  67321. * Gets the cursor point on the path
  67322. * @returns A point on the path cursor at the cursor location
  67323. */
  67324. getPoint(): Vector3;
  67325. /**
  67326. * Moves the cursor ahead by the step amount
  67327. * @param step The amount to move the cursor forward
  67328. * @returns This path cursor
  67329. */
  67330. moveAhead(step?: number): PathCursor;
  67331. /**
  67332. * Moves the cursor behind by the step amount
  67333. * @param step The amount to move the cursor back
  67334. * @returns This path cursor
  67335. */
  67336. moveBack(step?: number): PathCursor;
  67337. /**
  67338. * Moves the cursor by the step amount
  67339. * If the step amount is greater than one, an exception is thrown
  67340. * @param step The amount to move the cursor
  67341. * @returns This path cursor
  67342. */
  67343. move(step: number): PathCursor;
  67344. /**
  67345. * Ensures that the value is limited between zero and one
  67346. * @returns This path cursor
  67347. */
  67348. private ensureLimits;
  67349. /**
  67350. * Runs onchange callbacks on change (used by the animation engine)
  67351. * @returns This path cursor
  67352. */
  67353. private raiseOnChange;
  67354. /**
  67355. * Executes a function on change
  67356. * @param f A path cursor onchange callback
  67357. * @returns This path cursor
  67358. */
  67359. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67360. }
  67361. }
  67362. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  67363. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  67364. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  67365. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  67366. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  67367. }
  67368. declare module "babylonjs/Engines/Processors/Expressions/index" {
  67369. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  67370. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  67371. }
  67372. declare module "babylonjs/Engines/Processors/index" {
  67373. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  67374. export * from "babylonjs/Engines/Processors/Expressions/index";
  67375. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  67376. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  67377. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  67378. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  67379. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  67380. export * from "babylonjs/Engines/Processors/shaderProcessor";
  67381. }
  67382. declare module "babylonjs/Legacy/legacy" {
  67383. import * as Babylon from "babylonjs/index";
  67384. export * from "babylonjs/index";
  67385. }
  67386. declare module "babylonjs/Shaders/blur.fragment" {
  67387. /** @hidden */
  67388. export var blurPixelShader: {
  67389. name: string;
  67390. shader: string;
  67391. };
  67392. }
  67393. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  67394. /** @hidden */
  67395. export var pointCloudVertexDeclaration: {
  67396. name: string;
  67397. shader: string;
  67398. };
  67399. }
  67400. declare module "babylonjs" {
  67401. export * from "babylonjs/Legacy/legacy";
  67402. }
  67403. declare module BABYLON {
  67404. /** Alias type for value that can be null */
  67405. export type Nullable<T> = T | null;
  67406. /**
  67407. * Alias type for number that are floats
  67408. * @ignorenaming
  67409. */
  67410. export type float = number;
  67411. /**
  67412. * Alias type for number that are doubles.
  67413. * @ignorenaming
  67414. */
  67415. export type double = number;
  67416. /**
  67417. * Alias type for number that are integer
  67418. * @ignorenaming
  67419. */
  67420. export type int = number;
  67421. /** Alias type for number array or Float32Array */
  67422. export type FloatArray = number[] | Float32Array;
  67423. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  67424. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  67425. /**
  67426. * Alias for types that can be used by a Buffer or VertexBuffer.
  67427. */
  67428. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  67429. /**
  67430. * Alias type for primitive types
  67431. * @ignorenaming
  67432. */
  67433. type Primitive = undefined | null | boolean | string | number | Function;
  67434. /**
  67435. * Type modifier to make all the properties of an object Readonly
  67436. */
  67437. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  67438. /**
  67439. * Type modifier to make all the properties of an object Readonly recursively
  67440. */
  67441. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  67442. /**
  67443. * Type modifier to make object properties readonly.
  67444. */
  67445. export type DeepImmutableObject<T> = {
  67446. readonly [K in keyof T]: DeepImmutable<T[K]>;
  67447. };
  67448. /** @hidden */
  67449. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  67450. }
  67451. }
  67452. declare module BABYLON {
  67453. /**
  67454. * A class serves as a medium between the observable and its observers
  67455. */
  67456. export class EventState {
  67457. /**
  67458. * Create a new EventState
  67459. * @param mask defines the mask associated with this state
  67460. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67461. * @param target defines the original target of the state
  67462. * @param currentTarget defines the current target of the state
  67463. */
  67464. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67465. /**
  67466. * Initialize the current event state
  67467. * @param mask defines the mask associated with this state
  67468. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67469. * @param target defines the original target of the state
  67470. * @param currentTarget defines the current target of the state
  67471. * @returns the current event state
  67472. */
  67473. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67474. /**
  67475. * An Observer can set this property to true to prevent subsequent observers of being notified
  67476. */
  67477. skipNextObservers: boolean;
  67478. /**
  67479. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67480. */
  67481. mask: number;
  67482. /**
  67483. * The object that originally notified the event
  67484. */
  67485. target?: any;
  67486. /**
  67487. * The current object in the bubbling phase
  67488. */
  67489. currentTarget?: any;
  67490. /**
  67491. * This will be populated with the return value of the last function that was executed.
  67492. * If it is the first function in the callback chain it will be the event data.
  67493. */
  67494. lastReturnValue?: any;
  67495. }
  67496. /**
  67497. * Represent an Observer registered to a given Observable object.
  67498. */
  67499. export class Observer<T> {
  67500. /**
  67501. * Defines the callback to call when the observer is notified
  67502. */
  67503. callback: (eventData: T, eventState: EventState) => void;
  67504. /**
  67505. * Defines the mask of the observer (used to filter notifications)
  67506. */
  67507. mask: number;
  67508. /**
  67509. * Defines the current scope used to restore the JS context
  67510. */
  67511. scope: any;
  67512. /** @hidden */
  67513. _willBeUnregistered: boolean;
  67514. /**
  67515. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67516. */
  67517. unregisterOnNextCall: boolean;
  67518. /**
  67519. * Creates a new observer
  67520. * @param callback defines the callback to call when the observer is notified
  67521. * @param mask defines the mask of the observer (used to filter notifications)
  67522. * @param scope defines the current scope used to restore the JS context
  67523. */
  67524. constructor(
  67525. /**
  67526. * Defines the callback to call when the observer is notified
  67527. */
  67528. callback: (eventData: T, eventState: EventState) => void,
  67529. /**
  67530. * Defines the mask of the observer (used to filter notifications)
  67531. */
  67532. mask: number,
  67533. /**
  67534. * Defines the current scope used to restore the JS context
  67535. */
  67536. scope?: any);
  67537. }
  67538. /**
  67539. * Represent a list of observers registered to multiple Observables object.
  67540. */
  67541. export class MultiObserver<T> {
  67542. private _observers;
  67543. private _observables;
  67544. /**
  67545. * Release associated resources
  67546. */
  67547. dispose(): void;
  67548. /**
  67549. * Raise a callback when one of the observable will notify
  67550. * @param observables defines a list of observables to watch
  67551. * @param callback defines the callback to call on notification
  67552. * @param mask defines the mask used to filter notifications
  67553. * @param scope defines the current scope used to restore the JS context
  67554. * @returns the new MultiObserver
  67555. */
  67556. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67557. }
  67558. /**
  67559. * The Observable class is a simple implementation of the Observable pattern.
  67560. *
  67561. * 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.
  67562. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67563. * 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).
  67564. * 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.
  67565. */
  67566. export class Observable<T> {
  67567. private _observers;
  67568. private _eventState;
  67569. private _onObserverAdded;
  67570. /**
  67571. * Gets the list of observers
  67572. */
  67573. readonly observers: Array<Observer<T>>;
  67574. /**
  67575. * Creates a new observable
  67576. * @param onObserverAdded defines a callback to call when a new observer is added
  67577. */
  67578. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67579. /**
  67580. * Create a new Observer with the specified callback
  67581. * @param callback the callback that will be executed for that Observer
  67582. * @param mask the mask used to filter observers
  67583. * @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.
  67584. * @param scope optional scope for the callback to be called from
  67585. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67586. * @returns the new observer created for the callback
  67587. */
  67588. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67589. /**
  67590. * Create a new Observer with the specified callback and unregisters after the next notification
  67591. * @param callback the callback that will be executed for that Observer
  67592. * @returns the new observer created for the callback
  67593. */
  67594. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67595. /**
  67596. * Remove an Observer from the Observable object
  67597. * @param observer the instance of the Observer to remove
  67598. * @returns false if it doesn't belong to this Observable
  67599. */
  67600. remove(observer: Nullable<Observer<T>>): boolean;
  67601. /**
  67602. * Remove a callback from the Observable object
  67603. * @param callback the callback to remove
  67604. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67605. * @returns false if it doesn't belong to this Observable
  67606. */
  67607. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67608. private _deferUnregister;
  67609. private _remove;
  67610. /**
  67611. * Moves the observable to the top of the observer list making it get called first when notified
  67612. * @param observer the observer to move
  67613. */
  67614. makeObserverTopPriority(observer: Observer<T>): void;
  67615. /**
  67616. * Moves the observable to the bottom of the observer list making it get called last when notified
  67617. * @param observer the observer to move
  67618. */
  67619. makeObserverBottomPriority(observer: Observer<T>): void;
  67620. /**
  67621. * Notify all Observers by calling their respective callback with the given data
  67622. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67623. * @param eventData defines the data to send to all observers
  67624. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67625. * @param target defines the original target of the state
  67626. * @param currentTarget defines the current target of the state
  67627. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67628. */
  67629. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67630. /**
  67631. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67632. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67633. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67634. * and it is crucial that all callbacks will be executed.
  67635. * The order of the callbacks is kept, callbacks are not executed parallel.
  67636. *
  67637. * @param eventData The data to be sent to each callback
  67638. * @param mask is used to filter observers defaults to -1
  67639. * @param target defines the callback target (see EventState)
  67640. * @param currentTarget defines he current object in the bubbling phase
  67641. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67642. */
  67643. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67644. /**
  67645. * Notify a specific observer
  67646. * @param observer defines the observer to notify
  67647. * @param eventData defines the data to be sent to each callback
  67648. * @param mask is used to filter observers defaults to -1
  67649. */
  67650. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67651. /**
  67652. * Gets a boolean indicating if the observable has at least one observer
  67653. * @returns true is the Observable has at least one Observer registered
  67654. */
  67655. hasObservers(): boolean;
  67656. /**
  67657. * Clear the list of observers
  67658. */
  67659. clear(): void;
  67660. /**
  67661. * Clone the current observable
  67662. * @returns a new observable
  67663. */
  67664. clone(): Observable<T>;
  67665. /**
  67666. * Does this observable handles observer registered with a given mask
  67667. * @param mask defines the mask to be tested
  67668. * @return whether or not one observer registered with the given mask is handeled
  67669. **/
  67670. hasSpecificMask(mask?: number): boolean;
  67671. }
  67672. }
  67673. declare module BABYLON {
  67674. /**
  67675. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67676. * Babylon.js
  67677. */
  67678. export class DomManagement {
  67679. /**
  67680. * Checks if the window object exists
  67681. * @returns true if the window object exists
  67682. */
  67683. static IsWindowObjectExist(): boolean;
  67684. /**
  67685. * Checks if the navigator object exists
  67686. * @returns true if the navigator object exists
  67687. */
  67688. static IsNavigatorAvailable(): boolean;
  67689. /**
  67690. * Extracts text content from a DOM element hierarchy
  67691. * @param element defines the root element
  67692. * @returns a string
  67693. */
  67694. static GetDOMTextContent(element: HTMLElement): string;
  67695. }
  67696. }
  67697. declare module BABYLON {
  67698. /**
  67699. * Logger used througouht the application to allow configuration of
  67700. * the log level required for the messages.
  67701. */
  67702. export class Logger {
  67703. /**
  67704. * No log
  67705. */
  67706. static readonly NoneLogLevel: number;
  67707. /**
  67708. * Only message logs
  67709. */
  67710. static readonly MessageLogLevel: number;
  67711. /**
  67712. * Only warning logs
  67713. */
  67714. static readonly WarningLogLevel: number;
  67715. /**
  67716. * Only error logs
  67717. */
  67718. static readonly ErrorLogLevel: number;
  67719. /**
  67720. * All logs
  67721. */
  67722. static readonly AllLogLevel: number;
  67723. private static _LogCache;
  67724. /**
  67725. * Gets a value indicating the number of loading errors
  67726. * @ignorenaming
  67727. */
  67728. static errorsCount: number;
  67729. /**
  67730. * Callback called when a new log is added
  67731. */
  67732. static OnNewCacheEntry: (entry: string) => void;
  67733. private static _AddLogEntry;
  67734. private static _FormatMessage;
  67735. private static _LogDisabled;
  67736. private static _LogEnabled;
  67737. private static _WarnDisabled;
  67738. private static _WarnEnabled;
  67739. private static _ErrorDisabled;
  67740. private static _ErrorEnabled;
  67741. /**
  67742. * Log a message to the console
  67743. */
  67744. static Log: (message: string) => void;
  67745. /**
  67746. * Write a warning message to the console
  67747. */
  67748. static Warn: (message: string) => void;
  67749. /**
  67750. * Write an error message to the console
  67751. */
  67752. static Error: (message: string) => void;
  67753. /**
  67754. * Gets current log cache (list of logs)
  67755. */
  67756. static readonly LogCache: string;
  67757. /**
  67758. * Clears the log cache
  67759. */
  67760. static ClearLogCache(): void;
  67761. /**
  67762. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67763. */
  67764. static LogLevels: number;
  67765. }
  67766. }
  67767. declare module BABYLON {
  67768. /** @hidden */
  67769. export class _TypeStore {
  67770. /** @hidden */
  67771. static RegisteredTypes: {
  67772. [key: string]: Object;
  67773. };
  67774. /** @hidden */
  67775. static GetClass(fqdn: string): any;
  67776. }
  67777. }
  67778. declare module BABYLON {
  67779. /**
  67780. * Class containing a set of static utilities functions for deep copy.
  67781. */
  67782. export class DeepCopier {
  67783. /**
  67784. * Tries to copy an object by duplicating every property
  67785. * @param source defines the source object
  67786. * @param destination defines the target object
  67787. * @param doNotCopyList defines a list of properties to avoid
  67788. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67789. */
  67790. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67791. }
  67792. }
  67793. declare module BABYLON {
  67794. /**
  67795. * Class containing a set of static utilities functions for precision date
  67796. */
  67797. export class PrecisionDate {
  67798. /**
  67799. * Gets either window.performance.now() if supported or Date.now() else
  67800. */
  67801. static readonly Now: number;
  67802. }
  67803. }
  67804. declare module BABYLON {
  67805. /** @hidden */
  67806. export class _DevTools {
  67807. static WarnImport(name: string): string;
  67808. }
  67809. }
  67810. declare module BABYLON {
  67811. /**
  67812. * Interface used to define the mechanism to get data from the network
  67813. */
  67814. export interface IWebRequest {
  67815. /**
  67816. * Returns client's response url
  67817. */
  67818. responseURL: string;
  67819. /**
  67820. * Returns client's status
  67821. */
  67822. status: number;
  67823. /**
  67824. * Returns client's status as a text
  67825. */
  67826. statusText: string;
  67827. }
  67828. }
  67829. declare module BABYLON {
  67830. /**
  67831. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67832. */
  67833. export class WebRequest implements IWebRequest {
  67834. private _xhr;
  67835. /**
  67836. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67837. * i.e. when loading files, where the server/service expects an Authorization header
  67838. */
  67839. static CustomRequestHeaders: {
  67840. [key: string]: string;
  67841. };
  67842. /**
  67843. * Add callback functions in this array to update all the requests before they get sent to the network
  67844. */
  67845. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67846. private _injectCustomRequestHeaders;
  67847. /**
  67848. * Gets or sets a function to be called when loading progress changes
  67849. */
  67850. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67851. /**
  67852. * Returns client's state
  67853. */
  67854. readonly readyState: number;
  67855. /**
  67856. * Returns client's status
  67857. */
  67858. readonly status: number;
  67859. /**
  67860. * Returns client's status as a text
  67861. */
  67862. readonly statusText: string;
  67863. /**
  67864. * Returns client's response
  67865. */
  67866. readonly response: any;
  67867. /**
  67868. * Returns client's response url
  67869. */
  67870. readonly responseURL: string;
  67871. /**
  67872. * Returns client's response as text
  67873. */
  67874. readonly responseText: string;
  67875. /**
  67876. * Gets or sets the expected response type
  67877. */
  67878. responseType: XMLHttpRequestResponseType;
  67879. /** @hidden */
  67880. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67881. /** @hidden */
  67882. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67883. /**
  67884. * Cancels any network activity
  67885. */
  67886. abort(): void;
  67887. /**
  67888. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67889. * @param body defines an optional request body
  67890. */
  67891. send(body?: Document | BodyInit | null): void;
  67892. /**
  67893. * Sets the request method, request URL
  67894. * @param method defines the method to use (GET, POST, etc..)
  67895. * @param url defines the url to connect with
  67896. */
  67897. open(method: string, url: string): void;
  67898. /**
  67899. * Sets the value of a request header.
  67900. * @param name The name of the header whose value is to be set
  67901. * @param value The value to set as the body of the header
  67902. */
  67903. setRequestHeader(name: string, value: string): void;
  67904. /**
  67905. * Get the string containing the text of a particular header's value.
  67906. * @param name The name of the header
  67907. * @returns The string containing the text of the given header name
  67908. */
  67909. getResponseHeader(name: string): Nullable<string>;
  67910. }
  67911. }
  67912. declare module BABYLON {
  67913. /**
  67914. * File request interface
  67915. */
  67916. export interface IFileRequest {
  67917. /**
  67918. * Raised when the request is complete (success or error).
  67919. */
  67920. onCompleteObservable: Observable<IFileRequest>;
  67921. /**
  67922. * Aborts the request for a file.
  67923. */
  67924. abort: () => void;
  67925. }
  67926. }
  67927. declare module BABYLON {
  67928. /**
  67929. * Define options used to create a render target texture
  67930. */
  67931. export class RenderTargetCreationOptions {
  67932. /**
  67933. * Specifies is mipmaps must be generated
  67934. */
  67935. generateMipMaps?: boolean;
  67936. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67937. generateDepthBuffer?: boolean;
  67938. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67939. generateStencilBuffer?: boolean;
  67940. /** Defines texture type (int by default) */
  67941. type?: number;
  67942. /** Defines sampling mode (trilinear by default) */
  67943. samplingMode?: number;
  67944. /** Defines format (RGBA by default) */
  67945. format?: number;
  67946. }
  67947. }
  67948. declare module BABYLON {
  67949. /**
  67950. * @hidden
  67951. **/
  67952. export class _TimeToken {
  67953. _startTimeQuery: Nullable<WebGLQuery>;
  67954. _endTimeQuery: Nullable<WebGLQuery>;
  67955. _timeElapsedQuery: Nullable<WebGLQuery>;
  67956. _timeElapsedQueryEnded: boolean;
  67957. }
  67958. }
  67959. declare module BABYLON {
  67960. /** Defines the cross module used constants to avoid circular dependncies */
  67961. export class Constants {
  67962. /** Defines that alpha blending is disabled */
  67963. static readonly ALPHA_DISABLE: number;
  67964. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67965. static readonly ALPHA_ADD: number;
  67966. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67967. static readonly ALPHA_COMBINE: number;
  67968. /** Defines that alpha blending to DEST - SRC * DEST */
  67969. static readonly ALPHA_SUBTRACT: number;
  67970. /** Defines that alpha blending to SRC * DEST */
  67971. static readonly ALPHA_MULTIPLY: number;
  67972. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67973. static readonly ALPHA_MAXIMIZED: number;
  67974. /** Defines that alpha blending to SRC + DEST */
  67975. static readonly ALPHA_ONEONE: number;
  67976. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67977. static readonly ALPHA_PREMULTIPLIED: number;
  67978. /**
  67979. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67980. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67981. */
  67982. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67983. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67984. static readonly ALPHA_INTERPOLATE: number;
  67985. /**
  67986. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67987. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67988. */
  67989. static readonly ALPHA_SCREENMODE: number;
  67990. /**
  67991. * Defines that alpha blending to SRC + DST
  67992. * Alpha will be set to SRC ALPHA + DST ALPHA
  67993. */
  67994. static readonly ALPHA_ONEONE_ONEONE: number;
  67995. /**
  67996. * Defines that alpha blending to SRC * DST ALPHA + DST
  67997. * Alpha will be set to 0
  67998. */
  67999. static readonly ALPHA_ALPHATOCOLOR: number;
  68000. /**
  68001. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68002. */
  68003. static readonly ALPHA_REVERSEONEMINUS: number;
  68004. /**
  68005. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68006. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68007. */
  68008. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68009. /**
  68010. * Defines that alpha blending to SRC + DST
  68011. * Alpha will be set to SRC ALPHA
  68012. */
  68013. static readonly ALPHA_ONEONE_ONEZERO: number;
  68014. /** Defines that alpha blending equation a SUM */
  68015. static readonly ALPHA_EQUATION_ADD: number;
  68016. /** Defines that alpha blending equation a SUBSTRACTION */
  68017. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68018. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68019. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68020. /** Defines that alpha blending equation a MAX operation */
  68021. static readonly ALPHA_EQUATION_MAX: number;
  68022. /** Defines that alpha blending equation a MIN operation */
  68023. static readonly ALPHA_EQUATION_MIN: number;
  68024. /**
  68025. * Defines that alpha blending equation a DARKEN operation:
  68026. * It takes the min of the src and sums the alpha channels.
  68027. */
  68028. static readonly ALPHA_EQUATION_DARKEN: number;
  68029. /** Defines that the ressource is not delayed*/
  68030. static readonly DELAYLOADSTATE_NONE: number;
  68031. /** Defines that the ressource was successfully delay loaded */
  68032. static readonly DELAYLOADSTATE_LOADED: number;
  68033. /** Defines that the ressource is currently delay loading */
  68034. static readonly DELAYLOADSTATE_LOADING: number;
  68035. /** Defines that the ressource is delayed and has not started loading */
  68036. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68037. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68038. static readonly NEVER: number;
  68039. /** 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 */
  68040. static readonly ALWAYS: number;
  68041. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68042. static readonly LESS: number;
  68043. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68044. static readonly EQUAL: number;
  68045. /** 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 */
  68046. static readonly LEQUAL: number;
  68047. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68048. static readonly GREATER: number;
  68049. /** 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 */
  68050. static readonly GEQUAL: number;
  68051. /** 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 */
  68052. static readonly NOTEQUAL: number;
  68053. /** Passed to stencilOperation to specify that stencil value must be kept */
  68054. static readonly KEEP: number;
  68055. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68056. static readonly REPLACE: number;
  68057. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68058. static readonly INCR: number;
  68059. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68060. static readonly DECR: number;
  68061. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68062. static readonly INVERT: number;
  68063. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68064. static readonly INCR_WRAP: number;
  68065. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68066. static readonly DECR_WRAP: number;
  68067. /** Texture is not repeating outside of 0..1 UVs */
  68068. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68069. /** Texture is repeating outside of 0..1 UVs */
  68070. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68071. /** Texture is repeating and mirrored */
  68072. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68073. /** ALPHA */
  68074. static readonly TEXTUREFORMAT_ALPHA: number;
  68075. /** LUMINANCE */
  68076. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68077. /** LUMINANCE_ALPHA */
  68078. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68079. /** RGB */
  68080. static readonly TEXTUREFORMAT_RGB: number;
  68081. /** RGBA */
  68082. static readonly TEXTUREFORMAT_RGBA: number;
  68083. /** RED */
  68084. static readonly TEXTUREFORMAT_RED: number;
  68085. /** RED (2nd reference) */
  68086. static readonly TEXTUREFORMAT_R: number;
  68087. /** RG */
  68088. static readonly TEXTUREFORMAT_RG: number;
  68089. /** RED_INTEGER */
  68090. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68091. /** RED_INTEGER (2nd reference) */
  68092. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68093. /** RG_INTEGER */
  68094. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68095. /** RGB_INTEGER */
  68096. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68097. /** RGBA_INTEGER */
  68098. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68099. /** UNSIGNED_BYTE */
  68100. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68101. /** UNSIGNED_BYTE (2nd reference) */
  68102. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68103. /** FLOAT */
  68104. static readonly TEXTURETYPE_FLOAT: number;
  68105. /** HALF_FLOAT */
  68106. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68107. /** BYTE */
  68108. static readonly TEXTURETYPE_BYTE: number;
  68109. /** SHORT */
  68110. static readonly TEXTURETYPE_SHORT: number;
  68111. /** UNSIGNED_SHORT */
  68112. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68113. /** INT */
  68114. static readonly TEXTURETYPE_INT: number;
  68115. /** UNSIGNED_INT */
  68116. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68117. /** UNSIGNED_SHORT_4_4_4_4 */
  68118. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68119. /** UNSIGNED_SHORT_5_5_5_1 */
  68120. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68121. /** UNSIGNED_SHORT_5_6_5 */
  68122. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68123. /** UNSIGNED_INT_2_10_10_10_REV */
  68124. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68125. /** UNSIGNED_INT_24_8 */
  68126. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68127. /** UNSIGNED_INT_10F_11F_11F_REV */
  68128. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68129. /** UNSIGNED_INT_5_9_9_9_REV */
  68130. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68131. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68132. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68133. /** nearest is mag = nearest and min = nearest and mip = linear */
  68134. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68135. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68136. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68137. /** Trilinear is mag = linear and min = linear and mip = linear */
  68138. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68139. /** nearest is mag = nearest and min = nearest and mip = linear */
  68140. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68141. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68142. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68143. /** Trilinear is mag = linear and min = linear and mip = linear */
  68144. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68145. /** mag = nearest and min = nearest and mip = nearest */
  68146. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68147. /** mag = nearest and min = linear and mip = nearest */
  68148. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68149. /** mag = nearest and min = linear and mip = linear */
  68150. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68151. /** mag = nearest and min = linear and mip = none */
  68152. static readonly TEXTURE_NEAREST_LINEAR: number;
  68153. /** mag = nearest and min = nearest and mip = none */
  68154. static readonly TEXTURE_NEAREST_NEAREST: number;
  68155. /** mag = linear and min = nearest and mip = nearest */
  68156. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68157. /** mag = linear and min = nearest and mip = linear */
  68158. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68159. /** mag = linear and min = linear and mip = none */
  68160. static readonly TEXTURE_LINEAR_LINEAR: number;
  68161. /** mag = linear and min = nearest and mip = none */
  68162. static readonly TEXTURE_LINEAR_NEAREST: number;
  68163. /** Explicit coordinates mode */
  68164. static readonly TEXTURE_EXPLICIT_MODE: number;
  68165. /** Spherical coordinates mode */
  68166. static readonly TEXTURE_SPHERICAL_MODE: number;
  68167. /** Planar coordinates mode */
  68168. static readonly TEXTURE_PLANAR_MODE: number;
  68169. /** Cubic coordinates mode */
  68170. static readonly TEXTURE_CUBIC_MODE: number;
  68171. /** Projection coordinates mode */
  68172. static readonly TEXTURE_PROJECTION_MODE: number;
  68173. /** Skybox coordinates mode */
  68174. static readonly TEXTURE_SKYBOX_MODE: number;
  68175. /** Inverse Cubic coordinates mode */
  68176. static readonly TEXTURE_INVCUBIC_MODE: number;
  68177. /** Equirectangular coordinates mode */
  68178. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68179. /** Equirectangular Fixed coordinates mode */
  68180. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68181. /** Equirectangular Fixed Mirrored coordinates mode */
  68182. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68183. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68184. static readonly SCALEMODE_FLOOR: number;
  68185. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68186. static readonly SCALEMODE_NEAREST: number;
  68187. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68188. static readonly SCALEMODE_CEILING: number;
  68189. /**
  68190. * The dirty texture flag value
  68191. */
  68192. static readonly MATERIAL_TextureDirtyFlag: number;
  68193. /**
  68194. * The dirty light flag value
  68195. */
  68196. static readonly MATERIAL_LightDirtyFlag: number;
  68197. /**
  68198. * The dirty fresnel flag value
  68199. */
  68200. static readonly MATERIAL_FresnelDirtyFlag: number;
  68201. /**
  68202. * The dirty attribute flag value
  68203. */
  68204. static readonly MATERIAL_AttributesDirtyFlag: number;
  68205. /**
  68206. * The dirty misc flag value
  68207. */
  68208. static readonly MATERIAL_MiscDirtyFlag: number;
  68209. /**
  68210. * The all dirty flag value
  68211. */
  68212. static readonly MATERIAL_AllDirtyFlag: number;
  68213. /**
  68214. * Returns the triangle fill mode
  68215. */
  68216. static readonly MATERIAL_TriangleFillMode: number;
  68217. /**
  68218. * Returns the wireframe mode
  68219. */
  68220. static readonly MATERIAL_WireFrameFillMode: number;
  68221. /**
  68222. * Returns the point fill mode
  68223. */
  68224. static readonly MATERIAL_PointFillMode: number;
  68225. /**
  68226. * Returns the point list draw mode
  68227. */
  68228. static readonly MATERIAL_PointListDrawMode: number;
  68229. /**
  68230. * Returns the line list draw mode
  68231. */
  68232. static readonly MATERIAL_LineListDrawMode: number;
  68233. /**
  68234. * Returns the line loop draw mode
  68235. */
  68236. static readonly MATERIAL_LineLoopDrawMode: number;
  68237. /**
  68238. * Returns the line strip draw mode
  68239. */
  68240. static readonly MATERIAL_LineStripDrawMode: number;
  68241. /**
  68242. * Returns the triangle strip draw mode
  68243. */
  68244. static readonly MATERIAL_TriangleStripDrawMode: number;
  68245. /**
  68246. * Returns the triangle fan draw mode
  68247. */
  68248. static readonly MATERIAL_TriangleFanDrawMode: number;
  68249. /**
  68250. * Stores the clock-wise side orientation
  68251. */
  68252. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68253. /**
  68254. * Stores the counter clock-wise side orientation
  68255. */
  68256. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68257. /**
  68258. * Nothing
  68259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68260. */
  68261. static readonly ACTION_NothingTrigger: number;
  68262. /**
  68263. * On pick
  68264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68265. */
  68266. static readonly ACTION_OnPickTrigger: number;
  68267. /**
  68268. * On left pick
  68269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68270. */
  68271. static readonly ACTION_OnLeftPickTrigger: number;
  68272. /**
  68273. * On right pick
  68274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68275. */
  68276. static readonly ACTION_OnRightPickTrigger: number;
  68277. /**
  68278. * On center pick
  68279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68280. */
  68281. static readonly ACTION_OnCenterPickTrigger: number;
  68282. /**
  68283. * On pick down
  68284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68285. */
  68286. static readonly ACTION_OnPickDownTrigger: number;
  68287. /**
  68288. * On double pick
  68289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68290. */
  68291. static readonly ACTION_OnDoublePickTrigger: number;
  68292. /**
  68293. * On pick up
  68294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68295. */
  68296. static readonly ACTION_OnPickUpTrigger: number;
  68297. /**
  68298. * On pick out.
  68299. * This trigger will only be raised if you also declared a OnPickDown
  68300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68301. */
  68302. static readonly ACTION_OnPickOutTrigger: number;
  68303. /**
  68304. * On long press
  68305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68306. */
  68307. static readonly ACTION_OnLongPressTrigger: number;
  68308. /**
  68309. * On pointer over
  68310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68311. */
  68312. static readonly ACTION_OnPointerOverTrigger: number;
  68313. /**
  68314. * On pointer out
  68315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68316. */
  68317. static readonly ACTION_OnPointerOutTrigger: number;
  68318. /**
  68319. * On every frame
  68320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68321. */
  68322. static readonly ACTION_OnEveryFrameTrigger: number;
  68323. /**
  68324. * On intersection enter
  68325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68326. */
  68327. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68328. /**
  68329. * On intersection exit
  68330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68331. */
  68332. static readonly ACTION_OnIntersectionExitTrigger: number;
  68333. /**
  68334. * On key down
  68335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68336. */
  68337. static readonly ACTION_OnKeyDownTrigger: number;
  68338. /**
  68339. * On key up
  68340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68341. */
  68342. static readonly ACTION_OnKeyUpTrigger: number;
  68343. /**
  68344. * Billboard mode will only apply to Y axis
  68345. */
  68346. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68347. /**
  68348. * Billboard mode will apply to all axes
  68349. */
  68350. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68351. /**
  68352. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68353. */
  68354. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68355. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68356. * Test order :
  68357. * Is the bounding sphere outside the frustum ?
  68358. * If not, are the bounding box vertices outside the frustum ?
  68359. * It not, then the cullable object is in the frustum.
  68360. */
  68361. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68362. /** Culling strategy : Bounding Sphere Only.
  68363. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68364. * It's also less accurate than the standard because some not visible objects can still be selected.
  68365. * Test : is the bounding sphere outside the frustum ?
  68366. * If not, then the cullable object is in the frustum.
  68367. */
  68368. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68369. /** Culling strategy : Optimistic Inclusion.
  68370. * This in an inclusion test first, then the standard exclusion test.
  68371. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68372. * 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.
  68373. * Anyway, it's as accurate as the standard strategy.
  68374. * Test :
  68375. * Is the cullable object bounding sphere center in the frustum ?
  68376. * If not, apply the default culling strategy.
  68377. */
  68378. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68379. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68380. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68381. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68382. * 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.
  68383. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68384. * Test :
  68385. * Is the cullable object bounding sphere center in the frustum ?
  68386. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68387. */
  68388. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68389. /**
  68390. * No logging while loading
  68391. */
  68392. static readonly SCENELOADER_NO_LOGGING: number;
  68393. /**
  68394. * Minimal logging while loading
  68395. */
  68396. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68397. /**
  68398. * Summary logging while loading
  68399. */
  68400. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68401. /**
  68402. * Detailled logging while loading
  68403. */
  68404. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68405. }
  68406. }
  68407. declare module BABYLON {
  68408. /**
  68409. * This represents the required contract to create a new type of texture loader.
  68410. */
  68411. export interface IInternalTextureLoader {
  68412. /**
  68413. * Defines wether the loader supports cascade loading the different faces.
  68414. */
  68415. supportCascades: boolean;
  68416. /**
  68417. * This returns if the loader support the current file information.
  68418. * @param extension defines the file extension of the file being loaded
  68419. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68420. * @param fallback defines the fallback internal texture if any
  68421. * @param isBase64 defines whether the texture is encoded as a base64
  68422. * @param isBuffer defines whether the texture data are stored as a buffer
  68423. * @returns true if the loader can load the specified file
  68424. */
  68425. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68426. /**
  68427. * Transform the url before loading if required.
  68428. * @param rootUrl the url of the texture
  68429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68430. * @returns the transformed texture
  68431. */
  68432. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68433. /**
  68434. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68435. * @param rootUrl the url of the texture
  68436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68437. * @returns the fallback texture
  68438. */
  68439. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68440. /**
  68441. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68442. * @param data contains the texture data
  68443. * @param texture defines the BabylonJS internal texture
  68444. * @param createPolynomials will be true if polynomials have been requested
  68445. * @param onLoad defines the callback to trigger once the texture is ready
  68446. * @param onError defines the callback to trigger in case of error
  68447. */
  68448. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68449. /**
  68450. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68451. * @param data contains the texture data
  68452. * @param texture defines the BabylonJS internal texture
  68453. * @param callback defines the method to call once ready to upload
  68454. */
  68455. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68456. }
  68457. }
  68458. declare module BABYLON {
  68459. /**
  68460. * Class used to store and describe the pipeline context associated with an effect
  68461. */
  68462. export interface IPipelineContext {
  68463. /**
  68464. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68465. */
  68466. isAsync: boolean;
  68467. /**
  68468. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68469. */
  68470. isReady: boolean;
  68471. /** @hidden */
  68472. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68473. }
  68474. }
  68475. declare module BABYLON {
  68476. /**
  68477. * Class used to store gfx data (like WebGLBuffer)
  68478. */
  68479. export class DataBuffer {
  68480. /**
  68481. * Gets or sets the number of objects referencing this buffer
  68482. */
  68483. references: number;
  68484. /** Gets or sets the size of the underlying buffer */
  68485. capacity: number;
  68486. /**
  68487. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68488. */
  68489. is32Bits: boolean;
  68490. /**
  68491. * Gets the underlying buffer
  68492. */
  68493. readonly underlyingResource: any;
  68494. }
  68495. }
  68496. declare module BABYLON {
  68497. /** @hidden */
  68498. export interface IShaderProcessor {
  68499. attributeProcessor?: (attribute: string) => string;
  68500. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68501. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68502. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68503. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68504. lineProcessor?: (line: string, isFragment: boolean) => string;
  68505. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68506. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68507. }
  68508. }
  68509. declare module BABYLON {
  68510. /** @hidden */
  68511. export interface ProcessingOptions {
  68512. defines: string[];
  68513. indexParameters: any;
  68514. isFragment: boolean;
  68515. shouldUseHighPrecisionShader: boolean;
  68516. supportsUniformBuffers: boolean;
  68517. shadersRepository: string;
  68518. includesShadersStore: {
  68519. [key: string]: string;
  68520. };
  68521. processor?: IShaderProcessor;
  68522. version: string;
  68523. platformName: string;
  68524. lookForClosingBracketForUniformBuffer?: boolean;
  68525. }
  68526. }
  68527. declare module BABYLON {
  68528. /**
  68529. * Helper to manipulate strings
  68530. */
  68531. export class StringTools {
  68532. /**
  68533. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68534. * @param str Source string
  68535. * @param suffix Suffix to search for in the source string
  68536. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68537. */
  68538. static EndsWith(str: string, suffix: string): boolean;
  68539. /**
  68540. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68541. * @param str Source string
  68542. * @param suffix Suffix to search for in the source string
  68543. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68544. */
  68545. static StartsWith(str: string, suffix: string): boolean;
  68546. /**
  68547. * Decodes a buffer into a string
  68548. * @param buffer The buffer to decode
  68549. * @returns The decoded string
  68550. */
  68551. static Decode(buffer: Uint8Array | Uint16Array): string;
  68552. /**
  68553. * Encode a buffer to a base64 string
  68554. * @param buffer defines the buffer to encode
  68555. * @returns the encoded string
  68556. */
  68557. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68558. }
  68559. }
  68560. declare module BABYLON {
  68561. /** @hidden */
  68562. export class ShaderCodeNode {
  68563. line: string;
  68564. children: ShaderCodeNode[];
  68565. additionalDefineKey?: string;
  68566. additionalDefineValue?: string;
  68567. isValid(preprocessors: {
  68568. [key: string]: string;
  68569. }): boolean;
  68570. process(preprocessors: {
  68571. [key: string]: string;
  68572. }, options: ProcessingOptions): string;
  68573. }
  68574. }
  68575. declare module BABYLON {
  68576. /** @hidden */
  68577. export class ShaderCodeCursor {
  68578. private _lines;
  68579. lineIndex: number;
  68580. readonly currentLine: string;
  68581. readonly canRead: boolean;
  68582. lines: string[];
  68583. }
  68584. }
  68585. declare module BABYLON {
  68586. /** @hidden */
  68587. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68588. process(preprocessors: {
  68589. [key: string]: string;
  68590. }, options: ProcessingOptions): string;
  68591. }
  68592. }
  68593. declare module BABYLON {
  68594. /** @hidden */
  68595. export class ShaderDefineExpression {
  68596. isTrue(preprocessors: {
  68597. [key: string]: string;
  68598. }): boolean;
  68599. }
  68600. }
  68601. declare module BABYLON {
  68602. /** @hidden */
  68603. export class ShaderCodeTestNode extends ShaderCodeNode {
  68604. testExpression: ShaderDefineExpression;
  68605. isValid(preprocessors: {
  68606. [key: string]: string;
  68607. }): boolean;
  68608. }
  68609. }
  68610. declare module BABYLON {
  68611. /** @hidden */
  68612. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68613. define: string;
  68614. not: boolean;
  68615. constructor(define: string, not?: boolean);
  68616. isTrue(preprocessors: {
  68617. [key: string]: string;
  68618. }): boolean;
  68619. }
  68620. }
  68621. declare module BABYLON {
  68622. /** @hidden */
  68623. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68624. leftOperand: ShaderDefineExpression;
  68625. rightOperand: ShaderDefineExpression;
  68626. isTrue(preprocessors: {
  68627. [key: string]: string;
  68628. }): boolean;
  68629. }
  68630. }
  68631. declare module BABYLON {
  68632. /** @hidden */
  68633. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68634. leftOperand: ShaderDefineExpression;
  68635. rightOperand: ShaderDefineExpression;
  68636. isTrue(preprocessors: {
  68637. [key: string]: string;
  68638. }): boolean;
  68639. }
  68640. }
  68641. declare module BABYLON {
  68642. /** @hidden */
  68643. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68644. define: string;
  68645. operand: string;
  68646. testValue: string;
  68647. constructor(define: string, operand: string, testValue: string);
  68648. isTrue(preprocessors: {
  68649. [key: string]: string;
  68650. }): boolean;
  68651. }
  68652. }
  68653. declare module BABYLON {
  68654. /**
  68655. * Class used to enable access to offline support
  68656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68657. */
  68658. export interface IOfflineProvider {
  68659. /**
  68660. * Gets a boolean indicating if scene must be saved in the database
  68661. */
  68662. enableSceneOffline: boolean;
  68663. /**
  68664. * Gets a boolean indicating if textures must be saved in the database
  68665. */
  68666. enableTexturesOffline: boolean;
  68667. /**
  68668. * Open the offline support and make it available
  68669. * @param successCallback defines the callback to call on success
  68670. * @param errorCallback defines the callback to call on error
  68671. */
  68672. open(successCallback: () => void, errorCallback: () => void): void;
  68673. /**
  68674. * Loads an image from the offline support
  68675. * @param url defines the url to load from
  68676. * @param image defines the target DOM image
  68677. */
  68678. loadImage(url: string, image: HTMLImageElement): void;
  68679. /**
  68680. * Loads a file from offline support
  68681. * @param url defines the URL to load from
  68682. * @param sceneLoaded defines a callback to call on success
  68683. * @param progressCallBack defines a callback to call when progress changed
  68684. * @param errorCallback defines a callback to call on error
  68685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68686. */
  68687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68688. }
  68689. }
  68690. declare module BABYLON {
  68691. /**
  68692. * Class used to help managing file picking and drag'n'drop
  68693. * File Storage
  68694. */
  68695. export class FilesInputStore {
  68696. /**
  68697. * List of files ready to be loaded
  68698. */
  68699. static FilesToLoad: {
  68700. [key: string]: File;
  68701. };
  68702. }
  68703. }
  68704. declare module BABYLON {
  68705. /**
  68706. * Class used to define a retry strategy when error happens while loading assets
  68707. */
  68708. export class RetryStrategy {
  68709. /**
  68710. * Function used to defines an exponential back off strategy
  68711. * @param maxRetries defines the maximum number of retries (3 by default)
  68712. * @param baseInterval defines the interval between retries
  68713. * @returns the strategy function to use
  68714. */
  68715. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68716. }
  68717. }
  68718. declare module BABYLON {
  68719. /**
  68720. * @ignore
  68721. * Application error to support additional information when loading a file
  68722. */
  68723. export abstract class BaseError extends Error {
  68724. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  68725. }
  68726. }
  68727. declare module BABYLON {
  68728. /** @ignore */
  68729. export class LoadFileError extends BaseError {
  68730. request?: WebRequest;
  68731. file?: File;
  68732. /**
  68733. * Creates a new LoadFileError
  68734. * @param message defines the message of the error
  68735. * @param request defines the optional web request
  68736. * @param file defines the optional file
  68737. */
  68738. constructor(message: string, object?: WebRequest | File);
  68739. }
  68740. /** @ignore */
  68741. export class RequestFileError extends BaseError {
  68742. request: WebRequest;
  68743. /**
  68744. * Creates a new LoadFileError
  68745. * @param message defines the message of the error
  68746. * @param request defines the optional web request
  68747. */
  68748. constructor(message: string, request: WebRequest);
  68749. }
  68750. /** @ignore */
  68751. export class ReadFileError extends BaseError {
  68752. file: File;
  68753. /**
  68754. * Creates a new ReadFileError
  68755. * @param message defines the message of the error
  68756. * @param file defines the optional file
  68757. */
  68758. constructor(message: string, file: File);
  68759. }
  68760. /**
  68761. * @hidden
  68762. */
  68763. export class FileTools {
  68764. /**
  68765. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68766. */
  68767. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68768. /**
  68769. * Gets or sets the base URL to use to load assets
  68770. */
  68771. static BaseUrl: string;
  68772. /**
  68773. * Default behaviour for cors in the application.
  68774. * It can be a string if the expected behavior is identical in the entire app.
  68775. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68776. */
  68777. static CorsBehavior: string | ((url: string | string[]) => string);
  68778. /**
  68779. * Gets or sets a function used to pre-process url before using them to load assets
  68780. */
  68781. static PreprocessUrl: (url: string) => string;
  68782. /**
  68783. * Removes unwanted characters from an url
  68784. * @param url defines the url to clean
  68785. * @returns the cleaned url
  68786. */
  68787. private static _CleanUrl;
  68788. /**
  68789. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68790. * @param url define the url we are trying
  68791. * @param element define the dom element where to configure the cors policy
  68792. */
  68793. static SetCorsBehavior(url: string | string[], element: {
  68794. crossOrigin: string | null;
  68795. }): void;
  68796. /**
  68797. * Loads an image as an HTMLImageElement.
  68798. * @param input url string, ArrayBuffer, or Blob to load
  68799. * @param onLoad callback called when the image successfully loads
  68800. * @param onError callback called when the image fails to load
  68801. * @param offlineProvider offline provider for caching
  68802. * @param mimeType optional mime type
  68803. * @returns the HTMLImageElement of the loaded image
  68804. */
  68805. 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>;
  68806. /**
  68807. * Reads a file from a File object
  68808. * @param file defines the file to load
  68809. * @param onSuccess defines the callback to call when data is loaded
  68810. * @param onProgress defines the callback to call during loading process
  68811. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68812. * @param onError defines the callback to call when an error occurs
  68813. * @returns a file request object
  68814. */
  68815. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  68816. /**
  68817. * Loads a file from a url
  68818. * @param url url to load
  68819. * @param onSuccess callback called when the file successfully loads
  68820. * @param onProgress callback called while file is loading (if the server supports this mode)
  68821. * @param offlineProvider defines the offline provider for caching
  68822. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68823. * @param onError callback called when the file fails to load
  68824. * @returns a file request object
  68825. */
  68826. 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;
  68827. /**
  68828. * Loads a file
  68829. * @param url url to load
  68830. * @param onSuccess callback called when the file successfully loads
  68831. * @param onProgress callback called while file is loading (if the server supports this mode)
  68832. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68833. * @param onError callback called when the file fails to load
  68834. * @param onOpened callback called when the web request is opened
  68835. * @returns a file request object
  68836. */
  68837. 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;
  68838. /**
  68839. * Checks if the loaded document was accessed via `file:`-Protocol.
  68840. * @returns boolean
  68841. */
  68842. static IsFileURL(): boolean;
  68843. }
  68844. }
  68845. declare module BABYLON {
  68846. /** @hidden */
  68847. export class ShaderProcessor {
  68848. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68849. private static _ProcessPrecision;
  68850. private static _ExtractOperation;
  68851. private static _BuildSubExpression;
  68852. private static _BuildExpression;
  68853. private static _MoveCursorWithinIf;
  68854. private static _MoveCursor;
  68855. private static _EvaluatePreProcessors;
  68856. private static _PreparePreProcessors;
  68857. private static _ProcessShaderConversion;
  68858. private static _ProcessIncludes;
  68859. }
  68860. }
  68861. declare module BABYLON {
  68862. /**
  68863. * @hidden
  68864. */
  68865. export interface IColor4Like {
  68866. r: float;
  68867. g: float;
  68868. b: float;
  68869. a: float;
  68870. }
  68871. /**
  68872. * @hidden
  68873. */
  68874. export interface IColor3Like {
  68875. r: float;
  68876. g: float;
  68877. b: float;
  68878. }
  68879. /**
  68880. * @hidden
  68881. */
  68882. export interface IVector4Like {
  68883. x: float;
  68884. y: float;
  68885. z: float;
  68886. w: float;
  68887. }
  68888. /**
  68889. * @hidden
  68890. */
  68891. export interface IVector3Like {
  68892. x: float;
  68893. y: float;
  68894. z: float;
  68895. }
  68896. /**
  68897. * @hidden
  68898. */
  68899. export interface IVector2Like {
  68900. x: float;
  68901. y: float;
  68902. }
  68903. /**
  68904. * @hidden
  68905. */
  68906. export interface IMatrixLike {
  68907. toArray(): DeepImmutable<Float32Array>;
  68908. updateFlag: int;
  68909. }
  68910. /**
  68911. * @hidden
  68912. */
  68913. export interface IViewportLike {
  68914. x: float;
  68915. y: float;
  68916. width: float;
  68917. height: float;
  68918. }
  68919. /**
  68920. * @hidden
  68921. */
  68922. export interface IPlaneLike {
  68923. normal: IVector3Like;
  68924. d: float;
  68925. normalize(): void;
  68926. }
  68927. }
  68928. declare module BABYLON {
  68929. /**
  68930. * Interface used to define common properties for effect fallbacks
  68931. */
  68932. export interface IEffectFallbacks {
  68933. /**
  68934. * Removes the defines that should be removed when falling back.
  68935. * @param currentDefines defines the current define statements for the shader.
  68936. * @param effect defines the current effect we try to compile
  68937. * @returns The resulting defines with defines of the current rank removed.
  68938. */
  68939. reduce(currentDefines: string, effect: Effect): string;
  68940. /**
  68941. * Removes the fallback from the bound mesh.
  68942. */
  68943. unBindMesh(): void;
  68944. /**
  68945. * Checks to see if more fallbacks are still availible.
  68946. */
  68947. hasMoreFallbacks: boolean;
  68948. }
  68949. }
  68950. declare module BABYLON {
  68951. /**
  68952. * Class used to evalaute queries containing `and` and `or` operators
  68953. */
  68954. export class AndOrNotEvaluator {
  68955. /**
  68956. * Evaluate a query
  68957. * @param query defines the query to evaluate
  68958. * @param evaluateCallback defines the callback used to filter result
  68959. * @returns true if the query matches
  68960. */
  68961. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68962. private static _HandleParenthesisContent;
  68963. private static _SimplifyNegation;
  68964. }
  68965. }
  68966. declare module BABYLON {
  68967. /**
  68968. * Class used to store custom tags
  68969. */
  68970. export class Tags {
  68971. /**
  68972. * Adds support for tags on the given object
  68973. * @param obj defines the object to use
  68974. */
  68975. static EnableFor(obj: any): void;
  68976. /**
  68977. * Removes tags support
  68978. * @param obj defines the object to use
  68979. */
  68980. static DisableFor(obj: any): void;
  68981. /**
  68982. * Gets a boolean indicating if the given object has tags
  68983. * @param obj defines the object to use
  68984. * @returns a boolean
  68985. */
  68986. static HasTags(obj: any): boolean;
  68987. /**
  68988. * Gets the tags available on a given object
  68989. * @param obj defines the object to use
  68990. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68991. * @returns the tags
  68992. */
  68993. static GetTags(obj: any, asString?: boolean): any;
  68994. /**
  68995. * Adds tags to an object
  68996. * @param obj defines the object to use
  68997. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68998. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68999. */
  69000. static AddTagsTo(obj: any, tagsString: string): void;
  69001. /**
  69002. * @hidden
  69003. */
  69004. static _AddTagTo(obj: any, tag: string): void;
  69005. /**
  69006. * Removes specific tags from a specific object
  69007. * @param obj defines the object to use
  69008. * @param tagsString defines the tags to remove
  69009. */
  69010. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69011. /**
  69012. * @hidden
  69013. */
  69014. static _RemoveTagFrom(obj: any, tag: string): void;
  69015. /**
  69016. * Defines if tags hosted on an object match a given query
  69017. * @param obj defines the object to use
  69018. * @param tagsQuery defines the tag query
  69019. * @returns a boolean
  69020. */
  69021. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69022. }
  69023. }
  69024. declare module BABYLON {
  69025. /**
  69026. * Scalar computation library
  69027. */
  69028. export class Scalar {
  69029. /**
  69030. * Two pi constants convenient for computation.
  69031. */
  69032. static TwoPi: number;
  69033. /**
  69034. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69035. * @param a number
  69036. * @param b number
  69037. * @param epsilon (default = 1.401298E-45)
  69038. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69039. */
  69040. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69041. /**
  69042. * Returns a string : the upper case translation of the number i to hexadecimal.
  69043. * @param i number
  69044. * @returns the upper case translation of the number i to hexadecimal.
  69045. */
  69046. static ToHex(i: number): string;
  69047. /**
  69048. * Returns -1 if value is negative and +1 is value is positive.
  69049. * @param value the value
  69050. * @returns the value itself if it's equal to zero.
  69051. */
  69052. static Sign(value: number): number;
  69053. /**
  69054. * Returns the value itself if it's between min and max.
  69055. * Returns min if the value is lower than min.
  69056. * Returns max if the value is greater than max.
  69057. * @param value the value to clmap
  69058. * @param min the min value to clamp to (default: 0)
  69059. * @param max the max value to clamp to (default: 1)
  69060. * @returns the clamped value
  69061. */
  69062. static Clamp(value: number, min?: number, max?: number): number;
  69063. /**
  69064. * the log2 of value.
  69065. * @param value the value to compute log2 of
  69066. * @returns the log2 of value.
  69067. */
  69068. static Log2(value: number): number;
  69069. /**
  69070. * Loops the value, so that it is never larger than length and never smaller than 0.
  69071. *
  69072. * This is similar to the modulo operator but it works with floating point numbers.
  69073. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69074. * With t = 5 and length = 2.5, the result would be 0.0.
  69075. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69076. * @param value the value
  69077. * @param length the length
  69078. * @returns the looped value
  69079. */
  69080. static Repeat(value: number, length: number): number;
  69081. /**
  69082. * Normalize the value between 0.0 and 1.0 using min and max values
  69083. * @param value value to normalize
  69084. * @param min max to normalize between
  69085. * @param max min to normalize between
  69086. * @returns the normalized value
  69087. */
  69088. static Normalize(value: number, min: number, max: number): number;
  69089. /**
  69090. * Denormalize the value from 0.0 and 1.0 using min and max values
  69091. * @param normalized value to denormalize
  69092. * @param min max to denormalize between
  69093. * @param max min to denormalize between
  69094. * @returns the denormalized value
  69095. */
  69096. static Denormalize(normalized: number, min: number, max: number): number;
  69097. /**
  69098. * Calculates the shortest difference between two given angles given in degrees.
  69099. * @param current current angle in degrees
  69100. * @param target target angle in degrees
  69101. * @returns the delta
  69102. */
  69103. static DeltaAngle(current: number, target: number): number;
  69104. /**
  69105. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69106. * @param tx value
  69107. * @param length length
  69108. * @returns The returned value will move back and forth between 0 and length
  69109. */
  69110. static PingPong(tx: number, length: number): number;
  69111. /**
  69112. * Interpolates between min and max with smoothing at the limits.
  69113. *
  69114. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69115. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69116. * @param from from
  69117. * @param to to
  69118. * @param tx value
  69119. * @returns the smooth stepped value
  69120. */
  69121. static SmoothStep(from: number, to: number, tx: number): number;
  69122. /**
  69123. * Moves a value current towards target.
  69124. *
  69125. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69126. * Negative values of maxDelta pushes the value away from target.
  69127. * @param current current value
  69128. * @param target target value
  69129. * @param maxDelta max distance to move
  69130. * @returns resulting value
  69131. */
  69132. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69133. /**
  69134. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69135. *
  69136. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69137. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69138. * @param current current value
  69139. * @param target target value
  69140. * @param maxDelta max distance to move
  69141. * @returns resulting angle
  69142. */
  69143. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69144. /**
  69145. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69146. * @param start start value
  69147. * @param end target value
  69148. * @param amount amount to lerp between
  69149. * @returns the lerped value
  69150. */
  69151. static Lerp(start: number, end: number, amount: number): number;
  69152. /**
  69153. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69154. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69155. * @param start start value
  69156. * @param end target value
  69157. * @param amount amount to lerp between
  69158. * @returns the lerped value
  69159. */
  69160. static LerpAngle(start: number, end: number, amount: number): number;
  69161. /**
  69162. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69163. * @param a start value
  69164. * @param b target value
  69165. * @param value value between a and b
  69166. * @returns the inverseLerp value
  69167. */
  69168. static InverseLerp(a: number, b: number, value: number): number;
  69169. /**
  69170. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69171. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69172. * @param value1 spline value
  69173. * @param tangent1 spline value
  69174. * @param value2 spline value
  69175. * @param tangent2 spline value
  69176. * @param amount input value
  69177. * @returns hermite result
  69178. */
  69179. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69180. /**
  69181. * Returns a random float number between and min and max values
  69182. * @param min min value of random
  69183. * @param max max value of random
  69184. * @returns random value
  69185. */
  69186. static RandomRange(min: number, max: number): number;
  69187. /**
  69188. * This function returns percentage of a number in a given range.
  69189. *
  69190. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69191. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69192. * @param number to convert to percentage
  69193. * @param min min range
  69194. * @param max max range
  69195. * @returns the percentage
  69196. */
  69197. static RangeToPercent(number: number, min: number, max: number): number;
  69198. /**
  69199. * This function returns number that corresponds to the percentage in a given range.
  69200. *
  69201. * PercentToRange(0.34,0,100) will return 34.
  69202. * @param percent to convert to number
  69203. * @param min min range
  69204. * @param max max range
  69205. * @returns the number
  69206. */
  69207. static PercentToRange(percent: number, min: number, max: number): number;
  69208. /**
  69209. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69210. * @param angle The angle to normalize in radian.
  69211. * @return The converted angle.
  69212. */
  69213. static NormalizeRadians(angle: number): number;
  69214. }
  69215. }
  69216. declare module BABYLON {
  69217. /**
  69218. * Constant used to convert a value to gamma space
  69219. * @ignorenaming
  69220. */
  69221. export const ToGammaSpace: number;
  69222. /**
  69223. * Constant used to convert a value to linear space
  69224. * @ignorenaming
  69225. */
  69226. export const ToLinearSpace = 2.2;
  69227. /**
  69228. * Constant used to define the minimal number value in Babylon.js
  69229. * @ignorenaming
  69230. */
  69231. let Epsilon: number;
  69232. }
  69233. declare module BABYLON {
  69234. /**
  69235. * Class used to represent a viewport on screen
  69236. */
  69237. export class Viewport {
  69238. /** viewport left coordinate */
  69239. x: number;
  69240. /** viewport top coordinate */
  69241. y: number;
  69242. /**viewport width */
  69243. width: number;
  69244. /** viewport height */
  69245. height: number;
  69246. /**
  69247. * Creates a Viewport object located at (x, y) and sized (width, height)
  69248. * @param x defines viewport left coordinate
  69249. * @param y defines viewport top coordinate
  69250. * @param width defines the viewport width
  69251. * @param height defines the viewport height
  69252. */
  69253. constructor(
  69254. /** viewport left coordinate */
  69255. x: number,
  69256. /** viewport top coordinate */
  69257. y: number,
  69258. /**viewport width */
  69259. width: number,
  69260. /** viewport height */
  69261. height: number);
  69262. /**
  69263. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69264. * @param renderWidth defines the rendering width
  69265. * @param renderHeight defines the rendering height
  69266. * @returns a new Viewport
  69267. */
  69268. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69269. /**
  69270. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69271. * @param renderWidth defines the rendering width
  69272. * @param renderHeight defines the rendering height
  69273. * @param ref defines the target viewport
  69274. * @returns the current viewport
  69275. */
  69276. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69277. /**
  69278. * Returns a new Viewport copied from the current one
  69279. * @returns a new Viewport
  69280. */
  69281. clone(): Viewport;
  69282. }
  69283. }
  69284. declare module BABYLON {
  69285. /**
  69286. * Class containing a set of static utilities functions for arrays.
  69287. */
  69288. export class ArrayTools {
  69289. /**
  69290. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69291. * @param size the number of element to construct and put in the array
  69292. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69293. * @returns a new array filled with new objects
  69294. */
  69295. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69296. }
  69297. }
  69298. declare module BABYLON {
  69299. /**
  69300. * Class representing a vector containing 2 coordinates
  69301. */
  69302. export class Vector2 {
  69303. /** defines the first coordinate */
  69304. x: number;
  69305. /** defines the second coordinate */
  69306. y: number;
  69307. /**
  69308. * Creates a new Vector2 from the given x and y coordinates
  69309. * @param x defines the first coordinate
  69310. * @param y defines the second coordinate
  69311. */
  69312. constructor(
  69313. /** defines the first coordinate */
  69314. x?: number,
  69315. /** defines the second coordinate */
  69316. y?: number);
  69317. /**
  69318. * Gets a string with the Vector2 coordinates
  69319. * @returns a string with the Vector2 coordinates
  69320. */
  69321. toString(): string;
  69322. /**
  69323. * Gets class name
  69324. * @returns the string "Vector2"
  69325. */
  69326. getClassName(): string;
  69327. /**
  69328. * Gets current vector hash code
  69329. * @returns the Vector2 hash code as a number
  69330. */
  69331. getHashCode(): number;
  69332. /**
  69333. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69334. * @param array defines the source array
  69335. * @param index defines the offset in source array
  69336. * @returns the current Vector2
  69337. */
  69338. toArray(array: FloatArray, index?: number): Vector2;
  69339. /**
  69340. * Copy the current vector to an array
  69341. * @returns a new array with 2 elements: the Vector2 coordinates.
  69342. */
  69343. asArray(): number[];
  69344. /**
  69345. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69346. * @param source defines the source Vector2
  69347. * @returns the current updated Vector2
  69348. */
  69349. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69350. /**
  69351. * Sets the Vector2 coordinates with the given floats
  69352. * @param x defines the first coordinate
  69353. * @param y defines the second coordinate
  69354. * @returns the current updated Vector2
  69355. */
  69356. copyFromFloats(x: number, y: number): Vector2;
  69357. /**
  69358. * Sets the Vector2 coordinates with the given floats
  69359. * @param x defines the first coordinate
  69360. * @param y defines the second coordinate
  69361. * @returns the current updated Vector2
  69362. */
  69363. set(x: number, y: number): Vector2;
  69364. /**
  69365. * Add another vector with the current one
  69366. * @param otherVector defines the other vector
  69367. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69368. */
  69369. add(otherVector: DeepImmutable<Vector2>): Vector2;
  69370. /**
  69371. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69372. * @param otherVector defines the other vector
  69373. * @param result defines the target vector
  69374. * @returns the unmodified current Vector2
  69375. */
  69376. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69377. /**
  69378. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69379. * @param otherVector defines the other vector
  69380. * @returns the current updated Vector2
  69381. */
  69382. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69383. /**
  69384. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  69385. * @param otherVector defines the other vector
  69386. * @returns a new Vector2
  69387. */
  69388. addVector3(otherVector: Vector3): Vector2;
  69389. /**
  69390. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  69391. * @param otherVector defines the other vector
  69392. * @returns a new Vector2
  69393. */
  69394. subtract(otherVector: Vector2): Vector2;
  69395. /**
  69396. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  69397. * @param otherVector defines the other vector
  69398. * @param result defines the target vector
  69399. * @returns the unmodified current Vector2
  69400. */
  69401. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69402. /**
  69403. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  69404. * @param otherVector defines the other vector
  69405. * @returns the current updated Vector2
  69406. */
  69407. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69408. /**
  69409. * Multiplies in place the current Vector2 coordinates by the given ones
  69410. * @param otherVector defines the other vector
  69411. * @returns the current updated Vector2
  69412. */
  69413. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69414. /**
  69415. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  69416. * @param otherVector defines the other vector
  69417. * @returns a new Vector2
  69418. */
  69419. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  69420. /**
  69421. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  69422. * @param otherVector defines the other vector
  69423. * @param result defines the target vector
  69424. * @returns the unmodified current Vector2
  69425. */
  69426. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69427. /**
  69428. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  69429. * @param x defines the first coordinate
  69430. * @param y defines the second coordinate
  69431. * @returns a new Vector2
  69432. */
  69433. multiplyByFloats(x: number, y: number): Vector2;
  69434. /**
  69435. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  69436. * @param otherVector defines the other vector
  69437. * @returns a new Vector2
  69438. */
  69439. divide(otherVector: Vector2): Vector2;
  69440. /**
  69441. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  69442. * @param otherVector defines the other vector
  69443. * @param result defines the target vector
  69444. * @returns the unmodified current Vector2
  69445. */
  69446. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69447. /**
  69448. * Divides the current Vector2 coordinates by the given ones
  69449. * @param otherVector defines the other vector
  69450. * @returns the current updated Vector2
  69451. */
  69452. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69453. /**
  69454. * Gets a new Vector2 with current Vector2 negated coordinates
  69455. * @returns a new Vector2
  69456. */
  69457. negate(): Vector2;
  69458. /**
  69459. * Multiply the Vector2 coordinates by scale
  69460. * @param scale defines the scaling factor
  69461. * @returns the current updated Vector2
  69462. */
  69463. scaleInPlace(scale: number): Vector2;
  69464. /**
  69465. * Returns a new Vector2 scaled by "scale" from the current Vector2
  69466. * @param scale defines the scaling factor
  69467. * @returns a new Vector2
  69468. */
  69469. scale(scale: number): Vector2;
  69470. /**
  69471. * Scale the current Vector2 values by a factor to a given Vector2
  69472. * @param scale defines the scale factor
  69473. * @param result defines the Vector2 object where to store the result
  69474. * @returns the unmodified current Vector2
  69475. */
  69476. scaleToRef(scale: number, result: Vector2): Vector2;
  69477. /**
  69478. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  69479. * @param scale defines the scale factor
  69480. * @param result defines the Vector2 object where to store the result
  69481. * @returns the unmodified current Vector2
  69482. */
  69483. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  69484. /**
  69485. * Gets a boolean if two vectors are equals
  69486. * @param otherVector defines the other vector
  69487. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  69488. */
  69489. equals(otherVector: DeepImmutable<Vector2>): boolean;
  69490. /**
  69491. * Gets a boolean if two vectors are equals (using an epsilon value)
  69492. * @param otherVector defines the other vector
  69493. * @param epsilon defines the minimal distance to consider equality
  69494. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  69495. */
  69496. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  69497. /**
  69498. * Gets a new Vector2 from current Vector2 floored values
  69499. * @returns a new Vector2
  69500. */
  69501. floor(): Vector2;
  69502. /**
  69503. * Gets a new Vector2 from current Vector2 floored values
  69504. * @returns a new Vector2
  69505. */
  69506. fract(): Vector2;
  69507. /**
  69508. * Gets the length of the vector
  69509. * @returns the vector length (float)
  69510. */
  69511. length(): number;
  69512. /**
  69513. * Gets the vector squared length
  69514. * @returns the vector squared length (float)
  69515. */
  69516. lengthSquared(): number;
  69517. /**
  69518. * Normalize the vector
  69519. * @returns the current updated Vector2
  69520. */
  69521. normalize(): Vector2;
  69522. /**
  69523. * Gets a new Vector2 copied from the Vector2
  69524. * @returns a new Vector2
  69525. */
  69526. clone(): Vector2;
  69527. /**
  69528. * Gets a new Vector2(0, 0)
  69529. * @returns a new Vector2
  69530. */
  69531. static Zero(): Vector2;
  69532. /**
  69533. * Gets a new Vector2(1, 1)
  69534. * @returns a new Vector2
  69535. */
  69536. static One(): Vector2;
  69537. /**
  69538. * Gets a new Vector2 set from the given index element of the given array
  69539. * @param array defines the data source
  69540. * @param offset defines the offset in the data source
  69541. * @returns a new Vector2
  69542. */
  69543. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  69544. /**
  69545. * Sets "result" from the given index element of the given array
  69546. * @param array defines the data source
  69547. * @param offset defines the offset in the data source
  69548. * @param result defines the target vector
  69549. */
  69550. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  69551. /**
  69552. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69553. * @param value1 defines 1st point of control
  69554. * @param value2 defines 2nd point of control
  69555. * @param value3 defines 3rd point of control
  69556. * @param value4 defines 4th point of control
  69557. * @param amount defines the interpolation factor
  69558. * @returns a new Vector2
  69559. */
  69560. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  69561. /**
  69562. * 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".
  69563. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69564. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69565. * @param value defines the value to clamp
  69566. * @param min defines the lower limit
  69567. * @param max defines the upper limit
  69568. * @returns a new Vector2
  69569. */
  69570. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  69571. /**
  69572. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69573. * @param value1 defines the 1st control point
  69574. * @param tangent1 defines the outgoing tangent
  69575. * @param value2 defines the 2nd control point
  69576. * @param tangent2 defines the incoming tangent
  69577. * @param amount defines the interpolation factor
  69578. * @returns a new Vector2
  69579. */
  69580. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  69581. /**
  69582. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69583. * @param start defines the start vector
  69584. * @param end defines the end vector
  69585. * @param amount defines the interpolation factor
  69586. * @returns a new Vector2
  69587. */
  69588. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  69589. /**
  69590. * Gets the dot product of the vector "left" and the vector "right"
  69591. * @param left defines first vector
  69592. * @param right defines second vector
  69593. * @returns the dot product (float)
  69594. */
  69595. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  69596. /**
  69597. * Returns a new Vector2 equal to the normalized given vector
  69598. * @param vector defines the vector to normalize
  69599. * @returns a new Vector2
  69600. */
  69601. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  69602. /**
  69603. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69604. * @param left defines 1st vector
  69605. * @param right defines 2nd vector
  69606. * @returns a new Vector2
  69607. */
  69608. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69609. /**
  69610. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69611. * @param left defines 1st vector
  69612. * @param right defines 2nd vector
  69613. * @returns a new Vector2
  69614. */
  69615. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69616. /**
  69617. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69618. * @param vector defines the vector to transform
  69619. * @param transformation defines the matrix to apply
  69620. * @returns a new Vector2
  69621. */
  69622. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  69623. /**
  69624. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69625. * @param vector defines the vector to transform
  69626. * @param transformation defines the matrix to apply
  69627. * @param result defines the target vector
  69628. */
  69629. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  69630. /**
  69631. * Determines if a given vector is included in a triangle
  69632. * @param p defines the vector to test
  69633. * @param p0 defines 1st triangle point
  69634. * @param p1 defines 2nd triangle point
  69635. * @param p2 defines 3rd triangle point
  69636. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69637. */
  69638. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69639. /**
  69640. * Gets the distance between the vectors "value1" and "value2"
  69641. * @param value1 defines first vector
  69642. * @param value2 defines second vector
  69643. * @returns the distance between vectors
  69644. */
  69645. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69646. /**
  69647. * Returns the squared distance between the vectors "value1" and "value2"
  69648. * @param value1 defines first vector
  69649. * @param value2 defines second vector
  69650. * @returns the squared distance between vectors
  69651. */
  69652. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69653. /**
  69654. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69655. * @param value1 defines first vector
  69656. * @param value2 defines second vector
  69657. * @returns a new Vector2
  69658. */
  69659. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69660. /**
  69661. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69662. * @param p defines the middle point
  69663. * @param segA defines one point of the segment
  69664. * @param segB defines the other point of the segment
  69665. * @returns the shortest distance
  69666. */
  69667. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69668. }
  69669. /**
  69670. * Classed used to store (x,y,z) vector representation
  69671. * A Vector3 is the main object used in 3D geometry
  69672. * It can represent etiher the coordinates of a point the space, either a direction
  69673. * Reminder: js uses a left handed forward facing system
  69674. */
  69675. export class Vector3 {
  69676. /**
  69677. * Defines the first coordinates (on X axis)
  69678. */
  69679. x: number;
  69680. /**
  69681. * Defines the second coordinates (on Y axis)
  69682. */
  69683. y: number;
  69684. /**
  69685. * Defines the third coordinates (on Z axis)
  69686. */
  69687. z: number;
  69688. private static _UpReadOnly;
  69689. private static _ZeroReadOnly;
  69690. /**
  69691. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69692. * @param x defines the first coordinates (on X axis)
  69693. * @param y defines the second coordinates (on Y axis)
  69694. * @param z defines the third coordinates (on Z axis)
  69695. */
  69696. constructor(
  69697. /**
  69698. * Defines the first coordinates (on X axis)
  69699. */
  69700. x?: number,
  69701. /**
  69702. * Defines the second coordinates (on Y axis)
  69703. */
  69704. y?: number,
  69705. /**
  69706. * Defines the third coordinates (on Z axis)
  69707. */
  69708. z?: number);
  69709. /**
  69710. * Creates a string representation of the Vector3
  69711. * @returns a string with the Vector3 coordinates.
  69712. */
  69713. toString(): string;
  69714. /**
  69715. * Gets the class name
  69716. * @returns the string "Vector3"
  69717. */
  69718. getClassName(): string;
  69719. /**
  69720. * Creates the Vector3 hash code
  69721. * @returns a number which tends to be unique between Vector3 instances
  69722. */
  69723. getHashCode(): number;
  69724. /**
  69725. * Creates an array containing three elements : the coordinates of the Vector3
  69726. * @returns a new array of numbers
  69727. */
  69728. asArray(): number[];
  69729. /**
  69730. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69731. * @param array defines the destination array
  69732. * @param index defines the offset in the destination array
  69733. * @returns the current Vector3
  69734. */
  69735. toArray(array: FloatArray, index?: number): Vector3;
  69736. /**
  69737. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69738. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69739. */
  69740. toQuaternion(): Quaternion;
  69741. /**
  69742. * Adds the given vector to the current Vector3
  69743. * @param otherVector defines the second operand
  69744. * @returns the current updated Vector3
  69745. */
  69746. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69747. /**
  69748. * Adds the given coordinates to the current Vector3
  69749. * @param x defines the x coordinate of the operand
  69750. * @param y defines the y coordinate of the operand
  69751. * @param z defines the z coordinate of the operand
  69752. * @returns the current updated Vector3
  69753. */
  69754. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69755. /**
  69756. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69757. * @param otherVector defines the second operand
  69758. * @returns the resulting Vector3
  69759. */
  69760. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69761. /**
  69762. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69763. * @param otherVector defines the second operand
  69764. * @param result defines the Vector3 object where to store the result
  69765. * @returns the current Vector3
  69766. */
  69767. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69768. /**
  69769. * Subtract the given vector from the current Vector3
  69770. * @param otherVector defines the second operand
  69771. * @returns the current updated Vector3
  69772. */
  69773. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69774. /**
  69775. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69776. * @param otherVector defines the second operand
  69777. * @returns the resulting Vector3
  69778. */
  69779. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69780. /**
  69781. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69782. * @param otherVector defines the second operand
  69783. * @param result defines the Vector3 object where to store the result
  69784. * @returns the current Vector3
  69785. */
  69786. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69787. /**
  69788. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69789. * @param x defines the x coordinate of the operand
  69790. * @param y defines the y coordinate of the operand
  69791. * @param z defines the z coordinate of the operand
  69792. * @returns the resulting Vector3
  69793. */
  69794. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69795. /**
  69796. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69797. * @param x defines the x coordinate of the operand
  69798. * @param y defines the y coordinate of the operand
  69799. * @param z defines the z coordinate of the operand
  69800. * @param result defines the Vector3 object where to store the result
  69801. * @returns the current Vector3
  69802. */
  69803. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69804. /**
  69805. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69806. * @returns a new Vector3
  69807. */
  69808. negate(): Vector3;
  69809. /**
  69810. * Multiplies the Vector3 coordinates by the float "scale"
  69811. * @param scale defines the multiplier factor
  69812. * @returns the current updated Vector3
  69813. */
  69814. scaleInPlace(scale: number): Vector3;
  69815. /**
  69816. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69817. * @param scale defines the multiplier factor
  69818. * @returns a new Vector3
  69819. */
  69820. scale(scale: number): Vector3;
  69821. /**
  69822. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69823. * @param scale defines the multiplier factor
  69824. * @param result defines the Vector3 object where to store the result
  69825. * @returns the current Vector3
  69826. */
  69827. scaleToRef(scale: number, result: Vector3): Vector3;
  69828. /**
  69829. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69830. * @param scale defines the scale factor
  69831. * @param result defines the Vector3 object where to store the result
  69832. * @returns the unmodified current Vector3
  69833. */
  69834. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69835. /**
  69836. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69837. * @param otherVector defines the second operand
  69838. * @returns true if both vectors are equals
  69839. */
  69840. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69841. /**
  69842. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69843. * @param otherVector defines the second operand
  69844. * @param epsilon defines the minimal distance to define values as equals
  69845. * @returns true if both vectors are distant less than epsilon
  69846. */
  69847. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69848. /**
  69849. * Returns true if the current Vector3 coordinates equals the given floats
  69850. * @param x defines the x coordinate of the operand
  69851. * @param y defines the y coordinate of the operand
  69852. * @param z defines the z coordinate of the operand
  69853. * @returns true if both vectors are equals
  69854. */
  69855. equalsToFloats(x: number, y: number, z: number): boolean;
  69856. /**
  69857. * Multiplies the current Vector3 coordinates by the given ones
  69858. * @param otherVector defines the second operand
  69859. * @returns the current updated Vector3
  69860. */
  69861. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69862. /**
  69863. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69864. * @param otherVector defines the second operand
  69865. * @returns the new Vector3
  69866. */
  69867. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69868. /**
  69869. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69870. * @param otherVector defines the second operand
  69871. * @param result defines the Vector3 object where to store the result
  69872. * @returns the current Vector3
  69873. */
  69874. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69875. /**
  69876. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69877. * @param x defines the x coordinate of the operand
  69878. * @param y defines the y coordinate of the operand
  69879. * @param z defines the z coordinate of the operand
  69880. * @returns the new Vector3
  69881. */
  69882. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69883. /**
  69884. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69885. * @param otherVector defines the second operand
  69886. * @returns the new Vector3
  69887. */
  69888. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69889. /**
  69890. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69891. * @param otherVector defines the second operand
  69892. * @param result defines the Vector3 object where to store the result
  69893. * @returns the current Vector3
  69894. */
  69895. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69896. /**
  69897. * Divides the current Vector3 coordinates by the given ones.
  69898. * @param otherVector defines the second operand
  69899. * @returns the current updated Vector3
  69900. */
  69901. divideInPlace(otherVector: Vector3): Vector3;
  69902. /**
  69903. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69904. * @param other defines the second operand
  69905. * @returns the current updated Vector3
  69906. */
  69907. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69908. /**
  69909. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69910. * @param other defines the second operand
  69911. * @returns the current updated Vector3
  69912. */
  69913. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69914. /**
  69915. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69916. * @param x defines the x coordinate of the operand
  69917. * @param y defines the y coordinate of the operand
  69918. * @param z defines the z coordinate of the operand
  69919. * @returns the current updated Vector3
  69920. */
  69921. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69922. /**
  69923. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69924. * @param x defines the x coordinate of the operand
  69925. * @param y defines the y coordinate of the operand
  69926. * @param z defines the z coordinate of the operand
  69927. * @returns the current updated Vector3
  69928. */
  69929. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69930. /**
  69931. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69932. * Check if is non uniform within a certain amount of decimal places to account for this
  69933. * @param epsilon the amount the values can differ
  69934. * @returns if the the vector is non uniform to a certain number of decimal places
  69935. */
  69936. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69937. /**
  69938. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69939. */
  69940. readonly isNonUniform: boolean;
  69941. /**
  69942. * Gets a new Vector3 from current Vector3 floored values
  69943. * @returns a new Vector3
  69944. */
  69945. floor(): Vector3;
  69946. /**
  69947. * Gets a new Vector3 from current Vector3 floored values
  69948. * @returns a new Vector3
  69949. */
  69950. fract(): Vector3;
  69951. /**
  69952. * Gets the length of the Vector3
  69953. * @returns the length of the Vector3
  69954. */
  69955. length(): number;
  69956. /**
  69957. * Gets the squared length of the Vector3
  69958. * @returns squared length of the Vector3
  69959. */
  69960. lengthSquared(): number;
  69961. /**
  69962. * Normalize the current Vector3.
  69963. * Please note that this is an in place operation.
  69964. * @returns the current updated Vector3
  69965. */
  69966. normalize(): Vector3;
  69967. /**
  69968. * Reorders the x y z properties of the vector in place
  69969. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69970. * @returns the current updated vector
  69971. */
  69972. reorderInPlace(order: string): this;
  69973. /**
  69974. * Rotates the vector around 0,0,0 by a quaternion
  69975. * @param quaternion the rotation quaternion
  69976. * @param result vector to store the result
  69977. * @returns the resulting vector
  69978. */
  69979. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  69980. /**
  69981. * Rotates a vector around a given point
  69982. * @param quaternion the rotation quaternion
  69983. * @param point the point to rotate around
  69984. * @param result vector to store the result
  69985. * @returns the resulting vector
  69986. */
  69987. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  69988. /**
  69989. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  69990. * The cross product is then orthogonal to both current and "other"
  69991. * @param other defines the right operand
  69992. * @returns the cross product
  69993. */
  69994. cross(other: Vector3): Vector3;
  69995. /**
  69996. * Normalize the current Vector3 with the given input length.
  69997. * Please note that this is an in place operation.
  69998. * @param len the length of the vector
  69999. * @returns the current updated Vector3
  70000. */
  70001. normalizeFromLength(len: number): Vector3;
  70002. /**
  70003. * Normalize the current Vector3 to a new vector
  70004. * @returns the new Vector3
  70005. */
  70006. normalizeToNew(): Vector3;
  70007. /**
  70008. * Normalize the current Vector3 to the reference
  70009. * @param reference define the Vector3 to update
  70010. * @returns the updated Vector3
  70011. */
  70012. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70013. /**
  70014. * Creates a new Vector3 copied from the current Vector3
  70015. * @returns the new Vector3
  70016. */
  70017. clone(): Vector3;
  70018. /**
  70019. * Copies the given vector coordinates to the current Vector3 ones
  70020. * @param source defines the source Vector3
  70021. * @returns the current updated Vector3
  70022. */
  70023. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70024. /**
  70025. * Copies the given floats to the current Vector3 coordinates
  70026. * @param x defines the x coordinate of the operand
  70027. * @param y defines the y coordinate of the operand
  70028. * @param z defines the z coordinate of the operand
  70029. * @returns the current updated Vector3
  70030. */
  70031. copyFromFloats(x: number, y: number, z: number): Vector3;
  70032. /**
  70033. * Copies the given floats to the current Vector3 coordinates
  70034. * @param x defines the x coordinate of the operand
  70035. * @param y defines the y coordinate of the operand
  70036. * @param z defines the z coordinate of the operand
  70037. * @returns the current updated Vector3
  70038. */
  70039. set(x: number, y: number, z: number): Vector3;
  70040. /**
  70041. * Copies the given float to the current Vector3 coordinates
  70042. * @param v defines the x, y and z coordinates of the operand
  70043. * @returns the current updated Vector3
  70044. */
  70045. setAll(v: number): Vector3;
  70046. /**
  70047. * Get the clip factor between two vectors
  70048. * @param vector0 defines the first operand
  70049. * @param vector1 defines the second operand
  70050. * @param axis defines the axis to use
  70051. * @param size defines the size along the axis
  70052. * @returns the clip factor
  70053. */
  70054. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70055. /**
  70056. * Get angle between two vectors
  70057. * @param vector0 angle between vector0 and vector1
  70058. * @param vector1 angle between vector0 and vector1
  70059. * @param normal direction of the normal
  70060. * @return the angle between vector0 and vector1
  70061. */
  70062. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70063. /**
  70064. * Returns a new Vector3 set from the index "offset" of the given array
  70065. * @param array defines the source array
  70066. * @param offset defines the offset in the source array
  70067. * @returns the new Vector3
  70068. */
  70069. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70070. /**
  70071. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70072. * This function is deprecated. Use FromArray instead
  70073. * @param array defines the source array
  70074. * @param offset defines the offset in the source array
  70075. * @returns the new Vector3
  70076. */
  70077. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70078. /**
  70079. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70080. * @param array defines the source array
  70081. * @param offset defines the offset in the source array
  70082. * @param result defines the Vector3 where to store the result
  70083. */
  70084. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70085. /**
  70086. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70087. * This function is deprecated. Use FromArrayToRef instead.
  70088. * @param array defines the source array
  70089. * @param offset defines the offset in the source array
  70090. * @param result defines the Vector3 where to store the result
  70091. */
  70092. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70093. /**
  70094. * Sets the given vector "result" with the given floats.
  70095. * @param x defines the x coordinate of the source
  70096. * @param y defines the y coordinate of the source
  70097. * @param z defines the z coordinate of the source
  70098. * @param result defines the Vector3 where to store the result
  70099. */
  70100. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70101. /**
  70102. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70103. * @returns a new empty Vector3
  70104. */
  70105. static Zero(): Vector3;
  70106. /**
  70107. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70108. * @returns a new unit Vector3
  70109. */
  70110. static One(): Vector3;
  70111. /**
  70112. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70113. * @returns a new up Vector3
  70114. */
  70115. static Up(): Vector3;
  70116. /**
  70117. * Gets a up Vector3 that must not be updated
  70118. */
  70119. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70120. /**
  70121. * Gets a zero Vector3 that must not be updated
  70122. */
  70123. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70124. /**
  70125. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70126. * @returns a new down Vector3
  70127. */
  70128. static Down(): Vector3;
  70129. /**
  70130. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70131. * @returns a new forward Vector3
  70132. */
  70133. static Forward(): Vector3;
  70134. /**
  70135. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70136. * @returns a new forward Vector3
  70137. */
  70138. static Backward(): Vector3;
  70139. /**
  70140. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70141. * @returns a new right Vector3
  70142. */
  70143. static Right(): Vector3;
  70144. /**
  70145. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70146. * @returns a new left Vector3
  70147. */
  70148. static Left(): Vector3;
  70149. /**
  70150. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70151. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70152. * @param vector defines the Vector3 to transform
  70153. * @param transformation defines the transformation matrix
  70154. * @returns the transformed Vector3
  70155. */
  70156. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70157. /**
  70158. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70159. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70160. * @param vector defines the Vector3 to transform
  70161. * @param transformation defines the transformation matrix
  70162. * @param result defines the Vector3 where to store the result
  70163. */
  70164. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70165. /**
  70166. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70167. * This method computes tranformed coordinates only, not transformed direction vectors
  70168. * @param x define the x coordinate of the source vector
  70169. * @param y define the y coordinate of the source vector
  70170. * @param z define the z coordinate of the source vector
  70171. * @param transformation defines the transformation matrix
  70172. * @param result defines the Vector3 where to store the result
  70173. */
  70174. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70175. /**
  70176. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70177. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70178. * @param vector defines the Vector3 to transform
  70179. * @param transformation defines the transformation matrix
  70180. * @returns the new Vector3
  70181. */
  70182. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70183. /**
  70184. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70185. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70186. * @param vector defines the Vector3 to transform
  70187. * @param transformation defines the transformation matrix
  70188. * @param result defines the Vector3 where to store the result
  70189. */
  70190. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70191. /**
  70192. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70193. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70194. * @param x define the x coordinate of the source vector
  70195. * @param y define the y coordinate of the source vector
  70196. * @param z define the z coordinate of the source vector
  70197. * @param transformation defines the transformation matrix
  70198. * @param result defines the Vector3 where to store the result
  70199. */
  70200. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70201. /**
  70202. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70203. * @param value1 defines the first control point
  70204. * @param value2 defines the second control point
  70205. * @param value3 defines the third control point
  70206. * @param value4 defines the fourth control point
  70207. * @param amount defines the amount on the spline to use
  70208. * @returns the new Vector3
  70209. */
  70210. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70211. /**
  70212. * 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"
  70213. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70214. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70215. * @param value defines the current value
  70216. * @param min defines the lower range value
  70217. * @param max defines the upper range value
  70218. * @returns the new Vector3
  70219. */
  70220. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70221. /**
  70222. * 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"
  70223. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70224. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70225. * @param value defines the current value
  70226. * @param min defines the lower range value
  70227. * @param max defines the upper range value
  70228. * @param result defines the Vector3 where to store the result
  70229. */
  70230. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70231. /**
  70232. * Checks if a given vector is inside a specific range
  70233. * @param v defines the vector to test
  70234. * @param min defines the minimum range
  70235. * @param max defines the maximum range
  70236. */
  70237. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70238. /**
  70239. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70240. * @param value1 defines the first control point
  70241. * @param tangent1 defines the first tangent vector
  70242. * @param value2 defines the second control point
  70243. * @param tangent2 defines the second tangent vector
  70244. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70245. * @returns the new Vector3
  70246. */
  70247. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70248. /**
  70249. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70250. * @param start defines the start value
  70251. * @param end defines the end value
  70252. * @param amount max defines amount between both (between 0 and 1)
  70253. * @returns the new Vector3
  70254. */
  70255. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70256. /**
  70257. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70258. * @param start defines the start value
  70259. * @param end defines the end value
  70260. * @param amount max defines amount between both (between 0 and 1)
  70261. * @param result defines the Vector3 where to store the result
  70262. */
  70263. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70264. /**
  70265. * Returns the dot product (float) between the vectors "left" and "right"
  70266. * @param left defines the left operand
  70267. * @param right defines the right operand
  70268. * @returns the dot product
  70269. */
  70270. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70271. /**
  70272. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70273. * The cross product is then orthogonal to both "left" and "right"
  70274. * @param left defines the left operand
  70275. * @param right defines the right operand
  70276. * @returns the cross product
  70277. */
  70278. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70279. /**
  70280. * Sets the given vector "result" with the cross product of "left" and "right"
  70281. * The cross product is then orthogonal to both "left" and "right"
  70282. * @param left defines the left operand
  70283. * @param right defines the right operand
  70284. * @param result defines the Vector3 where to store the result
  70285. */
  70286. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70287. /**
  70288. * Returns a new Vector3 as the normalization of the given vector
  70289. * @param vector defines the Vector3 to normalize
  70290. * @returns the new Vector3
  70291. */
  70292. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70293. /**
  70294. * Sets the given vector "result" with the normalization of the given first vector
  70295. * @param vector defines the Vector3 to normalize
  70296. * @param result defines the Vector3 where to store the result
  70297. */
  70298. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70299. /**
  70300. * Project a Vector3 onto screen space
  70301. * @param vector defines the Vector3 to project
  70302. * @param world defines the world matrix to use
  70303. * @param transform defines the transform (view x projection) matrix to use
  70304. * @param viewport defines the screen viewport to use
  70305. * @returns the new Vector3
  70306. */
  70307. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70308. /** @hidden */
  70309. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70310. /**
  70311. * Unproject from screen space to object space
  70312. * @param source defines the screen space Vector3 to use
  70313. * @param viewportWidth defines the current width of the viewport
  70314. * @param viewportHeight defines the current height of the viewport
  70315. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70316. * @param transform defines the transform (view x projection) matrix to use
  70317. * @returns the new Vector3
  70318. */
  70319. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70320. /**
  70321. * Unproject from screen space to object space
  70322. * @param source defines the screen space Vector3 to use
  70323. * @param viewportWidth defines the current width of the viewport
  70324. * @param viewportHeight defines the current height of the viewport
  70325. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70326. * @param view defines the view matrix to use
  70327. * @param projection defines the projection matrix to use
  70328. * @returns the new Vector3
  70329. */
  70330. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70331. /**
  70332. * Unproject from screen space to object space
  70333. * @param source defines the screen space Vector3 to use
  70334. * @param viewportWidth defines the current width of the viewport
  70335. * @param viewportHeight defines the current height of the viewport
  70336. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70337. * @param view defines the view matrix to use
  70338. * @param projection defines the projection matrix to use
  70339. * @param result defines the Vector3 where to store the result
  70340. */
  70341. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70342. /**
  70343. * Unproject from screen space to object space
  70344. * @param sourceX defines the screen space x coordinate to use
  70345. * @param sourceY defines the screen space y coordinate to use
  70346. * @param sourceZ defines the screen space z coordinate to use
  70347. * @param viewportWidth defines the current width of the viewport
  70348. * @param viewportHeight defines the current height of the viewport
  70349. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70350. * @param view defines the view matrix to use
  70351. * @param projection defines the projection matrix to use
  70352. * @param result defines the Vector3 where to store the result
  70353. */
  70354. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70355. /**
  70356. * Gets the minimal coordinate values between two Vector3
  70357. * @param left defines the first operand
  70358. * @param right defines the second operand
  70359. * @returns the new Vector3
  70360. */
  70361. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70362. /**
  70363. * Gets the maximal coordinate values between two Vector3
  70364. * @param left defines the first operand
  70365. * @param right defines the second operand
  70366. * @returns the new Vector3
  70367. */
  70368. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70369. /**
  70370. * Returns the distance between the vectors "value1" and "value2"
  70371. * @param value1 defines the first operand
  70372. * @param value2 defines the second operand
  70373. * @returns the distance
  70374. */
  70375. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70376. /**
  70377. * Returns the squared distance between the vectors "value1" and "value2"
  70378. * @param value1 defines the first operand
  70379. * @param value2 defines the second operand
  70380. * @returns the squared distance
  70381. */
  70382. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70383. /**
  70384. * Returns a new Vector3 located at the center between "value1" and "value2"
  70385. * @param value1 defines the first operand
  70386. * @param value2 defines the second operand
  70387. * @returns the new Vector3
  70388. */
  70389. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  70390. /**
  70391. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70392. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70393. * to something in order to rotate it from its local system to the given target system
  70394. * Note: axis1, axis2 and axis3 are normalized during this operation
  70395. * @param axis1 defines the first axis
  70396. * @param axis2 defines the second axis
  70397. * @param axis3 defines the third axis
  70398. * @returns a new Vector3
  70399. */
  70400. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  70401. /**
  70402. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70403. * @param axis1 defines the first axis
  70404. * @param axis2 defines the second axis
  70405. * @param axis3 defines the third axis
  70406. * @param ref defines the Vector3 where to store the result
  70407. */
  70408. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  70409. }
  70410. /**
  70411. * Vector4 class created for EulerAngle class conversion to Quaternion
  70412. */
  70413. export class Vector4 {
  70414. /** x value of the vector */
  70415. x: number;
  70416. /** y value of the vector */
  70417. y: number;
  70418. /** z value of the vector */
  70419. z: number;
  70420. /** w value of the vector */
  70421. w: number;
  70422. /**
  70423. * Creates a Vector4 object from the given floats.
  70424. * @param x x value of the vector
  70425. * @param y y value of the vector
  70426. * @param z z value of the vector
  70427. * @param w w value of the vector
  70428. */
  70429. constructor(
  70430. /** x value of the vector */
  70431. x: number,
  70432. /** y value of the vector */
  70433. y: number,
  70434. /** z value of the vector */
  70435. z: number,
  70436. /** w value of the vector */
  70437. w: number);
  70438. /**
  70439. * Returns the string with the Vector4 coordinates.
  70440. * @returns a string containing all the vector values
  70441. */
  70442. toString(): string;
  70443. /**
  70444. * Returns the string "Vector4".
  70445. * @returns "Vector4"
  70446. */
  70447. getClassName(): string;
  70448. /**
  70449. * Returns the Vector4 hash code.
  70450. * @returns a unique hash code
  70451. */
  70452. getHashCode(): number;
  70453. /**
  70454. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70455. * @returns the resulting array
  70456. */
  70457. asArray(): number[];
  70458. /**
  70459. * Populates the given array from the given index with the Vector4 coordinates.
  70460. * @param array array to populate
  70461. * @param index index of the array to start at (default: 0)
  70462. * @returns the Vector4.
  70463. */
  70464. toArray(array: FloatArray, index?: number): Vector4;
  70465. /**
  70466. * Adds the given vector to the current Vector4.
  70467. * @param otherVector the vector to add
  70468. * @returns the updated Vector4.
  70469. */
  70470. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70471. /**
  70472. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70473. * @param otherVector the vector to add
  70474. * @returns the resulting vector
  70475. */
  70476. add(otherVector: DeepImmutable<Vector4>): Vector4;
  70477. /**
  70478. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70479. * @param otherVector the vector to add
  70480. * @param result the vector to store the result
  70481. * @returns the current Vector4.
  70482. */
  70483. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70484. /**
  70485. * Subtract in place the given vector from the current Vector4.
  70486. * @param otherVector the vector to subtract
  70487. * @returns the updated Vector4.
  70488. */
  70489. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70490. /**
  70491. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70492. * @param otherVector the vector to add
  70493. * @returns the new vector with the result
  70494. */
  70495. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  70496. /**
  70497. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70498. * @param otherVector the vector to subtract
  70499. * @param result the vector to store the result
  70500. * @returns the current Vector4.
  70501. */
  70502. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70503. /**
  70504. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70505. */
  70506. /**
  70507. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70508. * @param x value to subtract
  70509. * @param y value to subtract
  70510. * @param z value to subtract
  70511. * @param w value to subtract
  70512. * @returns new vector containing the result
  70513. */
  70514. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70515. /**
  70516. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70517. * @param x value to subtract
  70518. * @param y value to subtract
  70519. * @param z value to subtract
  70520. * @param w value to subtract
  70521. * @param result the vector to store the result in
  70522. * @returns the current Vector4.
  70523. */
  70524. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  70525. /**
  70526. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70527. * @returns a new vector with the negated values
  70528. */
  70529. negate(): Vector4;
  70530. /**
  70531. * Multiplies the current Vector4 coordinates by scale (float).
  70532. * @param scale the number to scale with
  70533. * @returns the updated Vector4.
  70534. */
  70535. scaleInPlace(scale: number): Vector4;
  70536. /**
  70537. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70538. * @param scale the number to scale with
  70539. * @returns a new vector with the result
  70540. */
  70541. scale(scale: number): Vector4;
  70542. /**
  70543. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70544. * @param scale the number to scale with
  70545. * @param result a vector to store the result in
  70546. * @returns the current Vector4.
  70547. */
  70548. scaleToRef(scale: number, result: Vector4): Vector4;
  70549. /**
  70550. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70551. * @param scale defines the scale factor
  70552. * @param result defines the Vector4 object where to store the result
  70553. * @returns the unmodified current Vector4
  70554. */
  70555. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  70556. /**
  70557. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70558. * @param otherVector the vector to compare against
  70559. * @returns true if they are equal
  70560. */
  70561. equals(otherVector: DeepImmutable<Vector4>): boolean;
  70562. /**
  70563. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70564. * @param otherVector vector to compare against
  70565. * @param epsilon (Default: very small number)
  70566. * @returns true if they are equal
  70567. */
  70568. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  70569. /**
  70570. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70571. * @param x x value to compare against
  70572. * @param y y value to compare against
  70573. * @param z z value to compare against
  70574. * @param w w value to compare against
  70575. * @returns true if equal
  70576. */
  70577. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  70578. /**
  70579. * Multiplies in place the current Vector4 by the given one.
  70580. * @param otherVector vector to multiple with
  70581. * @returns the updated Vector4.
  70582. */
  70583. multiplyInPlace(otherVector: Vector4): Vector4;
  70584. /**
  70585. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70586. * @param otherVector vector to multiple with
  70587. * @returns resulting new vector
  70588. */
  70589. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  70590. /**
  70591. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70592. * @param otherVector vector to multiple with
  70593. * @param result vector to store the result
  70594. * @returns the current Vector4.
  70595. */
  70596. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70597. /**
  70598. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70599. * @param x x value multiply with
  70600. * @param y y value multiply with
  70601. * @param z z value multiply with
  70602. * @param w w value multiply with
  70603. * @returns resulting new vector
  70604. */
  70605. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  70606. /**
  70607. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70608. * @param otherVector vector to devide with
  70609. * @returns resulting new vector
  70610. */
  70611. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  70612. /**
  70613. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70614. * @param otherVector vector to devide with
  70615. * @param result vector to store the result
  70616. * @returns the current Vector4.
  70617. */
  70618. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70619. /**
  70620. * Divides the current Vector3 coordinates by the given ones.
  70621. * @param otherVector vector to devide with
  70622. * @returns the updated Vector3.
  70623. */
  70624. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70625. /**
  70626. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70627. * @param other defines the second operand
  70628. * @returns the current updated Vector4
  70629. */
  70630. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70631. /**
  70632. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70633. * @param other defines the second operand
  70634. * @returns the current updated Vector4
  70635. */
  70636. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70637. /**
  70638. * Gets a new Vector4 from current Vector4 floored values
  70639. * @returns a new Vector4
  70640. */
  70641. floor(): Vector4;
  70642. /**
  70643. * Gets a new Vector4 from current Vector3 floored values
  70644. * @returns a new Vector4
  70645. */
  70646. fract(): Vector4;
  70647. /**
  70648. * Returns the Vector4 length (float).
  70649. * @returns the length
  70650. */
  70651. length(): number;
  70652. /**
  70653. * Returns the Vector4 squared length (float).
  70654. * @returns the length squared
  70655. */
  70656. lengthSquared(): number;
  70657. /**
  70658. * Normalizes in place the Vector4.
  70659. * @returns the updated Vector4.
  70660. */
  70661. normalize(): Vector4;
  70662. /**
  70663. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70664. * @returns this converted to a new vector3
  70665. */
  70666. toVector3(): Vector3;
  70667. /**
  70668. * Returns a new Vector4 copied from the current one.
  70669. * @returns the new cloned vector
  70670. */
  70671. clone(): Vector4;
  70672. /**
  70673. * Updates the current Vector4 with the given one coordinates.
  70674. * @param source the source vector to copy from
  70675. * @returns the updated Vector4.
  70676. */
  70677. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70678. /**
  70679. * Updates the current Vector4 coordinates with the given floats.
  70680. * @param x float to copy from
  70681. * @param y float to copy from
  70682. * @param z float to copy from
  70683. * @param w float to copy from
  70684. * @returns the updated Vector4.
  70685. */
  70686. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70687. /**
  70688. * Updates the current Vector4 coordinates with the given floats.
  70689. * @param x float to set from
  70690. * @param y float to set from
  70691. * @param z float to set from
  70692. * @param w float to set from
  70693. * @returns the updated Vector4.
  70694. */
  70695. set(x: number, y: number, z: number, w: number): Vector4;
  70696. /**
  70697. * Copies the given float to the current Vector3 coordinates
  70698. * @param v defines the x, y, z and w coordinates of the operand
  70699. * @returns the current updated Vector3
  70700. */
  70701. setAll(v: number): Vector4;
  70702. /**
  70703. * Returns a new Vector4 set from the starting index of the given array.
  70704. * @param array the array to pull values from
  70705. * @param offset the offset into the array to start at
  70706. * @returns the new vector
  70707. */
  70708. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70709. /**
  70710. * Updates the given vector "result" from the starting index of the given array.
  70711. * @param array the array to pull values from
  70712. * @param offset the offset into the array to start at
  70713. * @param result the vector to store the result in
  70714. */
  70715. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70716. /**
  70717. * Updates the given vector "result" from the starting index of the given Float32Array.
  70718. * @param array the array to pull values from
  70719. * @param offset the offset into the array to start at
  70720. * @param result the vector to store the result in
  70721. */
  70722. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70723. /**
  70724. * Updates the given vector "result" coordinates from the given floats.
  70725. * @param x float to set from
  70726. * @param y float to set from
  70727. * @param z float to set from
  70728. * @param w float to set from
  70729. * @param result the vector to the floats in
  70730. */
  70731. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70732. /**
  70733. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70734. * @returns the new vector
  70735. */
  70736. static Zero(): Vector4;
  70737. /**
  70738. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70739. * @returns the new vector
  70740. */
  70741. static One(): Vector4;
  70742. /**
  70743. * Returns a new normalized Vector4 from the given one.
  70744. * @param vector the vector to normalize
  70745. * @returns the vector
  70746. */
  70747. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70748. /**
  70749. * Updates the given vector "result" from the normalization of the given one.
  70750. * @param vector the vector to normalize
  70751. * @param result the vector to store the result in
  70752. */
  70753. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70754. /**
  70755. * Returns a vector with the minimum values from the left and right vectors
  70756. * @param left left vector to minimize
  70757. * @param right right vector to minimize
  70758. * @returns a new vector with the minimum of the left and right vector values
  70759. */
  70760. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70761. /**
  70762. * Returns a vector with the maximum values from the left and right vectors
  70763. * @param left left vector to maximize
  70764. * @param right right vector to maximize
  70765. * @returns a new vector with the maximum of the left and right vector values
  70766. */
  70767. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70768. /**
  70769. * Returns the distance (float) between the vectors "value1" and "value2".
  70770. * @param value1 value to calulate the distance between
  70771. * @param value2 value to calulate the distance between
  70772. * @return the distance between the two vectors
  70773. */
  70774. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70775. /**
  70776. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70777. * @param value1 value to calulate the distance between
  70778. * @param value2 value to calulate the distance between
  70779. * @return the distance between the two vectors squared
  70780. */
  70781. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70782. /**
  70783. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70784. * @param value1 value to calulate the center between
  70785. * @param value2 value to calulate the center between
  70786. * @return the center between the two vectors
  70787. */
  70788. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70789. /**
  70790. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70791. * This methods computes transformed normalized direction vectors only.
  70792. * @param vector the vector to transform
  70793. * @param transformation the transformation matrix to apply
  70794. * @returns the new vector
  70795. */
  70796. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70797. /**
  70798. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70799. * This methods computes transformed normalized direction vectors only.
  70800. * @param vector the vector to transform
  70801. * @param transformation the transformation matrix to apply
  70802. * @param result the vector to store the result in
  70803. */
  70804. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70805. /**
  70806. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70807. * This methods computes transformed normalized direction vectors only.
  70808. * @param x value to transform
  70809. * @param y value to transform
  70810. * @param z value to transform
  70811. * @param w value to transform
  70812. * @param transformation the transformation matrix to apply
  70813. * @param result the vector to store the results in
  70814. */
  70815. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70816. /**
  70817. * Creates a new Vector4 from a Vector3
  70818. * @param source defines the source data
  70819. * @param w defines the 4th component (default is 0)
  70820. * @returns a new Vector4
  70821. */
  70822. static FromVector3(source: Vector3, w?: number): Vector4;
  70823. }
  70824. /**
  70825. * Class used to store quaternion data
  70826. * @see https://en.wikipedia.org/wiki/Quaternion
  70827. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70828. */
  70829. export class Quaternion {
  70830. /** defines the first component (0 by default) */
  70831. x: number;
  70832. /** defines the second component (0 by default) */
  70833. y: number;
  70834. /** defines the third component (0 by default) */
  70835. z: number;
  70836. /** defines the fourth component (1.0 by default) */
  70837. w: number;
  70838. /**
  70839. * Creates a new Quaternion from the given floats
  70840. * @param x defines the first component (0 by default)
  70841. * @param y defines the second component (0 by default)
  70842. * @param z defines the third component (0 by default)
  70843. * @param w defines the fourth component (1.0 by default)
  70844. */
  70845. constructor(
  70846. /** defines the first component (0 by default) */
  70847. x?: number,
  70848. /** defines the second component (0 by default) */
  70849. y?: number,
  70850. /** defines the third component (0 by default) */
  70851. z?: number,
  70852. /** defines the fourth component (1.0 by default) */
  70853. w?: number);
  70854. /**
  70855. * Gets a string representation for the current quaternion
  70856. * @returns a string with the Quaternion coordinates
  70857. */
  70858. toString(): string;
  70859. /**
  70860. * Gets the class name of the quaternion
  70861. * @returns the string "Quaternion"
  70862. */
  70863. getClassName(): string;
  70864. /**
  70865. * Gets a hash code for this quaternion
  70866. * @returns the quaternion hash code
  70867. */
  70868. getHashCode(): number;
  70869. /**
  70870. * Copy the quaternion to an array
  70871. * @returns a new array populated with 4 elements from the quaternion coordinates
  70872. */
  70873. asArray(): number[];
  70874. /**
  70875. * Check if two quaternions are equals
  70876. * @param otherQuaternion defines the second operand
  70877. * @return true if the current quaternion and the given one coordinates are strictly equals
  70878. */
  70879. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70880. /**
  70881. * Clone the current quaternion
  70882. * @returns a new quaternion copied from the current one
  70883. */
  70884. clone(): Quaternion;
  70885. /**
  70886. * Copy a quaternion to the current one
  70887. * @param other defines the other quaternion
  70888. * @returns the updated current quaternion
  70889. */
  70890. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70891. /**
  70892. * Updates the current quaternion with the given float coordinates
  70893. * @param x defines the x coordinate
  70894. * @param y defines the y coordinate
  70895. * @param z defines the z coordinate
  70896. * @param w defines the w coordinate
  70897. * @returns the updated current quaternion
  70898. */
  70899. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70900. /**
  70901. * Updates the current quaternion from the given float coordinates
  70902. * @param x defines the x coordinate
  70903. * @param y defines the y coordinate
  70904. * @param z defines the z coordinate
  70905. * @param w defines the w coordinate
  70906. * @returns the updated current quaternion
  70907. */
  70908. set(x: number, y: number, z: number, w: number): Quaternion;
  70909. /**
  70910. * Adds two quaternions
  70911. * @param other defines the second operand
  70912. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70913. */
  70914. add(other: DeepImmutable<Quaternion>): Quaternion;
  70915. /**
  70916. * Add a quaternion to the current one
  70917. * @param other defines the quaternion to add
  70918. * @returns the current quaternion
  70919. */
  70920. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70921. /**
  70922. * Subtract two quaternions
  70923. * @param other defines the second operand
  70924. * @returns a new quaternion as the subtraction result of the given one from the current one
  70925. */
  70926. subtract(other: Quaternion): Quaternion;
  70927. /**
  70928. * Multiplies the current quaternion by a scale factor
  70929. * @param value defines the scale factor
  70930. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70931. */
  70932. scale(value: number): Quaternion;
  70933. /**
  70934. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70935. * @param scale defines the scale factor
  70936. * @param result defines the Quaternion object where to store the result
  70937. * @returns the unmodified current quaternion
  70938. */
  70939. scaleToRef(scale: number, result: Quaternion): Quaternion;
  70940. /**
  70941. * Multiplies in place the current quaternion by a scale factor
  70942. * @param value defines the scale factor
  70943. * @returns the current modified quaternion
  70944. */
  70945. scaleInPlace(value: number): Quaternion;
  70946. /**
  70947. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70948. * @param scale defines the scale factor
  70949. * @param result defines the Quaternion object where to store the result
  70950. * @returns the unmodified current quaternion
  70951. */
  70952. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  70953. /**
  70954. * Multiplies two quaternions
  70955. * @param q1 defines the second operand
  70956. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70957. */
  70958. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  70959. /**
  70960. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70961. * @param q1 defines the second operand
  70962. * @param result defines the target quaternion
  70963. * @returns the current quaternion
  70964. */
  70965. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  70966. /**
  70967. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70968. * @param q1 defines the second operand
  70969. * @returns the currentupdated quaternion
  70970. */
  70971. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  70972. /**
  70973. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70974. * @param ref defines the target quaternion
  70975. * @returns the current quaternion
  70976. */
  70977. conjugateToRef(ref: Quaternion): Quaternion;
  70978. /**
  70979. * Conjugates in place (1-q) the current quaternion
  70980. * @returns the current updated quaternion
  70981. */
  70982. conjugateInPlace(): Quaternion;
  70983. /**
  70984. * Conjugates in place (1-q) the current quaternion
  70985. * @returns a new quaternion
  70986. */
  70987. conjugate(): Quaternion;
  70988. /**
  70989. * Gets length of current quaternion
  70990. * @returns the quaternion length (float)
  70991. */
  70992. length(): number;
  70993. /**
  70994. * Normalize in place the current quaternion
  70995. * @returns the current updated quaternion
  70996. */
  70997. normalize(): Quaternion;
  70998. /**
  70999. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71000. * @param order is a reserved parameter and is ignore for now
  71001. * @returns a new Vector3 containing the Euler angles
  71002. */
  71003. toEulerAngles(order?: string): Vector3;
  71004. /**
  71005. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71006. * @param result defines the vector which will be filled with the Euler angles
  71007. * @param order is a reserved parameter and is ignore for now
  71008. * @returns the current unchanged quaternion
  71009. */
  71010. toEulerAnglesToRef(result: Vector3): Quaternion;
  71011. /**
  71012. * Updates the given rotation matrix with the current quaternion values
  71013. * @param result defines the target matrix
  71014. * @returns the current unchanged quaternion
  71015. */
  71016. toRotationMatrix(result: Matrix): Quaternion;
  71017. /**
  71018. * Updates the current quaternion from the given rotation matrix values
  71019. * @param matrix defines the source matrix
  71020. * @returns the current updated quaternion
  71021. */
  71022. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71023. /**
  71024. * Creates a new quaternion from a rotation matrix
  71025. * @param matrix defines the source matrix
  71026. * @returns a new quaternion created from the given rotation matrix values
  71027. */
  71028. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71029. /**
  71030. * Updates the given quaternion with the given rotation matrix values
  71031. * @param matrix defines the source matrix
  71032. * @param result defines the target quaternion
  71033. */
  71034. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71035. /**
  71036. * Returns the dot product (float) between the quaternions "left" and "right"
  71037. * @param left defines the left operand
  71038. * @param right defines the right operand
  71039. * @returns the dot product
  71040. */
  71041. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71042. /**
  71043. * Checks if the two quaternions are close to each other
  71044. * @param quat0 defines the first quaternion to check
  71045. * @param quat1 defines the second quaternion to check
  71046. * @returns true if the two quaternions are close to each other
  71047. */
  71048. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71049. /**
  71050. * Creates an empty quaternion
  71051. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71052. */
  71053. static Zero(): Quaternion;
  71054. /**
  71055. * Inverse a given quaternion
  71056. * @param q defines the source quaternion
  71057. * @returns a new quaternion as the inverted current quaternion
  71058. */
  71059. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71060. /**
  71061. * Inverse a given quaternion
  71062. * @param q defines the source quaternion
  71063. * @param result the quaternion the result will be stored in
  71064. * @returns the result quaternion
  71065. */
  71066. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71067. /**
  71068. * Creates an identity quaternion
  71069. * @returns the identity quaternion
  71070. */
  71071. static Identity(): Quaternion;
  71072. /**
  71073. * Gets a boolean indicating if the given quaternion is identity
  71074. * @param quaternion defines the quaternion to check
  71075. * @returns true if the quaternion is identity
  71076. */
  71077. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71078. /**
  71079. * Creates a quaternion from a rotation around an axis
  71080. * @param axis defines the axis to use
  71081. * @param angle defines the angle to use
  71082. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71083. */
  71084. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71085. /**
  71086. * Creates a rotation around an axis and stores it into the given quaternion
  71087. * @param axis defines the axis to use
  71088. * @param angle defines the angle to use
  71089. * @param result defines the target quaternion
  71090. * @returns the target quaternion
  71091. */
  71092. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71093. /**
  71094. * Creates a new quaternion from data stored into an array
  71095. * @param array defines the data source
  71096. * @param offset defines the offset in the source array where the data starts
  71097. * @returns a new quaternion
  71098. */
  71099. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71100. /**
  71101. * Create a quaternion from Euler rotation angles
  71102. * @param x Pitch
  71103. * @param y Yaw
  71104. * @param z Roll
  71105. * @returns the new Quaternion
  71106. */
  71107. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71108. /**
  71109. * Updates a quaternion from Euler rotation angles
  71110. * @param x Pitch
  71111. * @param y Yaw
  71112. * @param z Roll
  71113. * @param result the quaternion to store the result
  71114. * @returns the updated quaternion
  71115. */
  71116. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71117. /**
  71118. * Create a quaternion from Euler rotation vector
  71119. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71120. * @returns the new Quaternion
  71121. */
  71122. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71123. /**
  71124. * Updates a quaternion from Euler rotation vector
  71125. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71126. * @param result the quaternion to store the result
  71127. * @returns the updated quaternion
  71128. */
  71129. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71130. /**
  71131. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71132. * @param yaw defines the rotation around Y axis
  71133. * @param pitch defines the rotation around X axis
  71134. * @param roll defines the rotation around Z axis
  71135. * @returns the new quaternion
  71136. */
  71137. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71138. /**
  71139. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71140. * @param yaw defines the rotation around Y axis
  71141. * @param pitch defines the rotation around X axis
  71142. * @param roll defines the rotation around Z axis
  71143. * @param result defines the target quaternion
  71144. */
  71145. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71146. /**
  71147. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71148. * @param alpha defines the rotation around first axis
  71149. * @param beta defines the rotation around second axis
  71150. * @param gamma defines the rotation around third axis
  71151. * @returns the new quaternion
  71152. */
  71153. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71154. /**
  71155. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71156. * @param alpha defines the rotation around first axis
  71157. * @param beta defines the rotation around second axis
  71158. * @param gamma defines the rotation around third axis
  71159. * @param result defines the target quaternion
  71160. */
  71161. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71162. /**
  71163. * 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)
  71164. * @param axis1 defines the first axis
  71165. * @param axis2 defines the second axis
  71166. * @param axis3 defines the third axis
  71167. * @returns the new quaternion
  71168. */
  71169. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71170. /**
  71171. * 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
  71172. * @param axis1 defines the first axis
  71173. * @param axis2 defines the second axis
  71174. * @param axis3 defines the third axis
  71175. * @param ref defines the target quaternion
  71176. */
  71177. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71178. /**
  71179. * Interpolates between two quaternions
  71180. * @param left defines first quaternion
  71181. * @param right defines second quaternion
  71182. * @param amount defines the gradient to use
  71183. * @returns the new interpolated quaternion
  71184. */
  71185. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71186. /**
  71187. * Interpolates between two quaternions and stores it into a target quaternion
  71188. * @param left defines first quaternion
  71189. * @param right defines second quaternion
  71190. * @param amount defines the gradient to use
  71191. * @param result defines the target quaternion
  71192. */
  71193. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71194. /**
  71195. * Interpolate between two quaternions using Hermite interpolation
  71196. * @param value1 defines first quaternion
  71197. * @param tangent1 defines the incoming tangent
  71198. * @param value2 defines second quaternion
  71199. * @param tangent2 defines the outgoing tangent
  71200. * @param amount defines the target quaternion
  71201. * @returns the new interpolated quaternion
  71202. */
  71203. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71204. }
  71205. /**
  71206. * Class used to store matrix data (4x4)
  71207. */
  71208. export class Matrix {
  71209. private static _updateFlagSeed;
  71210. private static _identityReadOnly;
  71211. private _isIdentity;
  71212. private _isIdentityDirty;
  71213. private _isIdentity3x2;
  71214. private _isIdentity3x2Dirty;
  71215. /**
  71216. * Gets the update flag of the matrix which is an unique number for the matrix.
  71217. * It will be incremented every time the matrix data change.
  71218. * You can use it to speed the comparison between two versions of the same matrix.
  71219. */
  71220. updateFlag: number;
  71221. private readonly _m;
  71222. /**
  71223. * Gets the internal data of the matrix
  71224. */
  71225. readonly m: DeepImmutable<Float32Array>;
  71226. /** @hidden */
  71227. _markAsUpdated(): void;
  71228. /** @hidden */
  71229. private _updateIdentityStatus;
  71230. /**
  71231. * Creates an empty matrix (filled with zeros)
  71232. */
  71233. constructor();
  71234. /**
  71235. * Check if the current matrix is identity
  71236. * @returns true is the matrix is the identity matrix
  71237. */
  71238. isIdentity(): boolean;
  71239. /**
  71240. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71241. * @returns true is the matrix is the identity matrix
  71242. */
  71243. isIdentityAs3x2(): boolean;
  71244. /**
  71245. * Gets the determinant of the matrix
  71246. * @returns the matrix determinant
  71247. */
  71248. determinant(): number;
  71249. /**
  71250. * Returns the matrix as a Float32Array
  71251. * @returns the matrix underlying array
  71252. */
  71253. toArray(): DeepImmutable<Float32Array>;
  71254. /**
  71255. * Returns the matrix as a Float32Array
  71256. * @returns the matrix underlying array.
  71257. */
  71258. asArray(): DeepImmutable<Float32Array>;
  71259. /**
  71260. * Inverts the current matrix in place
  71261. * @returns the current inverted matrix
  71262. */
  71263. invert(): Matrix;
  71264. /**
  71265. * Sets all the matrix elements to zero
  71266. * @returns the current matrix
  71267. */
  71268. reset(): Matrix;
  71269. /**
  71270. * Adds the current matrix with a second one
  71271. * @param other defines the matrix to add
  71272. * @returns a new matrix as the addition of the current matrix and the given one
  71273. */
  71274. add(other: DeepImmutable<Matrix>): Matrix;
  71275. /**
  71276. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71277. * @param other defines the matrix to add
  71278. * @param result defines the target matrix
  71279. * @returns the current matrix
  71280. */
  71281. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71282. /**
  71283. * Adds in place the given matrix to the current matrix
  71284. * @param other defines the second operand
  71285. * @returns the current updated matrix
  71286. */
  71287. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71288. /**
  71289. * Sets the given matrix to the current inverted Matrix
  71290. * @param other defines the target matrix
  71291. * @returns the unmodified current matrix
  71292. */
  71293. invertToRef(other: Matrix): Matrix;
  71294. /**
  71295. * add a value at the specified position in the current Matrix
  71296. * @param index the index of the value within the matrix. between 0 and 15.
  71297. * @param value the value to be added
  71298. * @returns the current updated matrix
  71299. */
  71300. addAtIndex(index: number, value: number): Matrix;
  71301. /**
  71302. * mutiply the specified position in the current Matrix by a value
  71303. * @param index the index of the value within the matrix. between 0 and 15.
  71304. * @param value the value to be added
  71305. * @returns the current updated matrix
  71306. */
  71307. multiplyAtIndex(index: number, value: number): Matrix;
  71308. /**
  71309. * Inserts the translation vector (using 3 floats) in the current matrix
  71310. * @param x defines the 1st component of the translation
  71311. * @param y defines the 2nd component of the translation
  71312. * @param z defines the 3rd component of the translation
  71313. * @returns the current updated matrix
  71314. */
  71315. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71316. /**
  71317. * Adds the translation vector (using 3 floats) in the current matrix
  71318. * @param x defines the 1st component of the translation
  71319. * @param y defines the 2nd component of the translation
  71320. * @param z defines the 3rd component of the translation
  71321. * @returns the current updated matrix
  71322. */
  71323. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71324. /**
  71325. * Inserts the translation vector in the current matrix
  71326. * @param vector3 defines the translation to insert
  71327. * @returns the current updated matrix
  71328. */
  71329. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71330. /**
  71331. * Gets the translation value of the current matrix
  71332. * @returns a new Vector3 as the extracted translation from the matrix
  71333. */
  71334. getTranslation(): Vector3;
  71335. /**
  71336. * Fill a Vector3 with the extracted translation from the matrix
  71337. * @param result defines the Vector3 where to store the translation
  71338. * @returns the current matrix
  71339. */
  71340. getTranslationToRef(result: Vector3): Matrix;
  71341. /**
  71342. * Remove rotation and scaling part from the matrix
  71343. * @returns the updated matrix
  71344. */
  71345. removeRotationAndScaling(): Matrix;
  71346. /**
  71347. * Multiply two matrices
  71348. * @param other defines the second operand
  71349. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71350. */
  71351. multiply(other: DeepImmutable<Matrix>): Matrix;
  71352. /**
  71353. * Copy the current matrix from the given one
  71354. * @param other defines the source matrix
  71355. * @returns the current updated matrix
  71356. */
  71357. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71358. /**
  71359. * Populates the given array from the starting index with the current matrix values
  71360. * @param array defines the target array
  71361. * @param offset defines the offset in the target array where to start storing values
  71362. * @returns the current matrix
  71363. */
  71364. copyToArray(array: Float32Array, offset?: number): Matrix;
  71365. /**
  71366. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71367. * @param other defines the second operand
  71368. * @param result defines the matrix where to store the multiplication
  71369. * @returns the current matrix
  71370. */
  71371. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71372. /**
  71373. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71374. * @param other defines the second operand
  71375. * @param result defines the array where to store the multiplication
  71376. * @param offset defines the offset in the target array where to start storing values
  71377. * @returns the current matrix
  71378. */
  71379. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  71380. /**
  71381. * Check equality between this matrix and a second one
  71382. * @param value defines the second matrix to compare
  71383. * @returns true is the current matrix and the given one values are strictly equal
  71384. */
  71385. equals(value: DeepImmutable<Matrix>): boolean;
  71386. /**
  71387. * Clone the current matrix
  71388. * @returns a new matrix from the current matrix
  71389. */
  71390. clone(): Matrix;
  71391. /**
  71392. * Returns the name of the current matrix class
  71393. * @returns the string "Matrix"
  71394. */
  71395. getClassName(): string;
  71396. /**
  71397. * Gets the hash code of the current matrix
  71398. * @returns the hash code
  71399. */
  71400. getHashCode(): number;
  71401. /**
  71402. * Decomposes the current Matrix into a translation, rotation and scaling components
  71403. * @param scale defines the scale vector3 given as a reference to update
  71404. * @param rotation defines the rotation quaternion given as a reference to update
  71405. * @param translation defines the translation vector3 given as a reference to update
  71406. * @returns true if operation was successful
  71407. */
  71408. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  71409. /**
  71410. * Gets specific row of the matrix
  71411. * @param index defines the number of the row to get
  71412. * @returns the index-th row of the current matrix as a new Vector4
  71413. */
  71414. getRow(index: number): Nullable<Vector4>;
  71415. /**
  71416. * Sets the index-th row of the current matrix to the vector4 values
  71417. * @param index defines the number of the row to set
  71418. * @param row defines the target vector4
  71419. * @returns the updated current matrix
  71420. */
  71421. setRow(index: number, row: Vector4): Matrix;
  71422. /**
  71423. * Compute the transpose of the matrix
  71424. * @returns the new transposed matrix
  71425. */
  71426. transpose(): Matrix;
  71427. /**
  71428. * Compute the transpose of the matrix and store it in a given matrix
  71429. * @param result defines the target matrix
  71430. * @returns the current matrix
  71431. */
  71432. transposeToRef(result: Matrix): Matrix;
  71433. /**
  71434. * Sets the index-th row of the current matrix with the given 4 x float values
  71435. * @param index defines the row index
  71436. * @param x defines the x component to set
  71437. * @param y defines the y component to set
  71438. * @param z defines the z component to set
  71439. * @param w defines the w component to set
  71440. * @returns the updated current matrix
  71441. */
  71442. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  71443. /**
  71444. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71445. * @param scale defines the scale factor
  71446. * @returns a new matrix
  71447. */
  71448. scale(scale: number): Matrix;
  71449. /**
  71450. * Scale the current matrix values by a factor to a given result matrix
  71451. * @param scale defines the scale factor
  71452. * @param result defines the matrix to store the result
  71453. * @returns the current matrix
  71454. */
  71455. scaleToRef(scale: number, result: Matrix): Matrix;
  71456. /**
  71457. * Scale the current matrix values by a factor and add the result to a given matrix
  71458. * @param scale defines the scale factor
  71459. * @param result defines the Matrix to store the result
  71460. * @returns the current matrix
  71461. */
  71462. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  71463. /**
  71464. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71465. * @param ref matrix to store the result
  71466. */
  71467. toNormalMatrix(ref: Matrix): void;
  71468. /**
  71469. * Gets only rotation part of the current matrix
  71470. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71471. */
  71472. getRotationMatrix(): Matrix;
  71473. /**
  71474. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71475. * @param result defines the target matrix to store data to
  71476. * @returns the current matrix
  71477. */
  71478. getRotationMatrixToRef(result: Matrix): Matrix;
  71479. /**
  71480. * Toggles model matrix from being right handed to left handed in place and vice versa
  71481. */
  71482. toggleModelMatrixHandInPlace(): void;
  71483. /**
  71484. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71485. */
  71486. toggleProjectionMatrixHandInPlace(): void;
  71487. /**
  71488. * Creates a matrix from an array
  71489. * @param array defines the source array
  71490. * @param offset defines an offset in the source array
  71491. * @returns a new Matrix set from the starting index of the given array
  71492. */
  71493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  71494. /**
  71495. * Copy the content of an array into a given matrix
  71496. * @param array defines the source array
  71497. * @param offset defines an offset in the source array
  71498. * @param result defines the target matrix
  71499. */
  71500. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  71501. /**
  71502. * Stores an array into a matrix after having multiplied each component by a given factor
  71503. * @param array defines the source array
  71504. * @param offset defines the offset in the source array
  71505. * @param scale defines the scaling factor
  71506. * @param result defines the target matrix
  71507. */
  71508. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  71509. /**
  71510. * Gets an identity matrix that must not be updated
  71511. */
  71512. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  71513. /**
  71514. * Stores a list of values (16) inside a given matrix
  71515. * @param initialM11 defines 1st value of 1st row
  71516. * @param initialM12 defines 2nd value of 1st row
  71517. * @param initialM13 defines 3rd value of 1st row
  71518. * @param initialM14 defines 4th value of 1st row
  71519. * @param initialM21 defines 1st value of 2nd row
  71520. * @param initialM22 defines 2nd value of 2nd row
  71521. * @param initialM23 defines 3rd value of 2nd row
  71522. * @param initialM24 defines 4th value of 2nd row
  71523. * @param initialM31 defines 1st value of 3rd row
  71524. * @param initialM32 defines 2nd value of 3rd row
  71525. * @param initialM33 defines 3rd value of 3rd row
  71526. * @param initialM34 defines 4th value of 3rd row
  71527. * @param initialM41 defines 1st value of 4th row
  71528. * @param initialM42 defines 2nd value of 4th row
  71529. * @param initialM43 defines 3rd value of 4th row
  71530. * @param initialM44 defines 4th value of 4th row
  71531. * @param result defines the target matrix
  71532. */
  71533. 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;
  71534. /**
  71535. * Creates new matrix from a list of values (16)
  71536. * @param initialM11 defines 1st value of 1st row
  71537. * @param initialM12 defines 2nd value of 1st row
  71538. * @param initialM13 defines 3rd value of 1st row
  71539. * @param initialM14 defines 4th value of 1st row
  71540. * @param initialM21 defines 1st value of 2nd row
  71541. * @param initialM22 defines 2nd value of 2nd row
  71542. * @param initialM23 defines 3rd value of 2nd row
  71543. * @param initialM24 defines 4th value of 2nd row
  71544. * @param initialM31 defines 1st value of 3rd row
  71545. * @param initialM32 defines 2nd value of 3rd row
  71546. * @param initialM33 defines 3rd value of 3rd row
  71547. * @param initialM34 defines 4th value of 3rd row
  71548. * @param initialM41 defines 1st value of 4th row
  71549. * @param initialM42 defines 2nd value of 4th row
  71550. * @param initialM43 defines 3rd value of 4th row
  71551. * @param initialM44 defines 4th value of 4th row
  71552. * @returns the new matrix
  71553. */
  71554. 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;
  71555. /**
  71556. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71557. * @param scale defines the scale vector3
  71558. * @param rotation defines the rotation quaternion
  71559. * @param translation defines the translation vector3
  71560. * @returns a new matrix
  71561. */
  71562. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  71563. /**
  71564. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71565. * @param scale defines the scale vector3
  71566. * @param rotation defines the rotation quaternion
  71567. * @param translation defines the translation vector3
  71568. * @param result defines the target matrix
  71569. */
  71570. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  71571. /**
  71572. * Creates a new identity matrix
  71573. * @returns a new identity matrix
  71574. */
  71575. static Identity(): Matrix;
  71576. /**
  71577. * Creates a new identity matrix and stores the result in a given matrix
  71578. * @param result defines the target matrix
  71579. */
  71580. static IdentityToRef(result: Matrix): void;
  71581. /**
  71582. * Creates a new zero matrix
  71583. * @returns a new zero matrix
  71584. */
  71585. static Zero(): Matrix;
  71586. /**
  71587. * Creates a new rotation matrix for "angle" radians around the X axis
  71588. * @param angle defines the angle (in radians) to use
  71589. * @return the new matrix
  71590. */
  71591. static RotationX(angle: number): Matrix;
  71592. /**
  71593. * Creates a new matrix as the invert of a given matrix
  71594. * @param source defines the source matrix
  71595. * @returns the new matrix
  71596. */
  71597. static Invert(source: DeepImmutable<Matrix>): Matrix;
  71598. /**
  71599. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  71600. * @param angle defines the angle (in radians) to use
  71601. * @param result defines the target matrix
  71602. */
  71603. static RotationXToRef(angle: number, result: Matrix): void;
  71604. /**
  71605. * Creates a new rotation matrix for "angle" radians around the Y axis
  71606. * @param angle defines the angle (in radians) to use
  71607. * @return the new matrix
  71608. */
  71609. static RotationY(angle: number): Matrix;
  71610. /**
  71611. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  71612. * @param angle defines the angle (in radians) to use
  71613. * @param result defines the target matrix
  71614. */
  71615. static RotationYToRef(angle: number, result: Matrix): void;
  71616. /**
  71617. * Creates a new rotation matrix for "angle" radians around the Z axis
  71618. * @param angle defines the angle (in radians) to use
  71619. * @return the new matrix
  71620. */
  71621. static RotationZ(angle: number): Matrix;
  71622. /**
  71623. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  71624. * @param angle defines the angle (in radians) to use
  71625. * @param result defines the target matrix
  71626. */
  71627. static RotationZToRef(angle: number, result: Matrix): void;
  71628. /**
  71629. * Creates a new rotation matrix for "angle" radians around the given axis
  71630. * @param axis defines the axis to use
  71631. * @param angle defines the angle (in radians) to use
  71632. * @return the new matrix
  71633. */
  71634. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  71635. /**
  71636. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71637. * @param axis defines the axis to use
  71638. * @param angle defines the angle (in radians) to use
  71639. * @param result defines the target matrix
  71640. */
  71641. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71642. /**
  71643. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71644. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71645. * @param from defines the vector to align
  71646. * @param to defines the vector to align to
  71647. * @param result defines the target matrix
  71648. */
  71649. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71650. /**
  71651. * Creates a rotation matrix
  71652. * @param yaw defines the yaw angle in radians (Y axis)
  71653. * @param pitch defines the pitch angle in radians (X axis)
  71654. * @param roll defines the roll angle in radians (X axis)
  71655. * @returns the new rotation matrix
  71656. */
  71657. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71658. /**
  71659. * Creates a rotation matrix and stores it in a given matrix
  71660. * @param yaw defines the yaw angle in radians (Y axis)
  71661. * @param pitch defines the pitch angle in radians (X axis)
  71662. * @param roll defines the roll angle in radians (X axis)
  71663. * @param result defines the target matrix
  71664. */
  71665. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71666. /**
  71667. * Creates a scaling matrix
  71668. * @param x defines the scale factor on X axis
  71669. * @param y defines the scale factor on Y axis
  71670. * @param z defines the scale factor on Z axis
  71671. * @returns the new matrix
  71672. */
  71673. static Scaling(x: number, y: number, z: number): Matrix;
  71674. /**
  71675. * Creates a scaling matrix and stores it in a given matrix
  71676. * @param x defines the scale factor on X axis
  71677. * @param y defines the scale factor on Y axis
  71678. * @param z defines the scale factor on Z axis
  71679. * @param result defines the target matrix
  71680. */
  71681. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71682. /**
  71683. * Creates a translation matrix
  71684. * @param x defines the translation on X axis
  71685. * @param y defines the translation on Y axis
  71686. * @param z defines the translationon Z axis
  71687. * @returns the new matrix
  71688. */
  71689. static Translation(x: number, y: number, z: number): Matrix;
  71690. /**
  71691. * Creates a translation matrix and stores it in a given matrix
  71692. * @param x defines the translation on X axis
  71693. * @param y defines the translation on Y axis
  71694. * @param z defines the translationon Z axis
  71695. * @param result defines the target matrix
  71696. */
  71697. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71698. /**
  71699. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71700. * @param startValue defines the start value
  71701. * @param endValue defines the end value
  71702. * @param gradient defines the gradient factor
  71703. * @returns the new matrix
  71704. */
  71705. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71706. /**
  71707. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71708. * @param startValue defines the start value
  71709. * @param endValue defines the end value
  71710. * @param gradient defines the gradient factor
  71711. * @param result defines the Matrix object where to store data
  71712. */
  71713. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71714. /**
  71715. * Builds a new matrix whose values are computed by:
  71716. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71717. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71718. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71719. * @param startValue defines the first matrix
  71720. * @param endValue defines the second matrix
  71721. * @param gradient defines the gradient between the two matrices
  71722. * @returns the new matrix
  71723. */
  71724. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71725. /**
  71726. * Update a matrix to values which are computed by:
  71727. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71728. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71729. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71730. * @param startValue defines the first matrix
  71731. * @param endValue defines the second matrix
  71732. * @param gradient defines the gradient between the two matrices
  71733. * @param result defines the target matrix
  71734. */
  71735. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71736. /**
  71737. * 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"
  71738. * This function works in left handed mode
  71739. * @param eye defines the final position of the entity
  71740. * @param target defines where the entity should look at
  71741. * @param up defines the up vector for the entity
  71742. * @returns the new matrix
  71743. */
  71744. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71745. /**
  71746. * 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".
  71747. * This function works in left handed mode
  71748. * @param eye defines the final position of the entity
  71749. * @param target defines where the entity should look at
  71750. * @param up defines the up vector for the entity
  71751. * @param result defines the target matrix
  71752. */
  71753. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71754. /**
  71755. * 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"
  71756. * This function works in right handed mode
  71757. * @param eye defines the final position of the entity
  71758. * @param target defines where the entity should look at
  71759. * @param up defines the up vector for the entity
  71760. * @returns the new matrix
  71761. */
  71762. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71763. /**
  71764. * 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".
  71765. * This function works in right handed mode
  71766. * @param eye defines the final position of the entity
  71767. * @param target defines where the entity should look at
  71768. * @param up defines the up vector for the entity
  71769. * @param result defines the target matrix
  71770. */
  71771. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71772. /**
  71773. * Create a left-handed orthographic projection matrix
  71774. * @param width defines the viewport width
  71775. * @param height defines the viewport height
  71776. * @param znear defines the near clip plane
  71777. * @param zfar defines the far clip plane
  71778. * @returns a new matrix as a left-handed orthographic projection matrix
  71779. */
  71780. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71781. /**
  71782. * Store a left-handed orthographic projection to a given matrix
  71783. * @param width defines the viewport width
  71784. * @param height defines the viewport height
  71785. * @param znear defines the near clip plane
  71786. * @param zfar defines the far clip plane
  71787. * @param result defines the target matrix
  71788. */
  71789. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71790. /**
  71791. * Create a left-handed orthographic projection matrix
  71792. * @param left defines the viewport left coordinate
  71793. * @param right defines the viewport right coordinate
  71794. * @param bottom defines the viewport bottom coordinate
  71795. * @param top defines the viewport top coordinate
  71796. * @param znear defines the near clip plane
  71797. * @param zfar defines the far clip plane
  71798. * @returns a new matrix as a left-handed orthographic projection matrix
  71799. */
  71800. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71801. /**
  71802. * Stores a left-handed orthographic projection into a given matrix
  71803. * @param left defines the viewport left coordinate
  71804. * @param right defines the viewport right coordinate
  71805. * @param bottom defines the viewport bottom coordinate
  71806. * @param top defines the viewport top coordinate
  71807. * @param znear defines the near clip plane
  71808. * @param zfar defines the far clip plane
  71809. * @param result defines the target matrix
  71810. */
  71811. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71812. /**
  71813. * Creates a right-handed orthographic projection matrix
  71814. * @param left defines the viewport left coordinate
  71815. * @param right defines the viewport right coordinate
  71816. * @param bottom defines the viewport bottom coordinate
  71817. * @param top defines the viewport top coordinate
  71818. * @param znear defines the near clip plane
  71819. * @param zfar defines the far clip plane
  71820. * @returns a new matrix as a right-handed orthographic projection matrix
  71821. */
  71822. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71823. /**
  71824. * Stores a right-handed orthographic projection into a given matrix
  71825. * @param left defines the viewport left coordinate
  71826. * @param right defines the viewport right coordinate
  71827. * @param bottom defines the viewport bottom coordinate
  71828. * @param top defines the viewport top coordinate
  71829. * @param znear defines the near clip plane
  71830. * @param zfar defines the far clip plane
  71831. * @param result defines the target matrix
  71832. */
  71833. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71834. /**
  71835. * Creates a left-handed perspective projection matrix
  71836. * @param width defines the viewport width
  71837. * @param height defines the viewport height
  71838. * @param znear defines the near clip plane
  71839. * @param zfar defines the far clip plane
  71840. * @returns a new matrix as a left-handed perspective projection matrix
  71841. */
  71842. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71843. /**
  71844. * Creates a left-handed perspective projection matrix
  71845. * @param fov defines the horizontal field of view
  71846. * @param aspect defines the aspect ratio
  71847. * @param znear defines the near clip plane
  71848. * @param zfar defines the far clip plane
  71849. * @returns a new matrix as a left-handed perspective projection matrix
  71850. */
  71851. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71852. /**
  71853. * Stores a left-handed perspective projection into a given matrix
  71854. * @param fov defines the horizontal field of view
  71855. * @param aspect defines the aspect ratio
  71856. * @param znear defines the near clip plane
  71857. * @param zfar defines the far clip plane
  71858. * @param result defines the target matrix
  71859. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71860. */
  71861. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71862. /**
  71863. * Creates a right-handed perspective projection matrix
  71864. * @param fov defines the horizontal field of view
  71865. * @param aspect defines the aspect ratio
  71866. * @param znear defines the near clip plane
  71867. * @param zfar defines the far clip plane
  71868. * @returns a new matrix as a right-handed perspective projection matrix
  71869. */
  71870. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71871. /**
  71872. * Stores a right-handed perspective projection into a given matrix
  71873. * @param fov defines the horizontal field of view
  71874. * @param aspect defines the aspect ratio
  71875. * @param znear defines the near clip plane
  71876. * @param zfar defines the far clip plane
  71877. * @param result defines the target matrix
  71878. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71879. */
  71880. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71881. /**
  71882. * Stores a perspective projection for WebVR info a given matrix
  71883. * @param fov defines the field of view
  71884. * @param znear defines the near clip plane
  71885. * @param zfar defines the far clip plane
  71886. * @param result defines the target matrix
  71887. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71888. */
  71889. static PerspectiveFovWebVRToRef(fov: {
  71890. upDegrees: number;
  71891. downDegrees: number;
  71892. leftDegrees: number;
  71893. rightDegrees: number;
  71894. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71895. /**
  71896. * Computes a complete transformation matrix
  71897. * @param viewport defines the viewport to use
  71898. * @param world defines the world matrix
  71899. * @param view defines the view matrix
  71900. * @param projection defines the projection matrix
  71901. * @param zmin defines the near clip plane
  71902. * @param zmax defines the far clip plane
  71903. * @returns the transformation matrix
  71904. */
  71905. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71906. /**
  71907. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71908. * @param matrix defines the matrix to use
  71909. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71910. */
  71911. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71912. /**
  71913. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71914. * @param matrix defines the matrix to use
  71915. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71916. */
  71917. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71918. /**
  71919. * Compute the transpose of a given matrix
  71920. * @param matrix defines the matrix to transpose
  71921. * @returns the new matrix
  71922. */
  71923. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71924. /**
  71925. * Compute the transpose of a matrix and store it in a target matrix
  71926. * @param matrix defines the matrix to transpose
  71927. * @param result defines the target matrix
  71928. */
  71929. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71930. /**
  71931. * Computes a reflection matrix from a plane
  71932. * @param plane defines the reflection plane
  71933. * @returns a new matrix
  71934. */
  71935. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71936. /**
  71937. * Computes a reflection matrix from a plane
  71938. * @param plane defines the reflection plane
  71939. * @param result defines the target matrix
  71940. */
  71941. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  71942. /**
  71943. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  71944. * @param xaxis defines the value of the 1st axis
  71945. * @param yaxis defines the value of the 2nd axis
  71946. * @param zaxis defines the value of the 3rd axis
  71947. * @param result defines the target matrix
  71948. */
  71949. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  71950. /**
  71951. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  71952. * @param quat defines the quaternion to use
  71953. * @param result defines the target matrix
  71954. */
  71955. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  71956. }
  71957. /**
  71958. * @hidden
  71959. */
  71960. export class TmpVectors {
  71961. static Vector2: Vector2[];
  71962. static Vector3: Vector3[];
  71963. static Vector4: Vector4[];
  71964. static Quaternion: Quaternion[];
  71965. static Matrix: Matrix[];
  71966. }
  71967. }
  71968. declare module BABYLON {
  71969. /**
  71970. * Defines potential orientation for back face culling
  71971. */
  71972. export enum Orientation {
  71973. /**
  71974. * Clockwise
  71975. */
  71976. CW = 0,
  71977. /** Counter clockwise */
  71978. CCW = 1
  71979. }
  71980. /** Class used to represent a Bezier curve */
  71981. export class BezierCurve {
  71982. /**
  71983. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71984. * @param t defines the time
  71985. * @param x1 defines the left coordinate on X axis
  71986. * @param y1 defines the left coordinate on Y axis
  71987. * @param x2 defines the right coordinate on X axis
  71988. * @param y2 defines the right coordinate on Y axis
  71989. * @returns the interpolated value
  71990. */
  71991. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71992. }
  71993. /**
  71994. * Defines angle representation
  71995. */
  71996. export class Angle {
  71997. private _radians;
  71998. /**
  71999. * Creates an Angle object of "radians" radians (float).
  72000. * @param radians the angle in radians
  72001. */
  72002. constructor(radians: number);
  72003. /**
  72004. * Get value in degrees
  72005. * @returns the Angle value in degrees (float)
  72006. */
  72007. degrees(): number;
  72008. /**
  72009. * Get value in radians
  72010. * @returns the Angle value in radians (float)
  72011. */
  72012. radians(): number;
  72013. /**
  72014. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72015. * @param a defines first vector
  72016. * @param b defines second vector
  72017. * @returns a new Angle
  72018. */
  72019. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72020. /**
  72021. * Gets a new Angle object from the given float in radians
  72022. * @param radians defines the angle value in radians
  72023. * @returns a new Angle
  72024. */
  72025. static FromRadians(radians: number): Angle;
  72026. /**
  72027. * Gets a new Angle object from the given float in degrees
  72028. * @param degrees defines the angle value in degrees
  72029. * @returns a new Angle
  72030. */
  72031. static FromDegrees(degrees: number): Angle;
  72032. }
  72033. /**
  72034. * This represents an arc in a 2d space.
  72035. */
  72036. export class Arc2 {
  72037. /** Defines the start point of the arc */
  72038. startPoint: Vector2;
  72039. /** Defines the mid point of the arc */
  72040. midPoint: Vector2;
  72041. /** Defines the end point of the arc */
  72042. endPoint: Vector2;
  72043. /**
  72044. * Defines the center point of the arc.
  72045. */
  72046. centerPoint: Vector2;
  72047. /**
  72048. * Defines the radius of the arc.
  72049. */
  72050. radius: number;
  72051. /**
  72052. * Defines the angle of the arc (from mid point to end point).
  72053. */
  72054. angle: Angle;
  72055. /**
  72056. * Defines the start angle of the arc (from start point to middle point).
  72057. */
  72058. startAngle: Angle;
  72059. /**
  72060. * Defines the orientation of the arc (clock wise/counter clock wise).
  72061. */
  72062. orientation: Orientation;
  72063. /**
  72064. * Creates an Arc object from the three given points : start, middle and end.
  72065. * @param startPoint Defines the start point of the arc
  72066. * @param midPoint Defines the midlle point of the arc
  72067. * @param endPoint Defines the end point of the arc
  72068. */
  72069. constructor(
  72070. /** Defines the start point of the arc */
  72071. startPoint: Vector2,
  72072. /** Defines the mid point of the arc */
  72073. midPoint: Vector2,
  72074. /** Defines the end point of the arc */
  72075. endPoint: Vector2);
  72076. }
  72077. /**
  72078. * Represents a 2D path made up of multiple 2D points
  72079. */
  72080. export class Path2 {
  72081. private _points;
  72082. private _length;
  72083. /**
  72084. * If the path start and end point are the same
  72085. */
  72086. closed: boolean;
  72087. /**
  72088. * Creates a Path2 object from the starting 2D coordinates x and y.
  72089. * @param x the starting points x value
  72090. * @param y the starting points y value
  72091. */
  72092. constructor(x: number, y: number);
  72093. /**
  72094. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72095. * @param x the added points x value
  72096. * @param y the added points y value
  72097. * @returns the updated Path2.
  72098. */
  72099. addLineTo(x: number, y: number): Path2;
  72100. /**
  72101. * 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.
  72102. * @param midX middle point x value
  72103. * @param midY middle point y value
  72104. * @param endX end point x value
  72105. * @param endY end point y value
  72106. * @param numberOfSegments (default: 36)
  72107. * @returns the updated Path2.
  72108. */
  72109. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72110. /**
  72111. * Closes the Path2.
  72112. * @returns the Path2.
  72113. */
  72114. close(): Path2;
  72115. /**
  72116. * Gets the sum of the distance between each sequential point in the path
  72117. * @returns the Path2 total length (float).
  72118. */
  72119. length(): number;
  72120. /**
  72121. * Gets the points which construct the path
  72122. * @returns the Path2 internal array of points.
  72123. */
  72124. getPoints(): Vector2[];
  72125. /**
  72126. * Retreives the point at the distance aways from the starting point
  72127. * @param normalizedLengthPosition the length along the path to retreive the point from
  72128. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72129. */
  72130. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72131. /**
  72132. * Creates a new path starting from an x and y position
  72133. * @param x starting x value
  72134. * @param y starting y value
  72135. * @returns a new Path2 starting at the coordinates (x, y).
  72136. */
  72137. static StartingAt(x: number, y: number): Path2;
  72138. }
  72139. /**
  72140. * Represents a 3D path made up of multiple 3D points
  72141. */
  72142. export class Path3D {
  72143. /**
  72144. * an array of Vector3, the curve axis of the Path3D
  72145. */
  72146. path: Vector3[];
  72147. private _curve;
  72148. private _distances;
  72149. private _tangents;
  72150. private _normals;
  72151. private _binormals;
  72152. private _raw;
  72153. /**
  72154. * new Path3D(path, normal, raw)
  72155. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72156. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72157. * @param path an array of Vector3, the curve axis of the Path3D
  72158. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72159. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72160. */
  72161. constructor(
  72162. /**
  72163. * an array of Vector3, the curve axis of the Path3D
  72164. */
  72165. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72166. /**
  72167. * Returns the Path3D array of successive Vector3 designing its curve.
  72168. * @returns the Path3D array of successive Vector3 designing its curve.
  72169. */
  72170. getCurve(): Vector3[];
  72171. /**
  72172. * Returns an array populated with tangent vectors on each Path3D curve point.
  72173. * @returns an array populated with tangent vectors on each Path3D curve point.
  72174. */
  72175. getTangents(): Vector3[];
  72176. /**
  72177. * Returns an array populated with normal vectors on each Path3D curve point.
  72178. * @returns an array populated with normal vectors on each Path3D curve point.
  72179. */
  72180. getNormals(): Vector3[];
  72181. /**
  72182. * Returns an array populated with binormal vectors on each Path3D curve point.
  72183. * @returns an array populated with binormal vectors on each Path3D curve point.
  72184. */
  72185. getBinormals(): Vector3[];
  72186. /**
  72187. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72188. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72189. */
  72190. getDistances(): number[];
  72191. /**
  72192. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72193. * @param path path which all values are copied into the curves points
  72194. * @param firstNormal which should be projected onto the curve
  72195. * @returns the same object updated.
  72196. */
  72197. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72198. private _compute;
  72199. private _getFirstNonNullVector;
  72200. private _getLastNonNullVector;
  72201. private _normalVector;
  72202. }
  72203. /**
  72204. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72205. * A Curve3 is designed from a series of successive Vector3.
  72206. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72207. */
  72208. export class Curve3 {
  72209. private _points;
  72210. private _length;
  72211. /**
  72212. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72213. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72214. * @param v1 (Vector3) the control point
  72215. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72216. * @param nbPoints (integer) the wanted number of points in the curve
  72217. * @returns the created Curve3
  72218. */
  72219. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72220. /**
  72221. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72222. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72223. * @param v1 (Vector3) the first control point
  72224. * @param v2 (Vector3) the second control point
  72225. * @param v3 (Vector3) the end point of the Cubic Bezier
  72226. * @param nbPoints (integer) the wanted number of points in the curve
  72227. * @returns the created Curve3
  72228. */
  72229. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72230. /**
  72231. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72232. * @param p1 (Vector3) the origin point of the Hermite Spline
  72233. * @param t1 (Vector3) the tangent vector at the origin point
  72234. * @param p2 (Vector3) the end point of the Hermite Spline
  72235. * @param t2 (Vector3) the tangent vector at the end point
  72236. * @param nbPoints (integer) the wanted number of points in the curve
  72237. * @returns the created Curve3
  72238. */
  72239. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72240. /**
  72241. * Returns a Curve3 object along a CatmullRom Spline curve :
  72242. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72243. * @param nbPoints (integer) the wanted number of points between each curve control points
  72244. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72245. * @returns the created Curve3
  72246. */
  72247. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72248. /**
  72249. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72250. * A Curve3 is designed from a series of successive Vector3.
  72251. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72252. * @param points points which make up the curve
  72253. */
  72254. constructor(points: Vector3[]);
  72255. /**
  72256. * @returns the Curve3 stored array of successive Vector3
  72257. */
  72258. getPoints(): Vector3[];
  72259. /**
  72260. * @returns the computed length (float) of the curve.
  72261. */
  72262. length(): number;
  72263. /**
  72264. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72265. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72266. * curveA and curveB keep unchanged.
  72267. * @param curve the curve to continue from this curve
  72268. * @returns the newly constructed curve
  72269. */
  72270. continue(curve: DeepImmutable<Curve3>): Curve3;
  72271. private _computeLength;
  72272. }
  72273. }
  72274. declare module BABYLON {
  72275. /**
  72276. * This represents the main contract an easing function should follow.
  72277. * Easing functions are used throughout the animation system.
  72278. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72279. */
  72280. export interface IEasingFunction {
  72281. /**
  72282. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72283. * of the easing function.
  72284. * The link below provides some of the most common examples of easing functions.
  72285. * @see https://easings.net/
  72286. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72287. * @returns the corresponding value on the curve defined by the easing function
  72288. */
  72289. ease(gradient: number): number;
  72290. }
  72291. /**
  72292. * Base class used for every default easing function.
  72293. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72294. */
  72295. export class EasingFunction implements IEasingFunction {
  72296. /**
  72297. * Interpolation follows the mathematical formula associated with the easing function.
  72298. */
  72299. static readonly EASINGMODE_EASEIN: number;
  72300. /**
  72301. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72302. */
  72303. static readonly EASINGMODE_EASEOUT: number;
  72304. /**
  72305. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72306. */
  72307. static readonly EASINGMODE_EASEINOUT: number;
  72308. private _easingMode;
  72309. /**
  72310. * Sets the easing mode of the current function.
  72311. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72312. */
  72313. setEasingMode(easingMode: number): void;
  72314. /**
  72315. * Gets the current easing mode.
  72316. * @returns the easing mode
  72317. */
  72318. getEasingMode(): number;
  72319. /**
  72320. * @hidden
  72321. */
  72322. easeInCore(gradient: number): number;
  72323. /**
  72324. * Given an input gradient between 0 and 1, this returns the corresponding value
  72325. * of the easing function.
  72326. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72327. * @returns the corresponding value on the curve defined by the easing function
  72328. */
  72329. ease(gradient: number): number;
  72330. }
  72331. /**
  72332. * Easing function with a circle shape (see link below).
  72333. * @see https://easings.net/#easeInCirc
  72334. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72335. */
  72336. export class CircleEase extends EasingFunction implements IEasingFunction {
  72337. /** @hidden */
  72338. easeInCore(gradient: number): number;
  72339. }
  72340. /**
  72341. * Easing function with a ease back shape (see link below).
  72342. * @see https://easings.net/#easeInBack
  72343. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72344. */
  72345. export class BackEase extends EasingFunction implements IEasingFunction {
  72346. /** Defines the amplitude of the function */
  72347. amplitude: number;
  72348. /**
  72349. * Instantiates a back ease easing
  72350. * @see https://easings.net/#easeInBack
  72351. * @param amplitude Defines the amplitude of the function
  72352. */
  72353. constructor(
  72354. /** Defines the amplitude of the function */
  72355. amplitude?: number);
  72356. /** @hidden */
  72357. easeInCore(gradient: number): number;
  72358. }
  72359. /**
  72360. * Easing function with a bouncing shape (see link below).
  72361. * @see https://easings.net/#easeInBounce
  72362. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72363. */
  72364. export class BounceEase extends EasingFunction implements IEasingFunction {
  72365. /** Defines the number of bounces */
  72366. bounces: number;
  72367. /** Defines the amplitude of the bounce */
  72368. bounciness: number;
  72369. /**
  72370. * Instantiates a bounce easing
  72371. * @see https://easings.net/#easeInBounce
  72372. * @param bounces Defines the number of bounces
  72373. * @param bounciness Defines the amplitude of the bounce
  72374. */
  72375. constructor(
  72376. /** Defines the number of bounces */
  72377. bounces?: number,
  72378. /** Defines the amplitude of the bounce */
  72379. bounciness?: number);
  72380. /** @hidden */
  72381. easeInCore(gradient: number): number;
  72382. }
  72383. /**
  72384. * Easing function with a power of 3 shape (see link below).
  72385. * @see https://easings.net/#easeInCubic
  72386. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72387. */
  72388. export class CubicEase extends EasingFunction implements IEasingFunction {
  72389. /** @hidden */
  72390. easeInCore(gradient: number): number;
  72391. }
  72392. /**
  72393. * Easing function with an elastic shape (see link below).
  72394. * @see https://easings.net/#easeInElastic
  72395. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72396. */
  72397. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72398. /** Defines the number of oscillations*/
  72399. oscillations: number;
  72400. /** Defines the amplitude of the oscillations*/
  72401. springiness: number;
  72402. /**
  72403. * Instantiates an elastic easing function
  72404. * @see https://easings.net/#easeInElastic
  72405. * @param oscillations Defines the number of oscillations
  72406. * @param springiness Defines the amplitude of the oscillations
  72407. */
  72408. constructor(
  72409. /** Defines the number of oscillations*/
  72410. oscillations?: number,
  72411. /** Defines the amplitude of the oscillations*/
  72412. springiness?: number);
  72413. /** @hidden */
  72414. easeInCore(gradient: number): number;
  72415. }
  72416. /**
  72417. * Easing function with an exponential shape (see link below).
  72418. * @see https://easings.net/#easeInExpo
  72419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72420. */
  72421. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72422. /** Defines the exponent of the function */
  72423. exponent: number;
  72424. /**
  72425. * Instantiates an exponential easing function
  72426. * @see https://easings.net/#easeInExpo
  72427. * @param exponent Defines the exponent of the function
  72428. */
  72429. constructor(
  72430. /** Defines the exponent of the function */
  72431. exponent?: number);
  72432. /** @hidden */
  72433. easeInCore(gradient: number): number;
  72434. }
  72435. /**
  72436. * Easing function with a power shape (see link below).
  72437. * @see https://easings.net/#easeInQuad
  72438. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72439. */
  72440. export class PowerEase extends EasingFunction implements IEasingFunction {
  72441. /** Defines the power of the function */
  72442. power: number;
  72443. /**
  72444. * Instantiates an power base easing function
  72445. * @see https://easings.net/#easeInQuad
  72446. * @param power Defines the power of the function
  72447. */
  72448. constructor(
  72449. /** Defines the power of the function */
  72450. power?: number);
  72451. /** @hidden */
  72452. easeInCore(gradient: number): number;
  72453. }
  72454. /**
  72455. * Easing function with a power of 2 shape (see link below).
  72456. * @see https://easings.net/#easeInQuad
  72457. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72458. */
  72459. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72460. /** @hidden */
  72461. easeInCore(gradient: number): number;
  72462. }
  72463. /**
  72464. * Easing function with a power of 4 shape (see link below).
  72465. * @see https://easings.net/#easeInQuart
  72466. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72467. */
  72468. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72469. /** @hidden */
  72470. easeInCore(gradient: number): number;
  72471. }
  72472. /**
  72473. * Easing function with a power of 5 shape (see link below).
  72474. * @see https://easings.net/#easeInQuint
  72475. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72476. */
  72477. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72478. /** @hidden */
  72479. easeInCore(gradient: number): number;
  72480. }
  72481. /**
  72482. * Easing function with a sin shape (see link below).
  72483. * @see https://easings.net/#easeInSine
  72484. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72485. */
  72486. export class SineEase extends EasingFunction implements IEasingFunction {
  72487. /** @hidden */
  72488. easeInCore(gradient: number): number;
  72489. }
  72490. /**
  72491. * Easing function with a bezier shape (see link below).
  72492. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72493. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72494. */
  72495. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72496. /** Defines the x component of the start tangent in the bezier curve */
  72497. x1: number;
  72498. /** Defines the y component of the start tangent in the bezier curve */
  72499. y1: number;
  72500. /** Defines the x component of the end tangent in the bezier curve */
  72501. x2: number;
  72502. /** Defines the y component of the end tangent in the bezier curve */
  72503. y2: number;
  72504. /**
  72505. * Instantiates a bezier function
  72506. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72507. * @param x1 Defines the x component of the start tangent in the bezier curve
  72508. * @param y1 Defines the y component of the start tangent in the bezier curve
  72509. * @param x2 Defines the x component of the end tangent in the bezier curve
  72510. * @param y2 Defines the y component of the end tangent in the bezier curve
  72511. */
  72512. constructor(
  72513. /** Defines the x component of the start tangent in the bezier curve */
  72514. x1?: number,
  72515. /** Defines the y component of the start tangent in the bezier curve */
  72516. y1?: number,
  72517. /** Defines the x component of the end tangent in the bezier curve */
  72518. x2?: number,
  72519. /** Defines the y component of the end tangent in the bezier curve */
  72520. y2?: number);
  72521. /** @hidden */
  72522. easeInCore(gradient: number): number;
  72523. }
  72524. }
  72525. declare module BABYLON {
  72526. /**
  72527. * Class used to hold a RBG color
  72528. */
  72529. export class Color3 {
  72530. /**
  72531. * Defines the red component (between 0 and 1, default is 0)
  72532. */
  72533. r: number;
  72534. /**
  72535. * Defines the green component (between 0 and 1, default is 0)
  72536. */
  72537. g: number;
  72538. /**
  72539. * Defines the blue component (between 0 and 1, default is 0)
  72540. */
  72541. b: number;
  72542. /**
  72543. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  72544. * @param r defines the red component (between 0 and 1, default is 0)
  72545. * @param g defines the green component (between 0 and 1, default is 0)
  72546. * @param b defines the blue component (between 0 and 1, default is 0)
  72547. */
  72548. constructor(
  72549. /**
  72550. * Defines the red component (between 0 and 1, default is 0)
  72551. */
  72552. r?: number,
  72553. /**
  72554. * Defines the green component (between 0 and 1, default is 0)
  72555. */
  72556. g?: number,
  72557. /**
  72558. * Defines the blue component (between 0 and 1, default is 0)
  72559. */
  72560. b?: number);
  72561. /**
  72562. * Creates a string with the Color3 current values
  72563. * @returns the string representation of the Color3 object
  72564. */
  72565. toString(): string;
  72566. /**
  72567. * Returns the string "Color3"
  72568. * @returns "Color3"
  72569. */
  72570. getClassName(): string;
  72571. /**
  72572. * Compute the Color3 hash code
  72573. * @returns an unique number that can be used to hash Color3 objects
  72574. */
  72575. getHashCode(): number;
  72576. /**
  72577. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  72578. * @param array defines the array where to store the r,g,b components
  72579. * @param index defines an optional index in the target array to define where to start storing values
  72580. * @returns the current Color3 object
  72581. */
  72582. toArray(array: FloatArray, index?: number): Color3;
  72583. /**
  72584. * Returns a new Color4 object from the current Color3 and the given alpha
  72585. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  72586. * @returns a new Color4 object
  72587. */
  72588. toColor4(alpha?: number): Color4;
  72589. /**
  72590. * Returns a new array populated with 3 numeric elements : red, green and blue values
  72591. * @returns the new array
  72592. */
  72593. asArray(): number[];
  72594. /**
  72595. * Returns the luminance value
  72596. * @returns a float value
  72597. */
  72598. toLuminance(): number;
  72599. /**
  72600. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  72601. * @param otherColor defines the second operand
  72602. * @returns the new Color3 object
  72603. */
  72604. multiply(otherColor: DeepImmutable<Color3>): Color3;
  72605. /**
  72606. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  72607. * @param otherColor defines the second operand
  72608. * @param result defines the Color3 object where to store the result
  72609. * @returns the current Color3
  72610. */
  72611. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72612. /**
  72613. * Determines equality between Color3 objects
  72614. * @param otherColor defines the second operand
  72615. * @returns true if the rgb values are equal to the given ones
  72616. */
  72617. equals(otherColor: DeepImmutable<Color3>): boolean;
  72618. /**
  72619. * Determines equality between the current Color3 object and a set of r,b,g values
  72620. * @param r defines the red component to check
  72621. * @param g defines the green component to check
  72622. * @param b defines the blue component to check
  72623. * @returns true if the rgb values are equal to the given ones
  72624. */
  72625. equalsFloats(r: number, g: number, b: number): boolean;
  72626. /**
  72627. * Multiplies in place each rgb value by scale
  72628. * @param scale defines the scaling factor
  72629. * @returns the updated Color3
  72630. */
  72631. scale(scale: number): Color3;
  72632. /**
  72633. * Multiplies the rgb values by scale and stores the result into "result"
  72634. * @param scale defines the scaling factor
  72635. * @param result defines the Color3 object where to store the result
  72636. * @returns the unmodified current Color3
  72637. */
  72638. scaleToRef(scale: number, result: Color3): Color3;
  72639. /**
  72640. * Scale the current Color3 values by a factor and add the result to a given Color3
  72641. * @param scale defines the scale factor
  72642. * @param result defines color to store the result into
  72643. * @returns the unmodified current Color3
  72644. */
  72645. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72646. /**
  72647. * Clamps the rgb values by the min and max values and stores the result into "result"
  72648. * @param min defines minimum clamping value (default is 0)
  72649. * @param max defines maximum clamping value (default is 1)
  72650. * @param result defines color to store the result into
  72651. * @returns the original Color3
  72652. */
  72653. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72654. /**
  72655. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72656. * @param otherColor defines the second operand
  72657. * @returns the new Color3
  72658. */
  72659. add(otherColor: DeepImmutable<Color3>): Color3;
  72660. /**
  72661. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72662. * @param otherColor defines the second operand
  72663. * @param result defines Color3 object to store the result into
  72664. * @returns the unmodified current Color3
  72665. */
  72666. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72667. /**
  72668. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72669. * @param otherColor defines the second operand
  72670. * @returns the new Color3
  72671. */
  72672. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72673. /**
  72674. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72675. * @param otherColor defines the second operand
  72676. * @param result defines Color3 object to store the result into
  72677. * @returns the unmodified current Color3
  72678. */
  72679. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72680. /**
  72681. * Copy the current object
  72682. * @returns a new Color3 copied the current one
  72683. */
  72684. clone(): Color3;
  72685. /**
  72686. * Copies the rgb values from the source in the current Color3
  72687. * @param source defines the source Color3 object
  72688. * @returns the updated Color3 object
  72689. */
  72690. copyFrom(source: DeepImmutable<Color3>): Color3;
  72691. /**
  72692. * Updates the Color3 rgb values from the given floats
  72693. * @param r defines the red component to read from
  72694. * @param g defines the green component to read from
  72695. * @param b defines the blue component to read from
  72696. * @returns the current Color3 object
  72697. */
  72698. copyFromFloats(r: number, g: number, b: number): Color3;
  72699. /**
  72700. * Updates the Color3 rgb values from the given floats
  72701. * @param r defines the red component to read from
  72702. * @param g defines the green component to read from
  72703. * @param b defines the blue component to read from
  72704. * @returns the current Color3 object
  72705. */
  72706. set(r: number, g: number, b: number): Color3;
  72707. /**
  72708. * Compute the Color3 hexadecimal code as a string
  72709. * @returns a string containing the hexadecimal representation of the Color3 object
  72710. */
  72711. toHexString(): string;
  72712. /**
  72713. * Computes a new Color3 converted from the current one to linear space
  72714. * @returns a new Color3 object
  72715. */
  72716. toLinearSpace(): Color3;
  72717. /**
  72718. * Converts current color in rgb space to HSV values
  72719. * @returns a new color3 representing the HSV values
  72720. */
  72721. toHSV(): Color3;
  72722. /**
  72723. * Converts current color in rgb space to HSV values
  72724. * @param result defines the Color3 where to store the HSV values
  72725. */
  72726. toHSVToRef(result: Color3): void;
  72727. /**
  72728. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72729. * @param convertedColor defines the Color3 object where to store the linear space version
  72730. * @returns the unmodified Color3
  72731. */
  72732. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72733. /**
  72734. * Computes a new Color3 converted from the current one to gamma space
  72735. * @returns a new Color3 object
  72736. */
  72737. toGammaSpace(): Color3;
  72738. /**
  72739. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72740. * @param convertedColor defines the Color3 object where to store the gamma space version
  72741. * @returns the unmodified Color3
  72742. */
  72743. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72744. private static _BlackReadOnly;
  72745. /**
  72746. * Convert Hue, saturation and value to a Color3 (RGB)
  72747. * @param hue defines the hue
  72748. * @param saturation defines the saturation
  72749. * @param value defines the value
  72750. * @param result defines the Color3 where to store the RGB values
  72751. */
  72752. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72753. /**
  72754. * Creates a new Color3 from the string containing valid hexadecimal values
  72755. * @param hex defines a string containing valid hexadecimal values
  72756. * @returns a new Color3 object
  72757. */
  72758. static FromHexString(hex: string): Color3;
  72759. /**
  72760. * Creates a new Color3 from the starting index of the given array
  72761. * @param array defines the source array
  72762. * @param offset defines an offset in the source array
  72763. * @returns a new Color3 object
  72764. */
  72765. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72766. /**
  72767. * Creates a new Color3 from integer values (< 256)
  72768. * @param r defines the red component to read from (value between 0 and 255)
  72769. * @param g defines the green component to read from (value between 0 and 255)
  72770. * @param b defines the blue component to read from (value between 0 and 255)
  72771. * @returns a new Color3 object
  72772. */
  72773. static FromInts(r: number, g: number, b: number): Color3;
  72774. /**
  72775. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72776. * @param start defines the start Color3 value
  72777. * @param end defines the end Color3 value
  72778. * @param amount defines the gradient value between start and end
  72779. * @returns a new Color3 object
  72780. */
  72781. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72782. /**
  72783. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72784. * @param left defines the start value
  72785. * @param right defines the end value
  72786. * @param amount defines the gradient factor
  72787. * @param result defines the Color3 object where to store the result
  72788. */
  72789. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72790. /**
  72791. * Returns a Color3 value containing a red color
  72792. * @returns a new Color3 object
  72793. */
  72794. static Red(): Color3;
  72795. /**
  72796. * Returns a Color3 value containing a green color
  72797. * @returns a new Color3 object
  72798. */
  72799. static Green(): Color3;
  72800. /**
  72801. * Returns a Color3 value containing a blue color
  72802. * @returns a new Color3 object
  72803. */
  72804. static Blue(): Color3;
  72805. /**
  72806. * Returns a Color3 value containing a black color
  72807. * @returns a new Color3 object
  72808. */
  72809. static Black(): Color3;
  72810. /**
  72811. * Gets a Color3 value containing a black color that must not be updated
  72812. */
  72813. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72814. /**
  72815. * Returns a Color3 value containing a white color
  72816. * @returns a new Color3 object
  72817. */
  72818. static White(): Color3;
  72819. /**
  72820. * Returns a Color3 value containing a purple color
  72821. * @returns a new Color3 object
  72822. */
  72823. static Purple(): Color3;
  72824. /**
  72825. * Returns a Color3 value containing a magenta color
  72826. * @returns a new Color3 object
  72827. */
  72828. static Magenta(): Color3;
  72829. /**
  72830. * Returns a Color3 value containing a yellow color
  72831. * @returns a new Color3 object
  72832. */
  72833. static Yellow(): Color3;
  72834. /**
  72835. * Returns a Color3 value containing a gray color
  72836. * @returns a new Color3 object
  72837. */
  72838. static Gray(): Color3;
  72839. /**
  72840. * Returns a Color3 value containing a teal color
  72841. * @returns a new Color3 object
  72842. */
  72843. static Teal(): Color3;
  72844. /**
  72845. * Returns a Color3 value containing a random color
  72846. * @returns a new Color3 object
  72847. */
  72848. static Random(): Color3;
  72849. }
  72850. /**
  72851. * Class used to hold a RBGA color
  72852. */
  72853. export class Color4 {
  72854. /**
  72855. * Defines the red component (between 0 and 1, default is 0)
  72856. */
  72857. r: number;
  72858. /**
  72859. * Defines the green component (between 0 and 1, default is 0)
  72860. */
  72861. g: number;
  72862. /**
  72863. * Defines the blue component (between 0 and 1, default is 0)
  72864. */
  72865. b: number;
  72866. /**
  72867. * Defines the alpha component (between 0 and 1, default is 1)
  72868. */
  72869. a: number;
  72870. /**
  72871. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72872. * @param r defines the red component (between 0 and 1, default is 0)
  72873. * @param g defines the green component (between 0 and 1, default is 0)
  72874. * @param b defines the blue component (between 0 and 1, default is 0)
  72875. * @param a defines the alpha component (between 0 and 1, default is 1)
  72876. */
  72877. constructor(
  72878. /**
  72879. * Defines the red component (between 0 and 1, default is 0)
  72880. */
  72881. r?: number,
  72882. /**
  72883. * Defines the green component (between 0 and 1, default is 0)
  72884. */
  72885. g?: number,
  72886. /**
  72887. * Defines the blue component (between 0 and 1, default is 0)
  72888. */
  72889. b?: number,
  72890. /**
  72891. * Defines the alpha component (between 0 and 1, default is 1)
  72892. */
  72893. a?: number);
  72894. /**
  72895. * Adds in place the given Color4 values to the current Color4 object
  72896. * @param right defines the second operand
  72897. * @returns the current updated Color4 object
  72898. */
  72899. addInPlace(right: DeepImmutable<Color4>): Color4;
  72900. /**
  72901. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72902. * @returns the new array
  72903. */
  72904. asArray(): number[];
  72905. /**
  72906. * Stores from the starting index in the given array the Color4 successive values
  72907. * @param array defines the array where to store the r,g,b components
  72908. * @param index defines an optional index in the target array to define where to start storing values
  72909. * @returns the current Color4 object
  72910. */
  72911. toArray(array: number[], index?: number): Color4;
  72912. /**
  72913. * Determines equality between Color4 objects
  72914. * @param otherColor defines the second operand
  72915. * @returns true if the rgba values are equal to the given ones
  72916. */
  72917. equals(otherColor: DeepImmutable<Color4>): boolean;
  72918. /**
  72919. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72920. * @param right defines the second operand
  72921. * @returns a new Color4 object
  72922. */
  72923. add(right: DeepImmutable<Color4>): Color4;
  72924. /**
  72925. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72926. * @param right defines the second operand
  72927. * @returns a new Color4 object
  72928. */
  72929. subtract(right: DeepImmutable<Color4>): Color4;
  72930. /**
  72931. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72932. * @param right defines the second operand
  72933. * @param result defines the Color4 object where to store the result
  72934. * @returns the current Color4 object
  72935. */
  72936. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72937. /**
  72938. * Creates a new Color4 with the current Color4 values multiplied by scale
  72939. * @param scale defines the scaling factor to apply
  72940. * @returns a new Color4 object
  72941. */
  72942. scale(scale: number): Color4;
  72943. /**
  72944. * Multiplies the current Color4 values by scale and stores the result in "result"
  72945. * @param scale defines the scaling factor to apply
  72946. * @param result defines the Color4 object where to store the result
  72947. * @returns the current unmodified Color4
  72948. */
  72949. scaleToRef(scale: number, result: Color4): Color4;
  72950. /**
  72951. * Scale the current Color4 values by a factor and add the result to a given Color4
  72952. * @param scale defines the scale factor
  72953. * @param result defines the Color4 object where to store the result
  72954. * @returns the unmodified current Color4
  72955. */
  72956. scaleAndAddToRef(scale: number, result: Color4): Color4;
  72957. /**
  72958. * Clamps the rgb values by the min and max values and stores the result into "result"
  72959. * @param min defines minimum clamping value (default is 0)
  72960. * @param max defines maximum clamping value (default is 1)
  72961. * @param result defines color to store the result into.
  72962. * @returns the cuurent Color4
  72963. */
  72964. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  72965. /**
  72966. * Multipy an Color4 value by another and return a new Color4 object
  72967. * @param color defines the Color4 value to multiply by
  72968. * @returns a new Color4 object
  72969. */
  72970. multiply(color: Color4): Color4;
  72971. /**
  72972. * Multipy a Color4 value by another and push the result in a reference value
  72973. * @param color defines the Color4 value to multiply by
  72974. * @param result defines the Color4 to fill the result in
  72975. * @returns the result Color4
  72976. */
  72977. multiplyToRef(color: Color4, result: Color4): Color4;
  72978. /**
  72979. * Creates a string with the Color4 current values
  72980. * @returns the string representation of the Color4 object
  72981. */
  72982. toString(): string;
  72983. /**
  72984. * Returns the string "Color4"
  72985. * @returns "Color4"
  72986. */
  72987. getClassName(): string;
  72988. /**
  72989. * Compute the Color4 hash code
  72990. * @returns an unique number that can be used to hash Color4 objects
  72991. */
  72992. getHashCode(): number;
  72993. /**
  72994. * Creates a new Color4 copied from the current one
  72995. * @returns a new Color4 object
  72996. */
  72997. clone(): Color4;
  72998. /**
  72999. * Copies the given Color4 values into the current one
  73000. * @param source defines the source Color4 object
  73001. * @returns the current updated Color4 object
  73002. */
  73003. copyFrom(source: Color4): Color4;
  73004. /**
  73005. * Copies the given float values into the current one
  73006. * @param r defines the red component to read from
  73007. * @param g defines the green component to read from
  73008. * @param b defines the blue component to read from
  73009. * @param a defines the alpha component to read from
  73010. * @returns the current updated Color4 object
  73011. */
  73012. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73013. /**
  73014. * Copies the given float values into the current one
  73015. * @param r defines the red component to read from
  73016. * @param g defines the green component to read from
  73017. * @param b defines the blue component to read from
  73018. * @param a defines the alpha component to read from
  73019. * @returns the current updated Color4 object
  73020. */
  73021. set(r: number, g: number, b: number, a: number): Color4;
  73022. /**
  73023. * Compute the Color4 hexadecimal code as a string
  73024. * @returns a string containing the hexadecimal representation of the Color4 object
  73025. */
  73026. toHexString(): string;
  73027. /**
  73028. * Computes a new Color4 converted from the current one to linear space
  73029. * @returns a new Color4 object
  73030. */
  73031. toLinearSpace(): Color4;
  73032. /**
  73033. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73034. * @param convertedColor defines the Color4 object where to store the linear space version
  73035. * @returns the unmodified Color4
  73036. */
  73037. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73038. /**
  73039. * Computes a new Color4 converted from the current one to gamma space
  73040. * @returns a new Color4 object
  73041. */
  73042. toGammaSpace(): Color4;
  73043. /**
  73044. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73045. * @param convertedColor defines the Color4 object where to store the gamma space version
  73046. * @returns the unmodified Color4
  73047. */
  73048. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73049. /**
  73050. * Creates a new Color4 from the string containing valid hexadecimal values
  73051. * @param hex defines a string containing valid hexadecimal values
  73052. * @returns a new Color4 object
  73053. */
  73054. static FromHexString(hex: string): Color4;
  73055. /**
  73056. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73057. * @param left defines the start value
  73058. * @param right defines the end value
  73059. * @param amount defines the gradient factor
  73060. * @returns a new Color4 object
  73061. */
  73062. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73063. /**
  73064. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73065. * @param left defines the start value
  73066. * @param right defines the end value
  73067. * @param amount defines the gradient factor
  73068. * @param result defines the Color4 object where to store data
  73069. */
  73070. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73071. /**
  73072. * Creates a new Color4 from a Color3 and an alpha value
  73073. * @param color3 defines the source Color3 to read from
  73074. * @param alpha defines the alpha component (1.0 by default)
  73075. * @returns a new Color4 object
  73076. */
  73077. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73078. /**
  73079. * Creates a new Color4 from the starting index element of the given array
  73080. * @param array defines the source array to read from
  73081. * @param offset defines the offset in the source array
  73082. * @returns a new Color4 object
  73083. */
  73084. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73085. /**
  73086. * Creates a new Color3 from integer values (< 256)
  73087. * @param r defines the red component to read from (value between 0 and 255)
  73088. * @param g defines the green component to read from (value between 0 and 255)
  73089. * @param b defines the blue component to read from (value between 0 and 255)
  73090. * @param a defines the alpha component to read from (value between 0 and 255)
  73091. * @returns a new Color3 object
  73092. */
  73093. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73094. /**
  73095. * Check the content of a given array and convert it to an array containing RGBA data
  73096. * If the original array was already containing count * 4 values then it is returned directly
  73097. * @param colors defines the array to check
  73098. * @param count defines the number of RGBA data to expect
  73099. * @returns an array containing count * 4 values (RGBA)
  73100. */
  73101. static CheckColors4(colors: number[], count: number): number[];
  73102. }
  73103. /**
  73104. * @hidden
  73105. */
  73106. export class TmpColors {
  73107. static Color3: Color3[];
  73108. static Color4: Color4[];
  73109. }
  73110. }
  73111. declare module BABYLON {
  73112. /**
  73113. * Defines an interface which represents an animation key frame
  73114. */
  73115. export interface IAnimationKey {
  73116. /**
  73117. * Frame of the key frame
  73118. */
  73119. frame: number;
  73120. /**
  73121. * Value at the specifies key frame
  73122. */
  73123. value: any;
  73124. /**
  73125. * The input tangent for the cubic hermite spline
  73126. */
  73127. inTangent?: any;
  73128. /**
  73129. * The output tangent for the cubic hermite spline
  73130. */
  73131. outTangent?: any;
  73132. /**
  73133. * The animation interpolation type
  73134. */
  73135. interpolation?: AnimationKeyInterpolation;
  73136. }
  73137. /**
  73138. * Enum for the animation key frame interpolation type
  73139. */
  73140. export enum AnimationKeyInterpolation {
  73141. /**
  73142. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73143. */
  73144. STEP = 1
  73145. }
  73146. }
  73147. declare module BABYLON {
  73148. /**
  73149. * Represents the range of an animation
  73150. */
  73151. export class AnimationRange {
  73152. /**The name of the animation range**/
  73153. name: string;
  73154. /**The starting frame of the animation */
  73155. from: number;
  73156. /**The ending frame of the animation*/
  73157. to: number;
  73158. /**
  73159. * Initializes the range of an animation
  73160. * @param name The name of the animation range
  73161. * @param from The starting frame of the animation
  73162. * @param to The ending frame of the animation
  73163. */
  73164. constructor(
  73165. /**The name of the animation range**/
  73166. name: string,
  73167. /**The starting frame of the animation */
  73168. from: number,
  73169. /**The ending frame of the animation*/
  73170. to: number);
  73171. /**
  73172. * Makes a copy of the animation range
  73173. * @returns A copy of the animation range
  73174. */
  73175. clone(): AnimationRange;
  73176. }
  73177. }
  73178. declare module BABYLON {
  73179. /**
  73180. * Composed of a frame, and an action function
  73181. */
  73182. export class AnimationEvent {
  73183. /** The frame for which the event is triggered **/
  73184. frame: number;
  73185. /** The event to perform when triggered **/
  73186. action: (currentFrame: number) => void;
  73187. /** Specifies if the event should be triggered only once**/
  73188. onlyOnce?: boolean | undefined;
  73189. /**
  73190. * Specifies if the animation event is done
  73191. */
  73192. isDone: boolean;
  73193. /**
  73194. * Initializes the animation event
  73195. * @param frame The frame for which the event is triggered
  73196. * @param action The event to perform when triggered
  73197. * @param onlyOnce Specifies if the event should be triggered only once
  73198. */
  73199. constructor(
  73200. /** The frame for which the event is triggered **/
  73201. frame: number,
  73202. /** The event to perform when triggered **/
  73203. action: (currentFrame: number) => void,
  73204. /** Specifies if the event should be triggered only once**/
  73205. onlyOnce?: boolean | undefined);
  73206. /** @hidden */
  73207. _clone(): AnimationEvent;
  73208. }
  73209. }
  73210. declare module BABYLON {
  73211. /**
  73212. * Interface used to define a behavior
  73213. */
  73214. export interface Behavior<T> {
  73215. /** gets or sets behavior's name */
  73216. name: string;
  73217. /**
  73218. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73219. */
  73220. init(): void;
  73221. /**
  73222. * Called when the behavior is attached to a target
  73223. * @param target defines the target where the behavior is attached to
  73224. */
  73225. attach(target: T): void;
  73226. /**
  73227. * Called when the behavior is detached from its target
  73228. */
  73229. detach(): void;
  73230. }
  73231. /**
  73232. * Interface implemented by classes supporting behaviors
  73233. */
  73234. export interface IBehaviorAware<T> {
  73235. /**
  73236. * Attach a behavior
  73237. * @param behavior defines the behavior to attach
  73238. * @returns the current host
  73239. */
  73240. addBehavior(behavior: Behavior<T>): T;
  73241. /**
  73242. * Remove a behavior from the current object
  73243. * @param behavior defines the behavior to detach
  73244. * @returns the current host
  73245. */
  73246. removeBehavior(behavior: Behavior<T>): T;
  73247. /**
  73248. * Gets a behavior using its name to search
  73249. * @param name defines the name to search
  73250. * @returns the behavior or null if not found
  73251. */
  73252. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73253. }
  73254. }
  73255. declare module BABYLON {
  73256. /**
  73257. * Defines an array and its length.
  73258. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73259. */
  73260. export interface ISmartArrayLike<T> {
  73261. /**
  73262. * The data of the array.
  73263. */
  73264. data: Array<T>;
  73265. /**
  73266. * The active length of the array.
  73267. */
  73268. length: number;
  73269. }
  73270. /**
  73271. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73272. */
  73273. export class SmartArray<T> implements ISmartArrayLike<T> {
  73274. /**
  73275. * The full set of data from the array.
  73276. */
  73277. data: Array<T>;
  73278. /**
  73279. * The active length of the array.
  73280. */
  73281. length: number;
  73282. protected _id: number;
  73283. /**
  73284. * Instantiates a Smart Array.
  73285. * @param capacity defines the default capacity of the array.
  73286. */
  73287. constructor(capacity: number);
  73288. /**
  73289. * Pushes a value at the end of the active data.
  73290. * @param value defines the object to push in the array.
  73291. */
  73292. push(value: T): void;
  73293. /**
  73294. * Iterates over the active data and apply the lambda to them.
  73295. * @param func defines the action to apply on each value.
  73296. */
  73297. forEach(func: (content: T) => void): void;
  73298. /**
  73299. * Sorts the full sets of data.
  73300. * @param compareFn defines the comparison function to apply.
  73301. */
  73302. sort(compareFn: (a: T, b: T) => number): void;
  73303. /**
  73304. * Resets the active data to an empty array.
  73305. */
  73306. reset(): void;
  73307. /**
  73308. * Releases all the data from the array as well as the array.
  73309. */
  73310. dispose(): void;
  73311. /**
  73312. * Concats the active data with a given array.
  73313. * @param array defines the data to concatenate with.
  73314. */
  73315. concat(array: any): void;
  73316. /**
  73317. * Returns the position of a value in the active data.
  73318. * @param value defines the value to find the index for
  73319. * @returns the index if found in the active data otherwise -1
  73320. */
  73321. indexOf(value: T): number;
  73322. /**
  73323. * Returns whether an element is part of the active data.
  73324. * @param value defines the value to look for
  73325. * @returns true if found in the active data otherwise false
  73326. */
  73327. contains(value: T): boolean;
  73328. private static _GlobalId;
  73329. }
  73330. /**
  73331. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73332. * The data in this array can only be present once
  73333. */
  73334. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73335. private _duplicateId;
  73336. /**
  73337. * Pushes a value at the end of the active data.
  73338. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73339. * @param value defines the object to push in the array.
  73340. */
  73341. push(value: T): void;
  73342. /**
  73343. * Pushes a value at the end of the active data.
  73344. * If the data is already present, it won t be added again
  73345. * @param value defines the object to push in the array.
  73346. * @returns true if added false if it was already present
  73347. */
  73348. pushNoDuplicate(value: T): boolean;
  73349. /**
  73350. * Resets the active data to an empty array.
  73351. */
  73352. reset(): void;
  73353. /**
  73354. * Concats the active data with a given array.
  73355. * This ensures no dupplicate will be present in the result.
  73356. * @param array defines the data to concatenate with.
  73357. */
  73358. concatWithNoDuplicate(array: any): void;
  73359. }
  73360. }
  73361. declare module BABYLON {
  73362. /**
  73363. * @ignore
  73364. * This is a list of all the different input types that are available in the application.
  73365. * Fo instance: ArcRotateCameraGamepadInput...
  73366. */
  73367. export var CameraInputTypes: {};
  73368. /**
  73369. * This is the contract to implement in order to create a new input class.
  73370. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  73371. */
  73372. export interface ICameraInput<TCamera extends Camera> {
  73373. /**
  73374. * Defines the camera the input is attached to.
  73375. */
  73376. camera: Nullable<TCamera>;
  73377. /**
  73378. * Gets the class name of the current intput.
  73379. * @returns the class name
  73380. */
  73381. getClassName(): string;
  73382. /**
  73383. * Get the friendly name associated with the input class.
  73384. * @returns the input friendly name
  73385. */
  73386. getSimpleName(): string;
  73387. /**
  73388. * Attach the input controls to a specific dom element to get the input from.
  73389. * @param element Defines the element the controls should be listened from
  73390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73391. */
  73392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73393. /**
  73394. * Detach the current controls from the specified dom element.
  73395. * @param element Defines the element to stop listening the inputs from
  73396. */
  73397. detachControl(element: Nullable<HTMLElement>): void;
  73398. /**
  73399. * Update the current camera state depending on the inputs that have been used this frame.
  73400. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73401. */
  73402. checkInputs?: () => void;
  73403. }
  73404. /**
  73405. * Represents a map of input types to input instance or input index to input instance.
  73406. */
  73407. export interface CameraInputsMap<TCamera extends Camera> {
  73408. /**
  73409. * Accessor to the input by input type.
  73410. */
  73411. [name: string]: ICameraInput<TCamera>;
  73412. /**
  73413. * Accessor to the input by input index.
  73414. */
  73415. [idx: number]: ICameraInput<TCamera>;
  73416. }
  73417. /**
  73418. * This represents the input manager used within a camera.
  73419. * It helps dealing with all the different kind of input attached to a camera.
  73420. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73421. */
  73422. export class CameraInputsManager<TCamera extends Camera> {
  73423. /**
  73424. * Defines the list of inputs attahed to the camera.
  73425. */
  73426. attached: CameraInputsMap<TCamera>;
  73427. /**
  73428. * Defines the dom element the camera is collecting inputs from.
  73429. * This is null if the controls have not been attached.
  73430. */
  73431. attachedElement: Nullable<HTMLElement>;
  73432. /**
  73433. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73434. */
  73435. noPreventDefault: boolean;
  73436. /**
  73437. * Defined the camera the input manager belongs to.
  73438. */
  73439. camera: TCamera;
  73440. /**
  73441. * Update the current camera state depending on the inputs that have been used this frame.
  73442. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73443. */
  73444. checkInputs: () => void;
  73445. /**
  73446. * Instantiate a new Camera Input Manager.
  73447. * @param camera Defines the camera the input manager blongs to
  73448. */
  73449. constructor(camera: TCamera);
  73450. /**
  73451. * Add an input method to a camera
  73452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73453. * @param input camera input method
  73454. */
  73455. add(input: ICameraInput<TCamera>): void;
  73456. /**
  73457. * Remove a specific input method from a camera
  73458. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  73459. * @param inputToRemove camera input method
  73460. */
  73461. remove(inputToRemove: ICameraInput<TCamera>): void;
  73462. /**
  73463. * Remove a specific input type from a camera
  73464. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  73465. * @param inputType the type of the input to remove
  73466. */
  73467. removeByType(inputType: string): void;
  73468. private _addCheckInputs;
  73469. /**
  73470. * Attach the input controls to the currently attached dom element to listen the events from.
  73471. * @param input Defines the input to attach
  73472. */
  73473. attachInput(input: ICameraInput<TCamera>): void;
  73474. /**
  73475. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  73476. * @param element Defines the dom element to collect the events from
  73477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73478. */
  73479. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  73480. /**
  73481. * Detach the current manager inputs controls from a specific dom element.
  73482. * @param element Defines the dom element to collect the events from
  73483. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  73484. */
  73485. detachElement(element: HTMLElement, disconnect?: boolean): void;
  73486. /**
  73487. * Rebuild the dynamic inputCheck function from the current list of
  73488. * defined inputs in the manager.
  73489. */
  73490. rebuildInputCheck(): void;
  73491. /**
  73492. * Remove all attached input methods from a camera
  73493. */
  73494. clear(): void;
  73495. /**
  73496. * Serialize the current input manager attached to a camera.
  73497. * This ensures than once parsed,
  73498. * the input associated to the camera will be identical to the current ones
  73499. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  73500. */
  73501. serialize(serializedCamera: any): void;
  73502. /**
  73503. * Parses an input manager serialized JSON to restore the previous list of inputs
  73504. * and states associated to a camera.
  73505. * @param parsedCamera Defines the JSON to parse
  73506. */
  73507. parse(parsedCamera: any): void;
  73508. }
  73509. }
  73510. declare module BABYLON {
  73511. /**
  73512. * Class used to store data that will be store in GPU memory
  73513. */
  73514. export class Buffer {
  73515. private _engine;
  73516. private _buffer;
  73517. /** @hidden */
  73518. _data: Nullable<DataArray>;
  73519. private _updatable;
  73520. private _instanced;
  73521. private _divisor;
  73522. /**
  73523. * Gets the byte stride.
  73524. */
  73525. readonly byteStride: number;
  73526. /**
  73527. * Constructor
  73528. * @param engine the engine
  73529. * @param data the data to use for this buffer
  73530. * @param updatable whether the data is updatable
  73531. * @param stride the stride (optional)
  73532. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73533. * @param instanced whether the buffer is instanced (optional)
  73534. * @param useBytes set to true if the stride in in bytes (optional)
  73535. * @param divisor sets an optional divisor for instances (1 by default)
  73536. */
  73537. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  73538. /**
  73539. * Create a new VertexBuffer based on the current buffer
  73540. * @param kind defines the vertex buffer kind (position, normal, etc.)
  73541. * @param offset defines offset in the buffer (0 by default)
  73542. * @param size defines the size in floats of attributes (position is 3 for instance)
  73543. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  73544. * @param instanced defines if the vertex buffer contains indexed data
  73545. * @param useBytes defines if the offset and stride are in bytes *
  73546. * @param divisor sets an optional divisor for instances (1 by default)
  73547. * @returns the new vertex buffer
  73548. */
  73549. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  73550. /**
  73551. * Gets a boolean indicating if the Buffer is updatable?
  73552. * @returns true if the buffer is updatable
  73553. */
  73554. isUpdatable(): boolean;
  73555. /**
  73556. * Gets current buffer's data
  73557. * @returns a DataArray or null
  73558. */
  73559. getData(): Nullable<DataArray>;
  73560. /**
  73561. * Gets underlying native buffer
  73562. * @returns underlying native buffer
  73563. */
  73564. getBuffer(): Nullable<DataBuffer>;
  73565. /**
  73566. * Gets the stride in float32 units (i.e. byte stride / 4).
  73567. * May not be an integer if the byte stride is not divisible by 4.
  73568. * DEPRECATED. Use byteStride instead.
  73569. * @returns the stride in float32 units
  73570. */
  73571. getStrideSize(): number;
  73572. /**
  73573. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73574. * @param data defines the data to store
  73575. */
  73576. create(data?: Nullable<DataArray>): void;
  73577. /** @hidden */
  73578. _rebuild(): void;
  73579. /**
  73580. * Update current buffer data
  73581. * @param data defines the data to store
  73582. */
  73583. update(data: DataArray): void;
  73584. /**
  73585. * Updates the data directly.
  73586. * @param data the new data
  73587. * @param offset the new offset
  73588. * @param vertexCount the vertex count (optional)
  73589. * @param useBytes set to true if the offset is in bytes
  73590. */
  73591. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  73592. /**
  73593. * Release all resources
  73594. */
  73595. dispose(): void;
  73596. }
  73597. /**
  73598. * Specialized buffer used to store vertex data
  73599. */
  73600. export class VertexBuffer {
  73601. /** @hidden */
  73602. _buffer: Buffer;
  73603. private _kind;
  73604. private _size;
  73605. private _ownsBuffer;
  73606. private _instanced;
  73607. private _instanceDivisor;
  73608. /**
  73609. * The byte type.
  73610. */
  73611. static readonly BYTE: number;
  73612. /**
  73613. * The unsigned byte type.
  73614. */
  73615. static readonly UNSIGNED_BYTE: number;
  73616. /**
  73617. * The short type.
  73618. */
  73619. static readonly SHORT: number;
  73620. /**
  73621. * The unsigned short type.
  73622. */
  73623. static readonly UNSIGNED_SHORT: number;
  73624. /**
  73625. * The integer type.
  73626. */
  73627. static readonly INT: number;
  73628. /**
  73629. * The unsigned integer type.
  73630. */
  73631. static readonly UNSIGNED_INT: number;
  73632. /**
  73633. * The float type.
  73634. */
  73635. static readonly FLOAT: number;
  73636. /**
  73637. * Gets or sets the instance divisor when in instanced mode
  73638. */
  73639. instanceDivisor: number;
  73640. /**
  73641. * Gets the byte stride.
  73642. */
  73643. readonly byteStride: number;
  73644. /**
  73645. * Gets the byte offset.
  73646. */
  73647. readonly byteOffset: number;
  73648. /**
  73649. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73650. */
  73651. readonly normalized: boolean;
  73652. /**
  73653. * Gets the data type of each component in the array.
  73654. */
  73655. readonly type: number;
  73656. /**
  73657. * Constructor
  73658. * @param engine the engine
  73659. * @param data the data to use for this vertex buffer
  73660. * @param kind the vertex buffer kind
  73661. * @param updatable whether the data is updatable
  73662. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73663. * @param stride the stride (optional)
  73664. * @param instanced whether the buffer is instanced (optional)
  73665. * @param offset the offset of the data (optional)
  73666. * @param size the number of components (optional)
  73667. * @param type the type of the component (optional)
  73668. * @param normalized whether the data contains normalized data (optional)
  73669. * @param useBytes set to true if stride and offset are in bytes (optional)
  73670. * @param divisor defines the instance divisor to use (1 by default)
  73671. */
  73672. 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);
  73673. /** @hidden */
  73674. _rebuild(): void;
  73675. /**
  73676. * Returns the kind of the VertexBuffer (string)
  73677. * @returns a string
  73678. */
  73679. getKind(): string;
  73680. /**
  73681. * Gets a boolean indicating if the VertexBuffer is updatable?
  73682. * @returns true if the buffer is updatable
  73683. */
  73684. isUpdatable(): boolean;
  73685. /**
  73686. * Gets current buffer's data
  73687. * @returns a DataArray or null
  73688. */
  73689. getData(): Nullable<DataArray>;
  73690. /**
  73691. * Gets underlying native buffer
  73692. * @returns underlying native buffer
  73693. */
  73694. getBuffer(): Nullable<DataBuffer>;
  73695. /**
  73696. * Gets the stride in float32 units (i.e. byte stride / 4).
  73697. * May not be an integer if the byte stride is not divisible by 4.
  73698. * DEPRECATED. Use byteStride instead.
  73699. * @returns the stride in float32 units
  73700. */
  73701. getStrideSize(): number;
  73702. /**
  73703. * Returns the offset as a multiple of the type byte length.
  73704. * DEPRECATED. Use byteOffset instead.
  73705. * @returns the offset in bytes
  73706. */
  73707. getOffset(): number;
  73708. /**
  73709. * Returns the number of components per vertex attribute (integer)
  73710. * @returns the size in float
  73711. */
  73712. getSize(): number;
  73713. /**
  73714. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73715. * @returns true if this buffer is instanced
  73716. */
  73717. getIsInstanced(): boolean;
  73718. /**
  73719. * Returns the instancing divisor, zero for non-instanced (integer).
  73720. * @returns a number
  73721. */
  73722. getInstanceDivisor(): number;
  73723. /**
  73724. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73725. * @param data defines the data to store
  73726. */
  73727. create(data?: DataArray): void;
  73728. /**
  73729. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73730. * This function will create a new buffer if the current one is not updatable
  73731. * @param data defines the data to store
  73732. */
  73733. update(data: DataArray): void;
  73734. /**
  73735. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73736. * Returns the directly updated WebGLBuffer.
  73737. * @param data the new data
  73738. * @param offset the new offset
  73739. * @param useBytes set to true if the offset is in bytes
  73740. */
  73741. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73742. /**
  73743. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73744. */
  73745. dispose(): void;
  73746. /**
  73747. * Enumerates each value of this vertex buffer as numbers.
  73748. * @param count the number of values to enumerate
  73749. * @param callback the callback function called for each value
  73750. */
  73751. forEach(count: number, callback: (value: number, index: number) => void): void;
  73752. /**
  73753. * Positions
  73754. */
  73755. static readonly PositionKind: string;
  73756. /**
  73757. * Normals
  73758. */
  73759. static readonly NormalKind: string;
  73760. /**
  73761. * Tangents
  73762. */
  73763. static readonly TangentKind: string;
  73764. /**
  73765. * Texture coordinates
  73766. */
  73767. static readonly UVKind: string;
  73768. /**
  73769. * Texture coordinates 2
  73770. */
  73771. static readonly UV2Kind: string;
  73772. /**
  73773. * Texture coordinates 3
  73774. */
  73775. static readonly UV3Kind: string;
  73776. /**
  73777. * Texture coordinates 4
  73778. */
  73779. static readonly UV4Kind: string;
  73780. /**
  73781. * Texture coordinates 5
  73782. */
  73783. static readonly UV5Kind: string;
  73784. /**
  73785. * Texture coordinates 6
  73786. */
  73787. static readonly UV6Kind: string;
  73788. /**
  73789. * Colors
  73790. */
  73791. static readonly ColorKind: string;
  73792. /**
  73793. * Matrix indices (for bones)
  73794. */
  73795. static readonly MatricesIndicesKind: string;
  73796. /**
  73797. * Matrix weights (for bones)
  73798. */
  73799. static readonly MatricesWeightsKind: string;
  73800. /**
  73801. * Additional matrix indices (for bones)
  73802. */
  73803. static readonly MatricesIndicesExtraKind: string;
  73804. /**
  73805. * Additional matrix weights (for bones)
  73806. */
  73807. static readonly MatricesWeightsExtraKind: string;
  73808. /**
  73809. * Deduces the stride given a kind.
  73810. * @param kind The kind string to deduce
  73811. * @returns The deduced stride
  73812. */
  73813. static DeduceStride(kind: string): number;
  73814. /**
  73815. * Gets the byte length of the given type.
  73816. * @param type the type
  73817. * @returns the number of bytes
  73818. */
  73819. static GetTypeByteLength(type: number): number;
  73820. /**
  73821. * Enumerates each value of the given parameters as numbers.
  73822. * @param data the data to enumerate
  73823. * @param byteOffset the byte offset of the data
  73824. * @param byteStride the byte stride of the data
  73825. * @param componentCount the number of components per element
  73826. * @param componentType the type of the component
  73827. * @param count the number of values to enumerate
  73828. * @param normalized whether the data is normalized
  73829. * @param callback the callback function called for each value
  73830. */
  73831. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73832. private static _GetFloatValue;
  73833. }
  73834. }
  73835. declare module BABYLON {
  73836. /**
  73837. * @hidden
  73838. */
  73839. export class IntersectionInfo {
  73840. bu: Nullable<number>;
  73841. bv: Nullable<number>;
  73842. distance: number;
  73843. faceId: number;
  73844. subMeshId: number;
  73845. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73846. }
  73847. }
  73848. declare module BABYLON {
  73849. /**
  73850. * Represens a plane by the equation ax + by + cz + d = 0
  73851. */
  73852. export class Plane {
  73853. private static _TmpMatrix;
  73854. /**
  73855. * Normal of the plane (a,b,c)
  73856. */
  73857. normal: Vector3;
  73858. /**
  73859. * d component of the plane
  73860. */
  73861. d: number;
  73862. /**
  73863. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73864. * @param a a component of the plane
  73865. * @param b b component of the plane
  73866. * @param c c component of the plane
  73867. * @param d d component of the plane
  73868. */
  73869. constructor(a: number, b: number, c: number, d: number);
  73870. /**
  73871. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73872. */
  73873. asArray(): number[];
  73874. /**
  73875. * @returns a new plane copied from the current Plane.
  73876. */
  73877. clone(): Plane;
  73878. /**
  73879. * @returns the string "Plane".
  73880. */
  73881. getClassName(): string;
  73882. /**
  73883. * @returns the Plane hash code.
  73884. */
  73885. getHashCode(): number;
  73886. /**
  73887. * Normalize the current Plane in place.
  73888. * @returns the updated Plane.
  73889. */
  73890. normalize(): Plane;
  73891. /**
  73892. * Applies a transformation the plane and returns the result
  73893. * @param transformation the transformation matrix to be applied to the plane
  73894. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73895. */
  73896. transform(transformation: DeepImmutable<Matrix>): Plane;
  73897. /**
  73898. * Calcualtte the dot product between the point and the plane normal
  73899. * @param point point to calculate the dot product with
  73900. * @returns the dot product (float) of the point coordinates and the plane normal.
  73901. */
  73902. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73903. /**
  73904. * Updates the current Plane from the plane defined by the three given points.
  73905. * @param point1 one of the points used to contruct the plane
  73906. * @param point2 one of the points used to contruct the plane
  73907. * @param point3 one of the points used to contruct the plane
  73908. * @returns the updated Plane.
  73909. */
  73910. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73911. /**
  73912. * Checks if the plane is facing a given direction
  73913. * @param direction the direction to check if the plane is facing
  73914. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73915. * @returns True is the vector "direction" is the same side than the plane normal.
  73916. */
  73917. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73918. /**
  73919. * Calculates the distance to a point
  73920. * @param point point to calculate distance to
  73921. * @returns the signed distance (float) from the given point to the Plane.
  73922. */
  73923. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73924. /**
  73925. * Creates a plane from an array
  73926. * @param array the array to create a plane from
  73927. * @returns a new Plane from the given array.
  73928. */
  73929. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73930. /**
  73931. * Creates a plane from three points
  73932. * @param point1 point used to create the plane
  73933. * @param point2 point used to create the plane
  73934. * @param point3 point used to create the plane
  73935. * @returns a new Plane defined by the three given points.
  73936. */
  73937. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73938. /**
  73939. * Creates a plane from an origin point and a normal
  73940. * @param origin origin of the plane to be constructed
  73941. * @param normal normal of the plane to be constructed
  73942. * @returns a new Plane the normal vector to this plane at the given origin point.
  73943. * Note : the vector "normal" is updated because normalized.
  73944. */
  73945. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73946. /**
  73947. * Calculates the distance from a plane and a point
  73948. * @param origin origin of the plane to be constructed
  73949. * @param normal normal of the plane to be constructed
  73950. * @param point point to calculate distance to
  73951. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73952. */
  73953. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73954. }
  73955. }
  73956. declare module BABYLON {
  73957. /**
  73958. * Class used to store bounding sphere information
  73959. */
  73960. export class BoundingSphere {
  73961. /**
  73962. * Gets the center of the bounding sphere in local space
  73963. */
  73964. readonly center: Vector3;
  73965. /**
  73966. * Radius of the bounding sphere in local space
  73967. */
  73968. radius: number;
  73969. /**
  73970. * Gets the center of the bounding sphere in world space
  73971. */
  73972. readonly centerWorld: Vector3;
  73973. /**
  73974. * Radius of the bounding sphere in world space
  73975. */
  73976. radiusWorld: number;
  73977. /**
  73978. * Gets the minimum vector in local space
  73979. */
  73980. readonly minimum: Vector3;
  73981. /**
  73982. * Gets the maximum vector in local space
  73983. */
  73984. readonly maximum: Vector3;
  73985. private _worldMatrix;
  73986. private static readonly TmpVector3;
  73987. /**
  73988. * Creates a new bounding sphere
  73989. * @param min defines the minimum vector (in local space)
  73990. * @param max defines the maximum vector (in local space)
  73991. * @param worldMatrix defines the new world matrix
  73992. */
  73993. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73994. /**
  73995. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73996. * @param min defines the new minimum vector (in local space)
  73997. * @param max defines the new maximum vector (in local space)
  73998. * @param worldMatrix defines the new world matrix
  73999. */
  74000. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74001. /**
  74002. * Scale the current bounding sphere by applying a scale factor
  74003. * @param factor defines the scale factor to apply
  74004. * @returns the current bounding box
  74005. */
  74006. scale(factor: number): BoundingSphere;
  74007. /**
  74008. * Gets the world matrix of the bounding box
  74009. * @returns a matrix
  74010. */
  74011. getWorldMatrix(): DeepImmutable<Matrix>;
  74012. /** @hidden */
  74013. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74014. /**
  74015. * Tests if the bounding sphere is intersecting the frustum planes
  74016. * @param frustumPlanes defines the frustum planes to test
  74017. * @returns true if there is an intersection
  74018. */
  74019. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74020. /**
  74021. * Tests if the bounding sphere center is in between the frustum planes.
  74022. * Used for optimistic fast inclusion.
  74023. * @param frustumPlanes defines the frustum planes to test
  74024. * @returns true if the sphere center is in between the frustum planes
  74025. */
  74026. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74027. /**
  74028. * Tests if a point is inside the bounding sphere
  74029. * @param point defines the point to test
  74030. * @returns true if the point is inside the bounding sphere
  74031. */
  74032. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74033. /**
  74034. * Checks if two sphere intersct
  74035. * @param sphere0 sphere 0
  74036. * @param sphere1 sphere 1
  74037. * @returns true if the speres intersect
  74038. */
  74039. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74040. }
  74041. }
  74042. declare module BABYLON {
  74043. /**
  74044. * Class used to store bounding box information
  74045. */
  74046. export class BoundingBox implements ICullable {
  74047. /**
  74048. * Gets the 8 vectors representing the bounding box in local space
  74049. */
  74050. readonly vectors: Vector3[];
  74051. /**
  74052. * Gets the center of the bounding box in local space
  74053. */
  74054. readonly center: Vector3;
  74055. /**
  74056. * Gets the center of the bounding box in world space
  74057. */
  74058. readonly centerWorld: Vector3;
  74059. /**
  74060. * Gets the extend size in local space
  74061. */
  74062. readonly extendSize: Vector3;
  74063. /**
  74064. * Gets the extend size in world space
  74065. */
  74066. readonly extendSizeWorld: Vector3;
  74067. /**
  74068. * Gets the OBB (object bounding box) directions
  74069. */
  74070. readonly directions: Vector3[];
  74071. /**
  74072. * Gets the 8 vectors representing the bounding box in world space
  74073. */
  74074. readonly vectorsWorld: Vector3[];
  74075. /**
  74076. * Gets the minimum vector in world space
  74077. */
  74078. readonly minimumWorld: Vector3;
  74079. /**
  74080. * Gets the maximum vector in world space
  74081. */
  74082. readonly maximumWorld: Vector3;
  74083. /**
  74084. * Gets the minimum vector in local space
  74085. */
  74086. readonly minimum: Vector3;
  74087. /**
  74088. * Gets the maximum vector in local space
  74089. */
  74090. readonly maximum: Vector3;
  74091. private _worldMatrix;
  74092. private static readonly TmpVector3;
  74093. /**
  74094. * @hidden
  74095. */
  74096. _tag: number;
  74097. /**
  74098. * Creates a new bounding box
  74099. * @param min defines the minimum vector (in local space)
  74100. * @param max defines the maximum vector (in local space)
  74101. * @param worldMatrix defines the new world matrix
  74102. */
  74103. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74104. /**
  74105. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74106. * @param min defines the new minimum vector (in local space)
  74107. * @param max defines the new maximum vector (in local space)
  74108. * @param worldMatrix defines the new world matrix
  74109. */
  74110. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74111. /**
  74112. * Scale the current bounding box by applying a scale factor
  74113. * @param factor defines the scale factor to apply
  74114. * @returns the current bounding box
  74115. */
  74116. scale(factor: number): BoundingBox;
  74117. /**
  74118. * Gets the world matrix of the bounding box
  74119. * @returns a matrix
  74120. */
  74121. getWorldMatrix(): DeepImmutable<Matrix>;
  74122. /** @hidden */
  74123. _update(world: DeepImmutable<Matrix>): void;
  74124. /**
  74125. * Tests if the bounding box is intersecting the frustum planes
  74126. * @param frustumPlanes defines the frustum planes to test
  74127. * @returns true if there is an intersection
  74128. */
  74129. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74130. /**
  74131. * Tests if the bounding box is entirely inside the frustum planes
  74132. * @param frustumPlanes defines the frustum planes to test
  74133. * @returns true if there is an inclusion
  74134. */
  74135. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74136. /**
  74137. * Tests if a point is inside the bounding box
  74138. * @param point defines the point to test
  74139. * @returns true if the point is inside the bounding box
  74140. */
  74141. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74142. /**
  74143. * Tests if the bounding box intersects with a bounding sphere
  74144. * @param sphere defines the sphere to test
  74145. * @returns true if there is an intersection
  74146. */
  74147. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74148. /**
  74149. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74150. * @param min defines the min vector to use
  74151. * @param max defines the max vector to use
  74152. * @returns true if there is an intersection
  74153. */
  74154. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74155. /**
  74156. * Tests if two bounding boxes are intersections
  74157. * @param box0 defines the first box to test
  74158. * @param box1 defines the second box to test
  74159. * @returns true if there is an intersection
  74160. */
  74161. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74162. /**
  74163. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74164. * @param minPoint defines the minimum vector of the bounding box
  74165. * @param maxPoint defines the maximum vector of the bounding box
  74166. * @param sphereCenter defines the sphere center
  74167. * @param sphereRadius defines the sphere radius
  74168. * @returns true if there is an intersection
  74169. */
  74170. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74171. /**
  74172. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  74173. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74174. * @param frustumPlanes defines the frustum planes to test
  74175. * @return true if there is an inclusion
  74176. */
  74177. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74178. /**
  74179. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  74180. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74181. * @param frustumPlanes defines the frustum planes to test
  74182. * @return true if there is an intersection
  74183. */
  74184. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74185. }
  74186. }
  74187. declare module BABYLON {
  74188. /** @hidden */
  74189. export class Collider {
  74190. /** Define if a collision was found */
  74191. collisionFound: boolean;
  74192. /**
  74193. * Define last intersection point in local space
  74194. */
  74195. intersectionPoint: Vector3;
  74196. /**
  74197. * Define last collided mesh
  74198. */
  74199. collidedMesh: Nullable<AbstractMesh>;
  74200. private _collisionPoint;
  74201. private _planeIntersectionPoint;
  74202. private _tempVector;
  74203. private _tempVector2;
  74204. private _tempVector3;
  74205. private _tempVector4;
  74206. private _edge;
  74207. private _baseToVertex;
  74208. private _destinationPoint;
  74209. private _slidePlaneNormal;
  74210. private _displacementVector;
  74211. /** @hidden */
  74212. _radius: Vector3;
  74213. /** @hidden */
  74214. _retry: number;
  74215. private _velocity;
  74216. private _basePoint;
  74217. private _epsilon;
  74218. /** @hidden */
  74219. _velocityWorldLength: number;
  74220. /** @hidden */
  74221. _basePointWorld: Vector3;
  74222. private _velocityWorld;
  74223. private _normalizedVelocity;
  74224. /** @hidden */
  74225. _initialVelocity: Vector3;
  74226. /** @hidden */
  74227. _initialPosition: Vector3;
  74228. private _nearestDistance;
  74229. private _collisionMask;
  74230. collisionMask: number;
  74231. /**
  74232. * Gets the plane normal used to compute the sliding response (in local space)
  74233. */
  74234. readonly slidePlaneNormal: Vector3;
  74235. /** @hidden */
  74236. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74237. /** @hidden */
  74238. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74239. /** @hidden */
  74240. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74241. /** @hidden */
  74242. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74243. /** @hidden */
  74244. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74245. /** @hidden */
  74246. _getResponse(pos: Vector3, vel: Vector3): void;
  74247. }
  74248. }
  74249. declare module BABYLON {
  74250. /**
  74251. * Interface for cullable objects
  74252. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74253. */
  74254. export interface ICullable {
  74255. /**
  74256. * Checks if the object or part of the object is in the frustum
  74257. * @param frustumPlanes Camera near/planes
  74258. * @returns true if the object is in frustum otherwise false
  74259. */
  74260. isInFrustum(frustumPlanes: Plane[]): boolean;
  74261. /**
  74262. * Checks if a cullable object (mesh...) is in the camera frustum
  74263. * Unlike isInFrustum this cheks the full bounding box
  74264. * @param frustumPlanes Camera near/planes
  74265. * @returns true if the object is in frustum otherwise false
  74266. */
  74267. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74268. }
  74269. /**
  74270. * Info for a bounding data of a mesh
  74271. */
  74272. export class BoundingInfo implements ICullable {
  74273. /**
  74274. * Bounding box for the mesh
  74275. */
  74276. readonly boundingBox: BoundingBox;
  74277. /**
  74278. * Bounding sphere for the mesh
  74279. */
  74280. readonly boundingSphere: BoundingSphere;
  74281. private _isLocked;
  74282. private static readonly TmpVector3;
  74283. /**
  74284. * Constructs bounding info
  74285. * @param minimum min vector of the bounding box/sphere
  74286. * @param maximum max vector of the bounding box/sphere
  74287. * @param worldMatrix defines the new world matrix
  74288. */
  74289. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74290. /**
  74291. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74292. * @param min defines the new minimum vector (in local space)
  74293. * @param max defines the new maximum vector (in local space)
  74294. * @param worldMatrix defines the new world matrix
  74295. */
  74296. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74297. /**
  74298. * min vector of the bounding box/sphere
  74299. */
  74300. readonly minimum: Vector3;
  74301. /**
  74302. * max vector of the bounding box/sphere
  74303. */
  74304. readonly maximum: Vector3;
  74305. /**
  74306. * If the info is locked and won't be updated to avoid perf overhead
  74307. */
  74308. isLocked: boolean;
  74309. /**
  74310. * Updates the bounding sphere and box
  74311. * @param world world matrix to be used to update
  74312. */
  74313. update(world: DeepImmutable<Matrix>): void;
  74314. /**
  74315. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74316. * @param center New center of the bounding info
  74317. * @param extend New extend of the bounding info
  74318. * @returns the current bounding info
  74319. */
  74320. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74321. /**
  74322. * Scale the current bounding info by applying a scale factor
  74323. * @param factor defines the scale factor to apply
  74324. * @returns the current bounding info
  74325. */
  74326. scale(factor: number): BoundingInfo;
  74327. /**
  74328. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74329. * @param frustumPlanes defines the frustum to test
  74330. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74331. * @returns true if the bounding info is in the frustum planes
  74332. */
  74333. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74334. /**
  74335. * Gets the world distance between the min and max points of the bounding box
  74336. */
  74337. readonly diagonalLength: number;
  74338. /**
  74339. * Checks if a cullable object (mesh...) is in the camera frustum
  74340. * Unlike isInFrustum this cheks the full bounding box
  74341. * @param frustumPlanes Camera near/planes
  74342. * @returns true if the object is in frustum otherwise false
  74343. */
  74344. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74345. /** @hidden */
  74346. _checkCollision(collider: Collider): boolean;
  74347. /**
  74348. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74349. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74350. * @param point the point to check intersection with
  74351. * @returns if the point intersects
  74352. */
  74353. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74354. /**
  74355. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74356. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74357. * @param boundingInfo the bounding info to check intersection with
  74358. * @param precise if the intersection should be done using OBB
  74359. * @returns if the bounding info intersects
  74360. */
  74361. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  74362. }
  74363. }
  74364. declare module BABYLON {
  74365. /**
  74366. * Extracts minimum and maximum values from a list of indexed positions
  74367. * @param positions defines the positions to use
  74368. * @param indices defines the indices to the positions
  74369. * @param indexStart defines the start index
  74370. * @param indexCount defines the end index
  74371. * @param bias defines bias value to add to the result
  74372. * @return minimum and maximum values
  74373. */
  74374. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  74375. minimum: Vector3;
  74376. maximum: Vector3;
  74377. };
  74378. /**
  74379. * Extracts minimum and maximum values from a list of positions
  74380. * @param positions defines the positions to use
  74381. * @param start defines the start index in the positions array
  74382. * @param count defines the number of positions to handle
  74383. * @param bias defines bias value to add to the result
  74384. * @param stride defines the stride size to use (distance between two positions in the positions array)
  74385. * @return minimum and maximum values
  74386. */
  74387. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  74388. minimum: Vector3;
  74389. maximum: Vector3;
  74390. };
  74391. }
  74392. declare module BABYLON {
  74393. /** @hidden */
  74394. export class WebGLDataBuffer extends DataBuffer {
  74395. private _buffer;
  74396. constructor(resource: WebGLBuffer);
  74397. readonly underlyingResource: any;
  74398. }
  74399. }
  74400. declare module BABYLON {
  74401. /** @hidden */
  74402. export class WebGLPipelineContext implements IPipelineContext {
  74403. engine: ThinEngine;
  74404. program: Nullable<WebGLProgram>;
  74405. context?: WebGLRenderingContext;
  74406. vertexShader?: WebGLShader;
  74407. fragmentShader?: WebGLShader;
  74408. isParallelCompiled: boolean;
  74409. onCompiled?: () => void;
  74410. transformFeedback?: WebGLTransformFeedback | null;
  74411. readonly isAsync: boolean;
  74412. readonly isReady: boolean;
  74413. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  74414. }
  74415. }
  74416. declare module BABYLON {
  74417. interface ThinEngine {
  74418. /**
  74419. * Create an uniform buffer
  74420. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74421. * @param elements defines the content of the uniform buffer
  74422. * @returns the webGL uniform buffer
  74423. */
  74424. createUniformBuffer(elements: FloatArray): DataBuffer;
  74425. /**
  74426. * Create a dynamic uniform buffer
  74427. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74428. * @param elements defines the content of the uniform buffer
  74429. * @returns the webGL uniform buffer
  74430. */
  74431. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  74432. /**
  74433. * Update an existing uniform buffer
  74434. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74435. * @param uniformBuffer defines the target uniform buffer
  74436. * @param elements defines the content to update
  74437. * @param offset defines the offset in the uniform buffer where update should start
  74438. * @param count defines the size of the data to update
  74439. */
  74440. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  74441. /**
  74442. * Bind an uniform buffer to the current webGL context
  74443. * @param buffer defines the buffer to bind
  74444. */
  74445. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  74446. /**
  74447. * Bind a buffer to the current webGL context at a given location
  74448. * @param buffer defines the buffer to bind
  74449. * @param location defines the index where to bind the buffer
  74450. */
  74451. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  74452. /**
  74453. * Bind a specific block at a given index in a specific shader program
  74454. * @param pipelineContext defines the pipeline context to use
  74455. * @param blockName defines the block name
  74456. * @param index defines the index where to bind the block
  74457. */
  74458. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  74459. }
  74460. }
  74461. declare module BABYLON {
  74462. /**
  74463. * Uniform buffer objects.
  74464. *
  74465. * Handles blocks of uniform on the GPU.
  74466. *
  74467. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74468. *
  74469. * For more information, please refer to :
  74470. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74471. */
  74472. export class UniformBuffer {
  74473. private _engine;
  74474. private _buffer;
  74475. private _data;
  74476. private _bufferData;
  74477. private _dynamic?;
  74478. private _uniformLocations;
  74479. private _uniformSizes;
  74480. private _uniformLocationPointer;
  74481. private _needSync;
  74482. private _noUBO;
  74483. private _currentEffect;
  74484. /** @hidden */
  74485. _alreadyBound: boolean;
  74486. private static _MAX_UNIFORM_SIZE;
  74487. private static _tempBuffer;
  74488. /**
  74489. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  74490. * This is dynamic to allow compat with webgl 1 and 2.
  74491. * You will need to pass the name of the uniform as well as the value.
  74492. */
  74493. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  74494. /**
  74495. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  74496. * This is dynamic to allow compat with webgl 1 and 2.
  74497. * You will need to pass the name of the uniform as well as the value.
  74498. */
  74499. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  74500. /**
  74501. * Lambda to Update a single float in a uniform buffer.
  74502. * This is dynamic to allow compat with webgl 1 and 2.
  74503. * You will need to pass the name of the uniform as well as the value.
  74504. */
  74505. updateFloat: (name: string, x: number) => void;
  74506. /**
  74507. * Lambda to Update a vec2 of float in a uniform buffer.
  74508. * This is dynamic to allow compat with webgl 1 and 2.
  74509. * You will need to pass the name of the uniform as well as the value.
  74510. */
  74511. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  74512. /**
  74513. * Lambda to Update a vec3 of float in a uniform buffer.
  74514. * This is dynamic to allow compat with webgl 1 and 2.
  74515. * You will need to pass the name of the uniform as well as the value.
  74516. */
  74517. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  74518. /**
  74519. * Lambda to Update a vec4 of float in a uniform buffer.
  74520. * This is dynamic to allow compat with webgl 1 and 2.
  74521. * You will need to pass the name of the uniform as well as the value.
  74522. */
  74523. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  74524. /**
  74525. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  74526. * This is dynamic to allow compat with webgl 1 and 2.
  74527. * You will need to pass the name of the uniform as well as the value.
  74528. */
  74529. updateMatrix: (name: string, mat: Matrix) => void;
  74530. /**
  74531. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  74532. * This is dynamic to allow compat with webgl 1 and 2.
  74533. * You will need to pass the name of the uniform as well as the value.
  74534. */
  74535. updateVector3: (name: string, vector: Vector3) => void;
  74536. /**
  74537. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  74538. * This is dynamic to allow compat with webgl 1 and 2.
  74539. * You will need to pass the name of the uniform as well as the value.
  74540. */
  74541. updateVector4: (name: string, vector: Vector4) => void;
  74542. /**
  74543. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  74544. * This is dynamic to allow compat with webgl 1 and 2.
  74545. * You will need to pass the name of the uniform as well as the value.
  74546. */
  74547. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  74548. /**
  74549. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  74550. * This is dynamic to allow compat with webgl 1 and 2.
  74551. * You will need to pass the name of the uniform as well as the value.
  74552. */
  74553. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  74554. /**
  74555. * Instantiates a new Uniform buffer objects.
  74556. *
  74557. * Handles blocks of uniform on the GPU.
  74558. *
  74559. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74560. *
  74561. * For more information, please refer to :
  74562. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74563. * @param engine Define the engine the buffer is associated with
  74564. * @param data Define the data contained in the buffer
  74565. * @param dynamic Define if the buffer is updatable
  74566. */
  74567. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  74568. /**
  74569. * Indicates if the buffer is using the WebGL2 UBO implementation,
  74570. * or just falling back on setUniformXXX calls.
  74571. */
  74572. readonly useUbo: boolean;
  74573. /**
  74574. * Indicates if the WebGL underlying uniform buffer is in sync
  74575. * with the javascript cache data.
  74576. */
  74577. readonly isSync: boolean;
  74578. /**
  74579. * Indicates if the WebGL underlying uniform buffer is dynamic.
  74580. * Also, a dynamic UniformBuffer will disable cache verification and always
  74581. * update the underlying WebGL uniform buffer to the GPU.
  74582. * @returns if Dynamic, otherwise false
  74583. */
  74584. isDynamic(): boolean;
  74585. /**
  74586. * The data cache on JS side.
  74587. * @returns the underlying data as a float array
  74588. */
  74589. getData(): Float32Array;
  74590. /**
  74591. * The underlying WebGL Uniform buffer.
  74592. * @returns the webgl buffer
  74593. */
  74594. getBuffer(): Nullable<DataBuffer>;
  74595. /**
  74596. * std140 layout specifies how to align data within an UBO structure.
  74597. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  74598. * for specs.
  74599. */
  74600. private _fillAlignment;
  74601. /**
  74602. * Adds an uniform in the buffer.
  74603. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  74604. * for the layout to be correct !
  74605. * @param name Name of the uniform, as used in the uniform block in the shader.
  74606. * @param size Data size, or data directly.
  74607. */
  74608. addUniform(name: string, size: number | number[]): void;
  74609. /**
  74610. * Adds a Matrix 4x4 to the uniform buffer.
  74611. * @param name Name of the uniform, as used in the uniform block in the shader.
  74612. * @param mat A 4x4 matrix.
  74613. */
  74614. addMatrix(name: string, mat: Matrix): void;
  74615. /**
  74616. * Adds a vec2 to the uniform buffer.
  74617. * @param name Name of the uniform, as used in the uniform block in the shader.
  74618. * @param x Define the x component value of the vec2
  74619. * @param y Define the y component value of the vec2
  74620. */
  74621. addFloat2(name: string, x: number, y: number): void;
  74622. /**
  74623. * Adds a vec3 to the uniform buffer.
  74624. * @param name Name of the uniform, as used in the uniform block in the shader.
  74625. * @param x Define the x component value of the vec3
  74626. * @param y Define the y component value of the vec3
  74627. * @param z Define the z component value of the vec3
  74628. */
  74629. addFloat3(name: string, x: number, y: number, z: number): void;
  74630. /**
  74631. * Adds a vec3 to the uniform buffer.
  74632. * @param name Name of the uniform, as used in the uniform block in the shader.
  74633. * @param color Define the vec3 from a Color
  74634. */
  74635. addColor3(name: string, color: Color3): void;
  74636. /**
  74637. * Adds a vec4 to the uniform buffer.
  74638. * @param name Name of the uniform, as used in the uniform block in the shader.
  74639. * @param color Define the rgb components from a Color
  74640. * @param alpha Define the a component of the vec4
  74641. */
  74642. addColor4(name: string, color: Color3, alpha: number): void;
  74643. /**
  74644. * Adds a vec3 to the uniform buffer.
  74645. * @param name Name of the uniform, as used in the uniform block in the shader.
  74646. * @param vector Define the vec3 components from a Vector
  74647. */
  74648. addVector3(name: string, vector: Vector3): void;
  74649. /**
  74650. * Adds a Matrix 3x3 to the uniform buffer.
  74651. * @param name Name of the uniform, as used in the uniform block in the shader.
  74652. */
  74653. addMatrix3x3(name: string): void;
  74654. /**
  74655. * Adds a Matrix 2x2 to the uniform buffer.
  74656. * @param name Name of the uniform, as used in the uniform block in the shader.
  74657. */
  74658. addMatrix2x2(name: string): void;
  74659. /**
  74660. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74661. */
  74662. create(): void;
  74663. /** @hidden */
  74664. _rebuild(): void;
  74665. /**
  74666. * Updates the WebGL Uniform Buffer on the GPU.
  74667. * If the `dynamic` flag is set to true, no cache comparison is done.
  74668. * Otherwise, the buffer will be updated only if the cache differs.
  74669. */
  74670. update(): void;
  74671. /**
  74672. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74673. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74674. * @param data Define the flattened data
  74675. * @param size Define the size of the data.
  74676. */
  74677. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74678. private _valueCache;
  74679. private _cacheMatrix;
  74680. private _updateMatrix3x3ForUniform;
  74681. private _updateMatrix3x3ForEffect;
  74682. private _updateMatrix2x2ForEffect;
  74683. private _updateMatrix2x2ForUniform;
  74684. private _updateFloatForEffect;
  74685. private _updateFloatForUniform;
  74686. private _updateFloat2ForEffect;
  74687. private _updateFloat2ForUniform;
  74688. private _updateFloat3ForEffect;
  74689. private _updateFloat3ForUniform;
  74690. private _updateFloat4ForEffect;
  74691. private _updateFloat4ForUniform;
  74692. private _updateMatrixForEffect;
  74693. private _updateMatrixForUniform;
  74694. private _updateVector3ForEffect;
  74695. private _updateVector3ForUniform;
  74696. private _updateVector4ForEffect;
  74697. private _updateVector4ForUniform;
  74698. private _updateColor3ForEffect;
  74699. private _updateColor3ForUniform;
  74700. private _updateColor4ForEffect;
  74701. private _updateColor4ForUniform;
  74702. /**
  74703. * Sets a sampler uniform on the effect.
  74704. * @param name Define the name of the sampler.
  74705. * @param texture Define the texture to set in the sampler
  74706. */
  74707. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74708. /**
  74709. * Directly updates the value of the uniform in the cache AND on the GPU.
  74710. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74711. * @param data Define the flattened data
  74712. */
  74713. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74714. /**
  74715. * Binds this uniform buffer to an effect.
  74716. * @param effect Define the effect to bind the buffer to
  74717. * @param name Name of the uniform block in the shader.
  74718. */
  74719. bindToEffect(effect: Effect, name: string): void;
  74720. /**
  74721. * Disposes the uniform buffer.
  74722. */
  74723. dispose(): void;
  74724. }
  74725. }
  74726. declare module BABYLON {
  74727. /**
  74728. * Enum that determines the text-wrapping mode to use.
  74729. */
  74730. export enum InspectableType {
  74731. /**
  74732. * Checkbox for booleans
  74733. */
  74734. Checkbox = 0,
  74735. /**
  74736. * Sliders for numbers
  74737. */
  74738. Slider = 1,
  74739. /**
  74740. * Vector3
  74741. */
  74742. Vector3 = 2,
  74743. /**
  74744. * Quaternions
  74745. */
  74746. Quaternion = 3,
  74747. /**
  74748. * Color3
  74749. */
  74750. Color3 = 4,
  74751. /**
  74752. * String
  74753. */
  74754. String = 5
  74755. }
  74756. /**
  74757. * Interface used to define custom inspectable properties.
  74758. * This interface is used by the inspector to display custom property grids
  74759. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74760. */
  74761. export interface IInspectable {
  74762. /**
  74763. * Gets the label to display
  74764. */
  74765. label: string;
  74766. /**
  74767. * Gets the name of the property to edit
  74768. */
  74769. propertyName: string;
  74770. /**
  74771. * Gets the type of the editor to use
  74772. */
  74773. type: InspectableType;
  74774. /**
  74775. * Gets the minimum value of the property when using in "slider" mode
  74776. */
  74777. min?: number;
  74778. /**
  74779. * Gets the maximum value of the property when using in "slider" mode
  74780. */
  74781. max?: number;
  74782. /**
  74783. * Gets the setp to use when using in "slider" mode
  74784. */
  74785. step?: number;
  74786. }
  74787. }
  74788. declare module BABYLON {
  74789. /**
  74790. * Class used to provide helper for timing
  74791. */
  74792. export class TimingTools {
  74793. /**
  74794. * Polyfill for setImmediate
  74795. * @param action defines the action to execute after the current execution block
  74796. */
  74797. static SetImmediate(action: () => void): void;
  74798. }
  74799. }
  74800. declare module BABYLON {
  74801. /**
  74802. * Class used to enable instatition of objects by class name
  74803. */
  74804. export class InstantiationTools {
  74805. /**
  74806. * Use this object to register external classes like custom textures or material
  74807. * to allow the laoders to instantiate them
  74808. */
  74809. static RegisteredExternalClasses: {
  74810. [key: string]: Object;
  74811. };
  74812. /**
  74813. * Tries to instantiate a new object from a given class name
  74814. * @param className defines the class name to instantiate
  74815. * @returns the new object or null if the system was not able to do the instantiation
  74816. */
  74817. static Instantiate(className: string): any;
  74818. }
  74819. }
  74820. declare module BABYLON {
  74821. /**
  74822. * Define options used to create a depth texture
  74823. */
  74824. export class DepthTextureCreationOptions {
  74825. /** Specifies whether or not a stencil should be allocated in the texture */
  74826. generateStencil?: boolean;
  74827. /** Specifies whether or not bilinear filtering is enable on the texture */
  74828. bilinearFiltering?: boolean;
  74829. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74830. comparisonFunction?: number;
  74831. /** Specifies if the created texture is a cube texture */
  74832. isCube?: boolean;
  74833. }
  74834. }
  74835. declare module BABYLON {
  74836. interface ThinEngine {
  74837. /**
  74838. * Creates a depth stencil cube texture.
  74839. * This is only available in WebGL 2.
  74840. * @param size The size of face edge in the cube texture.
  74841. * @param options The options defining the cube texture.
  74842. * @returns The cube texture
  74843. */
  74844. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74845. /**
  74846. * Creates a cube texture
  74847. * @param rootUrl defines the url where the files to load is located
  74848. * @param scene defines the current scene
  74849. * @param files defines the list of files to load (1 per face)
  74850. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74851. * @param onLoad defines an optional callback raised when the texture is loaded
  74852. * @param onError defines an optional callback raised if there is an issue to load the texture
  74853. * @param format defines the format of the data
  74854. * @param forcedExtension defines the extension to use to pick the right loader
  74855. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74856. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74857. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74858. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74859. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74860. * @returns the cube texture as an InternalTexture
  74861. */
  74862. 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;
  74863. /**
  74864. * Creates a cube texture
  74865. * @param rootUrl defines the url where the files to load is located
  74866. * @param scene defines the current scene
  74867. * @param files defines the list of files to load (1 per face)
  74868. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74869. * @param onLoad defines an optional callback raised when the texture is loaded
  74870. * @param onError defines an optional callback raised if there is an issue to load the texture
  74871. * @param format defines the format of the data
  74872. * @param forcedExtension defines the extension to use to pick the right loader
  74873. * @returns the cube texture as an InternalTexture
  74874. */
  74875. 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;
  74876. /**
  74877. * Creates a cube texture
  74878. * @param rootUrl defines the url where the files to load is located
  74879. * @param scene defines the current scene
  74880. * @param files defines the list of files to load (1 per face)
  74881. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74882. * @param onLoad defines an optional callback raised when the texture is loaded
  74883. * @param onError defines an optional callback raised if there is an issue to load the texture
  74884. * @param format defines the format of the data
  74885. * @param forcedExtension defines the extension to use to pick the right loader
  74886. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74887. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74888. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74889. * @returns the cube texture as an InternalTexture
  74890. */
  74891. 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;
  74892. /** @hidden */
  74893. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74894. /** @hidden */
  74895. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74896. /** @hidden */
  74897. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74898. /** @hidden */
  74899. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74900. /**
  74901. * @hidden
  74902. */
  74903. _setCubeMapTextureParams(loadMipmap: boolean): void;
  74904. }
  74905. }
  74906. declare module BABYLON {
  74907. /**
  74908. * Class for creating a cube texture
  74909. */
  74910. export class CubeTexture extends BaseTexture {
  74911. private _delayedOnLoad;
  74912. /**
  74913. * The url of the texture
  74914. */
  74915. url: string;
  74916. /**
  74917. * Gets or sets the center of the bounding box associated with the cube texture.
  74918. * It must define where the camera used to render the texture was set
  74919. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74920. */
  74921. boundingBoxPosition: Vector3;
  74922. private _boundingBoxSize;
  74923. /**
  74924. * Gets or sets the size of the bounding box associated with the cube texture
  74925. * When defined, the cubemap will switch to local mode
  74926. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74927. * @example https://www.babylonjs-playground.com/#RNASML
  74928. */
  74929. /**
  74930. * Returns the bounding box size
  74931. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74932. */
  74933. boundingBoxSize: Vector3;
  74934. protected _rotationY: number;
  74935. /**
  74936. * Sets texture matrix rotation angle around Y axis in radians.
  74937. */
  74938. /**
  74939. * Gets texture matrix rotation angle around Y axis radians.
  74940. */
  74941. rotationY: number;
  74942. /**
  74943. * Are mip maps generated for this texture or not.
  74944. */
  74945. readonly noMipmap: boolean;
  74946. private _noMipmap;
  74947. private _files;
  74948. protected _forcedExtension: Nullable<string>;
  74949. private _extensions;
  74950. private _textureMatrix;
  74951. private _format;
  74952. private _createPolynomials;
  74953. /** @hidden */
  74954. _prefiltered: boolean;
  74955. /**
  74956. * Creates a cube texture from an array of image urls
  74957. * @param files defines an array of image urls
  74958. * @param scene defines the hosting scene
  74959. * @param noMipmap specifies if mip maps are not used
  74960. * @returns a cube texture
  74961. */
  74962. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74963. /**
  74964. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74965. * @param url defines the url of the prefiltered texture
  74966. * @param scene defines the scene the texture is attached to
  74967. * @param forcedExtension defines the extension of the file if different from the url
  74968. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74969. * @return the prefiltered texture
  74970. */
  74971. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74972. /**
  74973. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74974. * as prefiltered data.
  74975. * @param rootUrl defines the url of the texture or the root name of the six images
  74976. * @param scene defines the scene the texture is attached to
  74977. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74978. * @param noMipmap defines if mipmaps should be created or not
  74979. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74980. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74981. * @param onError defines a callback triggered in case of error during load
  74982. * @param format defines the internal format to use for the texture once loaded
  74983. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74984. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74985. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74986. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74987. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74988. * @return the cube texture
  74989. */
  74990. 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);
  74991. /**
  74992. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74993. */
  74994. readonly isPrefiltered: boolean;
  74995. /**
  74996. * Get the current class name of the texture useful for serialization or dynamic coding.
  74997. * @returns "CubeTexture"
  74998. */
  74999. getClassName(): string;
  75000. /**
  75001. * Update the url (and optional buffer) of this texture if url was null during construction.
  75002. * @param url the url of the texture
  75003. * @param forcedExtension defines the extension to use
  75004. * @param onLoad callback called when the texture is loaded (defaults to null)
  75005. */
  75006. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75007. /**
  75008. * Delays loading of the cube texture
  75009. * @param forcedExtension defines the extension to use
  75010. */
  75011. delayLoad(forcedExtension?: string): void;
  75012. /**
  75013. * Returns the reflection texture matrix
  75014. * @returns the reflection texture matrix
  75015. */
  75016. getReflectionTextureMatrix(): Matrix;
  75017. /**
  75018. * Sets the reflection texture matrix
  75019. * @param value Reflection texture matrix
  75020. */
  75021. setReflectionTextureMatrix(value: Matrix): void;
  75022. /**
  75023. * Parses text to create a cube texture
  75024. * @param parsedTexture define the serialized text to read from
  75025. * @param scene defines the hosting scene
  75026. * @param rootUrl defines the root url of the cube texture
  75027. * @returns a cube texture
  75028. */
  75029. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75030. /**
  75031. * Makes a clone, or deep copy, of the cube texture
  75032. * @returns a new cube texture
  75033. */
  75034. clone(): CubeTexture;
  75035. }
  75036. }
  75037. declare module BABYLON {
  75038. /**
  75039. * Manages the defines for the Material
  75040. */
  75041. export class MaterialDefines {
  75042. /** @hidden */
  75043. protected _keys: string[];
  75044. private _isDirty;
  75045. /** @hidden */
  75046. _renderId: number;
  75047. /** @hidden */
  75048. _areLightsDirty: boolean;
  75049. /** @hidden */
  75050. _areLightsDisposed: boolean;
  75051. /** @hidden */
  75052. _areAttributesDirty: boolean;
  75053. /** @hidden */
  75054. _areTexturesDirty: boolean;
  75055. /** @hidden */
  75056. _areFresnelDirty: boolean;
  75057. /** @hidden */
  75058. _areMiscDirty: boolean;
  75059. /** @hidden */
  75060. _areImageProcessingDirty: boolean;
  75061. /** @hidden */
  75062. _normals: boolean;
  75063. /** @hidden */
  75064. _uvs: boolean;
  75065. /** @hidden */
  75066. _needNormals: boolean;
  75067. /** @hidden */
  75068. _needUVs: boolean;
  75069. [id: string]: any;
  75070. /**
  75071. * Specifies if the material needs to be re-calculated
  75072. */
  75073. readonly isDirty: boolean;
  75074. /**
  75075. * Marks the material to indicate that it has been re-calculated
  75076. */
  75077. markAsProcessed(): void;
  75078. /**
  75079. * Marks the material to indicate that it needs to be re-calculated
  75080. */
  75081. markAsUnprocessed(): void;
  75082. /**
  75083. * Marks the material to indicate all of its defines need to be re-calculated
  75084. */
  75085. markAllAsDirty(): void;
  75086. /**
  75087. * Marks the material to indicate that image processing needs to be re-calculated
  75088. */
  75089. markAsImageProcessingDirty(): void;
  75090. /**
  75091. * Marks the material to indicate the lights need to be re-calculated
  75092. * @param disposed Defines whether the light is dirty due to dispose or not
  75093. */
  75094. markAsLightDirty(disposed?: boolean): void;
  75095. /**
  75096. * Marks the attribute state as changed
  75097. */
  75098. markAsAttributesDirty(): void;
  75099. /**
  75100. * Marks the texture state as changed
  75101. */
  75102. markAsTexturesDirty(): void;
  75103. /**
  75104. * Marks the fresnel state as changed
  75105. */
  75106. markAsFresnelDirty(): void;
  75107. /**
  75108. * Marks the misc state as changed
  75109. */
  75110. markAsMiscDirty(): void;
  75111. /**
  75112. * Rebuilds the material defines
  75113. */
  75114. rebuild(): void;
  75115. /**
  75116. * Specifies if two material defines are equal
  75117. * @param other - A material define instance to compare to
  75118. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75119. */
  75120. isEqual(other: MaterialDefines): boolean;
  75121. /**
  75122. * Clones this instance's defines to another instance
  75123. * @param other - material defines to clone values to
  75124. */
  75125. cloneTo(other: MaterialDefines): void;
  75126. /**
  75127. * Resets the material define values
  75128. */
  75129. reset(): void;
  75130. /**
  75131. * Converts the material define values to a string
  75132. * @returns - String of material define information
  75133. */
  75134. toString(): string;
  75135. }
  75136. }
  75137. declare module BABYLON {
  75138. /**
  75139. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75140. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75141. * 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;
  75142. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75143. */
  75144. export class ColorCurves {
  75145. private _dirty;
  75146. private _tempColor;
  75147. private _globalCurve;
  75148. private _highlightsCurve;
  75149. private _midtonesCurve;
  75150. private _shadowsCurve;
  75151. private _positiveCurve;
  75152. private _negativeCurve;
  75153. private _globalHue;
  75154. private _globalDensity;
  75155. private _globalSaturation;
  75156. private _globalExposure;
  75157. /**
  75158. * Gets the global Hue value.
  75159. * 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).
  75160. */
  75161. /**
  75162. * Sets the global Hue value.
  75163. * 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).
  75164. */
  75165. globalHue: number;
  75166. /**
  75167. * Gets the global Density value.
  75168. * 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.
  75169. * Values less than zero provide a filter of opposite hue.
  75170. */
  75171. /**
  75172. * Sets the global Density value.
  75173. * 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.
  75174. * Values less than zero provide a filter of opposite hue.
  75175. */
  75176. globalDensity: number;
  75177. /**
  75178. * Gets the global Saturation value.
  75179. * 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.
  75180. */
  75181. /**
  75182. * Sets the global Saturation value.
  75183. * 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.
  75184. */
  75185. globalSaturation: number;
  75186. /**
  75187. * Gets the global Exposure value.
  75188. * 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.
  75189. */
  75190. /**
  75191. * Sets the global Exposure value.
  75192. * 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.
  75193. */
  75194. globalExposure: number;
  75195. private _highlightsHue;
  75196. private _highlightsDensity;
  75197. private _highlightsSaturation;
  75198. private _highlightsExposure;
  75199. /**
  75200. * Gets the highlights Hue value.
  75201. * 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).
  75202. */
  75203. /**
  75204. * Sets the highlights Hue value.
  75205. * 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).
  75206. */
  75207. highlightsHue: number;
  75208. /**
  75209. * Gets the highlights Density value.
  75210. * 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.
  75211. * Values less than zero provide a filter of opposite hue.
  75212. */
  75213. /**
  75214. * Sets the highlights Density value.
  75215. * 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.
  75216. * Values less than zero provide a filter of opposite hue.
  75217. */
  75218. highlightsDensity: number;
  75219. /**
  75220. * Gets the highlights Saturation value.
  75221. * 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.
  75222. */
  75223. /**
  75224. * Sets the highlights Saturation value.
  75225. * 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.
  75226. */
  75227. highlightsSaturation: number;
  75228. /**
  75229. * Gets the highlights Exposure value.
  75230. * 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.
  75231. */
  75232. /**
  75233. * Sets the highlights Exposure value.
  75234. * 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.
  75235. */
  75236. highlightsExposure: number;
  75237. private _midtonesHue;
  75238. private _midtonesDensity;
  75239. private _midtonesSaturation;
  75240. private _midtonesExposure;
  75241. /**
  75242. * Gets the midtones Hue value.
  75243. * 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).
  75244. */
  75245. /**
  75246. * Sets the midtones Hue value.
  75247. * 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).
  75248. */
  75249. midtonesHue: number;
  75250. /**
  75251. * Gets the midtones Density value.
  75252. * 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.
  75253. * Values less than zero provide a filter of opposite hue.
  75254. */
  75255. /**
  75256. * Sets the midtones Density value.
  75257. * 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.
  75258. * Values less than zero provide a filter of opposite hue.
  75259. */
  75260. midtonesDensity: number;
  75261. /**
  75262. * Gets the midtones Saturation value.
  75263. * 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.
  75264. */
  75265. /**
  75266. * Sets the midtones Saturation value.
  75267. * 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.
  75268. */
  75269. midtonesSaturation: number;
  75270. /**
  75271. * Gets the midtones Exposure value.
  75272. * 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.
  75273. */
  75274. /**
  75275. * Sets the midtones Exposure value.
  75276. * 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.
  75277. */
  75278. midtonesExposure: number;
  75279. private _shadowsHue;
  75280. private _shadowsDensity;
  75281. private _shadowsSaturation;
  75282. private _shadowsExposure;
  75283. /**
  75284. * Gets the shadows Hue value.
  75285. * 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).
  75286. */
  75287. /**
  75288. * Sets the shadows Hue value.
  75289. * 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).
  75290. */
  75291. shadowsHue: number;
  75292. /**
  75293. * Gets the shadows Density value.
  75294. * 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.
  75295. * Values less than zero provide a filter of opposite hue.
  75296. */
  75297. /**
  75298. * Sets the shadows Density value.
  75299. * 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.
  75300. * Values less than zero provide a filter of opposite hue.
  75301. */
  75302. shadowsDensity: number;
  75303. /**
  75304. * Gets the shadows Saturation value.
  75305. * 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.
  75306. */
  75307. /**
  75308. * Sets the shadows Saturation value.
  75309. * 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.
  75310. */
  75311. shadowsSaturation: number;
  75312. /**
  75313. * Gets the shadows Exposure value.
  75314. * 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.
  75315. */
  75316. /**
  75317. * Sets the shadows Exposure value.
  75318. * 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.
  75319. */
  75320. shadowsExposure: number;
  75321. /**
  75322. * Returns the class name
  75323. * @returns The class name
  75324. */
  75325. getClassName(): string;
  75326. /**
  75327. * Binds the color curves to the shader.
  75328. * @param colorCurves The color curve to bind
  75329. * @param effect The effect to bind to
  75330. * @param positiveUniform The positive uniform shader parameter
  75331. * @param neutralUniform The neutral uniform shader parameter
  75332. * @param negativeUniform The negative uniform shader parameter
  75333. */
  75334. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75335. /**
  75336. * Prepare the list of uniforms associated with the ColorCurves effects.
  75337. * @param uniformsList The list of uniforms used in the effect
  75338. */
  75339. static PrepareUniforms(uniformsList: string[]): void;
  75340. /**
  75341. * Returns color grading data based on a hue, density, saturation and exposure value.
  75342. * @param filterHue The hue of the color filter.
  75343. * @param filterDensity The density of the color filter.
  75344. * @param saturation The saturation.
  75345. * @param exposure The exposure.
  75346. * @param result The result data container.
  75347. */
  75348. private getColorGradingDataToRef;
  75349. /**
  75350. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75351. * @param value The input slider value in range [-100,100].
  75352. * @returns Adjusted value.
  75353. */
  75354. private static applyColorGradingSliderNonlinear;
  75355. /**
  75356. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75357. * @param hue The hue (H) input.
  75358. * @param saturation The saturation (S) input.
  75359. * @param brightness The brightness (B) input.
  75360. * @result An RGBA color represented as Vector4.
  75361. */
  75362. private static fromHSBToRef;
  75363. /**
  75364. * Returns a value clamped between min and max
  75365. * @param value The value to clamp
  75366. * @param min The minimum of value
  75367. * @param max The maximum of value
  75368. * @returns The clamped value.
  75369. */
  75370. private static clamp;
  75371. /**
  75372. * Clones the current color curve instance.
  75373. * @return The cloned curves
  75374. */
  75375. clone(): ColorCurves;
  75376. /**
  75377. * Serializes the current color curve instance to a json representation.
  75378. * @return a JSON representation
  75379. */
  75380. serialize(): any;
  75381. /**
  75382. * Parses the color curve from a json representation.
  75383. * @param source the JSON source to parse
  75384. * @return The parsed curves
  75385. */
  75386. static Parse(source: any): ColorCurves;
  75387. }
  75388. }
  75389. declare module BABYLON {
  75390. /**
  75391. * Interface to follow in your material defines to integrate easily the
  75392. * Image proccessing functions.
  75393. * @hidden
  75394. */
  75395. export interface IImageProcessingConfigurationDefines {
  75396. IMAGEPROCESSING: boolean;
  75397. VIGNETTE: boolean;
  75398. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75399. VIGNETTEBLENDMODEOPAQUE: boolean;
  75400. TONEMAPPING: boolean;
  75401. TONEMAPPING_ACES: boolean;
  75402. CONTRAST: boolean;
  75403. EXPOSURE: boolean;
  75404. COLORCURVES: boolean;
  75405. COLORGRADING: boolean;
  75406. COLORGRADING3D: boolean;
  75407. SAMPLER3DGREENDEPTH: boolean;
  75408. SAMPLER3DBGRMAP: boolean;
  75409. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75410. }
  75411. /**
  75412. * @hidden
  75413. */
  75414. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  75415. IMAGEPROCESSING: boolean;
  75416. VIGNETTE: boolean;
  75417. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75418. VIGNETTEBLENDMODEOPAQUE: boolean;
  75419. TONEMAPPING: boolean;
  75420. TONEMAPPING_ACES: boolean;
  75421. CONTRAST: boolean;
  75422. COLORCURVES: boolean;
  75423. COLORGRADING: boolean;
  75424. COLORGRADING3D: boolean;
  75425. SAMPLER3DGREENDEPTH: boolean;
  75426. SAMPLER3DBGRMAP: boolean;
  75427. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75428. EXPOSURE: boolean;
  75429. constructor();
  75430. }
  75431. /**
  75432. * This groups together the common properties used for image processing either in direct forward pass
  75433. * or through post processing effect depending on the use of the image processing pipeline in your scene
  75434. * or not.
  75435. */
  75436. export class ImageProcessingConfiguration {
  75437. /**
  75438. * Default tone mapping applied in BabylonJS.
  75439. */
  75440. static readonly TONEMAPPING_STANDARD: number;
  75441. /**
  75442. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  75443. * to other engines rendering to increase portability.
  75444. */
  75445. static readonly TONEMAPPING_ACES: number;
  75446. /**
  75447. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  75448. */
  75449. colorCurves: Nullable<ColorCurves>;
  75450. private _colorCurvesEnabled;
  75451. /**
  75452. * Gets wether the color curves effect is enabled.
  75453. */
  75454. /**
  75455. * Sets wether the color curves effect is enabled.
  75456. */
  75457. colorCurvesEnabled: boolean;
  75458. private _colorGradingTexture;
  75459. /**
  75460. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75461. */
  75462. /**
  75463. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75464. */
  75465. colorGradingTexture: Nullable<BaseTexture>;
  75466. private _colorGradingEnabled;
  75467. /**
  75468. * Gets wether the color grading effect is enabled.
  75469. */
  75470. /**
  75471. * Sets wether the color grading effect is enabled.
  75472. */
  75473. colorGradingEnabled: boolean;
  75474. private _colorGradingWithGreenDepth;
  75475. /**
  75476. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  75477. */
  75478. /**
  75479. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  75480. */
  75481. colorGradingWithGreenDepth: boolean;
  75482. private _colorGradingBGR;
  75483. /**
  75484. * Gets wether the color grading texture contains BGR values.
  75485. */
  75486. /**
  75487. * Sets wether the color grading texture contains BGR values.
  75488. */
  75489. colorGradingBGR: boolean;
  75490. /** @hidden */
  75491. _exposure: number;
  75492. /**
  75493. * Gets the Exposure used in the effect.
  75494. */
  75495. /**
  75496. * Sets the Exposure used in the effect.
  75497. */
  75498. exposure: number;
  75499. private _toneMappingEnabled;
  75500. /**
  75501. * Gets wether the tone mapping effect is enabled.
  75502. */
  75503. /**
  75504. * Sets wether the tone mapping effect is enabled.
  75505. */
  75506. toneMappingEnabled: boolean;
  75507. private _toneMappingType;
  75508. /**
  75509. * Gets the type of tone mapping effect.
  75510. */
  75511. /**
  75512. * Sets the type of tone mapping effect used in BabylonJS.
  75513. */
  75514. toneMappingType: number;
  75515. protected _contrast: number;
  75516. /**
  75517. * Gets the contrast used in the effect.
  75518. */
  75519. /**
  75520. * Sets the contrast used in the effect.
  75521. */
  75522. contrast: number;
  75523. /**
  75524. * Vignette stretch size.
  75525. */
  75526. vignetteStretch: number;
  75527. /**
  75528. * Vignette centre X Offset.
  75529. */
  75530. vignetteCentreX: number;
  75531. /**
  75532. * Vignette centre Y Offset.
  75533. */
  75534. vignetteCentreY: number;
  75535. /**
  75536. * Vignette weight or intensity of the vignette effect.
  75537. */
  75538. vignetteWeight: number;
  75539. /**
  75540. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  75541. * if vignetteEnabled is set to true.
  75542. */
  75543. vignetteColor: Color4;
  75544. /**
  75545. * Camera field of view used by the Vignette effect.
  75546. */
  75547. vignetteCameraFov: number;
  75548. private _vignetteBlendMode;
  75549. /**
  75550. * Gets the vignette blend mode allowing different kind of effect.
  75551. */
  75552. /**
  75553. * Sets the vignette blend mode allowing different kind of effect.
  75554. */
  75555. vignetteBlendMode: number;
  75556. private _vignetteEnabled;
  75557. /**
  75558. * Gets wether the vignette effect is enabled.
  75559. */
  75560. /**
  75561. * Sets wether the vignette effect is enabled.
  75562. */
  75563. vignetteEnabled: boolean;
  75564. private _applyByPostProcess;
  75565. /**
  75566. * Gets wether the image processing is applied through a post process or not.
  75567. */
  75568. /**
  75569. * Sets wether the image processing is applied through a post process or not.
  75570. */
  75571. applyByPostProcess: boolean;
  75572. private _isEnabled;
  75573. /**
  75574. * Gets wether the image processing is enabled or not.
  75575. */
  75576. /**
  75577. * Sets wether the image processing is enabled or not.
  75578. */
  75579. isEnabled: boolean;
  75580. /**
  75581. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  75582. */
  75583. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  75584. /**
  75585. * Method called each time the image processing information changes requires to recompile the effect.
  75586. */
  75587. protected _updateParameters(): void;
  75588. /**
  75589. * Gets the current class name.
  75590. * @return "ImageProcessingConfiguration"
  75591. */
  75592. getClassName(): string;
  75593. /**
  75594. * Prepare the list of uniforms associated with the Image Processing effects.
  75595. * @param uniforms The list of uniforms used in the effect
  75596. * @param defines the list of defines currently in use
  75597. */
  75598. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  75599. /**
  75600. * Prepare the list of samplers associated with the Image Processing effects.
  75601. * @param samplersList The list of uniforms used in the effect
  75602. * @param defines the list of defines currently in use
  75603. */
  75604. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  75605. /**
  75606. * Prepare the list of defines associated to the shader.
  75607. * @param defines the list of defines to complete
  75608. * @param forPostProcess Define if we are currently in post process mode or not
  75609. */
  75610. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  75611. /**
  75612. * Returns true if all the image processing information are ready.
  75613. * @returns True if ready, otherwise, false
  75614. */
  75615. isReady(): boolean;
  75616. /**
  75617. * Binds the image processing to the shader.
  75618. * @param effect The effect to bind to
  75619. * @param aspectRatio Define the current aspect ratio of the effect
  75620. */
  75621. bind(effect: Effect, aspectRatio?: number): void;
  75622. /**
  75623. * Clones the current image processing instance.
  75624. * @return The cloned image processing
  75625. */
  75626. clone(): ImageProcessingConfiguration;
  75627. /**
  75628. * Serializes the current image processing instance to a json representation.
  75629. * @return a JSON representation
  75630. */
  75631. serialize(): any;
  75632. /**
  75633. * Parses the image processing from a json representation.
  75634. * @param source the JSON source to parse
  75635. * @return The parsed image processing
  75636. */
  75637. static Parse(source: any): ImageProcessingConfiguration;
  75638. private static _VIGNETTEMODE_MULTIPLY;
  75639. private static _VIGNETTEMODE_OPAQUE;
  75640. /**
  75641. * Used to apply the vignette as a mix with the pixel color.
  75642. */
  75643. static readonly VIGNETTEMODE_MULTIPLY: number;
  75644. /**
  75645. * Used to apply the vignette as a replacement of the pixel color.
  75646. */
  75647. static readonly VIGNETTEMODE_OPAQUE: number;
  75648. }
  75649. }
  75650. declare module BABYLON {
  75651. /** @hidden */
  75652. export var postprocessVertexShader: {
  75653. name: string;
  75654. shader: string;
  75655. };
  75656. }
  75657. declare module BABYLON {
  75658. interface ThinEngine {
  75659. /**
  75660. * Creates a new render target texture
  75661. * @param size defines the size of the texture
  75662. * @param options defines the options used to create the texture
  75663. * @returns a new render target texture stored in an InternalTexture
  75664. */
  75665. createRenderTargetTexture(size: number | {
  75666. width: number;
  75667. height: number;
  75668. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75669. /**
  75670. * Creates a depth stencil texture.
  75671. * This is only available in WebGL 2 or with the depth texture extension available.
  75672. * @param size The size of face edge in the texture.
  75673. * @param options The options defining the texture.
  75674. * @returns The texture
  75675. */
  75676. createDepthStencilTexture(size: number | {
  75677. width: number;
  75678. height: number;
  75679. }, options: DepthTextureCreationOptions): InternalTexture;
  75680. /** @hidden */
  75681. _createDepthStencilTexture(size: number | {
  75682. width: number;
  75683. height: number;
  75684. }, options: DepthTextureCreationOptions): InternalTexture;
  75685. }
  75686. }
  75687. declare module BABYLON {
  75688. /** Defines supported spaces */
  75689. export enum Space {
  75690. /** Local (object) space */
  75691. LOCAL = 0,
  75692. /** World space */
  75693. WORLD = 1,
  75694. /** Bone space */
  75695. BONE = 2
  75696. }
  75697. /** Defines the 3 main axes */
  75698. export class Axis {
  75699. /** X axis */
  75700. static X: Vector3;
  75701. /** Y axis */
  75702. static Y: Vector3;
  75703. /** Z axis */
  75704. static Z: Vector3;
  75705. }
  75706. }
  75707. declare module BABYLON {
  75708. /**
  75709. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75710. * This is the base of the follow, arc rotate cameras and Free camera
  75711. * @see http://doc.babylonjs.com/features/cameras
  75712. */
  75713. export class TargetCamera extends Camera {
  75714. private static _RigCamTransformMatrix;
  75715. private static _TargetTransformMatrix;
  75716. private static _TargetFocalPoint;
  75717. /**
  75718. * Define the current direction the camera is moving to
  75719. */
  75720. cameraDirection: Vector3;
  75721. /**
  75722. * Define the current rotation the camera is rotating to
  75723. */
  75724. cameraRotation: Vector2;
  75725. /**
  75726. * When set, the up vector of the camera will be updated by the rotation of the camera
  75727. */
  75728. updateUpVectorFromRotation: boolean;
  75729. private _tmpQuaternion;
  75730. /**
  75731. * Define the current rotation of the camera
  75732. */
  75733. rotation: Vector3;
  75734. /**
  75735. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75736. */
  75737. rotationQuaternion: Quaternion;
  75738. /**
  75739. * Define the current speed of the camera
  75740. */
  75741. speed: number;
  75742. /**
  75743. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75744. * around all axis.
  75745. */
  75746. noRotationConstraint: boolean;
  75747. /**
  75748. * Define the current target of the camera as an object or a position.
  75749. */
  75750. lockedTarget: any;
  75751. /** @hidden */
  75752. _currentTarget: Vector3;
  75753. /** @hidden */
  75754. _initialFocalDistance: number;
  75755. /** @hidden */
  75756. _viewMatrix: Matrix;
  75757. /** @hidden */
  75758. _camMatrix: Matrix;
  75759. /** @hidden */
  75760. _cameraTransformMatrix: Matrix;
  75761. /** @hidden */
  75762. _cameraRotationMatrix: Matrix;
  75763. /** @hidden */
  75764. _referencePoint: Vector3;
  75765. /** @hidden */
  75766. _transformedReferencePoint: Vector3;
  75767. protected _globalCurrentTarget: Vector3;
  75768. protected _globalCurrentUpVector: Vector3;
  75769. /** @hidden */
  75770. _reset: () => void;
  75771. private _defaultUp;
  75772. /**
  75773. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75774. * This is the base of the follow, arc rotate cameras and Free camera
  75775. * @see http://doc.babylonjs.com/features/cameras
  75776. * @param name Defines the name of the camera in the scene
  75777. * @param position Defines the start position of the camera in the scene
  75778. * @param scene Defines the scene the camera belongs to
  75779. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75780. */
  75781. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75782. /**
  75783. * Gets the position in front of the camera at a given distance.
  75784. * @param distance The distance from the camera we want the position to be
  75785. * @returns the position
  75786. */
  75787. getFrontPosition(distance: number): Vector3;
  75788. /** @hidden */
  75789. _getLockedTargetPosition(): Nullable<Vector3>;
  75790. private _storedPosition;
  75791. private _storedRotation;
  75792. private _storedRotationQuaternion;
  75793. /**
  75794. * Store current camera state of the camera (fov, position, rotation, etc..)
  75795. * @returns the camera
  75796. */
  75797. storeState(): Camera;
  75798. /**
  75799. * Restored camera state. You must call storeState() first
  75800. * @returns whether it was successful or not
  75801. * @hidden
  75802. */
  75803. _restoreStateValues(): boolean;
  75804. /** @hidden */
  75805. _initCache(): void;
  75806. /** @hidden */
  75807. _updateCache(ignoreParentClass?: boolean): void;
  75808. /** @hidden */
  75809. _isSynchronizedViewMatrix(): boolean;
  75810. /** @hidden */
  75811. _computeLocalCameraSpeed(): number;
  75812. /**
  75813. * Defines the target the camera should look at.
  75814. * @param target Defines the new target as a Vector or a mesh
  75815. */
  75816. setTarget(target: Vector3): void;
  75817. /**
  75818. * Return the current target position of the camera. This value is expressed in local space.
  75819. * @returns the target position
  75820. */
  75821. getTarget(): Vector3;
  75822. /** @hidden */
  75823. _decideIfNeedsToMove(): boolean;
  75824. /** @hidden */
  75825. _updatePosition(): void;
  75826. /** @hidden */
  75827. _checkInputs(): void;
  75828. protected _updateCameraRotationMatrix(): void;
  75829. /**
  75830. * 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)
  75831. * @returns the current camera
  75832. */
  75833. private _rotateUpVectorWithCameraRotationMatrix;
  75834. private _cachedRotationZ;
  75835. private _cachedQuaternionRotationZ;
  75836. /** @hidden */
  75837. _getViewMatrix(): Matrix;
  75838. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75839. /**
  75840. * @hidden
  75841. */
  75842. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75843. /**
  75844. * @hidden
  75845. */
  75846. _updateRigCameras(): void;
  75847. private _getRigCamPositionAndTarget;
  75848. /**
  75849. * Gets the current object class name.
  75850. * @return the class name
  75851. */
  75852. getClassName(): string;
  75853. }
  75854. }
  75855. declare module BABYLON {
  75856. /**
  75857. * Gather the list of keyboard event types as constants.
  75858. */
  75859. export class KeyboardEventTypes {
  75860. /**
  75861. * The keydown event is fired when a key becomes active (pressed).
  75862. */
  75863. static readonly KEYDOWN: number;
  75864. /**
  75865. * The keyup event is fired when a key has been released.
  75866. */
  75867. static readonly KEYUP: number;
  75868. }
  75869. /**
  75870. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75871. */
  75872. export class KeyboardInfo {
  75873. /**
  75874. * Defines the type of event (KeyboardEventTypes)
  75875. */
  75876. type: number;
  75877. /**
  75878. * Defines the related dom event
  75879. */
  75880. event: KeyboardEvent;
  75881. /**
  75882. * Instantiates a new keyboard info.
  75883. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75884. * @param type Defines the type of event (KeyboardEventTypes)
  75885. * @param event Defines the related dom event
  75886. */
  75887. constructor(
  75888. /**
  75889. * Defines the type of event (KeyboardEventTypes)
  75890. */
  75891. type: number,
  75892. /**
  75893. * Defines the related dom event
  75894. */
  75895. event: KeyboardEvent);
  75896. }
  75897. /**
  75898. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75899. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75900. */
  75901. export class KeyboardInfoPre extends KeyboardInfo {
  75902. /**
  75903. * Defines the type of event (KeyboardEventTypes)
  75904. */
  75905. type: number;
  75906. /**
  75907. * Defines the related dom event
  75908. */
  75909. event: KeyboardEvent;
  75910. /**
  75911. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75912. */
  75913. skipOnPointerObservable: boolean;
  75914. /**
  75915. * Instantiates a new keyboard pre info.
  75916. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75917. * @param type Defines the type of event (KeyboardEventTypes)
  75918. * @param event Defines the related dom event
  75919. */
  75920. constructor(
  75921. /**
  75922. * Defines the type of event (KeyboardEventTypes)
  75923. */
  75924. type: number,
  75925. /**
  75926. * Defines the related dom event
  75927. */
  75928. event: KeyboardEvent);
  75929. }
  75930. }
  75931. declare module BABYLON {
  75932. /**
  75933. * Manage the keyboard inputs to control the movement of a free camera.
  75934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75935. */
  75936. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75937. /**
  75938. * Defines the camera the input is attached to.
  75939. */
  75940. camera: FreeCamera;
  75941. /**
  75942. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75943. */
  75944. keysUp: number[];
  75945. /**
  75946. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75947. */
  75948. keysDown: number[];
  75949. /**
  75950. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75951. */
  75952. keysLeft: number[];
  75953. /**
  75954. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75955. */
  75956. keysRight: number[];
  75957. private _keys;
  75958. private _onCanvasBlurObserver;
  75959. private _onKeyboardObserver;
  75960. private _engine;
  75961. private _scene;
  75962. /**
  75963. * Attach the input controls to a specific dom element to get the input from.
  75964. * @param element Defines the element the controls should be listened from
  75965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75966. */
  75967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75968. /**
  75969. * Detach the current controls from the specified dom element.
  75970. * @param element Defines the element to stop listening the inputs from
  75971. */
  75972. detachControl(element: Nullable<HTMLElement>): void;
  75973. /**
  75974. * Update the current camera state depending on the inputs that have been used this frame.
  75975. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75976. */
  75977. checkInputs(): void;
  75978. /**
  75979. * Gets the class name of the current intput.
  75980. * @returns the class name
  75981. */
  75982. getClassName(): string;
  75983. /** @hidden */
  75984. _onLostFocus(): void;
  75985. /**
  75986. * Get the friendly name associated with the input class.
  75987. * @returns the input friendly name
  75988. */
  75989. getSimpleName(): string;
  75990. }
  75991. }
  75992. declare module BABYLON {
  75993. /**
  75994. * Interface describing all the common properties and methods a shadow light needs to implement.
  75995. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75996. * as well as binding the different shadow properties to the effects.
  75997. */
  75998. export interface IShadowLight extends Light {
  75999. /**
  76000. * The light id in the scene (used in scene.findLighById for instance)
  76001. */
  76002. id: string;
  76003. /**
  76004. * The position the shdow will be casted from.
  76005. */
  76006. position: Vector3;
  76007. /**
  76008. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76009. */
  76010. direction: Vector3;
  76011. /**
  76012. * The transformed position. Position of the light in world space taking parenting in account.
  76013. */
  76014. transformedPosition: Vector3;
  76015. /**
  76016. * The transformed direction. Direction of the light in world space taking parenting in account.
  76017. */
  76018. transformedDirection: Vector3;
  76019. /**
  76020. * The friendly name of the light in the scene.
  76021. */
  76022. name: string;
  76023. /**
  76024. * Defines the shadow projection clipping minimum z value.
  76025. */
  76026. shadowMinZ: number;
  76027. /**
  76028. * Defines the shadow projection clipping maximum z value.
  76029. */
  76030. shadowMaxZ: number;
  76031. /**
  76032. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76033. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76034. */
  76035. computeTransformedInformation(): boolean;
  76036. /**
  76037. * Gets the scene the light belongs to.
  76038. * @returns The scene
  76039. */
  76040. getScene(): Scene;
  76041. /**
  76042. * Callback defining a custom Projection Matrix Builder.
  76043. * This can be used to override the default projection matrix computation.
  76044. */
  76045. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76046. /**
  76047. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76048. * @param matrix The materix to updated with the projection information
  76049. * @param viewMatrix The transform matrix of the light
  76050. * @param renderList The list of mesh to render in the map
  76051. * @returns The current light
  76052. */
  76053. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76054. /**
  76055. * Gets the current depth scale used in ESM.
  76056. * @returns The scale
  76057. */
  76058. getDepthScale(): number;
  76059. /**
  76060. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76061. * @returns true if a cube texture needs to be use
  76062. */
  76063. needCube(): boolean;
  76064. /**
  76065. * Detects if the projection matrix requires to be recomputed this frame.
  76066. * @returns true if it requires to be recomputed otherwise, false.
  76067. */
  76068. needProjectionMatrixCompute(): boolean;
  76069. /**
  76070. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76071. */
  76072. forceProjectionMatrixCompute(): void;
  76073. /**
  76074. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76075. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76076. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76077. */
  76078. getShadowDirection(faceIndex?: number): Vector3;
  76079. /**
  76080. * Gets the minZ used for shadow according to both the scene and the light.
  76081. * @param activeCamera The camera we are returning the min for
  76082. * @returns the depth min z
  76083. */
  76084. getDepthMinZ(activeCamera: Camera): number;
  76085. /**
  76086. * Gets the maxZ used for shadow according to both the scene and the light.
  76087. * @param activeCamera The camera we are returning the max for
  76088. * @returns the depth max z
  76089. */
  76090. getDepthMaxZ(activeCamera: Camera): number;
  76091. }
  76092. /**
  76093. * Base implementation IShadowLight
  76094. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76095. */
  76096. export abstract class ShadowLight extends Light implements IShadowLight {
  76097. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76098. protected _position: Vector3;
  76099. protected _setPosition(value: Vector3): void;
  76100. /**
  76101. * Sets the position the shadow will be casted from. Also use as the light position for both
  76102. * point and spot lights.
  76103. */
  76104. /**
  76105. * Sets the position the shadow will be casted from. Also use as the light position for both
  76106. * point and spot lights.
  76107. */
  76108. position: Vector3;
  76109. protected _direction: Vector3;
  76110. protected _setDirection(value: Vector3): void;
  76111. /**
  76112. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76113. * Also use as the light direction on spot and directional lights.
  76114. */
  76115. /**
  76116. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76117. * Also use as the light direction on spot and directional lights.
  76118. */
  76119. direction: Vector3;
  76120. private _shadowMinZ;
  76121. /**
  76122. * Gets the shadow projection clipping minimum z value.
  76123. */
  76124. /**
  76125. * Sets the shadow projection clipping minimum z value.
  76126. */
  76127. shadowMinZ: number;
  76128. private _shadowMaxZ;
  76129. /**
  76130. * Sets the shadow projection clipping maximum z value.
  76131. */
  76132. /**
  76133. * Gets the shadow projection clipping maximum z value.
  76134. */
  76135. shadowMaxZ: number;
  76136. /**
  76137. * Callback defining a custom Projection Matrix Builder.
  76138. * This can be used to override the default projection matrix computation.
  76139. */
  76140. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76141. /**
  76142. * The transformed position. Position of the light in world space taking parenting in account.
  76143. */
  76144. transformedPosition: Vector3;
  76145. /**
  76146. * The transformed direction. Direction of the light in world space taking parenting in account.
  76147. */
  76148. transformedDirection: Vector3;
  76149. private _needProjectionMatrixCompute;
  76150. /**
  76151. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76152. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76153. */
  76154. computeTransformedInformation(): boolean;
  76155. /**
  76156. * Return the depth scale used for the shadow map.
  76157. * @returns the depth scale.
  76158. */
  76159. getDepthScale(): number;
  76160. /**
  76161. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76162. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76163. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76164. */
  76165. getShadowDirection(faceIndex?: number): Vector3;
  76166. /**
  76167. * Returns the ShadowLight absolute position in the World.
  76168. * @returns the position vector in world space
  76169. */
  76170. getAbsolutePosition(): Vector3;
  76171. /**
  76172. * Sets the ShadowLight direction toward the passed target.
  76173. * @param target The point to target in local space
  76174. * @returns the updated ShadowLight direction
  76175. */
  76176. setDirectionToTarget(target: Vector3): Vector3;
  76177. /**
  76178. * Returns the light rotation in euler definition.
  76179. * @returns the x y z rotation in local space.
  76180. */
  76181. getRotation(): Vector3;
  76182. /**
  76183. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76184. * @returns true if a cube texture needs to be use
  76185. */
  76186. needCube(): boolean;
  76187. /**
  76188. * Detects if the projection matrix requires to be recomputed this frame.
  76189. * @returns true if it requires to be recomputed otherwise, false.
  76190. */
  76191. needProjectionMatrixCompute(): boolean;
  76192. /**
  76193. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76194. */
  76195. forceProjectionMatrixCompute(): void;
  76196. /** @hidden */
  76197. _initCache(): void;
  76198. /** @hidden */
  76199. _isSynchronized(): boolean;
  76200. /**
  76201. * Computes the world matrix of the node
  76202. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  76203. * @returns the world matrix
  76204. */
  76205. computeWorldMatrix(force?: boolean): Matrix;
  76206. /**
  76207. * Gets the minZ used for shadow according to both the scene and the light.
  76208. * @param activeCamera The camera we are returning the min for
  76209. * @returns the depth min z
  76210. */
  76211. getDepthMinZ(activeCamera: Camera): number;
  76212. /**
  76213. * Gets the maxZ used for shadow according to both the scene and the light.
  76214. * @param activeCamera The camera we are returning the max for
  76215. * @returns the depth max z
  76216. */
  76217. getDepthMaxZ(activeCamera: Camera): number;
  76218. /**
  76219. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76220. * @param matrix The materix to updated with the projection information
  76221. * @param viewMatrix The transform matrix of the light
  76222. * @param renderList The list of mesh to render in the map
  76223. * @returns The current light
  76224. */
  76225. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76226. }
  76227. }
  76228. declare module BABYLON {
  76229. /**
  76230. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76231. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76232. */
  76233. export class EffectFallbacks implements IEffectFallbacks {
  76234. private _defines;
  76235. private _currentRank;
  76236. private _maxRank;
  76237. private _mesh;
  76238. /**
  76239. * Removes the fallback from the bound mesh.
  76240. */
  76241. unBindMesh(): void;
  76242. /**
  76243. * Adds a fallback on the specified property.
  76244. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76245. * @param define The name of the define in the shader
  76246. */
  76247. addFallback(rank: number, define: string): void;
  76248. /**
  76249. * Sets the mesh to use CPU skinning when needing to fallback.
  76250. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76251. * @param mesh The mesh to use the fallbacks.
  76252. */
  76253. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76254. /**
  76255. * Checks to see if more fallbacks are still availible.
  76256. */
  76257. readonly hasMoreFallbacks: boolean;
  76258. /**
  76259. * Removes the defines that should be removed when falling back.
  76260. * @param currentDefines defines the current define statements for the shader.
  76261. * @param effect defines the current effect we try to compile
  76262. * @returns The resulting defines with defines of the current rank removed.
  76263. */
  76264. reduce(currentDefines: string, effect: Effect): string;
  76265. }
  76266. }
  76267. declare module BABYLON {
  76268. /**
  76269. * "Static Class" containing the most commonly used helper while dealing with material for
  76270. * rendering purpose.
  76271. *
  76272. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76273. *
  76274. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76275. */
  76276. export class MaterialHelper {
  76277. /**
  76278. * Bind the current view position to an effect.
  76279. * @param effect The effect to be bound
  76280. * @param scene The scene the eyes position is used from
  76281. */
  76282. static BindEyePosition(effect: Effect, scene: Scene): void;
  76283. /**
  76284. * Helps preparing the defines values about the UVs in used in the effect.
  76285. * UVs are shared as much as we can accross channels in the shaders.
  76286. * @param texture The texture we are preparing the UVs for
  76287. * @param defines The defines to update
  76288. * @param key The channel key "diffuse", "specular"... used in the shader
  76289. */
  76290. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76291. /**
  76292. * Binds a texture matrix value to its corrsponding uniform
  76293. * @param texture The texture to bind the matrix for
  76294. * @param uniformBuffer The uniform buffer receivin the data
  76295. * @param key The channel key "diffuse", "specular"... used in the shader
  76296. */
  76297. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76298. /**
  76299. * Gets the current status of the fog (should it be enabled?)
  76300. * @param mesh defines the mesh to evaluate for fog support
  76301. * @param scene defines the hosting scene
  76302. * @returns true if fog must be enabled
  76303. */
  76304. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76305. /**
  76306. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76307. * @param mesh defines the current mesh
  76308. * @param scene defines the current scene
  76309. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76310. * @param pointsCloud defines if point cloud rendering has to be turned on
  76311. * @param fogEnabled defines if fog has to be turned on
  76312. * @param alphaTest defines if alpha testing has to be turned on
  76313. * @param defines defines the current list of defines
  76314. */
  76315. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76316. /**
  76317. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76318. * @param scene defines the current scene
  76319. * @param engine defines the current engine
  76320. * @param defines specifies the list of active defines
  76321. * @param useInstances defines if instances have to be turned on
  76322. * @param useClipPlane defines if clip plane have to be turned on
  76323. */
  76324. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76325. /**
  76326. * Prepares the defines for bones
  76327. * @param mesh The mesh containing the geometry data we will draw
  76328. * @param defines The defines to update
  76329. */
  76330. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76331. /**
  76332. * Prepares the defines for morph targets
  76333. * @param mesh The mesh containing the geometry data we will draw
  76334. * @param defines The defines to update
  76335. */
  76336. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76337. /**
  76338. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76339. * @param mesh The mesh containing the geometry data we will draw
  76340. * @param defines The defines to update
  76341. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76342. * @param useBones Precise whether bones should be used or not (override mesh info)
  76343. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76344. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76345. * @returns false if defines are considered not dirty and have not been checked
  76346. */
  76347. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76348. /**
  76349. * Prepares the defines related to multiview
  76350. * @param scene The scene we are intending to draw
  76351. * @param defines The defines to update
  76352. */
  76353. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76354. /**
  76355. * Prepares the defines related to the light information passed in parameter
  76356. * @param scene The scene we are intending to draw
  76357. * @param mesh The mesh the effect is compiling for
  76358. * @param light The light the effect is compiling for
  76359. * @param lightIndex The index of the light
  76360. * @param defines The defines to update
  76361. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76362. * @param state Defines the current state regarding what is needed (normals, etc...)
  76363. */
  76364. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  76365. needNormals: boolean;
  76366. needRebuild: boolean;
  76367. shadowEnabled: boolean;
  76368. specularEnabled: boolean;
  76369. lightmapMode: boolean;
  76370. }): void;
  76371. /**
  76372. * Prepares the defines related to the light information passed in parameter
  76373. * @param scene The scene we are intending to draw
  76374. * @param mesh The mesh the effect is compiling for
  76375. * @param defines The defines to update
  76376. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76377. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76378. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76379. * @returns true if normals will be required for the rest of the effect
  76380. */
  76381. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  76382. /**
  76383. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  76384. * @param lightIndex defines the light index
  76385. * @param uniformsList The uniform list
  76386. * @param samplersList The sampler list
  76387. * @param projectedLightTexture defines if projected texture must be used
  76388. * @param uniformBuffersList defines an optional list of uniform buffers
  76389. */
  76390. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  76391. /**
  76392. * Prepares the uniforms and samplers list to be used in the effect
  76393. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  76394. * @param samplersList The sampler list
  76395. * @param defines The defines helping in the list generation
  76396. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  76397. */
  76398. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  76399. /**
  76400. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  76401. * @param defines The defines to update while falling back
  76402. * @param fallbacks The authorized effect fallbacks
  76403. * @param maxSimultaneousLights The maximum number of lights allowed
  76404. * @param rank the current rank of the Effect
  76405. * @returns The newly affected rank
  76406. */
  76407. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  76408. private static _TmpMorphInfluencers;
  76409. /**
  76410. * Prepares the list of attributes required for morph targets according to the effect defines.
  76411. * @param attribs The current list of supported attribs
  76412. * @param mesh The mesh to prepare the morph targets attributes for
  76413. * @param influencers The number of influencers
  76414. */
  76415. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  76416. /**
  76417. * Prepares the list of attributes required for morph targets according to the effect defines.
  76418. * @param attribs The current list of supported attribs
  76419. * @param mesh The mesh to prepare the morph targets attributes for
  76420. * @param defines The current Defines of the effect
  76421. */
  76422. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  76423. /**
  76424. * Prepares the list of attributes required for bones according to the effect defines.
  76425. * @param attribs The current list of supported attribs
  76426. * @param mesh The mesh to prepare the bones attributes for
  76427. * @param defines The current Defines of the effect
  76428. * @param fallbacks The current efffect fallback strategy
  76429. */
  76430. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  76431. /**
  76432. * Check and prepare the list of attributes required for instances according to the effect defines.
  76433. * @param attribs The current list of supported attribs
  76434. * @param defines The current MaterialDefines of the effect
  76435. */
  76436. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  76437. /**
  76438. * Add the list of attributes required for instances to the attribs array.
  76439. * @param attribs The current list of supported attribs
  76440. */
  76441. static PushAttributesForInstances(attribs: string[]): void;
  76442. /**
  76443. * Binds the light information to the effect.
  76444. * @param light The light containing the generator
  76445. * @param effect The effect we are binding the data to
  76446. * @param lightIndex The light index in the effect used to render
  76447. */
  76448. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  76449. /**
  76450. * Binds the lights information from the scene to the effect for the given mesh.
  76451. * @param light Light to bind
  76452. * @param lightIndex Light index
  76453. * @param scene The scene where the light belongs to
  76454. * @param effect The effect we are binding the data to
  76455. * @param useSpecular Defines if specular is supported
  76456. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76457. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76458. */
  76459. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76460. /**
  76461. * Binds the lights information from the scene to the effect for the given mesh.
  76462. * @param scene The scene the lights belongs to
  76463. * @param mesh The mesh we are binding the information to render
  76464. * @param effect The effect we are binding the data to
  76465. * @param defines The generated defines for the effect
  76466. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  76467. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76468. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76469. */
  76470. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76471. private static _tempFogColor;
  76472. /**
  76473. * Binds the fog information from the scene to the effect for the given mesh.
  76474. * @param scene The scene the lights belongs to
  76475. * @param mesh The mesh we are binding the information to render
  76476. * @param effect The effect we are binding the data to
  76477. * @param linearSpace Defines if the fog effect is applied in linear space
  76478. */
  76479. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  76480. /**
  76481. * Binds the bones information from the mesh to the effect.
  76482. * @param mesh The mesh we are binding the information to render
  76483. * @param effect The effect we are binding the data to
  76484. */
  76485. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  76486. /**
  76487. * Binds the morph targets information from the mesh to the effect.
  76488. * @param abstractMesh The mesh we are binding the information to render
  76489. * @param effect The effect we are binding the data to
  76490. */
  76491. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  76492. /**
  76493. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  76494. * @param defines The generated defines used in the effect
  76495. * @param effect The effect we are binding the data to
  76496. * @param scene The scene we are willing to render with logarithmic scale for
  76497. */
  76498. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  76499. /**
  76500. * Binds the clip plane information from the scene to the effect.
  76501. * @param scene The scene the clip plane information are extracted from
  76502. * @param effect The effect we are binding the data to
  76503. */
  76504. static BindClipPlane(effect: Effect, scene: Scene): void;
  76505. }
  76506. }
  76507. declare module BABYLON {
  76508. /** @hidden */
  76509. export var packingFunctions: {
  76510. name: string;
  76511. shader: string;
  76512. };
  76513. }
  76514. declare module BABYLON {
  76515. /** @hidden */
  76516. export var shadowMapPixelShader: {
  76517. name: string;
  76518. shader: string;
  76519. };
  76520. }
  76521. declare module BABYLON {
  76522. /** @hidden */
  76523. export var bonesDeclaration: {
  76524. name: string;
  76525. shader: string;
  76526. };
  76527. }
  76528. declare module BABYLON {
  76529. /** @hidden */
  76530. export var morphTargetsVertexGlobalDeclaration: {
  76531. name: string;
  76532. shader: string;
  76533. };
  76534. }
  76535. declare module BABYLON {
  76536. /** @hidden */
  76537. export var morphTargetsVertexDeclaration: {
  76538. name: string;
  76539. shader: string;
  76540. };
  76541. }
  76542. declare module BABYLON {
  76543. /** @hidden */
  76544. export var instancesDeclaration: {
  76545. name: string;
  76546. shader: string;
  76547. };
  76548. }
  76549. declare module BABYLON {
  76550. /** @hidden */
  76551. export var helperFunctions: {
  76552. name: string;
  76553. shader: string;
  76554. };
  76555. }
  76556. declare module BABYLON {
  76557. /** @hidden */
  76558. export var morphTargetsVertex: {
  76559. name: string;
  76560. shader: string;
  76561. };
  76562. }
  76563. declare module BABYLON {
  76564. /** @hidden */
  76565. export var instancesVertex: {
  76566. name: string;
  76567. shader: string;
  76568. };
  76569. }
  76570. declare module BABYLON {
  76571. /** @hidden */
  76572. export var bonesVertex: {
  76573. name: string;
  76574. shader: string;
  76575. };
  76576. }
  76577. declare module BABYLON {
  76578. /** @hidden */
  76579. export var shadowMapVertexShader: {
  76580. name: string;
  76581. shader: string;
  76582. };
  76583. }
  76584. declare module BABYLON {
  76585. /** @hidden */
  76586. export var depthBoxBlurPixelShader: {
  76587. name: string;
  76588. shader: string;
  76589. };
  76590. }
  76591. declare module BABYLON {
  76592. /**
  76593. * Defines the options associated with the creation of a custom shader for a shadow generator.
  76594. */
  76595. export interface ICustomShaderOptions {
  76596. /**
  76597. * Gets or sets the custom shader name to use
  76598. */
  76599. shaderName: string;
  76600. /**
  76601. * The list of attribute names used in the shader
  76602. */
  76603. attributes?: string[];
  76604. /**
  76605. * The list of unifrom names used in the shader
  76606. */
  76607. uniforms?: string[];
  76608. /**
  76609. * The list of sampler names used in the shader
  76610. */
  76611. samplers?: string[];
  76612. /**
  76613. * The list of defines used in the shader
  76614. */
  76615. defines?: string[];
  76616. }
  76617. /**
  76618. * Interface to implement to create a shadow generator compatible with BJS.
  76619. */
  76620. export interface IShadowGenerator {
  76621. /**
  76622. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76623. * @returns The render target texture if present otherwise, null
  76624. */
  76625. getShadowMap(): Nullable<RenderTargetTexture>;
  76626. /**
  76627. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76628. * @returns The render target texture if the shadow map is present otherwise, null
  76629. */
  76630. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76631. /**
  76632. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76633. * @param subMesh The submesh we want to render in the shadow map
  76634. * @param useInstances Defines wether will draw in the map using instances
  76635. * @returns true if ready otherwise, false
  76636. */
  76637. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76638. /**
  76639. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76640. * @param defines Defines of the material we want to update
  76641. * @param lightIndex Index of the light in the enabled light list of the material
  76642. */
  76643. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76644. /**
  76645. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76646. * defined in the generator but impacting the effect).
  76647. * It implies the unifroms available on the materials are the standard BJS ones.
  76648. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76649. * @param effect The effect we are binfing the information for
  76650. */
  76651. bindShadowLight(lightIndex: string, effect: Effect): void;
  76652. /**
  76653. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76654. * (eq to shadow prjection matrix * light transform matrix)
  76655. * @returns The transform matrix used to create the shadow map
  76656. */
  76657. getTransformMatrix(): Matrix;
  76658. /**
  76659. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76660. * Cube and 2D textures for instance.
  76661. */
  76662. recreateShadowMap(): void;
  76663. /**
  76664. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76665. * @param onCompiled Callback triggered at the and of the effects compilation
  76666. * @param options Sets of optional options forcing the compilation with different modes
  76667. */
  76668. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76669. useInstances: boolean;
  76670. }>): void;
  76671. /**
  76672. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76673. * @param options Sets of optional options forcing the compilation with different modes
  76674. * @returns A promise that resolves when the compilation completes
  76675. */
  76676. forceCompilationAsync(options?: Partial<{
  76677. useInstances: boolean;
  76678. }>): Promise<void>;
  76679. /**
  76680. * Serializes the shadow generator setup to a json object.
  76681. * @returns The serialized JSON object
  76682. */
  76683. serialize(): any;
  76684. /**
  76685. * Disposes the Shadow map and related Textures and effects.
  76686. */
  76687. dispose(): void;
  76688. }
  76689. /**
  76690. * Default implementation IShadowGenerator.
  76691. * This is the main object responsible of generating shadows in the framework.
  76692. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76693. */
  76694. export class ShadowGenerator implements IShadowGenerator {
  76695. /**
  76696. * Shadow generator mode None: no filtering applied.
  76697. */
  76698. static readonly FILTER_NONE: number;
  76699. /**
  76700. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76701. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76702. */
  76703. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76704. /**
  76705. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76706. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76707. */
  76708. static readonly FILTER_POISSONSAMPLING: number;
  76709. /**
  76710. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76711. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76712. */
  76713. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76714. /**
  76715. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76716. * edge artifacts on steep falloff.
  76717. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76718. */
  76719. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76720. /**
  76721. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76722. * edge artifacts on steep falloff.
  76723. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76724. */
  76725. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76726. /**
  76727. * Shadow generator mode PCF: Percentage Closer Filtering
  76728. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76729. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76730. */
  76731. static readonly FILTER_PCF: number;
  76732. /**
  76733. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76734. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76735. * Contact Hardening
  76736. */
  76737. static readonly FILTER_PCSS: number;
  76738. /**
  76739. * Reserved for PCF and PCSS
  76740. * Highest Quality.
  76741. *
  76742. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76743. *
  76744. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76745. */
  76746. static readonly QUALITY_HIGH: number;
  76747. /**
  76748. * Reserved for PCF and PCSS
  76749. * Good tradeoff for quality/perf cross devices
  76750. *
  76751. * Execute PCF on a 3*3 kernel.
  76752. *
  76753. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76754. */
  76755. static readonly QUALITY_MEDIUM: number;
  76756. /**
  76757. * Reserved for PCF and PCSS
  76758. * The lowest quality but the fastest.
  76759. *
  76760. * Execute PCF on a 1*1 kernel.
  76761. *
  76762. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76763. */
  76764. static readonly QUALITY_LOW: number;
  76765. /** Gets or sets the custom shader name to use */
  76766. customShaderOptions: ICustomShaderOptions;
  76767. /**
  76768. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76769. */
  76770. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76771. /**
  76772. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76773. */
  76774. onAfterShadowMapRenderObservable: Observable<Effect>;
  76775. /**
  76776. * Observable triggered before a mesh is rendered in the shadow map.
  76777. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76778. */
  76779. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76780. /**
  76781. * Observable triggered after a mesh is rendered in the shadow map.
  76782. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76783. */
  76784. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76785. private _bias;
  76786. /**
  76787. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76788. */
  76789. /**
  76790. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76791. */
  76792. bias: number;
  76793. private _normalBias;
  76794. /**
  76795. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76796. */
  76797. /**
  76798. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76799. */
  76800. normalBias: number;
  76801. private _blurBoxOffset;
  76802. /**
  76803. * Gets the blur box offset: offset applied during the blur pass.
  76804. * Only useful if useKernelBlur = false
  76805. */
  76806. /**
  76807. * Sets the blur box offset: offset applied during the blur pass.
  76808. * Only useful if useKernelBlur = false
  76809. */
  76810. blurBoxOffset: number;
  76811. private _blurScale;
  76812. /**
  76813. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76814. * 2 means half of the size.
  76815. */
  76816. /**
  76817. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76818. * 2 means half of the size.
  76819. */
  76820. blurScale: number;
  76821. private _blurKernel;
  76822. /**
  76823. * Gets the blur kernel: kernel size of the blur pass.
  76824. * Only useful if useKernelBlur = true
  76825. */
  76826. /**
  76827. * Sets the blur kernel: kernel size of the blur pass.
  76828. * Only useful if useKernelBlur = true
  76829. */
  76830. blurKernel: number;
  76831. private _useKernelBlur;
  76832. /**
  76833. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76834. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76835. */
  76836. /**
  76837. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76838. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76839. */
  76840. useKernelBlur: boolean;
  76841. private _depthScale;
  76842. /**
  76843. * Gets the depth scale used in ESM mode.
  76844. */
  76845. /**
  76846. * Sets the depth scale used in ESM mode.
  76847. * This can override the scale stored on the light.
  76848. */
  76849. depthScale: number;
  76850. private _filter;
  76851. /**
  76852. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76853. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76854. */
  76855. /**
  76856. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76857. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76858. */
  76859. filter: number;
  76860. /**
  76861. * Gets if the current filter is set to Poisson Sampling.
  76862. */
  76863. /**
  76864. * Sets the current filter to Poisson Sampling.
  76865. */
  76866. usePoissonSampling: boolean;
  76867. /**
  76868. * Gets if the current filter is set to ESM.
  76869. */
  76870. /**
  76871. * Sets the current filter is to ESM.
  76872. */
  76873. useExponentialShadowMap: boolean;
  76874. /**
  76875. * Gets if the current filter is set to filtered ESM.
  76876. */
  76877. /**
  76878. * Gets if the current filter is set to filtered ESM.
  76879. */
  76880. useBlurExponentialShadowMap: boolean;
  76881. /**
  76882. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76883. * exponential to prevent steep falloff artifacts).
  76884. */
  76885. /**
  76886. * Sets the current filter to "close ESM" (using the inverse of the
  76887. * exponential to prevent steep falloff artifacts).
  76888. */
  76889. useCloseExponentialShadowMap: boolean;
  76890. /**
  76891. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76892. * exponential to prevent steep falloff artifacts).
  76893. */
  76894. /**
  76895. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76896. * exponential to prevent steep falloff artifacts).
  76897. */
  76898. useBlurCloseExponentialShadowMap: boolean;
  76899. /**
  76900. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76901. */
  76902. /**
  76903. * Sets the current filter to "PCF" (percentage closer filtering).
  76904. */
  76905. usePercentageCloserFiltering: boolean;
  76906. private _filteringQuality;
  76907. /**
  76908. * Gets the PCF or PCSS Quality.
  76909. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76910. */
  76911. /**
  76912. * Sets the PCF or PCSS Quality.
  76913. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76914. */
  76915. filteringQuality: number;
  76916. /**
  76917. * Gets if the current filter is set to "PCSS" (contact hardening).
  76918. */
  76919. /**
  76920. * Sets the current filter to "PCSS" (contact hardening).
  76921. */
  76922. useContactHardeningShadow: boolean;
  76923. private _contactHardeningLightSizeUVRatio;
  76924. /**
  76925. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76926. * Using a ratio helps keeping shape stability independently of the map size.
  76927. *
  76928. * It does not account for the light projection as it was having too much
  76929. * instability during the light setup or during light position changes.
  76930. *
  76931. * Only valid if useContactHardeningShadow is true.
  76932. */
  76933. /**
  76934. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76935. * Using a ratio helps keeping shape stability independently of the map size.
  76936. *
  76937. * It does not account for the light projection as it was having too much
  76938. * instability during the light setup or during light position changes.
  76939. *
  76940. * Only valid if useContactHardeningShadow is true.
  76941. */
  76942. contactHardeningLightSizeUVRatio: number;
  76943. private _darkness;
  76944. /** Gets or sets the actual darkness of a shadow */
  76945. darkness: number;
  76946. /**
  76947. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76948. * 0 means strongest and 1 would means no shadow.
  76949. * @returns the darkness.
  76950. */
  76951. getDarkness(): number;
  76952. /**
  76953. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76954. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76955. * @returns the shadow generator allowing fluent coding.
  76956. */
  76957. setDarkness(darkness: number): ShadowGenerator;
  76958. private _transparencyShadow;
  76959. /** Gets or sets the ability to have transparent shadow */
  76960. transparencyShadow: boolean;
  76961. /**
  76962. * Sets the ability to have transparent shadow (boolean).
  76963. * @param transparent True if transparent else False
  76964. * @returns the shadow generator allowing fluent coding
  76965. */
  76966. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76967. private _shadowMap;
  76968. private _shadowMap2;
  76969. /**
  76970. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76971. * @returns The render target texture if present otherwise, null
  76972. */
  76973. getShadowMap(): Nullable<RenderTargetTexture>;
  76974. /**
  76975. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76976. * @returns The render target texture if the shadow map is present otherwise, null
  76977. */
  76978. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76979. /**
  76980. * Gets the class name of that object
  76981. * @returns "ShadowGenerator"
  76982. */
  76983. getClassName(): string;
  76984. /**
  76985. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76986. * @param mesh Mesh to add
  76987. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76988. * @returns the Shadow Generator itself
  76989. */
  76990. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76991. /**
  76992. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76993. * @param mesh Mesh to remove
  76994. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76995. * @returns the Shadow Generator itself
  76996. */
  76997. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76998. /**
  76999. * Controls the extent to which the shadows fade out at the edge of the frustum
  77000. * Used only by directionals and spots
  77001. */
  77002. frustumEdgeFalloff: number;
  77003. private _light;
  77004. /**
  77005. * Returns the associated light object.
  77006. * @returns the light generating the shadow
  77007. */
  77008. getLight(): IShadowLight;
  77009. /**
  77010. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77011. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77012. * It might on the other hand introduce peter panning.
  77013. */
  77014. forceBackFacesOnly: boolean;
  77015. private _scene;
  77016. private _lightDirection;
  77017. private _effect;
  77018. private _viewMatrix;
  77019. private _projectionMatrix;
  77020. private _transformMatrix;
  77021. private _cachedPosition;
  77022. private _cachedDirection;
  77023. private _cachedDefines;
  77024. private _currentRenderID;
  77025. private _boxBlurPostprocess;
  77026. private _kernelBlurXPostprocess;
  77027. private _kernelBlurYPostprocess;
  77028. private _blurPostProcesses;
  77029. private _mapSize;
  77030. private _currentFaceIndex;
  77031. private _currentFaceIndexCache;
  77032. private _textureType;
  77033. private _defaultTextureMatrix;
  77034. private _storedUniqueId;
  77035. /** @hidden */
  77036. static _SceneComponentInitialization: (scene: Scene) => void;
  77037. /**
  77038. * Creates a ShadowGenerator object.
  77039. * A ShadowGenerator is the required tool to use the shadows.
  77040. * Each light casting shadows needs to use its own ShadowGenerator.
  77041. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77042. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77043. * @param light The light object generating the shadows.
  77044. * @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.
  77045. */
  77046. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77047. private _initializeGenerator;
  77048. private _initializeShadowMap;
  77049. private _initializeBlurRTTAndPostProcesses;
  77050. private _renderForShadowMap;
  77051. private _renderSubMeshForShadowMap;
  77052. private _applyFilterValues;
  77053. /**
  77054. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77055. * @param onCompiled Callback triggered at the and of the effects compilation
  77056. * @param options Sets of optional options forcing the compilation with different modes
  77057. */
  77058. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77059. useInstances: boolean;
  77060. }>): void;
  77061. /**
  77062. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77063. * @param options Sets of optional options forcing the compilation with different modes
  77064. * @returns A promise that resolves when the compilation completes
  77065. */
  77066. forceCompilationAsync(options?: Partial<{
  77067. useInstances: boolean;
  77068. }>): Promise<void>;
  77069. /**
  77070. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77071. * @param subMesh The submesh we want to render in the shadow map
  77072. * @param useInstances Defines wether will draw in the map using instances
  77073. * @returns true if ready otherwise, false
  77074. */
  77075. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77076. /**
  77077. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77078. * @param defines Defines of the material we want to update
  77079. * @param lightIndex Index of the light in the enabled light list of the material
  77080. */
  77081. prepareDefines(defines: any, lightIndex: number): void;
  77082. /**
  77083. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77084. * defined in the generator but impacting the effect).
  77085. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77086. * @param effect The effect we are binfing the information for
  77087. */
  77088. bindShadowLight(lightIndex: string, effect: Effect): void;
  77089. /**
  77090. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77091. * (eq to shadow prjection matrix * light transform matrix)
  77092. * @returns The transform matrix used to create the shadow map
  77093. */
  77094. getTransformMatrix(): Matrix;
  77095. /**
  77096. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77097. * Cube and 2D textures for instance.
  77098. */
  77099. recreateShadowMap(): void;
  77100. private _disposeBlurPostProcesses;
  77101. private _disposeRTTandPostProcesses;
  77102. /**
  77103. * Disposes the ShadowGenerator.
  77104. * Returns nothing.
  77105. */
  77106. dispose(): void;
  77107. /**
  77108. * Serializes the shadow generator setup to a json object.
  77109. * @returns The serialized JSON object
  77110. */
  77111. serialize(): any;
  77112. /**
  77113. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77114. * @param parsedShadowGenerator The JSON object to parse
  77115. * @param scene The scene to create the shadow map for
  77116. * @returns The parsed shadow generator
  77117. */
  77118. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77119. }
  77120. }
  77121. declare module BABYLON {
  77122. /**
  77123. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77124. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77125. * 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.
  77126. */
  77127. export abstract class Light extends Node {
  77128. /**
  77129. * Falloff Default: light is falling off following the material specification:
  77130. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77131. */
  77132. static readonly FALLOFF_DEFAULT: number;
  77133. /**
  77134. * Falloff Physical: light is falling off following the inverse squared distance law.
  77135. */
  77136. static readonly FALLOFF_PHYSICAL: number;
  77137. /**
  77138. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77139. * to enhance interoperability with other engines.
  77140. */
  77141. static readonly FALLOFF_GLTF: number;
  77142. /**
  77143. * Falloff Standard: light is falling off like in the standard material
  77144. * to enhance interoperability with other materials.
  77145. */
  77146. static readonly FALLOFF_STANDARD: number;
  77147. /**
  77148. * If every light affecting the material is in this lightmapMode,
  77149. * material.lightmapTexture adds or multiplies
  77150. * (depends on material.useLightmapAsShadowmap)
  77151. * after every other light calculations.
  77152. */
  77153. static readonly LIGHTMAP_DEFAULT: number;
  77154. /**
  77155. * material.lightmapTexture as only diffuse lighting from this light
  77156. * adds only specular lighting from this light
  77157. * adds dynamic shadows
  77158. */
  77159. static readonly LIGHTMAP_SPECULAR: number;
  77160. /**
  77161. * material.lightmapTexture as only lighting
  77162. * no light calculation from this light
  77163. * only adds dynamic shadows from this light
  77164. */
  77165. static readonly LIGHTMAP_SHADOWSONLY: number;
  77166. /**
  77167. * Each light type uses the default quantity according to its type:
  77168. * point/spot lights use luminous intensity
  77169. * directional lights use illuminance
  77170. */
  77171. static readonly INTENSITYMODE_AUTOMATIC: number;
  77172. /**
  77173. * lumen (lm)
  77174. */
  77175. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  77176. /**
  77177. * candela (lm/sr)
  77178. */
  77179. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  77180. /**
  77181. * lux (lm/m^2)
  77182. */
  77183. static readonly INTENSITYMODE_ILLUMINANCE: number;
  77184. /**
  77185. * nit (cd/m^2)
  77186. */
  77187. static readonly INTENSITYMODE_LUMINANCE: number;
  77188. /**
  77189. * Light type const id of the point light.
  77190. */
  77191. static readonly LIGHTTYPEID_POINTLIGHT: number;
  77192. /**
  77193. * Light type const id of the directional light.
  77194. */
  77195. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77196. /**
  77197. * Light type const id of the spot light.
  77198. */
  77199. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77200. /**
  77201. * Light type const id of the hemispheric light.
  77202. */
  77203. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77204. /**
  77205. * Diffuse gives the basic color to an object.
  77206. */
  77207. diffuse: Color3;
  77208. /**
  77209. * Specular produces a highlight color on an object.
  77210. * Note: This is note affecting PBR materials.
  77211. */
  77212. specular: Color3;
  77213. /**
  77214. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77215. * falling off base on range or angle.
  77216. * This can be set to any values in Light.FALLOFF_x.
  77217. *
  77218. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77219. * other types of materials.
  77220. */
  77221. falloffType: number;
  77222. /**
  77223. * Strength of the light.
  77224. * Note: By default it is define in the framework own unit.
  77225. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77226. */
  77227. intensity: number;
  77228. private _range;
  77229. protected _inverseSquaredRange: number;
  77230. /**
  77231. * Defines how far from the source the light is impacting in scene units.
  77232. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77233. */
  77234. /**
  77235. * Defines how far from the source the light is impacting in scene units.
  77236. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77237. */
  77238. range: number;
  77239. /**
  77240. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77241. * of light.
  77242. */
  77243. private _photometricScale;
  77244. private _intensityMode;
  77245. /**
  77246. * Gets the photometric scale used to interpret the intensity.
  77247. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77248. */
  77249. /**
  77250. * Sets the photometric scale used to interpret the intensity.
  77251. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77252. */
  77253. intensityMode: number;
  77254. private _radius;
  77255. /**
  77256. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77257. */
  77258. /**
  77259. * sets the light radius used by PBR Materials to simulate soft area lights.
  77260. */
  77261. radius: number;
  77262. private _renderPriority;
  77263. /**
  77264. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77265. * exceeding the number allowed of the materials.
  77266. */
  77267. renderPriority: number;
  77268. private _shadowEnabled;
  77269. /**
  77270. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77271. * the current shadow generator.
  77272. */
  77273. /**
  77274. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77275. * the current shadow generator.
  77276. */
  77277. shadowEnabled: boolean;
  77278. private _includedOnlyMeshes;
  77279. /**
  77280. * Gets the only meshes impacted by this light.
  77281. */
  77282. /**
  77283. * Sets the only meshes impacted by this light.
  77284. */
  77285. includedOnlyMeshes: AbstractMesh[];
  77286. private _excludedMeshes;
  77287. /**
  77288. * Gets the meshes not impacted by this light.
  77289. */
  77290. /**
  77291. * Sets the meshes not impacted by this light.
  77292. */
  77293. excludedMeshes: AbstractMesh[];
  77294. private _excludeWithLayerMask;
  77295. /**
  77296. * Gets the layer id use to find what meshes are not impacted by the light.
  77297. * Inactive if 0
  77298. */
  77299. /**
  77300. * Sets the layer id use to find what meshes are not impacted by the light.
  77301. * Inactive if 0
  77302. */
  77303. excludeWithLayerMask: number;
  77304. private _includeOnlyWithLayerMask;
  77305. /**
  77306. * Gets the layer id use to find what meshes are impacted by the light.
  77307. * Inactive if 0
  77308. */
  77309. /**
  77310. * Sets the layer id use to find what meshes are impacted by the light.
  77311. * Inactive if 0
  77312. */
  77313. includeOnlyWithLayerMask: number;
  77314. private _lightmapMode;
  77315. /**
  77316. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77317. */
  77318. /**
  77319. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77320. */
  77321. lightmapMode: number;
  77322. /**
  77323. * Shadow generator associted to the light.
  77324. * @hidden Internal use only.
  77325. */
  77326. _shadowGenerator: Nullable<IShadowGenerator>;
  77327. /**
  77328. * @hidden Internal use only.
  77329. */
  77330. _excludedMeshesIds: string[];
  77331. /**
  77332. * @hidden Internal use only.
  77333. */
  77334. _includedOnlyMeshesIds: string[];
  77335. /**
  77336. * The current light unifom buffer.
  77337. * @hidden Internal use only.
  77338. */
  77339. _uniformBuffer: UniformBuffer;
  77340. /** @hidden */
  77341. _renderId: number;
  77342. /**
  77343. * Creates a Light object in the scene.
  77344. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77345. * @param name The firendly name of the light
  77346. * @param scene The scene the light belongs too
  77347. */
  77348. constructor(name: string, scene: Scene);
  77349. protected abstract _buildUniformLayout(): void;
  77350. /**
  77351. * Sets the passed Effect "effect" with the Light information.
  77352. * @param effect The effect to update
  77353. * @param lightIndex The index of the light in the effect to update
  77354. * @returns The light
  77355. */
  77356. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77357. /**
  77358. * Sets the passed Effect "effect" with the Light information.
  77359. * @param effect The effect to update
  77360. * @param lightDataUniformName The uniform used to store light data (position or direction)
  77361. * @returns The light
  77362. */
  77363. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  77364. /**
  77365. * Returns the string "Light".
  77366. * @returns the class name
  77367. */
  77368. getClassName(): string;
  77369. /** @hidden */
  77370. readonly _isLight: boolean;
  77371. /**
  77372. * Converts the light information to a readable string for debug purpose.
  77373. * @param fullDetails Supports for multiple levels of logging within scene loading
  77374. * @returns the human readable light info
  77375. */
  77376. toString(fullDetails?: boolean): string;
  77377. /** @hidden */
  77378. protected _syncParentEnabledState(): void;
  77379. /**
  77380. * Set the enabled state of this node.
  77381. * @param value - the new enabled state
  77382. */
  77383. setEnabled(value: boolean): void;
  77384. /**
  77385. * Returns the Light associated shadow generator if any.
  77386. * @return the associated shadow generator.
  77387. */
  77388. getShadowGenerator(): Nullable<IShadowGenerator>;
  77389. /**
  77390. * Returns a Vector3, the absolute light position in the World.
  77391. * @returns the world space position of the light
  77392. */
  77393. getAbsolutePosition(): Vector3;
  77394. /**
  77395. * Specifies if the light will affect the passed mesh.
  77396. * @param mesh The mesh to test against the light
  77397. * @return true the mesh is affected otherwise, false.
  77398. */
  77399. canAffectMesh(mesh: AbstractMesh): boolean;
  77400. /**
  77401. * Sort function to order lights for rendering.
  77402. * @param a First Light object to compare to second.
  77403. * @param b Second Light object to compare first.
  77404. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  77405. */
  77406. static CompareLightsPriority(a: Light, b: Light): number;
  77407. /**
  77408. * Releases resources associated with this node.
  77409. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77410. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77411. */
  77412. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77413. /**
  77414. * Returns the light type ID (integer).
  77415. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  77416. */
  77417. getTypeID(): number;
  77418. /**
  77419. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  77420. * @returns the scaled intensity in intensity mode unit
  77421. */
  77422. getScaledIntensity(): number;
  77423. /**
  77424. * Returns a new Light object, named "name", from the current one.
  77425. * @param name The name of the cloned light
  77426. * @returns the new created light
  77427. */
  77428. clone(name: string): Nullable<Light>;
  77429. /**
  77430. * Serializes the current light into a Serialization object.
  77431. * @returns the serialized object.
  77432. */
  77433. serialize(): any;
  77434. /**
  77435. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  77436. * This new light is named "name" and added to the passed scene.
  77437. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  77438. * @param name The friendly name of the light
  77439. * @param scene The scene the new light will belong to
  77440. * @returns the constructor function
  77441. */
  77442. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  77443. /**
  77444. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  77445. * @param parsedLight The JSON representation of the light
  77446. * @param scene The scene to create the parsed light in
  77447. * @returns the created light after parsing
  77448. */
  77449. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  77450. private _hookArrayForExcluded;
  77451. private _hookArrayForIncludedOnly;
  77452. private _resyncMeshes;
  77453. /**
  77454. * Forces the meshes to update their light related information in their rendering used effects
  77455. * @hidden Internal Use Only
  77456. */
  77457. _markMeshesAsLightDirty(): void;
  77458. /**
  77459. * Recomputes the cached photometric scale if needed.
  77460. */
  77461. private _computePhotometricScale;
  77462. /**
  77463. * Returns the Photometric Scale according to the light type and intensity mode.
  77464. */
  77465. private _getPhotometricScale;
  77466. /**
  77467. * Reorder the light in the scene according to their defined priority.
  77468. * @hidden Internal Use Only
  77469. */
  77470. _reorderLightsInScene(): void;
  77471. /**
  77472. * Prepares the list of defines specific to the light type.
  77473. * @param defines the list of defines
  77474. * @param lightIndex defines the index of the light for the effect
  77475. */
  77476. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  77477. }
  77478. }
  77479. declare module BABYLON {
  77480. /**
  77481. * Interface used to define Action
  77482. */
  77483. export interface IAction {
  77484. /**
  77485. * Trigger for the action
  77486. */
  77487. trigger: number;
  77488. /** Options of the trigger */
  77489. triggerOptions: any;
  77490. /**
  77491. * Gets the trigger parameters
  77492. * @returns the trigger parameters
  77493. */
  77494. getTriggerParameter(): any;
  77495. /**
  77496. * Internal only - executes current action event
  77497. * @hidden
  77498. */
  77499. _executeCurrent(evt?: ActionEvent): void;
  77500. /**
  77501. * Serialize placeholder for child classes
  77502. * @param parent of child
  77503. * @returns the serialized object
  77504. */
  77505. serialize(parent: any): any;
  77506. /**
  77507. * Internal only
  77508. * @hidden
  77509. */
  77510. _prepare(): void;
  77511. /**
  77512. * Internal only - manager for action
  77513. * @hidden
  77514. */
  77515. _actionManager: AbstractActionManager;
  77516. /**
  77517. * Adds action to chain of actions, may be a DoNothingAction
  77518. * @param action defines the next action to execute
  77519. * @returns The action passed in
  77520. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77521. */
  77522. then(action: IAction): IAction;
  77523. }
  77524. /**
  77525. * The action to be carried out following a trigger
  77526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77527. */
  77528. export class Action implements IAction {
  77529. /** the trigger, with or without parameters, for the action */
  77530. triggerOptions: any;
  77531. /**
  77532. * Trigger for the action
  77533. */
  77534. trigger: number;
  77535. /**
  77536. * Internal only - manager for action
  77537. * @hidden
  77538. */
  77539. _actionManager: ActionManager;
  77540. private _nextActiveAction;
  77541. private _child;
  77542. private _condition?;
  77543. private _triggerParameter;
  77544. /**
  77545. * An event triggered prior to action being executed.
  77546. */
  77547. onBeforeExecuteObservable: Observable<Action>;
  77548. /**
  77549. * Creates a new Action
  77550. * @param triggerOptions the trigger, with or without parameters, for the action
  77551. * @param condition an optional determinant of action
  77552. */
  77553. constructor(
  77554. /** the trigger, with or without parameters, for the action */
  77555. triggerOptions: any, condition?: Condition);
  77556. /**
  77557. * Internal only
  77558. * @hidden
  77559. */
  77560. _prepare(): void;
  77561. /**
  77562. * Gets the trigger parameters
  77563. * @returns the trigger parameters
  77564. */
  77565. getTriggerParameter(): any;
  77566. /**
  77567. * Internal only - executes current action event
  77568. * @hidden
  77569. */
  77570. _executeCurrent(evt?: ActionEvent): void;
  77571. /**
  77572. * Execute placeholder for child classes
  77573. * @param evt optional action event
  77574. */
  77575. execute(evt?: ActionEvent): void;
  77576. /**
  77577. * Skips to next active action
  77578. */
  77579. skipToNextActiveAction(): void;
  77580. /**
  77581. * Adds action to chain of actions, may be a DoNothingAction
  77582. * @param action defines the next action to execute
  77583. * @returns The action passed in
  77584. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77585. */
  77586. then(action: Action): Action;
  77587. /**
  77588. * Internal only
  77589. * @hidden
  77590. */
  77591. _getProperty(propertyPath: string): string;
  77592. /**
  77593. * Internal only
  77594. * @hidden
  77595. */
  77596. _getEffectiveTarget(target: any, propertyPath: string): any;
  77597. /**
  77598. * Serialize placeholder for child classes
  77599. * @param parent of child
  77600. * @returns the serialized object
  77601. */
  77602. serialize(parent: any): any;
  77603. /**
  77604. * Internal only called by serialize
  77605. * @hidden
  77606. */
  77607. protected _serialize(serializedAction: any, parent?: any): any;
  77608. /**
  77609. * Internal only
  77610. * @hidden
  77611. */
  77612. static _SerializeValueAsString: (value: any) => string;
  77613. /**
  77614. * Internal only
  77615. * @hidden
  77616. */
  77617. static _GetTargetProperty: (target: Node | Scene) => {
  77618. name: string;
  77619. targetType: string;
  77620. value: string;
  77621. };
  77622. }
  77623. }
  77624. declare module BABYLON {
  77625. /**
  77626. * A Condition applied to an Action
  77627. */
  77628. export class Condition {
  77629. /**
  77630. * Internal only - manager for action
  77631. * @hidden
  77632. */
  77633. _actionManager: ActionManager;
  77634. /**
  77635. * Internal only
  77636. * @hidden
  77637. */
  77638. _evaluationId: number;
  77639. /**
  77640. * Internal only
  77641. * @hidden
  77642. */
  77643. _currentResult: boolean;
  77644. /**
  77645. * Creates a new Condition
  77646. * @param actionManager the manager of the action the condition is applied to
  77647. */
  77648. constructor(actionManager: ActionManager);
  77649. /**
  77650. * Check if the current condition is valid
  77651. * @returns a boolean
  77652. */
  77653. isValid(): boolean;
  77654. /**
  77655. * Internal only
  77656. * @hidden
  77657. */
  77658. _getProperty(propertyPath: string): string;
  77659. /**
  77660. * Internal only
  77661. * @hidden
  77662. */
  77663. _getEffectiveTarget(target: any, propertyPath: string): any;
  77664. /**
  77665. * Serialize placeholder for child classes
  77666. * @returns the serialized object
  77667. */
  77668. serialize(): any;
  77669. /**
  77670. * Internal only
  77671. * @hidden
  77672. */
  77673. protected _serialize(serializedCondition: any): any;
  77674. }
  77675. /**
  77676. * Defines specific conditional operators as extensions of Condition
  77677. */
  77678. export class ValueCondition extends Condition {
  77679. /** path to specify the property of the target the conditional operator uses */
  77680. propertyPath: string;
  77681. /** the value compared by the conditional operator against the current value of the property */
  77682. value: any;
  77683. /** the conditional operator, default ValueCondition.IsEqual */
  77684. operator: number;
  77685. /**
  77686. * Internal only
  77687. * @hidden
  77688. */
  77689. private static _IsEqual;
  77690. /**
  77691. * Internal only
  77692. * @hidden
  77693. */
  77694. private static _IsDifferent;
  77695. /**
  77696. * Internal only
  77697. * @hidden
  77698. */
  77699. private static _IsGreater;
  77700. /**
  77701. * Internal only
  77702. * @hidden
  77703. */
  77704. private static _IsLesser;
  77705. /**
  77706. * returns the number for IsEqual
  77707. */
  77708. static readonly IsEqual: number;
  77709. /**
  77710. * Returns the number for IsDifferent
  77711. */
  77712. static readonly IsDifferent: number;
  77713. /**
  77714. * Returns the number for IsGreater
  77715. */
  77716. static readonly IsGreater: number;
  77717. /**
  77718. * Returns the number for IsLesser
  77719. */
  77720. static readonly IsLesser: number;
  77721. /**
  77722. * Internal only The action manager for the condition
  77723. * @hidden
  77724. */
  77725. _actionManager: ActionManager;
  77726. /**
  77727. * Internal only
  77728. * @hidden
  77729. */
  77730. private _target;
  77731. /**
  77732. * Internal only
  77733. * @hidden
  77734. */
  77735. private _effectiveTarget;
  77736. /**
  77737. * Internal only
  77738. * @hidden
  77739. */
  77740. private _property;
  77741. /**
  77742. * Creates a new ValueCondition
  77743. * @param actionManager manager for the action the condition applies to
  77744. * @param target for the action
  77745. * @param propertyPath path to specify the property of the target the conditional operator uses
  77746. * @param value the value compared by the conditional operator against the current value of the property
  77747. * @param operator the conditional operator, default ValueCondition.IsEqual
  77748. */
  77749. constructor(actionManager: ActionManager, target: any,
  77750. /** path to specify the property of the target the conditional operator uses */
  77751. propertyPath: string,
  77752. /** the value compared by the conditional operator against the current value of the property */
  77753. value: any,
  77754. /** the conditional operator, default ValueCondition.IsEqual */
  77755. operator?: number);
  77756. /**
  77757. * Compares the given value with the property value for the specified conditional operator
  77758. * @returns the result of the comparison
  77759. */
  77760. isValid(): boolean;
  77761. /**
  77762. * Serialize the ValueCondition into a JSON compatible object
  77763. * @returns serialization object
  77764. */
  77765. serialize(): any;
  77766. /**
  77767. * Gets the name of the conditional operator for the ValueCondition
  77768. * @param operator the conditional operator
  77769. * @returns the name
  77770. */
  77771. static GetOperatorName(operator: number): string;
  77772. }
  77773. /**
  77774. * Defines a predicate condition as an extension of Condition
  77775. */
  77776. export class PredicateCondition extends Condition {
  77777. /** defines the predicate function used to validate the condition */
  77778. predicate: () => boolean;
  77779. /**
  77780. * Internal only - manager for action
  77781. * @hidden
  77782. */
  77783. _actionManager: ActionManager;
  77784. /**
  77785. * Creates a new PredicateCondition
  77786. * @param actionManager manager for the action the condition applies to
  77787. * @param predicate defines the predicate function used to validate the condition
  77788. */
  77789. constructor(actionManager: ActionManager,
  77790. /** defines the predicate function used to validate the condition */
  77791. predicate: () => boolean);
  77792. /**
  77793. * @returns the validity of the predicate condition
  77794. */
  77795. isValid(): boolean;
  77796. }
  77797. /**
  77798. * Defines a state condition as an extension of Condition
  77799. */
  77800. export class StateCondition extends Condition {
  77801. /** Value to compare with target state */
  77802. value: string;
  77803. /**
  77804. * Internal only - manager for action
  77805. * @hidden
  77806. */
  77807. _actionManager: ActionManager;
  77808. /**
  77809. * Internal only
  77810. * @hidden
  77811. */
  77812. private _target;
  77813. /**
  77814. * Creates a new StateCondition
  77815. * @param actionManager manager for the action the condition applies to
  77816. * @param target of the condition
  77817. * @param value to compare with target state
  77818. */
  77819. constructor(actionManager: ActionManager, target: any,
  77820. /** Value to compare with target state */
  77821. value: string);
  77822. /**
  77823. * Gets a boolean indicating if the current condition is met
  77824. * @returns the validity of the state
  77825. */
  77826. isValid(): boolean;
  77827. /**
  77828. * Serialize the StateCondition into a JSON compatible object
  77829. * @returns serialization object
  77830. */
  77831. serialize(): any;
  77832. }
  77833. }
  77834. declare module BABYLON {
  77835. /**
  77836. * This defines an action responsible to toggle a boolean once triggered.
  77837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77838. */
  77839. export class SwitchBooleanAction extends Action {
  77840. /**
  77841. * The path to the boolean property in the target object
  77842. */
  77843. propertyPath: string;
  77844. private _target;
  77845. private _effectiveTarget;
  77846. private _property;
  77847. /**
  77848. * Instantiate the action
  77849. * @param triggerOptions defines the trigger options
  77850. * @param target defines the object containing the boolean
  77851. * @param propertyPath defines the path to the boolean property in the target object
  77852. * @param condition defines the trigger related conditions
  77853. */
  77854. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77855. /** @hidden */
  77856. _prepare(): void;
  77857. /**
  77858. * Execute the action toggle the boolean value.
  77859. */
  77860. execute(): void;
  77861. /**
  77862. * Serializes the actions and its related information.
  77863. * @param parent defines the object to serialize in
  77864. * @returns the serialized object
  77865. */
  77866. serialize(parent: any): any;
  77867. }
  77868. /**
  77869. * This defines an action responsible to set a the state field of the target
  77870. * to a desired value once triggered.
  77871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77872. */
  77873. export class SetStateAction extends Action {
  77874. /**
  77875. * The value to store in the state field.
  77876. */
  77877. value: string;
  77878. private _target;
  77879. /**
  77880. * Instantiate the action
  77881. * @param triggerOptions defines the trigger options
  77882. * @param target defines the object containing the state property
  77883. * @param value defines the value to store in the state field
  77884. * @param condition defines the trigger related conditions
  77885. */
  77886. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77887. /**
  77888. * Execute the action and store the value on the target state property.
  77889. */
  77890. execute(): void;
  77891. /**
  77892. * Serializes the actions and its related information.
  77893. * @param parent defines the object to serialize in
  77894. * @returns the serialized object
  77895. */
  77896. serialize(parent: any): any;
  77897. }
  77898. /**
  77899. * This defines an action responsible to set a property of the target
  77900. * to a desired value once triggered.
  77901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77902. */
  77903. export class SetValueAction extends Action {
  77904. /**
  77905. * The path of the property to set in the target.
  77906. */
  77907. propertyPath: string;
  77908. /**
  77909. * The value to set in the property
  77910. */
  77911. value: any;
  77912. private _target;
  77913. private _effectiveTarget;
  77914. private _property;
  77915. /**
  77916. * Instantiate the action
  77917. * @param triggerOptions defines the trigger options
  77918. * @param target defines the object containing the property
  77919. * @param propertyPath defines the path of the property to set in the target
  77920. * @param value defines the value to set in the property
  77921. * @param condition defines the trigger related conditions
  77922. */
  77923. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77924. /** @hidden */
  77925. _prepare(): void;
  77926. /**
  77927. * Execute the action and set the targetted property to the desired value.
  77928. */
  77929. execute(): void;
  77930. /**
  77931. * Serializes the actions and its related information.
  77932. * @param parent defines the object to serialize in
  77933. * @returns the serialized object
  77934. */
  77935. serialize(parent: any): any;
  77936. }
  77937. /**
  77938. * This defines an action responsible to increment the target value
  77939. * to a desired value once triggered.
  77940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77941. */
  77942. export class IncrementValueAction extends Action {
  77943. /**
  77944. * The path of the property to increment in the target.
  77945. */
  77946. propertyPath: string;
  77947. /**
  77948. * The value we should increment the property by.
  77949. */
  77950. value: any;
  77951. private _target;
  77952. private _effectiveTarget;
  77953. private _property;
  77954. /**
  77955. * Instantiate the action
  77956. * @param triggerOptions defines the trigger options
  77957. * @param target defines the object containing the property
  77958. * @param propertyPath defines the path of the property to increment in the target
  77959. * @param value defines the value value we should increment the property by
  77960. * @param condition defines the trigger related conditions
  77961. */
  77962. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77963. /** @hidden */
  77964. _prepare(): void;
  77965. /**
  77966. * Execute the action and increment the target of the value amount.
  77967. */
  77968. execute(): void;
  77969. /**
  77970. * Serializes the actions and its related information.
  77971. * @param parent defines the object to serialize in
  77972. * @returns the serialized object
  77973. */
  77974. serialize(parent: any): any;
  77975. }
  77976. /**
  77977. * This defines an action responsible to start an animation once triggered.
  77978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77979. */
  77980. export class PlayAnimationAction extends Action {
  77981. /**
  77982. * Where the animation should start (animation frame)
  77983. */
  77984. from: number;
  77985. /**
  77986. * Where the animation should stop (animation frame)
  77987. */
  77988. to: number;
  77989. /**
  77990. * Define if the animation should loop or stop after the first play.
  77991. */
  77992. loop?: boolean;
  77993. private _target;
  77994. /**
  77995. * Instantiate the action
  77996. * @param triggerOptions defines the trigger options
  77997. * @param target defines the target animation or animation name
  77998. * @param from defines from where the animation should start (animation frame)
  77999. * @param end defines where the animation should stop (animation frame)
  78000. * @param loop defines if the animation should loop or stop after the first play
  78001. * @param condition defines the trigger related conditions
  78002. */
  78003. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78004. /** @hidden */
  78005. _prepare(): void;
  78006. /**
  78007. * Execute the action and play the animation.
  78008. */
  78009. execute(): void;
  78010. /**
  78011. * Serializes the actions and its related information.
  78012. * @param parent defines the object to serialize in
  78013. * @returns the serialized object
  78014. */
  78015. serialize(parent: any): any;
  78016. }
  78017. /**
  78018. * This defines an action responsible to stop an animation once triggered.
  78019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78020. */
  78021. export class StopAnimationAction extends Action {
  78022. private _target;
  78023. /**
  78024. * Instantiate the action
  78025. * @param triggerOptions defines the trigger options
  78026. * @param target defines the target animation or animation name
  78027. * @param condition defines the trigger related conditions
  78028. */
  78029. constructor(triggerOptions: any, target: any, condition?: Condition);
  78030. /** @hidden */
  78031. _prepare(): void;
  78032. /**
  78033. * Execute the action and stop the animation.
  78034. */
  78035. execute(): void;
  78036. /**
  78037. * Serializes the actions and its related information.
  78038. * @param parent defines the object to serialize in
  78039. * @returns the serialized object
  78040. */
  78041. serialize(parent: any): any;
  78042. }
  78043. /**
  78044. * This defines an action responsible that does nothing once triggered.
  78045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78046. */
  78047. export class DoNothingAction extends Action {
  78048. /**
  78049. * Instantiate the action
  78050. * @param triggerOptions defines the trigger options
  78051. * @param condition defines the trigger related conditions
  78052. */
  78053. constructor(triggerOptions?: any, condition?: Condition);
  78054. /**
  78055. * Execute the action and do nothing.
  78056. */
  78057. execute(): void;
  78058. /**
  78059. * Serializes the actions and its related information.
  78060. * @param parent defines the object to serialize in
  78061. * @returns the serialized object
  78062. */
  78063. serialize(parent: any): any;
  78064. }
  78065. /**
  78066. * This defines an action responsible to trigger several actions once triggered.
  78067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78068. */
  78069. export class CombineAction extends Action {
  78070. /**
  78071. * The list of aggregated animations to run.
  78072. */
  78073. children: Action[];
  78074. /**
  78075. * Instantiate the action
  78076. * @param triggerOptions defines the trigger options
  78077. * @param children defines the list of aggregated animations to run
  78078. * @param condition defines the trigger related conditions
  78079. */
  78080. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78081. /** @hidden */
  78082. _prepare(): void;
  78083. /**
  78084. * Execute the action and executes all the aggregated actions.
  78085. */
  78086. execute(evt: ActionEvent): void;
  78087. /**
  78088. * Serializes the actions and its related information.
  78089. * @param parent defines the object to serialize in
  78090. * @returns the serialized object
  78091. */
  78092. serialize(parent: any): any;
  78093. }
  78094. /**
  78095. * This defines an action responsible to run code (external event) once triggered.
  78096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78097. */
  78098. export class ExecuteCodeAction extends Action {
  78099. /**
  78100. * The callback function to run.
  78101. */
  78102. func: (evt: ActionEvent) => void;
  78103. /**
  78104. * Instantiate the action
  78105. * @param triggerOptions defines the trigger options
  78106. * @param func defines the callback function to run
  78107. * @param condition defines the trigger related conditions
  78108. */
  78109. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78110. /**
  78111. * Execute the action and run the attached code.
  78112. */
  78113. execute(evt: ActionEvent): void;
  78114. }
  78115. /**
  78116. * This defines an action responsible to set the parent property of the target once triggered.
  78117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78118. */
  78119. export class SetParentAction extends Action {
  78120. private _parent;
  78121. private _target;
  78122. /**
  78123. * Instantiate the action
  78124. * @param triggerOptions defines the trigger options
  78125. * @param target defines the target containing the parent property
  78126. * @param parent defines from where the animation should start (animation frame)
  78127. * @param condition defines the trigger related conditions
  78128. */
  78129. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78130. /** @hidden */
  78131. _prepare(): void;
  78132. /**
  78133. * Execute the action and set the parent property.
  78134. */
  78135. execute(): void;
  78136. /**
  78137. * Serializes the actions and its related information.
  78138. * @param parent defines the object to serialize in
  78139. * @returns the serialized object
  78140. */
  78141. serialize(parent: any): any;
  78142. }
  78143. }
  78144. declare module BABYLON {
  78145. /**
  78146. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78147. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78149. */
  78150. export class ActionManager extends AbstractActionManager {
  78151. /**
  78152. * Nothing
  78153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78154. */
  78155. static readonly NothingTrigger: number;
  78156. /**
  78157. * On pick
  78158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78159. */
  78160. static readonly OnPickTrigger: number;
  78161. /**
  78162. * On left pick
  78163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78164. */
  78165. static readonly OnLeftPickTrigger: number;
  78166. /**
  78167. * On right pick
  78168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78169. */
  78170. static readonly OnRightPickTrigger: number;
  78171. /**
  78172. * On center pick
  78173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78174. */
  78175. static readonly OnCenterPickTrigger: number;
  78176. /**
  78177. * On pick down
  78178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78179. */
  78180. static readonly OnPickDownTrigger: number;
  78181. /**
  78182. * On double pick
  78183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78184. */
  78185. static readonly OnDoublePickTrigger: number;
  78186. /**
  78187. * On pick up
  78188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78189. */
  78190. static readonly OnPickUpTrigger: number;
  78191. /**
  78192. * On pick out.
  78193. * This trigger will only be raised if you also declared a OnPickDown
  78194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78195. */
  78196. static readonly OnPickOutTrigger: number;
  78197. /**
  78198. * On long press
  78199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78200. */
  78201. static readonly OnLongPressTrigger: number;
  78202. /**
  78203. * On pointer over
  78204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78205. */
  78206. static readonly OnPointerOverTrigger: number;
  78207. /**
  78208. * On pointer out
  78209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78210. */
  78211. static readonly OnPointerOutTrigger: number;
  78212. /**
  78213. * On every frame
  78214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78215. */
  78216. static readonly OnEveryFrameTrigger: number;
  78217. /**
  78218. * On intersection enter
  78219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78220. */
  78221. static readonly OnIntersectionEnterTrigger: number;
  78222. /**
  78223. * On intersection exit
  78224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78225. */
  78226. static readonly OnIntersectionExitTrigger: number;
  78227. /**
  78228. * On key down
  78229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78230. */
  78231. static readonly OnKeyDownTrigger: number;
  78232. /**
  78233. * On key up
  78234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78235. */
  78236. static readonly OnKeyUpTrigger: number;
  78237. private _scene;
  78238. /**
  78239. * Creates a new action manager
  78240. * @param scene defines the hosting scene
  78241. */
  78242. constructor(scene: Scene);
  78243. /**
  78244. * Releases all associated resources
  78245. */
  78246. dispose(): void;
  78247. /**
  78248. * Gets hosting scene
  78249. * @returns the hosting scene
  78250. */
  78251. getScene(): Scene;
  78252. /**
  78253. * Does this action manager handles actions of any of the given triggers
  78254. * @param triggers defines the triggers to be tested
  78255. * @return a boolean indicating whether one (or more) of the triggers is handled
  78256. */
  78257. hasSpecificTriggers(triggers: number[]): boolean;
  78258. /**
  78259. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78260. * speed.
  78261. * @param triggerA defines the trigger to be tested
  78262. * @param triggerB defines the trigger to be tested
  78263. * @return a boolean indicating whether one (or more) of the triggers is handled
  78264. */
  78265. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78266. /**
  78267. * Does this action manager handles actions of a given trigger
  78268. * @param trigger defines the trigger to be tested
  78269. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78270. * @return whether the trigger is handled
  78271. */
  78272. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78273. /**
  78274. * Does this action manager has pointer triggers
  78275. */
  78276. readonly hasPointerTriggers: boolean;
  78277. /**
  78278. * Does this action manager has pick triggers
  78279. */
  78280. readonly hasPickTriggers: boolean;
  78281. /**
  78282. * Registers an action to this action manager
  78283. * @param action defines the action to be registered
  78284. * @return the action amended (prepared) after registration
  78285. */
  78286. registerAction(action: IAction): Nullable<IAction>;
  78287. /**
  78288. * Unregisters an action to this action manager
  78289. * @param action defines the action to be unregistered
  78290. * @return a boolean indicating whether the action has been unregistered
  78291. */
  78292. unregisterAction(action: IAction): Boolean;
  78293. /**
  78294. * Process a specific trigger
  78295. * @param trigger defines the trigger to process
  78296. * @param evt defines the event details to be processed
  78297. */
  78298. processTrigger(trigger: number, evt?: IActionEvent): void;
  78299. /** @hidden */
  78300. _getEffectiveTarget(target: any, propertyPath: string): any;
  78301. /** @hidden */
  78302. _getProperty(propertyPath: string): string;
  78303. /**
  78304. * Serialize this manager to a JSON object
  78305. * @param name defines the property name to store this manager
  78306. * @returns a JSON representation of this manager
  78307. */
  78308. serialize(name: string): any;
  78309. /**
  78310. * Creates a new ActionManager from a JSON data
  78311. * @param parsedActions defines the JSON data to read from
  78312. * @param object defines the hosting mesh
  78313. * @param scene defines the hosting scene
  78314. */
  78315. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78316. /**
  78317. * Get a trigger name by index
  78318. * @param trigger defines the trigger index
  78319. * @returns a trigger name
  78320. */
  78321. static GetTriggerName(trigger: number): string;
  78322. }
  78323. }
  78324. declare module BABYLON {
  78325. /**
  78326. * Class representing a ray with position and direction
  78327. */
  78328. export class Ray {
  78329. /** origin point */
  78330. origin: Vector3;
  78331. /** direction */
  78332. direction: Vector3;
  78333. /** length of the ray */
  78334. length: number;
  78335. private static readonly TmpVector3;
  78336. private _tmpRay;
  78337. /**
  78338. * Creates a new ray
  78339. * @param origin origin point
  78340. * @param direction direction
  78341. * @param length length of the ray
  78342. */
  78343. constructor(
  78344. /** origin point */
  78345. origin: Vector3,
  78346. /** direction */
  78347. direction: Vector3,
  78348. /** length of the ray */
  78349. length?: number);
  78350. /**
  78351. * Checks if the ray intersects a box
  78352. * @param minimum bound of the box
  78353. * @param maximum bound of the box
  78354. * @param intersectionTreshold extra extend to be added to the box in all direction
  78355. * @returns if the box was hit
  78356. */
  78357. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78358. /**
  78359. * Checks if the ray intersects a box
  78360. * @param box the bounding box to check
  78361. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78362. * @returns if the box was hit
  78363. */
  78364. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78365. /**
  78366. * If the ray hits a sphere
  78367. * @param sphere the bounding sphere to check
  78368. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78369. * @returns true if it hits the sphere
  78370. */
  78371. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78372. /**
  78373. * If the ray hits a triange
  78374. * @param vertex0 triangle vertex
  78375. * @param vertex1 triangle vertex
  78376. * @param vertex2 triangle vertex
  78377. * @returns intersection information if hit
  78378. */
  78379. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78380. /**
  78381. * Checks if ray intersects a plane
  78382. * @param plane the plane to check
  78383. * @returns the distance away it was hit
  78384. */
  78385. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78386. /**
  78387. * Calculate the intercept of a ray on a given axis
  78388. * @param axis to check 'x' | 'y' | 'z'
  78389. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78390. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78391. */
  78392. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78393. /**
  78394. * Checks if ray intersects a mesh
  78395. * @param mesh the mesh to check
  78396. * @param fastCheck if only the bounding box should checked
  78397. * @returns picking info of the intersecton
  78398. */
  78399. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78400. /**
  78401. * Checks if ray intersects a mesh
  78402. * @param meshes the meshes to check
  78403. * @param fastCheck if only the bounding box should checked
  78404. * @param results array to store result in
  78405. * @returns Array of picking infos
  78406. */
  78407. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78408. private _comparePickingInfo;
  78409. private static smallnum;
  78410. private static rayl;
  78411. /**
  78412. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78413. * @param sega the first point of the segment to test the intersection against
  78414. * @param segb the second point of the segment to test the intersection against
  78415. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78416. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78417. */
  78418. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78419. /**
  78420. * Update the ray from viewport position
  78421. * @param x position
  78422. * @param y y position
  78423. * @param viewportWidth viewport width
  78424. * @param viewportHeight viewport height
  78425. * @param world world matrix
  78426. * @param view view matrix
  78427. * @param projection projection matrix
  78428. * @returns this ray updated
  78429. */
  78430. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78431. /**
  78432. * Creates a ray with origin and direction of 0,0,0
  78433. * @returns the new ray
  78434. */
  78435. static Zero(): Ray;
  78436. /**
  78437. * Creates a new ray from screen space and viewport
  78438. * @param x position
  78439. * @param y y position
  78440. * @param viewportWidth viewport width
  78441. * @param viewportHeight viewport height
  78442. * @param world world matrix
  78443. * @param view view matrix
  78444. * @param projection projection matrix
  78445. * @returns new ray
  78446. */
  78447. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78448. /**
  78449. * 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
  78450. * transformed to the given world matrix.
  78451. * @param origin The origin point
  78452. * @param end The end point
  78453. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78454. * @returns the new ray
  78455. */
  78456. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78457. /**
  78458. * Transforms a ray by a matrix
  78459. * @param ray ray to transform
  78460. * @param matrix matrix to apply
  78461. * @returns the resulting new ray
  78462. */
  78463. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78464. /**
  78465. * Transforms a ray by a matrix
  78466. * @param ray ray to transform
  78467. * @param matrix matrix to apply
  78468. * @param result ray to store result in
  78469. */
  78470. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78471. /**
  78472. * Unproject a ray from screen space to object space
  78473. * @param sourceX defines the screen space x coordinate to use
  78474. * @param sourceY defines the screen space y coordinate to use
  78475. * @param viewportWidth defines the current width of the viewport
  78476. * @param viewportHeight defines the current height of the viewport
  78477. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78478. * @param view defines the view matrix to use
  78479. * @param projection defines the projection matrix to use
  78480. */
  78481. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78482. }
  78483. /**
  78484. * Type used to define predicate used to select faces when a mesh intersection is detected
  78485. */
  78486. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78487. interface Scene {
  78488. /** @hidden */
  78489. _tempPickingRay: Nullable<Ray>;
  78490. /** @hidden */
  78491. _cachedRayForTransform: Ray;
  78492. /** @hidden */
  78493. _pickWithRayInverseMatrix: Matrix;
  78494. /** @hidden */
  78495. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78496. /** @hidden */
  78497. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78498. }
  78499. }
  78500. declare module BABYLON {
  78501. /**
  78502. * Groups all the scene component constants in one place to ease maintenance.
  78503. * @hidden
  78504. */
  78505. export class SceneComponentConstants {
  78506. static readonly NAME_EFFECTLAYER: string;
  78507. static readonly NAME_LAYER: string;
  78508. static readonly NAME_LENSFLARESYSTEM: string;
  78509. static readonly NAME_BOUNDINGBOXRENDERER: string;
  78510. static readonly NAME_PARTICLESYSTEM: string;
  78511. static readonly NAME_GAMEPAD: string;
  78512. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  78513. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  78514. static readonly NAME_DEPTHRENDERER: string;
  78515. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  78516. static readonly NAME_SPRITE: string;
  78517. static readonly NAME_OUTLINERENDERER: string;
  78518. static readonly NAME_PROCEDURALTEXTURE: string;
  78519. static readonly NAME_SHADOWGENERATOR: string;
  78520. static readonly NAME_OCTREE: string;
  78521. static readonly NAME_PHYSICSENGINE: string;
  78522. static readonly NAME_AUDIO: string;
  78523. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  78524. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78525. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  78526. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78527. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  78528. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  78529. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  78530. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  78531. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  78532. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  78533. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  78534. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  78535. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  78536. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  78537. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  78538. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  78539. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  78540. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  78541. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  78542. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  78543. static readonly STEP_AFTERRENDER_AUDIO: number;
  78544. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  78545. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  78546. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  78547. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  78548. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  78549. static readonly STEP_POINTERMOVE_SPRITE: number;
  78550. static readonly STEP_POINTERDOWN_SPRITE: number;
  78551. static readonly STEP_POINTERUP_SPRITE: number;
  78552. }
  78553. /**
  78554. * This represents a scene component.
  78555. *
  78556. * This is used to decouple the dependency the scene is having on the different workloads like
  78557. * layers, post processes...
  78558. */
  78559. export interface ISceneComponent {
  78560. /**
  78561. * The name of the component. Each component must have a unique name.
  78562. */
  78563. name: string;
  78564. /**
  78565. * The scene the component belongs to.
  78566. */
  78567. scene: Scene;
  78568. /**
  78569. * Register the component to one instance of a scene.
  78570. */
  78571. register(): void;
  78572. /**
  78573. * Rebuilds the elements related to this component in case of
  78574. * context lost for instance.
  78575. */
  78576. rebuild(): void;
  78577. /**
  78578. * Disposes the component and the associated ressources.
  78579. */
  78580. dispose(): void;
  78581. }
  78582. /**
  78583. * This represents a SERIALIZABLE scene component.
  78584. *
  78585. * This extends Scene Component to add Serialization methods on top.
  78586. */
  78587. export interface ISceneSerializableComponent extends ISceneComponent {
  78588. /**
  78589. * Adds all the elements from the container to the scene
  78590. * @param container the container holding the elements
  78591. */
  78592. addFromContainer(container: AbstractScene): void;
  78593. /**
  78594. * Removes all the elements in the container from the scene
  78595. * @param container contains the elements to remove
  78596. * @param dispose if the removed element should be disposed (default: false)
  78597. */
  78598. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  78599. /**
  78600. * Serializes the component data to the specified json object
  78601. * @param serializationObject The object to serialize to
  78602. */
  78603. serialize(serializationObject: any): void;
  78604. }
  78605. /**
  78606. * Strong typing of a Mesh related stage step action
  78607. */
  78608. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  78609. /**
  78610. * Strong typing of a Evaluate Sub Mesh related stage step action
  78611. */
  78612. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  78613. /**
  78614. * Strong typing of a Active Mesh related stage step action
  78615. */
  78616. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  78617. /**
  78618. * Strong typing of a Camera related stage step action
  78619. */
  78620. export type CameraStageAction = (camera: Camera) => void;
  78621. /**
  78622. * Strong typing of a Camera Frame buffer related stage step action
  78623. */
  78624. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  78625. /**
  78626. * Strong typing of a Render Target related stage step action
  78627. */
  78628. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  78629. /**
  78630. * Strong typing of a RenderingGroup related stage step action
  78631. */
  78632. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  78633. /**
  78634. * Strong typing of a Mesh Render related stage step action
  78635. */
  78636. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  78637. /**
  78638. * Strong typing of a simple stage step action
  78639. */
  78640. export type SimpleStageAction = () => void;
  78641. /**
  78642. * Strong typing of a render target action.
  78643. */
  78644. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78645. /**
  78646. * Strong typing of a pointer move action.
  78647. */
  78648. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78649. /**
  78650. * Strong typing of a pointer up/down action.
  78651. */
  78652. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78653. /**
  78654. * Representation of a stage in the scene (Basically a list of ordered steps)
  78655. * @hidden
  78656. */
  78657. export class Stage<T extends Function> extends Array<{
  78658. index: number;
  78659. component: ISceneComponent;
  78660. action: T;
  78661. }> {
  78662. /**
  78663. * Hide ctor from the rest of the world.
  78664. * @param items The items to add.
  78665. */
  78666. private constructor();
  78667. /**
  78668. * Creates a new Stage.
  78669. * @returns A new instance of a Stage
  78670. */
  78671. static Create<T extends Function>(): Stage<T>;
  78672. /**
  78673. * Registers a step in an ordered way in the targeted stage.
  78674. * @param index Defines the position to register the step in
  78675. * @param component Defines the component attached to the step
  78676. * @param action Defines the action to launch during the step
  78677. */
  78678. registerStep(index: number, component: ISceneComponent, action: T): void;
  78679. /**
  78680. * Clears all the steps from the stage.
  78681. */
  78682. clear(): void;
  78683. }
  78684. }
  78685. declare module BABYLON {
  78686. interface Scene {
  78687. /** @hidden */
  78688. _pointerOverSprite: Nullable<Sprite>;
  78689. /** @hidden */
  78690. _pickedDownSprite: Nullable<Sprite>;
  78691. /** @hidden */
  78692. _tempSpritePickingRay: Nullable<Ray>;
  78693. /**
  78694. * All of the sprite managers added to this scene
  78695. * @see http://doc.babylonjs.com/babylon101/sprites
  78696. */
  78697. spriteManagers: Array<ISpriteManager>;
  78698. /**
  78699. * An event triggered when sprites rendering is about to start
  78700. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78701. */
  78702. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78703. /**
  78704. * An event triggered when sprites rendering is done
  78705. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78706. */
  78707. onAfterSpritesRenderingObservable: Observable<Scene>;
  78708. /** @hidden */
  78709. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78710. /** Launch a ray to try to pick a sprite in the scene
  78711. * @param x position on screen
  78712. * @param y position on screen
  78713. * @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
  78714. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78715. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78716. * @returns a PickingInfo
  78717. */
  78718. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78719. /** Use the given ray to pick a sprite in the scene
  78720. * @param ray The ray (in world space) to use to pick meshes
  78721. * @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
  78722. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78723. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78724. * @returns a PickingInfo
  78725. */
  78726. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78727. /** @hidden */
  78728. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78729. /** Launch a ray to try to pick sprites in the scene
  78730. * @param x position on screen
  78731. * @param y position on screen
  78732. * @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
  78733. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78734. * @returns a PickingInfo array
  78735. */
  78736. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78737. /** Use the given ray to pick sprites in the scene
  78738. * @param ray The ray (in world space) to use to pick meshes
  78739. * @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
  78740. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78741. * @returns a PickingInfo array
  78742. */
  78743. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78744. /**
  78745. * Force the sprite under the pointer
  78746. * @param sprite defines the sprite to use
  78747. */
  78748. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78749. /**
  78750. * Gets the sprite under the pointer
  78751. * @returns a Sprite or null if no sprite is under the pointer
  78752. */
  78753. getPointerOverSprite(): Nullable<Sprite>;
  78754. }
  78755. /**
  78756. * Defines the sprite scene component responsible to manage sprites
  78757. * in a given scene.
  78758. */
  78759. export class SpriteSceneComponent implements ISceneComponent {
  78760. /**
  78761. * The component name helpfull to identify the component in the list of scene components.
  78762. */
  78763. readonly name: string;
  78764. /**
  78765. * The scene the component belongs to.
  78766. */
  78767. scene: Scene;
  78768. /** @hidden */
  78769. private _spritePredicate;
  78770. /**
  78771. * Creates a new instance of the component for the given scene
  78772. * @param scene Defines the scene to register the component in
  78773. */
  78774. constructor(scene: Scene);
  78775. /**
  78776. * Registers the component in a given scene
  78777. */
  78778. register(): void;
  78779. /**
  78780. * Rebuilds the elements related to this component in case of
  78781. * context lost for instance.
  78782. */
  78783. rebuild(): void;
  78784. /**
  78785. * Disposes the component and the associated ressources.
  78786. */
  78787. dispose(): void;
  78788. private _pickSpriteButKeepRay;
  78789. private _pointerMove;
  78790. private _pointerDown;
  78791. private _pointerUp;
  78792. }
  78793. }
  78794. declare module BABYLON {
  78795. /** @hidden */
  78796. export var fogFragmentDeclaration: {
  78797. name: string;
  78798. shader: string;
  78799. };
  78800. }
  78801. declare module BABYLON {
  78802. /** @hidden */
  78803. export var fogFragment: {
  78804. name: string;
  78805. shader: string;
  78806. };
  78807. }
  78808. declare module BABYLON {
  78809. /** @hidden */
  78810. export var spritesPixelShader: {
  78811. name: string;
  78812. shader: string;
  78813. };
  78814. }
  78815. declare module BABYLON {
  78816. /** @hidden */
  78817. export var fogVertexDeclaration: {
  78818. name: string;
  78819. shader: string;
  78820. };
  78821. }
  78822. declare module BABYLON {
  78823. /** @hidden */
  78824. export var spritesVertexShader: {
  78825. name: string;
  78826. shader: string;
  78827. };
  78828. }
  78829. declare module BABYLON {
  78830. /**
  78831. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78832. */
  78833. export interface ISpriteManager extends IDisposable {
  78834. /**
  78835. * Restricts the camera to viewing objects with the same layerMask.
  78836. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78837. */
  78838. layerMask: number;
  78839. /**
  78840. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78841. */
  78842. isPickable: boolean;
  78843. /**
  78844. * Specifies the rendering group id for this mesh (0 by default)
  78845. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78846. */
  78847. renderingGroupId: number;
  78848. /**
  78849. * Defines the list of sprites managed by the manager.
  78850. */
  78851. sprites: Array<Sprite>;
  78852. /**
  78853. * Tests the intersection of a sprite with a specific ray.
  78854. * @param ray The ray we are sending to test the collision
  78855. * @param camera The camera space we are sending rays in
  78856. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78857. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78858. * @returns picking info or null.
  78859. */
  78860. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78861. /**
  78862. * Intersects the sprites with a ray
  78863. * @param ray defines the ray to intersect with
  78864. * @param camera defines the current active camera
  78865. * @param predicate defines a predicate used to select candidate sprites
  78866. * @returns null if no hit or a PickingInfo array
  78867. */
  78868. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78869. /**
  78870. * Renders the list of sprites on screen.
  78871. */
  78872. render(): void;
  78873. }
  78874. /**
  78875. * Class used to manage multiple sprites on the same spritesheet
  78876. * @see http://doc.babylonjs.com/babylon101/sprites
  78877. */
  78878. export class SpriteManager implements ISpriteManager {
  78879. /** defines the manager's name */
  78880. name: string;
  78881. /** Gets the list of sprites */
  78882. sprites: Sprite[];
  78883. /** Gets or sets the rendering group id (0 by default) */
  78884. renderingGroupId: number;
  78885. /** Gets or sets camera layer mask */
  78886. layerMask: number;
  78887. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78888. fogEnabled: boolean;
  78889. /** Gets or sets a boolean indicating if the sprites are pickable */
  78890. isPickable: boolean;
  78891. /** Defines the default width of a cell in the spritesheet */
  78892. cellWidth: number;
  78893. /** Defines the default height of a cell in the spritesheet */
  78894. cellHeight: number;
  78895. /** Associative array from JSON sprite data file */
  78896. private _cellData;
  78897. /** Array of sprite names from JSON sprite data file */
  78898. private _spriteMap;
  78899. /** True when packed cell data from JSON file is ready*/
  78900. private _packedAndReady;
  78901. /**
  78902. * An event triggered when the manager is disposed.
  78903. */
  78904. onDisposeObservable: Observable<SpriteManager>;
  78905. private _onDisposeObserver;
  78906. /**
  78907. * Callback called when the manager is disposed
  78908. */
  78909. onDispose: () => void;
  78910. private _capacity;
  78911. private _fromPacked;
  78912. private _spriteTexture;
  78913. private _epsilon;
  78914. private _scene;
  78915. private _vertexData;
  78916. private _buffer;
  78917. private _vertexBuffers;
  78918. private _indexBuffer;
  78919. private _effectBase;
  78920. private _effectFog;
  78921. /**
  78922. * Gets or sets the spritesheet texture
  78923. */
  78924. texture: Texture;
  78925. /**
  78926. * Creates a new sprite manager
  78927. * @param name defines the manager's name
  78928. * @param imgUrl defines the sprite sheet url
  78929. * @param capacity defines the maximum allowed number of sprites
  78930. * @param cellSize defines the size of a sprite cell
  78931. * @param scene defines the hosting scene
  78932. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78933. * @param samplingMode defines the smapling mode to use with spritesheet
  78934. * @param fromPacked set to false; do not alter
  78935. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78936. */
  78937. constructor(
  78938. /** defines the manager's name */
  78939. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78940. private _makePacked;
  78941. private _appendSpriteVertex;
  78942. /**
  78943. * Intersects the sprites with a ray
  78944. * @param ray defines the ray to intersect with
  78945. * @param camera defines the current active camera
  78946. * @param predicate defines a predicate used to select candidate sprites
  78947. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78948. * @returns null if no hit or a PickingInfo
  78949. */
  78950. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78951. /**
  78952. * Intersects the sprites with a ray
  78953. * @param ray defines the ray to intersect with
  78954. * @param camera defines the current active camera
  78955. * @param predicate defines a predicate used to select candidate sprites
  78956. * @returns null if no hit or a PickingInfo array
  78957. */
  78958. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78959. /**
  78960. * Render all child sprites
  78961. */
  78962. render(): void;
  78963. /**
  78964. * Release associated resources
  78965. */
  78966. dispose(): void;
  78967. }
  78968. }
  78969. declare module BABYLON {
  78970. /**
  78971. * Class used to represent a sprite
  78972. * @see http://doc.babylonjs.com/babylon101/sprites
  78973. */
  78974. export class Sprite {
  78975. /** defines the name */
  78976. name: string;
  78977. /** Gets or sets the current world position */
  78978. position: Vector3;
  78979. /** Gets or sets the main color */
  78980. color: Color4;
  78981. /** Gets or sets the width */
  78982. width: number;
  78983. /** Gets or sets the height */
  78984. height: number;
  78985. /** Gets or sets rotation angle */
  78986. angle: number;
  78987. /** Gets or sets the cell index in the sprite sheet */
  78988. cellIndex: number;
  78989. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78990. cellRef: string;
  78991. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78992. invertU: number;
  78993. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78994. invertV: number;
  78995. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78996. disposeWhenFinishedAnimating: boolean;
  78997. /** Gets the list of attached animations */
  78998. animations: Animation[];
  78999. /** Gets or sets a boolean indicating if the sprite can be picked */
  79000. isPickable: boolean;
  79001. /**
  79002. * Gets or sets the associated action manager
  79003. */
  79004. actionManager: Nullable<ActionManager>;
  79005. private _animationStarted;
  79006. private _loopAnimation;
  79007. private _fromIndex;
  79008. private _toIndex;
  79009. private _delay;
  79010. private _direction;
  79011. private _manager;
  79012. private _time;
  79013. private _onAnimationEnd;
  79014. /**
  79015. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79016. */
  79017. isVisible: boolean;
  79018. /**
  79019. * Gets or sets the sprite size
  79020. */
  79021. size: number;
  79022. /**
  79023. * Creates a new Sprite
  79024. * @param name defines the name
  79025. * @param manager defines the manager
  79026. */
  79027. constructor(
  79028. /** defines the name */
  79029. name: string, manager: ISpriteManager);
  79030. /**
  79031. * Starts an animation
  79032. * @param from defines the initial key
  79033. * @param to defines the end key
  79034. * @param loop defines if the animation must loop
  79035. * @param delay defines the start delay (in ms)
  79036. * @param onAnimationEnd defines a callback to call when animation ends
  79037. */
  79038. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79039. /** Stops current animation (if any) */
  79040. stopAnimation(): void;
  79041. /** @hidden */
  79042. _animate(deltaTime: number): void;
  79043. /** Release associated resources */
  79044. dispose(): void;
  79045. }
  79046. }
  79047. declare module BABYLON {
  79048. /**
  79049. * Information about the result of picking within a scene
  79050. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79051. */
  79052. export class PickingInfo {
  79053. /** @hidden */
  79054. _pickingUnavailable: boolean;
  79055. /**
  79056. * If the pick collided with an object
  79057. */
  79058. hit: boolean;
  79059. /**
  79060. * Distance away where the pick collided
  79061. */
  79062. distance: number;
  79063. /**
  79064. * The location of pick collision
  79065. */
  79066. pickedPoint: Nullable<Vector3>;
  79067. /**
  79068. * The mesh corresponding the the pick collision
  79069. */
  79070. pickedMesh: Nullable<AbstractMesh>;
  79071. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79072. bu: number;
  79073. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79074. bv: number;
  79075. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79076. faceId: number;
  79077. /** Id of the the submesh that was picked */
  79078. subMeshId: number;
  79079. /** If a sprite was picked, this will be the sprite the pick collided with */
  79080. pickedSprite: Nullable<Sprite>;
  79081. /**
  79082. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79083. */
  79084. originMesh: Nullable<AbstractMesh>;
  79085. /**
  79086. * The ray that was used to perform the picking.
  79087. */
  79088. ray: Nullable<Ray>;
  79089. /**
  79090. * Gets the normal correspodning to the face the pick collided with
  79091. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79092. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79093. * @returns The normal correspodning to the face the pick collided with
  79094. */
  79095. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79096. /**
  79097. * Gets the texture coordinates of where the pick occured
  79098. * @returns the vector containing the coordnates of the texture
  79099. */
  79100. getTextureCoordinates(): Nullable<Vector2>;
  79101. }
  79102. }
  79103. declare module BABYLON {
  79104. /**
  79105. * Gather the list of pointer event types as constants.
  79106. */
  79107. export class PointerEventTypes {
  79108. /**
  79109. * 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.
  79110. */
  79111. static readonly POINTERDOWN: number;
  79112. /**
  79113. * The pointerup event is fired when a pointer is no longer active.
  79114. */
  79115. static readonly POINTERUP: number;
  79116. /**
  79117. * The pointermove event is fired when a pointer changes coordinates.
  79118. */
  79119. static readonly POINTERMOVE: number;
  79120. /**
  79121. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79122. */
  79123. static readonly POINTERWHEEL: number;
  79124. /**
  79125. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79126. */
  79127. static readonly POINTERPICK: number;
  79128. /**
  79129. * The pointertap event is fired when a the object has been touched and released without drag.
  79130. */
  79131. static readonly POINTERTAP: number;
  79132. /**
  79133. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79134. */
  79135. static readonly POINTERDOUBLETAP: number;
  79136. }
  79137. /**
  79138. * Base class of pointer info types.
  79139. */
  79140. export class PointerInfoBase {
  79141. /**
  79142. * Defines the type of event (PointerEventTypes)
  79143. */
  79144. type: number;
  79145. /**
  79146. * Defines the related dom event
  79147. */
  79148. event: PointerEvent | MouseWheelEvent;
  79149. /**
  79150. * Instantiates the base class of pointers info.
  79151. * @param type Defines the type of event (PointerEventTypes)
  79152. * @param event Defines the related dom event
  79153. */
  79154. constructor(
  79155. /**
  79156. * Defines the type of event (PointerEventTypes)
  79157. */
  79158. type: number,
  79159. /**
  79160. * Defines the related dom event
  79161. */
  79162. event: PointerEvent | MouseWheelEvent);
  79163. }
  79164. /**
  79165. * This class is used to store pointer related info for the onPrePointerObservable event.
  79166. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79167. */
  79168. export class PointerInfoPre extends PointerInfoBase {
  79169. /**
  79170. * Ray from a pointer if availible (eg. 6dof controller)
  79171. */
  79172. ray: Nullable<Ray>;
  79173. /**
  79174. * Defines the local position of the pointer on the canvas.
  79175. */
  79176. localPosition: Vector2;
  79177. /**
  79178. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79179. */
  79180. skipOnPointerObservable: boolean;
  79181. /**
  79182. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79183. * @param type Defines the type of event (PointerEventTypes)
  79184. * @param event Defines the related dom event
  79185. * @param localX Defines the local x coordinates of the pointer when the event occured
  79186. * @param localY Defines the local y coordinates of the pointer when the event occured
  79187. */
  79188. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79189. }
  79190. /**
  79191. * This type contains all the data related to a pointer event in Babylon.js.
  79192. * 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.
  79193. */
  79194. export class PointerInfo extends PointerInfoBase {
  79195. /**
  79196. * Defines the picking info associated to the info (if any)\
  79197. */
  79198. pickInfo: Nullable<PickingInfo>;
  79199. /**
  79200. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79201. * @param type Defines the type of event (PointerEventTypes)
  79202. * @param event Defines the related dom event
  79203. * @param pickInfo Defines the picking info associated to the info (if any)\
  79204. */
  79205. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79206. /**
  79207. * Defines the picking info associated to the info (if any)\
  79208. */
  79209. pickInfo: Nullable<PickingInfo>);
  79210. }
  79211. /**
  79212. * Data relating to a touch event on the screen.
  79213. */
  79214. export interface PointerTouch {
  79215. /**
  79216. * X coordinate of touch.
  79217. */
  79218. x: number;
  79219. /**
  79220. * Y coordinate of touch.
  79221. */
  79222. y: number;
  79223. /**
  79224. * Id of touch. Unique for each finger.
  79225. */
  79226. pointerId: number;
  79227. /**
  79228. * Event type passed from DOM.
  79229. */
  79230. type: any;
  79231. }
  79232. }
  79233. declare module BABYLON {
  79234. /**
  79235. * Manage the mouse inputs to control the movement of a free camera.
  79236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79237. */
  79238. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79239. /**
  79240. * Define if touch is enabled in the mouse input
  79241. */
  79242. touchEnabled: boolean;
  79243. /**
  79244. * Defines the camera the input is attached to.
  79245. */
  79246. camera: FreeCamera;
  79247. /**
  79248. * Defines the buttons associated with the input to handle camera move.
  79249. */
  79250. buttons: number[];
  79251. /**
  79252. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79253. */
  79254. angularSensibility: number;
  79255. private _pointerInput;
  79256. private _onMouseMove;
  79257. private _observer;
  79258. private previousPosition;
  79259. /**
  79260. * Observable for when a pointer move event occurs containing the move offset
  79261. */
  79262. onPointerMovedObservable: Observable<{
  79263. offsetX: number;
  79264. offsetY: number;
  79265. }>;
  79266. /**
  79267. * @hidden
  79268. * If the camera should be rotated automatically based on pointer movement
  79269. */
  79270. _allowCameraRotation: boolean;
  79271. /**
  79272. * Manage the mouse inputs to control the movement of a free camera.
  79273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79274. * @param touchEnabled Defines if touch is enabled or not
  79275. */
  79276. constructor(
  79277. /**
  79278. * Define if touch is enabled in the mouse input
  79279. */
  79280. touchEnabled?: boolean);
  79281. /**
  79282. * Attach the input controls to a specific dom element to get the input from.
  79283. * @param element Defines the element the controls should be listened from
  79284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79285. */
  79286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79287. /**
  79288. * Called on JS contextmenu event.
  79289. * Override this method to provide functionality.
  79290. */
  79291. protected onContextMenu(evt: PointerEvent): void;
  79292. /**
  79293. * Detach the current controls from the specified dom element.
  79294. * @param element Defines the element to stop listening the inputs from
  79295. */
  79296. detachControl(element: Nullable<HTMLElement>): void;
  79297. /**
  79298. * Gets the class name of the current intput.
  79299. * @returns the class name
  79300. */
  79301. getClassName(): string;
  79302. /**
  79303. * Get the friendly name associated with the input class.
  79304. * @returns the input friendly name
  79305. */
  79306. getSimpleName(): string;
  79307. }
  79308. }
  79309. declare module BABYLON {
  79310. /**
  79311. * Manage the touch inputs to control the movement of a free camera.
  79312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79313. */
  79314. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79315. /**
  79316. * Defines the camera the input is attached to.
  79317. */
  79318. camera: FreeCamera;
  79319. /**
  79320. * Defines the touch sensibility for rotation.
  79321. * The higher the faster.
  79322. */
  79323. touchAngularSensibility: number;
  79324. /**
  79325. * Defines the touch sensibility for move.
  79326. * The higher the faster.
  79327. */
  79328. touchMoveSensibility: number;
  79329. private _offsetX;
  79330. private _offsetY;
  79331. private _pointerPressed;
  79332. private _pointerInput;
  79333. private _observer;
  79334. private _onLostFocus;
  79335. /**
  79336. * Attach the input controls to a specific dom element to get the input from.
  79337. * @param element Defines the element the controls should be listened from
  79338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79339. */
  79340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79341. /**
  79342. * Detach the current controls from the specified dom element.
  79343. * @param element Defines the element to stop listening the inputs from
  79344. */
  79345. detachControl(element: Nullable<HTMLElement>): void;
  79346. /**
  79347. * Update the current camera state depending on the inputs that have been used this frame.
  79348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79349. */
  79350. checkInputs(): void;
  79351. /**
  79352. * Gets the class name of the current intput.
  79353. * @returns the class name
  79354. */
  79355. getClassName(): string;
  79356. /**
  79357. * Get the friendly name associated with the input class.
  79358. * @returns the input friendly name
  79359. */
  79360. getSimpleName(): string;
  79361. }
  79362. }
  79363. declare module BABYLON {
  79364. /**
  79365. * Default Inputs manager for the FreeCamera.
  79366. * It groups all the default supported inputs for ease of use.
  79367. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79368. */
  79369. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79370. /**
  79371. * @hidden
  79372. */
  79373. _mouseInput: Nullable<FreeCameraMouseInput>;
  79374. /**
  79375. * Instantiates a new FreeCameraInputsManager.
  79376. * @param camera Defines the camera the inputs belong to
  79377. */
  79378. constructor(camera: FreeCamera);
  79379. /**
  79380. * Add keyboard input support to the input manager.
  79381. * @returns the current input manager
  79382. */
  79383. addKeyboard(): FreeCameraInputsManager;
  79384. /**
  79385. * Add mouse input support to the input manager.
  79386. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79387. * @returns the current input manager
  79388. */
  79389. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79390. /**
  79391. * Removes the mouse input support from the manager
  79392. * @returns the current input manager
  79393. */
  79394. removeMouse(): FreeCameraInputsManager;
  79395. /**
  79396. * Add touch input support to the input manager.
  79397. * @returns the current input manager
  79398. */
  79399. addTouch(): FreeCameraInputsManager;
  79400. /**
  79401. * Remove all attached input methods from a camera
  79402. */
  79403. clear(): void;
  79404. }
  79405. }
  79406. declare module BABYLON {
  79407. /**
  79408. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79409. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79410. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79411. */
  79412. export class FreeCamera extends TargetCamera {
  79413. /**
  79414. * Define the collision ellipsoid of the camera.
  79415. * This is helpful to simulate a camera body like the player body around the camera
  79416. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79417. */
  79418. ellipsoid: Vector3;
  79419. /**
  79420. * Define an offset for the position of the ellipsoid around the camera.
  79421. * This can be helpful to determine the center of the body near the gravity center of the body
  79422. * instead of its head.
  79423. */
  79424. ellipsoidOffset: Vector3;
  79425. /**
  79426. * Enable or disable collisions of the camera with the rest of the scene objects.
  79427. */
  79428. checkCollisions: boolean;
  79429. /**
  79430. * Enable or disable gravity on the camera.
  79431. */
  79432. applyGravity: boolean;
  79433. /**
  79434. * Define the input manager associated to the camera.
  79435. */
  79436. inputs: FreeCameraInputsManager;
  79437. /**
  79438. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79439. * Higher values reduce sensitivity.
  79440. */
  79441. /**
  79442. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79443. * Higher values reduce sensitivity.
  79444. */
  79445. angularSensibility: number;
  79446. /**
  79447. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79448. */
  79449. keysUp: number[];
  79450. /**
  79451. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79452. */
  79453. keysDown: number[];
  79454. /**
  79455. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79456. */
  79457. keysLeft: number[];
  79458. /**
  79459. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79460. */
  79461. keysRight: number[];
  79462. /**
  79463. * Event raised when the camera collide with a mesh in the scene.
  79464. */
  79465. onCollide: (collidedMesh: AbstractMesh) => void;
  79466. private _collider;
  79467. private _needMoveForGravity;
  79468. private _oldPosition;
  79469. private _diffPosition;
  79470. private _newPosition;
  79471. /** @hidden */
  79472. _localDirection: Vector3;
  79473. /** @hidden */
  79474. _transformedDirection: Vector3;
  79475. /**
  79476. * Instantiates a Free Camera.
  79477. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79478. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79479. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79480. * @param name Define the name of the camera in the scene
  79481. * @param position Define the start position of the camera in the scene
  79482. * @param scene Define the scene the camera belongs to
  79483. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79484. */
  79485. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79486. /**
  79487. * Attached controls to the current camera.
  79488. * @param element Defines the element the controls should be listened from
  79489. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79490. */
  79491. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79492. /**
  79493. * Detach the current controls from the camera.
  79494. * The camera will stop reacting to inputs.
  79495. * @param element Defines the element to stop listening the inputs from
  79496. */
  79497. detachControl(element: HTMLElement): void;
  79498. private _collisionMask;
  79499. /**
  79500. * Define a collision mask to limit the list of object the camera can collide with
  79501. */
  79502. collisionMask: number;
  79503. /** @hidden */
  79504. _collideWithWorld(displacement: Vector3): void;
  79505. private _onCollisionPositionChange;
  79506. /** @hidden */
  79507. _checkInputs(): void;
  79508. /** @hidden */
  79509. _decideIfNeedsToMove(): boolean;
  79510. /** @hidden */
  79511. _updatePosition(): void;
  79512. /**
  79513. * Destroy the camera and release the current resources hold by it.
  79514. */
  79515. dispose(): void;
  79516. /**
  79517. * Gets the current object class name.
  79518. * @return the class name
  79519. */
  79520. getClassName(): string;
  79521. }
  79522. }
  79523. declare module BABYLON {
  79524. /**
  79525. * Represents a gamepad control stick position
  79526. */
  79527. export class StickValues {
  79528. /**
  79529. * The x component of the control stick
  79530. */
  79531. x: number;
  79532. /**
  79533. * The y component of the control stick
  79534. */
  79535. y: number;
  79536. /**
  79537. * Initializes the gamepad x and y control stick values
  79538. * @param x The x component of the gamepad control stick value
  79539. * @param y The y component of the gamepad control stick value
  79540. */
  79541. constructor(
  79542. /**
  79543. * The x component of the control stick
  79544. */
  79545. x: number,
  79546. /**
  79547. * The y component of the control stick
  79548. */
  79549. y: number);
  79550. }
  79551. /**
  79552. * An interface which manages callbacks for gamepad button changes
  79553. */
  79554. export interface GamepadButtonChanges {
  79555. /**
  79556. * Called when a gamepad has been changed
  79557. */
  79558. changed: boolean;
  79559. /**
  79560. * Called when a gamepad press event has been triggered
  79561. */
  79562. pressChanged: boolean;
  79563. /**
  79564. * Called when a touch event has been triggered
  79565. */
  79566. touchChanged: boolean;
  79567. /**
  79568. * Called when a value has changed
  79569. */
  79570. valueChanged: boolean;
  79571. }
  79572. /**
  79573. * Represents a gamepad
  79574. */
  79575. export class Gamepad {
  79576. /**
  79577. * The id of the gamepad
  79578. */
  79579. id: string;
  79580. /**
  79581. * The index of the gamepad
  79582. */
  79583. index: number;
  79584. /**
  79585. * The browser gamepad
  79586. */
  79587. browserGamepad: any;
  79588. /**
  79589. * Specifies what type of gamepad this represents
  79590. */
  79591. type: number;
  79592. private _leftStick;
  79593. private _rightStick;
  79594. /** @hidden */
  79595. _isConnected: boolean;
  79596. private _leftStickAxisX;
  79597. private _leftStickAxisY;
  79598. private _rightStickAxisX;
  79599. private _rightStickAxisY;
  79600. /**
  79601. * Triggered when the left control stick has been changed
  79602. */
  79603. private _onleftstickchanged;
  79604. /**
  79605. * Triggered when the right control stick has been changed
  79606. */
  79607. private _onrightstickchanged;
  79608. /**
  79609. * Represents a gamepad controller
  79610. */
  79611. static GAMEPAD: number;
  79612. /**
  79613. * Represents a generic controller
  79614. */
  79615. static GENERIC: number;
  79616. /**
  79617. * Represents an XBox controller
  79618. */
  79619. static XBOX: number;
  79620. /**
  79621. * Represents a pose-enabled controller
  79622. */
  79623. static POSE_ENABLED: number;
  79624. /**
  79625. * Represents an Dual Shock controller
  79626. */
  79627. static DUALSHOCK: number;
  79628. /**
  79629. * Specifies whether the left control stick should be Y-inverted
  79630. */
  79631. protected _invertLeftStickY: boolean;
  79632. /**
  79633. * Specifies if the gamepad has been connected
  79634. */
  79635. readonly isConnected: boolean;
  79636. /**
  79637. * Initializes the gamepad
  79638. * @param id The id of the gamepad
  79639. * @param index The index of the gamepad
  79640. * @param browserGamepad The browser gamepad
  79641. * @param leftStickX The x component of the left joystick
  79642. * @param leftStickY The y component of the left joystick
  79643. * @param rightStickX The x component of the right joystick
  79644. * @param rightStickY The y component of the right joystick
  79645. */
  79646. constructor(
  79647. /**
  79648. * The id of the gamepad
  79649. */
  79650. id: string,
  79651. /**
  79652. * The index of the gamepad
  79653. */
  79654. index: number,
  79655. /**
  79656. * The browser gamepad
  79657. */
  79658. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79659. /**
  79660. * Callback triggered when the left joystick has changed
  79661. * @param callback
  79662. */
  79663. onleftstickchanged(callback: (values: StickValues) => void): void;
  79664. /**
  79665. * Callback triggered when the right joystick has changed
  79666. * @param callback
  79667. */
  79668. onrightstickchanged(callback: (values: StickValues) => void): void;
  79669. /**
  79670. * Gets the left joystick
  79671. */
  79672. /**
  79673. * Sets the left joystick values
  79674. */
  79675. leftStick: StickValues;
  79676. /**
  79677. * Gets the right joystick
  79678. */
  79679. /**
  79680. * Sets the right joystick value
  79681. */
  79682. rightStick: StickValues;
  79683. /**
  79684. * Updates the gamepad joystick positions
  79685. */
  79686. update(): void;
  79687. /**
  79688. * Disposes the gamepad
  79689. */
  79690. dispose(): void;
  79691. }
  79692. /**
  79693. * Represents a generic gamepad
  79694. */
  79695. export class GenericPad extends Gamepad {
  79696. private _buttons;
  79697. private _onbuttondown;
  79698. private _onbuttonup;
  79699. /**
  79700. * Observable triggered when a button has been pressed
  79701. */
  79702. onButtonDownObservable: Observable<number>;
  79703. /**
  79704. * Observable triggered when a button has been released
  79705. */
  79706. onButtonUpObservable: Observable<number>;
  79707. /**
  79708. * Callback triggered when a button has been pressed
  79709. * @param callback Called when a button has been pressed
  79710. */
  79711. onbuttondown(callback: (buttonPressed: number) => void): void;
  79712. /**
  79713. * Callback triggered when a button has been released
  79714. * @param callback Called when a button has been released
  79715. */
  79716. onbuttonup(callback: (buttonReleased: number) => void): void;
  79717. /**
  79718. * Initializes the generic gamepad
  79719. * @param id The id of the generic gamepad
  79720. * @param index The index of the generic gamepad
  79721. * @param browserGamepad The browser gamepad
  79722. */
  79723. constructor(id: string, index: number, browserGamepad: any);
  79724. private _setButtonValue;
  79725. /**
  79726. * Updates the generic gamepad
  79727. */
  79728. update(): void;
  79729. /**
  79730. * Disposes the generic gamepad
  79731. */
  79732. dispose(): void;
  79733. }
  79734. }
  79735. declare module BABYLON {
  79736. interface Engine {
  79737. /**
  79738. * Creates a raw texture
  79739. * @param data defines the data to store in the texture
  79740. * @param width defines the width of the texture
  79741. * @param height defines the height of the texture
  79742. * @param format defines the format of the data
  79743. * @param generateMipMaps defines if the engine should generate the mip levels
  79744. * @param invertY defines if data must be stored with Y axis inverted
  79745. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79746. * @param compression defines the compression used (null by default)
  79747. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79748. * @returns the raw texture inside an InternalTexture
  79749. */
  79750. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79751. /**
  79752. * Update a raw texture
  79753. * @param texture defines the texture to update
  79754. * @param data defines the data to store in the texture
  79755. * @param format defines the format of the data
  79756. * @param invertY defines if data must be stored with Y axis inverted
  79757. */
  79758. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79759. /**
  79760. * Update a raw texture
  79761. * @param texture defines the texture to update
  79762. * @param data defines the data to store in the texture
  79763. * @param format defines the format of the data
  79764. * @param invertY defines if data must be stored with Y axis inverted
  79765. * @param compression defines the compression used (null by default)
  79766. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79767. */
  79768. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79769. /**
  79770. * Creates a new raw cube texture
  79771. * @param data defines the array of data to use to create each face
  79772. * @param size defines the size of the textures
  79773. * @param format defines the format of the data
  79774. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79775. * @param generateMipMaps defines if the engine should generate the mip levels
  79776. * @param invertY defines if data must be stored with Y axis inverted
  79777. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79778. * @param compression defines the compression used (null by default)
  79779. * @returns the cube texture as an InternalTexture
  79780. */
  79781. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79782. /**
  79783. * Update a raw cube texture
  79784. * @param texture defines the texture to udpdate
  79785. * @param data defines the data to store
  79786. * @param format defines the data format
  79787. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79788. * @param invertY defines if data must be stored with Y axis inverted
  79789. */
  79790. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79791. /**
  79792. * Update a raw cube texture
  79793. * @param texture defines the texture to udpdate
  79794. * @param data defines the data to store
  79795. * @param format defines the data format
  79796. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79797. * @param invertY defines if data must be stored with Y axis inverted
  79798. * @param compression defines the compression used (null by default)
  79799. */
  79800. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79801. /**
  79802. * Update a raw cube texture
  79803. * @param texture defines the texture to udpdate
  79804. * @param data defines the data to store
  79805. * @param format defines the data format
  79806. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79807. * @param invertY defines if data must be stored with Y axis inverted
  79808. * @param compression defines the compression used (null by default)
  79809. * @param level defines which level of the texture to update
  79810. */
  79811. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79812. /**
  79813. * Creates a new raw cube texture from a specified url
  79814. * @param url defines the url where the data is located
  79815. * @param scene defines the current scene
  79816. * @param size defines the size of the textures
  79817. * @param format defines the format of the data
  79818. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79819. * @param noMipmap defines if the engine should avoid generating the mip levels
  79820. * @param callback defines a callback used to extract texture data from loaded data
  79821. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79822. * @param onLoad defines a callback called when texture is loaded
  79823. * @param onError defines a callback called if there is an error
  79824. * @returns the cube texture as an InternalTexture
  79825. */
  79826. 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;
  79827. /**
  79828. * Creates a new raw cube texture from a specified url
  79829. * @param url defines the url where the data is located
  79830. * @param scene defines the current scene
  79831. * @param size defines the size of the textures
  79832. * @param format defines the format of the data
  79833. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79834. * @param noMipmap defines if the engine should avoid generating the mip levels
  79835. * @param callback defines a callback used to extract texture data from loaded data
  79836. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79837. * @param onLoad defines a callback called when texture is loaded
  79838. * @param onError defines a callback called if there is an error
  79839. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79840. * @param invertY defines if data must be stored with Y axis inverted
  79841. * @returns the cube texture as an InternalTexture
  79842. */
  79843. 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;
  79844. /**
  79845. * Creates a new raw 3D texture
  79846. * @param data defines the data used to create the texture
  79847. * @param width defines the width of the texture
  79848. * @param height defines the height of the texture
  79849. * @param depth defines the depth of the texture
  79850. * @param format defines the format of the texture
  79851. * @param generateMipMaps defines if the engine must generate mip levels
  79852. * @param invertY defines if data must be stored with Y axis inverted
  79853. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79854. * @param compression defines the compressed used (can be null)
  79855. * @param textureType defines the compressed used (can be null)
  79856. * @returns a new raw 3D texture (stored in an InternalTexture)
  79857. */
  79858. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79859. /**
  79860. * Update a raw 3D texture
  79861. * @param texture defines the texture to update
  79862. * @param data defines the data to store
  79863. * @param format defines the data format
  79864. * @param invertY defines if data must be stored with Y axis inverted
  79865. */
  79866. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79867. /**
  79868. * Update a raw 3D texture
  79869. * @param texture defines the texture to update
  79870. * @param data defines the data to store
  79871. * @param format defines the data format
  79872. * @param invertY defines if data must be stored with Y axis inverted
  79873. * @param compression defines the used compression (can be null)
  79874. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79875. */
  79876. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79877. }
  79878. }
  79879. declare module BABYLON {
  79880. /**
  79881. * Raw texture can help creating a texture directly from an array of data.
  79882. * This can be super useful if you either get the data from an uncompressed source or
  79883. * if you wish to create your texture pixel by pixel.
  79884. */
  79885. export class RawTexture extends Texture {
  79886. /**
  79887. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79888. */
  79889. format: number;
  79890. private _engine;
  79891. /**
  79892. * Instantiates a new RawTexture.
  79893. * Raw texture can help creating a texture directly from an array of data.
  79894. * This can be super useful if you either get the data from an uncompressed source or
  79895. * if you wish to create your texture pixel by pixel.
  79896. * @param data define the array of data to use to create the texture
  79897. * @param width define the width of the texture
  79898. * @param height define the height of the texture
  79899. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79900. * @param scene define the scene the texture belongs to
  79901. * @param generateMipMaps define whether mip maps should be generated or not
  79902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79904. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79905. */
  79906. constructor(data: ArrayBufferView, width: number, height: number,
  79907. /**
  79908. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79909. */
  79910. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79911. /**
  79912. * Updates the texture underlying data.
  79913. * @param data Define the new data of the texture
  79914. */
  79915. update(data: ArrayBufferView): void;
  79916. /**
  79917. * Creates a luminance texture from some data.
  79918. * @param data Define the texture data
  79919. * @param width Define the width of the texture
  79920. * @param height Define the height of the texture
  79921. * @param scene Define the scene the texture belongs to
  79922. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79923. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79924. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79925. * @returns the luminance texture
  79926. */
  79927. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79928. /**
  79929. * Creates a luminance alpha texture from some data.
  79930. * @param data Define the texture data
  79931. * @param width Define the width of the texture
  79932. * @param height Define the height of the texture
  79933. * @param scene Define the scene the texture belongs to
  79934. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79937. * @returns the luminance alpha texture
  79938. */
  79939. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79940. /**
  79941. * Creates an alpha texture from some data.
  79942. * @param data Define the texture data
  79943. * @param width Define the width of the texture
  79944. * @param height Define the height of the texture
  79945. * @param scene Define the scene the texture belongs to
  79946. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79947. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79948. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79949. * @returns the alpha texture
  79950. */
  79951. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79952. /**
  79953. * Creates a RGB texture from some data.
  79954. * @param data Define the texture data
  79955. * @param width Define the width of the texture
  79956. * @param height Define the height of the texture
  79957. * @param scene Define the scene the texture belongs to
  79958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79962. * @returns the RGB alpha texture
  79963. */
  79964. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79965. /**
  79966. * Creates a RGBA texture from some data.
  79967. * @param data Define the texture data
  79968. * @param width Define the width of the texture
  79969. * @param height Define the height of the texture
  79970. * @param scene Define the scene the texture belongs to
  79971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79974. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79975. * @returns the RGBA texture
  79976. */
  79977. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79978. /**
  79979. * Creates a R texture from some data.
  79980. * @param data Define the texture data
  79981. * @param width Define the width of the texture
  79982. * @param height Define the height of the texture
  79983. * @param scene Define the scene the texture belongs to
  79984. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79985. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79986. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79987. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79988. * @returns the R texture
  79989. */
  79990. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79991. }
  79992. }
  79993. declare module BABYLON {
  79994. /**
  79995. * Interface for the size containing width and height
  79996. */
  79997. export interface ISize {
  79998. /**
  79999. * Width
  80000. */
  80001. width: number;
  80002. /**
  80003. * Heighht
  80004. */
  80005. height: number;
  80006. }
  80007. /**
  80008. * Size containing widht and height
  80009. */
  80010. export class Size implements ISize {
  80011. /**
  80012. * Width
  80013. */
  80014. width: number;
  80015. /**
  80016. * Height
  80017. */
  80018. height: number;
  80019. /**
  80020. * Creates a Size object from the given width and height (floats).
  80021. * @param width width of the new size
  80022. * @param height height of the new size
  80023. */
  80024. constructor(width: number, height: number);
  80025. /**
  80026. * Returns a string with the Size width and height
  80027. * @returns a string with the Size width and height
  80028. */
  80029. toString(): string;
  80030. /**
  80031. * "Size"
  80032. * @returns the string "Size"
  80033. */
  80034. getClassName(): string;
  80035. /**
  80036. * Returns the Size hash code.
  80037. * @returns a hash code for a unique width and height
  80038. */
  80039. getHashCode(): number;
  80040. /**
  80041. * Updates the current size from the given one.
  80042. * @param src the given size
  80043. */
  80044. copyFrom(src: Size): void;
  80045. /**
  80046. * Updates in place the current Size from the given floats.
  80047. * @param width width of the new size
  80048. * @param height height of the new size
  80049. * @returns the updated Size.
  80050. */
  80051. copyFromFloats(width: number, height: number): Size;
  80052. /**
  80053. * Updates in place the current Size from the given floats.
  80054. * @param width width to set
  80055. * @param height height to set
  80056. * @returns the updated Size.
  80057. */
  80058. set(width: number, height: number): Size;
  80059. /**
  80060. * Multiplies the width and height by numbers
  80061. * @param w factor to multiple the width by
  80062. * @param h factor to multiple the height by
  80063. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80064. */
  80065. multiplyByFloats(w: number, h: number): Size;
  80066. /**
  80067. * Clones the size
  80068. * @returns a new Size copied from the given one.
  80069. */
  80070. clone(): Size;
  80071. /**
  80072. * True if the current Size and the given one width and height are strictly equal.
  80073. * @param other the other size to compare against
  80074. * @returns True if the current Size and the given one width and height are strictly equal.
  80075. */
  80076. equals(other: Size): boolean;
  80077. /**
  80078. * The surface of the Size : width * height (float).
  80079. */
  80080. readonly surface: number;
  80081. /**
  80082. * Create a new size of zero
  80083. * @returns a new Size set to (0.0, 0.0)
  80084. */
  80085. static Zero(): Size;
  80086. /**
  80087. * Sums the width and height of two sizes
  80088. * @param otherSize size to add to this size
  80089. * @returns a new Size set as the addition result of the current Size and the given one.
  80090. */
  80091. add(otherSize: Size): Size;
  80092. /**
  80093. * Subtracts the width and height of two
  80094. * @param otherSize size to subtract to this size
  80095. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80096. */
  80097. subtract(otherSize: Size): Size;
  80098. /**
  80099. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80100. * @param start starting size to lerp between
  80101. * @param end end size to lerp between
  80102. * @param amount amount to lerp between the start and end values
  80103. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80104. */
  80105. static Lerp(start: Size, end: Size, amount: number): Size;
  80106. }
  80107. }
  80108. declare module BABYLON {
  80109. /**
  80110. * Defines a runtime animation
  80111. */
  80112. export class RuntimeAnimation {
  80113. private _events;
  80114. /**
  80115. * The current frame of the runtime animation
  80116. */
  80117. private _currentFrame;
  80118. /**
  80119. * The animation used by the runtime animation
  80120. */
  80121. private _animation;
  80122. /**
  80123. * The target of the runtime animation
  80124. */
  80125. private _target;
  80126. /**
  80127. * The initiating animatable
  80128. */
  80129. private _host;
  80130. /**
  80131. * The original value of the runtime animation
  80132. */
  80133. private _originalValue;
  80134. /**
  80135. * The original blend value of the runtime animation
  80136. */
  80137. private _originalBlendValue;
  80138. /**
  80139. * The offsets cache of the runtime animation
  80140. */
  80141. private _offsetsCache;
  80142. /**
  80143. * The high limits cache of the runtime animation
  80144. */
  80145. private _highLimitsCache;
  80146. /**
  80147. * Specifies if the runtime animation has been stopped
  80148. */
  80149. private _stopped;
  80150. /**
  80151. * The blending factor of the runtime animation
  80152. */
  80153. private _blendingFactor;
  80154. /**
  80155. * The BabylonJS scene
  80156. */
  80157. private _scene;
  80158. /**
  80159. * The current value of the runtime animation
  80160. */
  80161. private _currentValue;
  80162. /** @hidden */
  80163. _animationState: _IAnimationState;
  80164. /**
  80165. * The active target of the runtime animation
  80166. */
  80167. private _activeTargets;
  80168. private _currentActiveTarget;
  80169. private _directTarget;
  80170. /**
  80171. * The target path of the runtime animation
  80172. */
  80173. private _targetPath;
  80174. /**
  80175. * The weight of the runtime animation
  80176. */
  80177. private _weight;
  80178. /**
  80179. * The ratio offset of the runtime animation
  80180. */
  80181. private _ratioOffset;
  80182. /**
  80183. * The previous delay of the runtime animation
  80184. */
  80185. private _previousDelay;
  80186. /**
  80187. * The previous ratio of the runtime animation
  80188. */
  80189. private _previousRatio;
  80190. private _enableBlending;
  80191. private _keys;
  80192. private _minFrame;
  80193. private _maxFrame;
  80194. private _minValue;
  80195. private _maxValue;
  80196. private _targetIsArray;
  80197. /**
  80198. * Gets the current frame of the runtime animation
  80199. */
  80200. readonly currentFrame: number;
  80201. /**
  80202. * Gets the weight of the runtime animation
  80203. */
  80204. readonly weight: number;
  80205. /**
  80206. * Gets the current value of the runtime animation
  80207. */
  80208. readonly currentValue: any;
  80209. /**
  80210. * Gets the target path of the runtime animation
  80211. */
  80212. readonly targetPath: string;
  80213. /**
  80214. * Gets the actual target of the runtime animation
  80215. */
  80216. readonly target: any;
  80217. /** @hidden */
  80218. _onLoop: () => void;
  80219. /**
  80220. * Create a new RuntimeAnimation object
  80221. * @param target defines the target of the animation
  80222. * @param animation defines the source animation object
  80223. * @param scene defines the hosting scene
  80224. * @param host defines the initiating Animatable
  80225. */
  80226. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80227. private _preparePath;
  80228. /**
  80229. * Gets the animation from the runtime animation
  80230. */
  80231. readonly animation: Animation;
  80232. /**
  80233. * Resets the runtime animation to the beginning
  80234. * @param restoreOriginal defines whether to restore the target property to the original value
  80235. */
  80236. reset(restoreOriginal?: boolean): void;
  80237. /**
  80238. * Specifies if the runtime animation is stopped
  80239. * @returns Boolean specifying if the runtime animation is stopped
  80240. */
  80241. isStopped(): boolean;
  80242. /**
  80243. * Disposes of the runtime animation
  80244. */
  80245. dispose(): void;
  80246. /**
  80247. * Apply the interpolated value to the target
  80248. * @param currentValue defines the value computed by the animation
  80249. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80250. */
  80251. setValue(currentValue: any, weight: number): void;
  80252. private _getOriginalValues;
  80253. private _setValue;
  80254. /**
  80255. * Gets the loop pmode of the runtime animation
  80256. * @returns Loop Mode
  80257. */
  80258. private _getCorrectLoopMode;
  80259. /**
  80260. * Move the current animation to a given frame
  80261. * @param frame defines the frame to move to
  80262. */
  80263. goToFrame(frame: number): void;
  80264. /**
  80265. * @hidden Internal use only
  80266. */
  80267. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80268. /**
  80269. * Execute the current animation
  80270. * @param delay defines the delay to add to the current frame
  80271. * @param from defines the lower bound of the animation range
  80272. * @param to defines the upper bound of the animation range
  80273. * @param loop defines if the current animation must loop
  80274. * @param speedRatio defines the current speed ratio
  80275. * @param weight defines the weight of the animation (default is -1 so no weight)
  80276. * @param onLoop optional callback called when animation loops
  80277. * @returns a boolean indicating if the animation is running
  80278. */
  80279. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80280. }
  80281. }
  80282. declare module BABYLON {
  80283. /**
  80284. * Class used to store an actual running animation
  80285. */
  80286. export class Animatable {
  80287. /** defines the target object */
  80288. target: any;
  80289. /** defines the starting frame number (default is 0) */
  80290. fromFrame: number;
  80291. /** defines the ending frame number (default is 100) */
  80292. toFrame: number;
  80293. /** defines if the animation must loop (default is false) */
  80294. loopAnimation: boolean;
  80295. /** defines a callback to call when animation ends if it is not looping */
  80296. onAnimationEnd?: (() => void) | null | undefined;
  80297. /** defines a callback to call when animation loops */
  80298. onAnimationLoop?: (() => void) | null | undefined;
  80299. private _localDelayOffset;
  80300. private _pausedDelay;
  80301. private _runtimeAnimations;
  80302. private _paused;
  80303. private _scene;
  80304. private _speedRatio;
  80305. private _weight;
  80306. private _syncRoot;
  80307. /**
  80308. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80309. * This will only apply for non looping animation (default is true)
  80310. */
  80311. disposeOnEnd: boolean;
  80312. /**
  80313. * Gets a boolean indicating if the animation has started
  80314. */
  80315. animationStarted: boolean;
  80316. /**
  80317. * Observer raised when the animation ends
  80318. */
  80319. onAnimationEndObservable: Observable<Animatable>;
  80320. /**
  80321. * Observer raised when the animation loops
  80322. */
  80323. onAnimationLoopObservable: Observable<Animatable>;
  80324. /**
  80325. * Gets the root Animatable used to synchronize and normalize animations
  80326. */
  80327. readonly syncRoot: Nullable<Animatable>;
  80328. /**
  80329. * Gets the current frame of the first RuntimeAnimation
  80330. * Used to synchronize Animatables
  80331. */
  80332. readonly masterFrame: number;
  80333. /**
  80334. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80335. */
  80336. weight: number;
  80337. /**
  80338. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80339. */
  80340. speedRatio: number;
  80341. /**
  80342. * Creates a new Animatable
  80343. * @param scene defines the hosting scene
  80344. * @param target defines the target object
  80345. * @param fromFrame defines the starting frame number (default is 0)
  80346. * @param toFrame defines the ending frame number (default is 100)
  80347. * @param loopAnimation defines if the animation must loop (default is false)
  80348. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80349. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80350. * @param animations defines a group of animation to add to the new Animatable
  80351. * @param onAnimationLoop defines a callback to call when animation loops
  80352. */
  80353. constructor(scene: Scene,
  80354. /** defines the target object */
  80355. target: any,
  80356. /** defines the starting frame number (default is 0) */
  80357. fromFrame?: number,
  80358. /** defines the ending frame number (default is 100) */
  80359. toFrame?: number,
  80360. /** defines if the animation must loop (default is false) */
  80361. loopAnimation?: boolean, speedRatio?: number,
  80362. /** defines a callback to call when animation ends if it is not looping */
  80363. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80364. /** defines a callback to call when animation loops */
  80365. onAnimationLoop?: (() => void) | null | undefined);
  80366. /**
  80367. * Synchronize and normalize current Animatable with a source Animatable
  80368. * This is useful when using animation weights and when animations are not of the same length
  80369. * @param root defines the root Animatable to synchronize with
  80370. * @returns the current Animatable
  80371. */
  80372. syncWith(root: Animatable): Animatable;
  80373. /**
  80374. * Gets the list of runtime animations
  80375. * @returns an array of RuntimeAnimation
  80376. */
  80377. getAnimations(): RuntimeAnimation[];
  80378. /**
  80379. * Adds more animations to the current animatable
  80380. * @param target defines the target of the animations
  80381. * @param animations defines the new animations to add
  80382. */
  80383. appendAnimations(target: any, animations: Animation[]): void;
  80384. /**
  80385. * Gets the source animation for a specific property
  80386. * @param property defines the propertyu to look for
  80387. * @returns null or the source animation for the given property
  80388. */
  80389. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80390. /**
  80391. * Gets the runtime animation for a specific property
  80392. * @param property defines the propertyu to look for
  80393. * @returns null or the runtime animation for the given property
  80394. */
  80395. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80396. /**
  80397. * Resets the animatable to its original state
  80398. */
  80399. reset(): void;
  80400. /**
  80401. * Allows the animatable to blend with current running animations
  80402. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80403. * @param blendingSpeed defines the blending speed to use
  80404. */
  80405. enableBlending(blendingSpeed: number): void;
  80406. /**
  80407. * Disable animation blending
  80408. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80409. */
  80410. disableBlending(): void;
  80411. /**
  80412. * Jump directly to a given frame
  80413. * @param frame defines the frame to jump to
  80414. */
  80415. goToFrame(frame: number): void;
  80416. /**
  80417. * Pause the animation
  80418. */
  80419. pause(): void;
  80420. /**
  80421. * Restart the animation
  80422. */
  80423. restart(): void;
  80424. private _raiseOnAnimationEnd;
  80425. /**
  80426. * Stop and delete the current animation
  80427. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80428. * @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)
  80429. */
  80430. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80431. /**
  80432. * Wait asynchronously for the animation to end
  80433. * @returns a promise which will be fullfilled when the animation ends
  80434. */
  80435. waitAsync(): Promise<Animatable>;
  80436. /** @hidden */
  80437. _animate(delay: number): boolean;
  80438. }
  80439. interface Scene {
  80440. /** @hidden */
  80441. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80442. /** @hidden */
  80443. _processLateAnimationBindingsForMatrices(holder: {
  80444. totalWeight: number;
  80445. animations: RuntimeAnimation[];
  80446. originalValue: Matrix;
  80447. }): any;
  80448. /** @hidden */
  80449. _processLateAnimationBindingsForQuaternions(holder: {
  80450. totalWeight: number;
  80451. animations: RuntimeAnimation[];
  80452. originalValue: Quaternion;
  80453. }, refQuaternion: Quaternion): Quaternion;
  80454. /** @hidden */
  80455. _processLateAnimationBindings(): void;
  80456. /**
  80457. * Will start the animation sequence of a given target
  80458. * @param target defines the target
  80459. * @param from defines from which frame should animation start
  80460. * @param to defines until which frame should animation run.
  80461. * @param weight defines the weight to apply to the animation (1.0 by default)
  80462. * @param loop defines if the animation loops
  80463. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80464. * @param onAnimationEnd defines the function to be executed when the animation ends
  80465. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80466. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80467. * @param onAnimationLoop defines the callback to call when an animation loops
  80468. * @returns the animatable object created for this animation
  80469. */
  80470. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80471. /**
  80472. * Will start the animation sequence of a given target
  80473. * @param target defines the target
  80474. * @param from defines from which frame should animation start
  80475. * @param to defines until which frame should animation run.
  80476. * @param loop defines if the animation loops
  80477. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80478. * @param onAnimationEnd defines the function to be executed when the animation ends
  80479. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80480. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80481. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80482. * @param onAnimationLoop defines the callback to call when an animation loops
  80483. * @returns the animatable object created for this animation
  80484. */
  80485. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80486. /**
  80487. * Will start the animation sequence of a given target and its hierarchy
  80488. * @param target defines the target
  80489. * @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.
  80490. * @param from defines from which frame should animation start
  80491. * @param to defines until which frame should animation run.
  80492. * @param loop defines if the animation loops
  80493. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80494. * @param onAnimationEnd defines the function to be executed when the animation ends
  80495. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80496. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80497. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80498. * @param onAnimationLoop defines the callback to call when an animation loops
  80499. * @returns the list of created animatables
  80500. */
  80501. 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[];
  80502. /**
  80503. * Begin a new animation on a given node
  80504. * @param target defines the target where the animation will take place
  80505. * @param animations defines the list of animations to start
  80506. * @param from defines the initial value
  80507. * @param to defines the final value
  80508. * @param loop defines if you want animation to loop (off by default)
  80509. * @param speedRatio defines the speed ratio to apply to all animations
  80510. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80511. * @param onAnimationLoop defines the callback to call when an animation loops
  80512. * @returns the list of created animatables
  80513. */
  80514. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80515. /**
  80516. * Begin a new animation on a given node and its hierarchy
  80517. * @param target defines the root node where the animation will take place
  80518. * @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.
  80519. * @param animations defines the list of animations to start
  80520. * @param from defines the initial value
  80521. * @param to defines the final value
  80522. * @param loop defines if you want animation to loop (off by default)
  80523. * @param speedRatio defines the speed ratio to apply to all animations
  80524. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80525. * @param onAnimationLoop defines the callback to call when an animation loops
  80526. * @returns the list of animatables created for all nodes
  80527. */
  80528. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80529. /**
  80530. * Gets the animatable associated with a specific target
  80531. * @param target defines the target of the animatable
  80532. * @returns the required animatable if found
  80533. */
  80534. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80535. /**
  80536. * Gets all animatables associated with a given target
  80537. * @param target defines the target to look animatables for
  80538. * @returns an array of Animatables
  80539. */
  80540. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80541. /**
  80542. * Stops and removes all animations that have been applied to the scene
  80543. */
  80544. stopAllAnimations(): void;
  80545. /**
  80546. * Gets the current delta time used by animation engine
  80547. */
  80548. deltaTime: number;
  80549. }
  80550. interface Bone {
  80551. /**
  80552. * Copy an animation range from another bone
  80553. * @param source defines the source bone
  80554. * @param rangeName defines the range name to copy
  80555. * @param frameOffset defines the frame offset
  80556. * @param rescaleAsRequired defines if rescaling must be applied if required
  80557. * @param skelDimensionsRatio defines the scaling ratio
  80558. * @returns true if operation was successful
  80559. */
  80560. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80561. }
  80562. }
  80563. declare module BABYLON {
  80564. /**
  80565. * Class used to override all child animations of a given target
  80566. */
  80567. export class AnimationPropertiesOverride {
  80568. /**
  80569. * Gets or sets a value indicating if animation blending must be used
  80570. */
  80571. enableBlending: boolean;
  80572. /**
  80573. * Gets or sets the blending speed to use when enableBlending is true
  80574. */
  80575. blendingSpeed: number;
  80576. /**
  80577. * Gets or sets the default loop mode to use
  80578. */
  80579. loopMode: number;
  80580. }
  80581. }
  80582. declare module BABYLON {
  80583. /**
  80584. * Class used to handle skinning animations
  80585. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80586. */
  80587. export class Skeleton implements IAnimatable {
  80588. /** defines the skeleton name */
  80589. name: string;
  80590. /** defines the skeleton Id */
  80591. id: string;
  80592. /**
  80593. * Defines the list of child bones
  80594. */
  80595. bones: Bone[];
  80596. /**
  80597. * Defines an estimate of the dimension of the skeleton at rest
  80598. */
  80599. dimensionsAtRest: Vector3;
  80600. /**
  80601. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  80602. */
  80603. needInitialSkinMatrix: boolean;
  80604. /**
  80605. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  80606. */
  80607. overrideMesh: Nullable<AbstractMesh>;
  80608. /**
  80609. * Gets the list of animations attached to this skeleton
  80610. */
  80611. animations: Array<Animation>;
  80612. private _scene;
  80613. private _isDirty;
  80614. private _transformMatrices;
  80615. private _transformMatrixTexture;
  80616. private _meshesWithPoseMatrix;
  80617. private _animatables;
  80618. private _identity;
  80619. private _synchronizedWithMesh;
  80620. private _ranges;
  80621. private _lastAbsoluteTransformsUpdateId;
  80622. private _canUseTextureForBones;
  80623. private _uniqueId;
  80624. /** @hidden */
  80625. _numBonesWithLinkedTransformNode: number;
  80626. /** @hidden */
  80627. _hasWaitingData: Nullable<boolean>;
  80628. /**
  80629. * Specifies if the skeleton should be serialized
  80630. */
  80631. doNotSerialize: boolean;
  80632. private _useTextureToStoreBoneMatrices;
  80633. /**
  80634. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  80635. * Please note that this option is not available if the hardware does not support it
  80636. */
  80637. useTextureToStoreBoneMatrices: boolean;
  80638. private _animationPropertiesOverride;
  80639. /**
  80640. * Gets or sets the animation properties override
  80641. */
  80642. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80643. /**
  80644. * List of inspectable custom properties (used by the Inspector)
  80645. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80646. */
  80647. inspectableCustomProperties: IInspectable[];
  80648. /**
  80649. * An observable triggered before computing the skeleton's matrices
  80650. */
  80651. onBeforeComputeObservable: Observable<Skeleton>;
  80652. /**
  80653. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80654. */
  80655. readonly isUsingTextureForMatrices: boolean;
  80656. /**
  80657. * Gets the unique ID of this skeleton
  80658. */
  80659. readonly uniqueId: number;
  80660. /**
  80661. * Creates a new skeleton
  80662. * @param name defines the skeleton name
  80663. * @param id defines the skeleton Id
  80664. * @param scene defines the hosting scene
  80665. */
  80666. constructor(
  80667. /** defines the skeleton name */
  80668. name: string,
  80669. /** defines the skeleton Id */
  80670. id: string, scene: Scene);
  80671. /**
  80672. * Gets the current object class name.
  80673. * @return the class name
  80674. */
  80675. getClassName(): string;
  80676. /**
  80677. * Returns an array containing the root bones
  80678. * @returns an array containing the root bones
  80679. */
  80680. getChildren(): Array<Bone>;
  80681. /**
  80682. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80683. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80684. * @returns a Float32Array containing matrices data
  80685. */
  80686. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80687. /**
  80688. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80689. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80690. * @returns a raw texture containing the data
  80691. */
  80692. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80693. /**
  80694. * Gets the current hosting scene
  80695. * @returns a scene object
  80696. */
  80697. getScene(): Scene;
  80698. /**
  80699. * Gets a string representing the current skeleton data
  80700. * @param fullDetails defines a boolean indicating if we want a verbose version
  80701. * @returns a string representing the current skeleton data
  80702. */
  80703. toString(fullDetails?: boolean): string;
  80704. /**
  80705. * Get bone's index searching by name
  80706. * @param name defines bone's name to search for
  80707. * @return the indice of the bone. Returns -1 if not found
  80708. */
  80709. getBoneIndexByName(name: string): number;
  80710. /**
  80711. * Creater a new animation range
  80712. * @param name defines the name of the range
  80713. * @param from defines the start key
  80714. * @param to defines the end key
  80715. */
  80716. createAnimationRange(name: string, from: number, to: number): void;
  80717. /**
  80718. * Delete a specific animation range
  80719. * @param name defines the name of the range
  80720. * @param deleteFrames defines if frames must be removed as well
  80721. */
  80722. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80723. /**
  80724. * Gets a specific animation range
  80725. * @param name defines the name of the range to look for
  80726. * @returns the requested animation range or null if not found
  80727. */
  80728. getAnimationRange(name: string): Nullable<AnimationRange>;
  80729. /**
  80730. * Gets the list of all animation ranges defined on this skeleton
  80731. * @returns an array
  80732. */
  80733. getAnimationRanges(): Nullable<AnimationRange>[];
  80734. /**
  80735. * Copy animation range from a source skeleton.
  80736. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80737. * @param source defines the source skeleton
  80738. * @param name defines the name of the range to copy
  80739. * @param rescaleAsRequired defines if rescaling must be applied if required
  80740. * @returns true if operation was successful
  80741. */
  80742. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80743. /**
  80744. * Forces the skeleton to go to rest pose
  80745. */
  80746. returnToRest(): void;
  80747. private _getHighestAnimationFrame;
  80748. /**
  80749. * Begin a specific animation range
  80750. * @param name defines the name of the range to start
  80751. * @param loop defines if looping must be turned on (false by default)
  80752. * @param speedRatio defines the speed ratio to apply (1 by default)
  80753. * @param onAnimationEnd defines a callback which will be called when animation will end
  80754. * @returns a new animatable
  80755. */
  80756. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80757. /** @hidden */
  80758. _markAsDirty(): void;
  80759. /** @hidden */
  80760. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80761. /** @hidden */
  80762. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80763. private _computeTransformMatrices;
  80764. /**
  80765. * Build all resources required to render a skeleton
  80766. */
  80767. prepare(): void;
  80768. /**
  80769. * Gets the list of animatables currently running for this skeleton
  80770. * @returns an array of animatables
  80771. */
  80772. getAnimatables(): IAnimatable[];
  80773. /**
  80774. * Clone the current skeleton
  80775. * @param name defines the name of the new skeleton
  80776. * @param id defines the id of the new skeleton
  80777. * @returns the new skeleton
  80778. */
  80779. clone(name: string, id: string): Skeleton;
  80780. /**
  80781. * Enable animation blending for this skeleton
  80782. * @param blendingSpeed defines the blending speed to apply
  80783. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80784. */
  80785. enableBlending(blendingSpeed?: number): void;
  80786. /**
  80787. * Releases all resources associated with the current skeleton
  80788. */
  80789. dispose(): void;
  80790. /**
  80791. * Serialize the skeleton in a JSON object
  80792. * @returns a JSON object
  80793. */
  80794. serialize(): any;
  80795. /**
  80796. * Creates a new skeleton from serialized data
  80797. * @param parsedSkeleton defines the serialized data
  80798. * @param scene defines the hosting scene
  80799. * @returns a new skeleton
  80800. */
  80801. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80802. /**
  80803. * Compute all node absolute transforms
  80804. * @param forceUpdate defines if computation must be done even if cache is up to date
  80805. */
  80806. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80807. /**
  80808. * Gets the root pose matrix
  80809. * @returns a matrix
  80810. */
  80811. getPoseMatrix(): Nullable<Matrix>;
  80812. /**
  80813. * Sorts bones per internal index
  80814. */
  80815. sortBones(): void;
  80816. private _sortBones;
  80817. }
  80818. }
  80819. declare module BABYLON {
  80820. /**
  80821. * Class used to store bone information
  80822. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80823. */
  80824. export class Bone extends Node {
  80825. /**
  80826. * defines the bone name
  80827. */
  80828. name: string;
  80829. private static _tmpVecs;
  80830. private static _tmpQuat;
  80831. private static _tmpMats;
  80832. /**
  80833. * Gets the list of child bones
  80834. */
  80835. children: Bone[];
  80836. /** Gets the animations associated with this bone */
  80837. animations: Animation[];
  80838. /**
  80839. * Gets or sets bone length
  80840. */
  80841. length: number;
  80842. /**
  80843. * @hidden Internal only
  80844. * Set this value to map this bone to a different index in the transform matrices
  80845. * Set this value to -1 to exclude the bone from the transform matrices
  80846. */
  80847. _index: Nullable<number>;
  80848. private _skeleton;
  80849. private _localMatrix;
  80850. private _restPose;
  80851. private _baseMatrix;
  80852. private _absoluteTransform;
  80853. private _invertedAbsoluteTransform;
  80854. private _parent;
  80855. private _scalingDeterminant;
  80856. private _worldTransform;
  80857. private _localScaling;
  80858. private _localRotation;
  80859. private _localPosition;
  80860. private _needToDecompose;
  80861. private _needToCompose;
  80862. /** @hidden */
  80863. _linkedTransformNode: Nullable<TransformNode>;
  80864. /** @hidden */
  80865. _waitingTransformNodeId: Nullable<string>;
  80866. /** @hidden */
  80867. /** @hidden */
  80868. _matrix: Matrix;
  80869. /**
  80870. * Create a new bone
  80871. * @param name defines the bone name
  80872. * @param skeleton defines the parent skeleton
  80873. * @param parentBone defines the parent (can be null if the bone is the root)
  80874. * @param localMatrix defines the local matrix
  80875. * @param restPose defines the rest pose matrix
  80876. * @param baseMatrix defines the base matrix
  80877. * @param index defines index of the bone in the hiearchy
  80878. */
  80879. constructor(
  80880. /**
  80881. * defines the bone name
  80882. */
  80883. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80884. /**
  80885. * Gets the current object class name.
  80886. * @return the class name
  80887. */
  80888. getClassName(): string;
  80889. /**
  80890. * Gets the parent skeleton
  80891. * @returns a skeleton
  80892. */
  80893. getSkeleton(): Skeleton;
  80894. /**
  80895. * Gets parent bone
  80896. * @returns a bone or null if the bone is the root of the bone hierarchy
  80897. */
  80898. getParent(): Nullable<Bone>;
  80899. /**
  80900. * Returns an array containing the root bones
  80901. * @returns an array containing the root bones
  80902. */
  80903. getChildren(): Array<Bone>;
  80904. /**
  80905. * Sets the parent bone
  80906. * @param parent defines the parent (can be null if the bone is the root)
  80907. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80908. */
  80909. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80910. /**
  80911. * Gets the local matrix
  80912. * @returns a matrix
  80913. */
  80914. getLocalMatrix(): Matrix;
  80915. /**
  80916. * Gets the base matrix (initial matrix which remains unchanged)
  80917. * @returns a matrix
  80918. */
  80919. getBaseMatrix(): Matrix;
  80920. /**
  80921. * Gets the rest pose matrix
  80922. * @returns a matrix
  80923. */
  80924. getRestPose(): Matrix;
  80925. /**
  80926. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80927. */
  80928. getWorldMatrix(): Matrix;
  80929. /**
  80930. * Sets the local matrix to rest pose matrix
  80931. */
  80932. returnToRest(): void;
  80933. /**
  80934. * Gets the inverse of the absolute transform matrix.
  80935. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80936. * @returns a matrix
  80937. */
  80938. getInvertedAbsoluteTransform(): Matrix;
  80939. /**
  80940. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80941. * @returns a matrix
  80942. */
  80943. getAbsoluteTransform(): Matrix;
  80944. /**
  80945. * Links with the given transform node.
  80946. * The local matrix of this bone is copied from the transform node every frame.
  80947. * @param transformNode defines the transform node to link to
  80948. */
  80949. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80950. /**
  80951. * Gets the node used to drive the bone's transformation
  80952. * @returns a transform node or null
  80953. */
  80954. getTransformNode(): Nullable<TransformNode>;
  80955. /** Gets or sets current position (in local space) */
  80956. position: Vector3;
  80957. /** Gets or sets current rotation (in local space) */
  80958. rotation: Vector3;
  80959. /** Gets or sets current rotation quaternion (in local space) */
  80960. rotationQuaternion: Quaternion;
  80961. /** Gets or sets current scaling (in local space) */
  80962. scaling: Vector3;
  80963. /**
  80964. * Gets the animation properties override
  80965. */
  80966. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80967. private _decompose;
  80968. private _compose;
  80969. /**
  80970. * Update the base and local matrices
  80971. * @param matrix defines the new base or local matrix
  80972. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80973. * @param updateLocalMatrix defines if the local matrix should be updated
  80974. */
  80975. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80976. /** @hidden */
  80977. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80978. /**
  80979. * Flag the bone as dirty (Forcing it to update everything)
  80980. */
  80981. markAsDirty(): void;
  80982. /** @hidden */
  80983. _markAsDirtyAndCompose(): void;
  80984. private _markAsDirtyAndDecompose;
  80985. /**
  80986. * Translate the bone in local or world space
  80987. * @param vec The amount to translate the bone
  80988. * @param space The space that the translation is in
  80989. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80990. */
  80991. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80992. /**
  80993. * Set the postion of the bone in local or world space
  80994. * @param position The position to set the bone
  80995. * @param space The space that the position is in
  80996. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80997. */
  80998. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80999. /**
  81000. * Set the absolute position of the bone (world space)
  81001. * @param position The position to set the bone
  81002. * @param mesh The mesh that this bone is attached to
  81003. */
  81004. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81005. /**
  81006. * Scale the bone on the x, y and z axes (in local space)
  81007. * @param x The amount to scale the bone on the x axis
  81008. * @param y The amount to scale the bone on the y axis
  81009. * @param z The amount to scale the bone on the z axis
  81010. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81011. */
  81012. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81013. /**
  81014. * Set the bone scaling in local space
  81015. * @param scale defines the scaling vector
  81016. */
  81017. setScale(scale: Vector3): void;
  81018. /**
  81019. * Gets the current scaling in local space
  81020. * @returns the current scaling vector
  81021. */
  81022. getScale(): Vector3;
  81023. /**
  81024. * Gets the current scaling in local space and stores it in a target vector
  81025. * @param result defines the target vector
  81026. */
  81027. getScaleToRef(result: Vector3): void;
  81028. /**
  81029. * Set the yaw, pitch, and roll of the bone in local or world space
  81030. * @param yaw The rotation of the bone on the y axis
  81031. * @param pitch The rotation of the bone on the x axis
  81032. * @param roll The rotation of the bone on the z axis
  81033. * @param space The space that the axes of rotation are in
  81034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81035. */
  81036. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81037. /**
  81038. * Add a rotation to the bone on an axis in local or world space
  81039. * @param axis The axis to rotate the bone on
  81040. * @param amount The amount to rotate the bone
  81041. * @param space The space that the axis is in
  81042. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81043. */
  81044. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81045. /**
  81046. * Set the rotation of the bone to a particular axis angle in local or world space
  81047. * @param axis The axis to rotate the bone on
  81048. * @param angle The angle that the bone should be rotated to
  81049. * @param space The space that the axis is in
  81050. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81051. */
  81052. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81053. /**
  81054. * Set the euler rotation of the bone in local of world space
  81055. * @param rotation The euler rotation that the bone should be set to
  81056. * @param space The space that the rotation is in
  81057. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81058. */
  81059. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81060. /**
  81061. * Set the quaternion rotation of the bone in local of world space
  81062. * @param quat The quaternion rotation that the bone should be set to
  81063. * @param space The space that the rotation is in
  81064. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81065. */
  81066. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81067. /**
  81068. * Set the rotation matrix of the bone in local of world space
  81069. * @param rotMat The rotation matrix that the bone should be set to
  81070. * @param space The space that the rotation is in
  81071. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81072. */
  81073. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81074. private _rotateWithMatrix;
  81075. private _getNegativeRotationToRef;
  81076. /**
  81077. * Get the position of the bone in local or world space
  81078. * @param space The space that the returned position is in
  81079. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81080. * @returns The position of the bone
  81081. */
  81082. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81083. /**
  81084. * Copy the position of the bone to a vector3 in local or world space
  81085. * @param space The space that the returned position is in
  81086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81087. * @param result The vector3 to copy the position to
  81088. */
  81089. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81090. /**
  81091. * Get the absolute position of the bone (world space)
  81092. * @param mesh The mesh that this bone is attached to
  81093. * @returns The absolute position of the bone
  81094. */
  81095. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81096. /**
  81097. * Copy the absolute position of the bone (world space) to the result param
  81098. * @param mesh The mesh that this bone is attached to
  81099. * @param result The vector3 to copy the absolute position to
  81100. */
  81101. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81102. /**
  81103. * Compute the absolute transforms of this bone and its children
  81104. */
  81105. computeAbsoluteTransforms(): void;
  81106. /**
  81107. * Get the world direction from an axis that is in the local space of the bone
  81108. * @param localAxis The local direction that is used to compute the world direction
  81109. * @param mesh The mesh that this bone is attached to
  81110. * @returns The world direction
  81111. */
  81112. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81113. /**
  81114. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81115. * @param localAxis The local direction that is used to compute the world direction
  81116. * @param mesh The mesh that this bone is attached to
  81117. * @param result The vector3 that the world direction will be copied to
  81118. */
  81119. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81120. /**
  81121. * Get the euler rotation of the bone in local or world space
  81122. * @param space The space that the rotation should be in
  81123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81124. * @returns The euler rotation
  81125. */
  81126. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81127. /**
  81128. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81129. * @param space The space that the rotation should be in
  81130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81131. * @param result The vector3 that the rotation should be copied to
  81132. */
  81133. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81134. /**
  81135. * Get the quaternion rotation of the bone in either local or world space
  81136. * @param space The space that the rotation should be in
  81137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81138. * @returns The quaternion rotation
  81139. */
  81140. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  81141. /**
  81142. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  81143. * @param space The space that the rotation should be in
  81144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81145. * @param result The quaternion that the rotation should be copied to
  81146. */
  81147. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  81148. /**
  81149. * Get the rotation matrix of the bone in local or world space
  81150. * @param space The space that the rotation should be in
  81151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81152. * @returns The rotation matrix
  81153. */
  81154. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  81155. /**
  81156. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  81157. * @param space The space that the rotation should be in
  81158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81159. * @param result The quaternion that the rotation should be copied to
  81160. */
  81161. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  81162. /**
  81163. * Get the world position of a point that is in the local space of the bone
  81164. * @param position The local position
  81165. * @param mesh The mesh that this bone is attached to
  81166. * @returns The world position
  81167. */
  81168. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81169. /**
  81170. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  81171. * @param position The local position
  81172. * @param mesh The mesh that this bone is attached to
  81173. * @param result The vector3 that the world position should be copied to
  81174. */
  81175. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81176. /**
  81177. * Get the local position of a point that is in world space
  81178. * @param position The world position
  81179. * @param mesh The mesh that this bone is attached to
  81180. * @returns The local position
  81181. */
  81182. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81183. /**
  81184. * Get the local position of a point that is in world space and copy it to the result param
  81185. * @param position The world position
  81186. * @param mesh The mesh that this bone is attached to
  81187. * @param result The vector3 that the local position should be copied to
  81188. */
  81189. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81190. }
  81191. }
  81192. declare module BABYLON {
  81193. /**
  81194. * 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.
  81195. * @see https://doc.babylonjs.com/how_to/transformnode
  81196. */
  81197. export class TransformNode extends Node {
  81198. /**
  81199. * Object will not rotate to face the camera
  81200. */
  81201. static BILLBOARDMODE_NONE: number;
  81202. /**
  81203. * Object will rotate to face the camera but only on the x axis
  81204. */
  81205. static BILLBOARDMODE_X: number;
  81206. /**
  81207. * Object will rotate to face the camera but only on the y axis
  81208. */
  81209. static BILLBOARDMODE_Y: number;
  81210. /**
  81211. * Object will rotate to face the camera but only on the z axis
  81212. */
  81213. static BILLBOARDMODE_Z: number;
  81214. /**
  81215. * Object will rotate to face the camera
  81216. */
  81217. static BILLBOARDMODE_ALL: number;
  81218. /**
  81219. * Object will rotate to face the camera's position instead of orientation
  81220. */
  81221. static BILLBOARDMODE_USE_POSITION: number;
  81222. private _forward;
  81223. private _forwardInverted;
  81224. private _up;
  81225. private _right;
  81226. private _rightInverted;
  81227. private _position;
  81228. private _rotation;
  81229. private _rotationQuaternion;
  81230. protected _scaling: Vector3;
  81231. protected _isDirty: boolean;
  81232. private _transformToBoneReferal;
  81233. private _isAbsoluteSynced;
  81234. private _billboardMode;
  81235. /**
  81236. * Gets or sets the billboard mode. Default is 0.
  81237. *
  81238. * | Value | Type | Description |
  81239. * | --- | --- | --- |
  81240. * | 0 | BILLBOARDMODE_NONE | |
  81241. * | 1 | BILLBOARDMODE_X | |
  81242. * | 2 | BILLBOARDMODE_Y | |
  81243. * | 4 | BILLBOARDMODE_Z | |
  81244. * | 7 | BILLBOARDMODE_ALL | |
  81245. *
  81246. */
  81247. billboardMode: number;
  81248. private _preserveParentRotationForBillboard;
  81249. /**
  81250. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81251. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81252. */
  81253. preserveParentRotationForBillboard: boolean;
  81254. /**
  81255. * 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
  81256. */
  81257. scalingDeterminant: number;
  81258. private _infiniteDistance;
  81259. /**
  81260. * Gets or sets the distance of the object to max, often used by skybox
  81261. */
  81262. infiniteDistance: boolean;
  81263. /**
  81264. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81265. * By default the system will update normals to compensate
  81266. */
  81267. ignoreNonUniformScaling: boolean;
  81268. /**
  81269. * 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
  81270. */
  81271. reIntegrateRotationIntoRotationQuaternion: boolean;
  81272. /** @hidden */
  81273. _poseMatrix: Nullable<Matrix>;
  81274. /** @hidden */
  81275. _localMatrix: Matrix;
  81276. private _usePivotMatrix;
  81277. private _absolutePosition;
  81278. private _absoluteScaling;
  81279. private _absoluteRotationQuaternion;
  81280. private _pivotMatrix;
  81281. private _pivotMatrixInverse;
  81282. protected _postMultiplyPivotMatrix: boolean;
  81283. protected _isWorldMatrixFrozen: boolean;
  81284. /** @hidden */
  81285. _indexInSceneTransformNodesArray: number;
  81286. /**
  81287. * An event triggered after the world matrix is updated
  81288. */
  81289. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81290. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81291. /**
  81292. * Gets a string identifying the name of the class
  81293. * @returns "TransformNode" string
  81294. */
  81295. getClassName(): string;
  81296. /**
  81297. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81298. */
  81299. position: Vector3;
  81300. /**
  81301. * 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)).
  81302. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81303. */
  81304. rotation: Vector3;
  81305. /**
  81306. * 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)).
  81307. */
  81308. scaling: Vector3;
  81309. /**
  81310. * 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).
  81311. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81312. */
  81313. rotationQuaternion: Nullable<Quaternion>;
  81314. /**
  81315. * The forward direction of that transform in world space.
  81316. */
  81317. readonly forward: Vector3;
  81318. /**
  81319. * The up direction of that transform in world space.
  81320. */
  81321. readonly up: Vector3;
  81322. /**
  81323. * The right direction of that transform in world space.
  81324. */
  81325. readonly right: Vector3;
  81326. /**
  81327. * Copies the parameter passed Matrix into the mesh Pose matrix.
  81328. * @param matrix the matrix to copy the pose from
  81329. * @returns this TransformNode.
  81330. */
  81331. updatePoseMatrix(matrix: Matrix): TransformNode;
  81332. /**
  81333. * Returns the mesh Pose matrix.
  81334. * @returns the pose matrix
  81335. */
  81336. getPoseMatrix(): Matrix;
  81337. /** @hidden */
  81338. _isSynchronized(): boolean;
  81339. /** @hidden */
  81340. _initCache(): void;
  81341. /**
  81342. * Flag the transform node as dirty (Forcing it to update everything)
  81343. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  81344. * @returns this transform node
  81345. */
  81346. markAsDirty(property: string): TransformNode;
  81347. /**
  81348. * Returns the current mesh absolute position.
  81349. * Returns a Vector3.
  81350. */
  81351. readonly absolutePosition: Vector3;
  81352. /**
  81353. * Returns the current mesh absolute scaling.
  81354. * Returns a Vector3.
  81355. */
  81356. readonly absoluteScaling: Vector3;
  81357. /**
  81358. * Returns the current mesh absolute rotation.
  81359. * Returns a Quaternion.
  81360. */
  81361. readonly absoluteRotationQuaternion: Quaternion;
  81362. /**
  81363. * Sets a new matrix to apply before all other transformation
  81364. * @param matrix defines the transform matrix
  81365. * @returns the current TransformNode
  81366. */
  81367. setPreTransformMatrix(matrix: Matrix): TransformNode;
  81368. /**
  81369. * Sets a new pivot matrix to the current node
  81370. * @param matrix defines the new pivot matrix to use
  81371. * @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
  81372. * @returns the current TransformNode
  81373. */
  81374. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  81375. /**
  81376. * Returns the mesh pivot matrix.
  81377. * Default : Identity.
  81378. * @returns the matrix
  81379. */
  81380. getPivotMatrix(): Matrix;
  81381. /**
  81382. * Instantiate (when possible) or clone that node with its hierarchy
  81383. * @param newParent defines the new parent to use for the instance (or clone)
  81384. * @returns an instance (or a clone) of the current node with its hiearchy
  81385. */
  81386. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  81387. /**
  81388. * Prevents the World matrix to be computed any longer
  81389. * @param newWorldMatrix defines an optional matrix to use as world matrix
  81390. * @returns the TransformNode.
  81391. */
  81392. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  81393. /**
  81394. * Allows back the World matrix computation.
  81395. * @returns the TransformNode.
  81396. */
  81397. unfreezeWorldMatrix(): this;
  81398. /**
  81399. * True if the World matrix has been frozen.
  81400. */
  81401. readonly isWorldMatrixFrozen: boolean;
  81402. /**
  81403. * Retuns the mesh absolute position in the World.
  81404. * @returns a Vector3.
  81405. */
  81406. getAbsolutePosition(): Vector3;
  81407. /**
  81408. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  81409. * @param absolutePosition the absolute position to set
  81410. * @returns the TransformNode.
  81411. */
  81412. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  81413. /**
  81414. * Sets the mesh position in its local space.
  81415. * @param vector3 the position to set in localspace
  81416. * @returns the TransformNode.
  81417. */
  81418. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  81419. /**
  81420. * Returns the mesh position in the local space from the current World matrix values.
  81421. * @returns a new Vector3.
  81422. */
  81423. getPositionExpressedInLocalSpace(): Vector3;
  81424. /**
  81425. * Translates the mesh along the passed Vector3 in its local space.
  81426. * @param vector3 the distance to translate in localspace
  81427. * @returns the TransformNode.
  81428. */
  81429. locallyTranslate(vector3: Vector3): TransformNode;
  81430. private static _lookAtVectorCache;
  81431. /**
  81432. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  81433. * @param targetPoint the position (must be in same space as current mesh) to look at
  81434. * @param yawCor optional yaw (y-axis) correction in radians
  81435. * @param pitchCor optional pitch (x-axis) correction in radians
  81436. * @param rollCor optional roll (z-axis) correction in radians
  81437. * @param space the choosen space of the target
  81438. * @returns the TransformNode.
  81439. */
  81440. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  81441. /**
  81442. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81443. * This Vector3 is expressed in the World space.
  81444. * @param localAxis axis to rotate
  81445. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81446. */
  81447. getDirection(localAxis: Vector3): Vector3;
  81448. /**
  81449. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  81450. * localAxis is expressed in the mesh local space.
  81451. * result is computed in the Wordl space from the mesh World matrix.
  81452. * @param localAxis axis to rotate
  81453. * @param result the resulting transformnode
  81454. * @returns this TransformNode.
  81455. */
  81456. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  81457. /**
  81458. * Sets this transform node rotation to the given local axis.
  81459. * @param localAxis the axis in local space
  81460. * @param yawCor optional yaw (y-axis) correction in radians
  81461. * @param pitchCor optional pitch (x-axis) correction in radians
  81462. * @param rollCor optional roll (z-axis) correction in radians
  81463. * @returns this TransformNode
  81464. */
  81465. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  81466. /**
  81467. * Sets a new pivot point to the current node
  81468. * @param point defines the new pivot point to use
  81469. * @param space defines if the point is in world or local space (local by default)
  81470. * @returns the current TransformNode
  81471. */
  81472. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  81473. /**
  81474. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  81475. * @returns the pivot point
  81476. */
  81477. getPivotPoint(): Vector3;
  81478. /**
  81479. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  81480. * @param result the vector3 to store the result
  81481. * @returns this TransformNode.
  81482. */
  81483. getPivotPointToRef(result: Vector3): TransformNode;
  81484. /**
  81485. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  81486. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  81487. */
  81488. getAbsolutePivotPoint(): Vector3;
  81489. /**
  81490. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  81491. * @param result vector3 to store the result
  81492. * @returns this TransformNode.
  81493. */
  81494. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  81495. /**
  81496. * Defines the passed node as the parent of the current node.
  81497. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  81498. * @see https://doc.babylonjs.com/how_to/parenting
  81499. * @param node the node ot set as the parent
  81500. * @returns this TransformNode.
  81501. */
  81502. setParent(node: Nullable<Node>): TransformNode;
  81503. private _nonUniformScaling;
  81504. /**
  81505. * True if the scaling property of this object is non uniform eg. (1,2,1)
  81506. */
  81507. readonly nonUniformScaling: boolean;
  81508. /** @hidden */
  81509. _updateNonUniformScalingState(value: boolean): boolean;
  81510. /**
  81511. * Attach the current TransformNode to another TransformNode associated with a bone
  81512. * @param bone Bone affecting the TransformNode
  81513. * @param affectedTransformNode TransformNode associated with the bone
  81514. * @returns this object
  81515. */
  81516. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  81517. /**
  81518. * Detach the transform node if its associated with a bone
  81519. * @returns this object
  81520. */
  81521. detachFromBone(): TransformNode;
  81522. private static _rotationAxisCache;
  81523. /**
  81524. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  81525. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81526. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81527. * The passed axis is also normalized.
  81528. * @param axis the axis to rotate around
  81529. * @param amount the amount to rotate in radians
  81530. * @param space Space to rotate in (Default: local)
  81531. * @returns the TransformNode.
  81532. */
  81533. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  81534. /**
  81535. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  81536. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81537. * The passed axis is also normalized. .
  81538. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  81539. * @param point the point to rotate around
  81540. * @param axis the axis to rotate around
  81541. * @param amount the amount to rotate in radians
  81542. * @returns the TransformNode
  81543. */
  81544. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  81545. /**
  81546. * Translates the mesh along the axis vector for the passed distance in the given space.
  81547. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81548. * @param axis the axis to translate in
  81549. * @param distance the distance to translate
  81550. * @param space Space to rotate in (Default: local)
  81551. * @returns the TransformNode.
  81552. */
  81553. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  81554. /**
  81555. * Adds a rotation step to the mesh current rotation.
  81556. * x, y, z are Euler angles expressed in radians.
  81557. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  81558. * This means this rotation is made in the mesh local space only.
  81559. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  81560. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  81561. * ```javascript
  81562. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  81563. * ```
  81564. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  81565. * 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.
  81566. * @param x Rotation to add
  81567. * @param y Rotation to add
  81568. * @param z Rotation to add
  81569. * @returns the TransformNode.
  81570. */
  81571. addRotation(x: number, y: number, z: number): TransformNode;
  81572. /**
  81573. * @hidden
  81574. */
  81575. protected _getEffectiveParent(): Nullable<Node>;
  81576. /**
  81577. * Computes the world matrix of the node
  81578. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81579. * @returns the world matrix
  81580. */
  81581. computeWorldMatrix(force?: boolean): Matrix;
  81582. protected _afterComputeWorldMatrix(): void;
  81583. /**
  81584. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  81585. * @param func callback function to add
  81586. *
  81587. * @returns the TransformNode.
  81588. */
  81589. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81590. /**
  81591. * Removes a registered callback function.
  81592. * @param func callback function to remove
  81593. * @returns the TransformNode.
  81594. */
  81595. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81596. /**
  81597. * Gets the position of the current mesh in camera space
  81598. * @param camera defines the camera to use
  81599. * @returns a position
  81600. */
  81601. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  81602. /**
  81603. * Returns the distance from the mesh to the active camera
  81604. * @param camera defines the camera to use
  81605. * @returns the distance
  81606. */
  81607. getDistanceToCamera(camera?: Nullable<Camera>): number;
  81608. /**
  81609. * Clone the current transform node
  81610. * @param name Name of the new clone
  81611. * @param newParent New parent for the clone
  81612. * @param doNotCloneChildren Do not clone children hierarchy
  81613. * @returns the new transform node
  81614. */
  81615. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  81616. /**
  81617. * Serializes the objects information.
  81618. * @param currentSerializationObject defines the object to serialize in
  81619. * @returns the serialized object
  81620. */
  81621. serialize(currentSerializationObject?: any): any;
  81622. /**
  81623. * Returns a new TransformNode object parsed from the source provided.
  81624. * @param parsedTransformNode is the source.
  81625. * @param scene the scne the object belongs to
  81626. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  81627. * @returns a new TransformNode object parsed from the source provided.
  81628. */
  81629. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  81630. /**
  81631. * Get all child-transformNodes of this node
  81632. * @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
  81633. * @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
  81634. * @returns an array of TransformNode
  81635. */
  81636. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  81637. /**
  81638. * Releases resources associated with this transform node.
  81639. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81640. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81641. */
  81642. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81643. /**
  81644. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81645. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81646. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81647. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81648. * @returns the current mesh
  81649. */
  81650. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81651. private _syncAbsoluteScalingAndRotation;
  81652. }
  81653. }
  81654. declare module BABYLON {
  81655. /**
  81656. * Defines the types of pose enabled controllers that are supported
  81657. */
  81658. export enum PoseEnabledControllerType {
  81659. /**
  81660. * HTC Vive
  81661. */
  81662. VIVE = 0,
  81663. /**
  81664. * Oculus Rift
  81665. */
  81666. OCULUS = 1,
  81667. /**
  81668. * Windows mixed reality
  81669. */
  81670. WINDOWS = 2,
  81671. /**
  81672. * Samsung gear VR
  81673. */
  81674. GEAR_VR = 3,
  81675. /**
  81676. * Google Daydream
  81677. */
  81678. DAYDREAM = 4,
  81679. /**
  81680. * Generic
  81681. */
  81682. GENERIC = 5
  81683. }
  81684. /**
  81685. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81686. */
  81687. export interface MutableGamepadButton {
  81688. /**
  81689. * Value of the button/trigger
  81690. */
  81691. value: number;
  81692. /**
  81693. * If the button/trigger is currently touched
  81694. */
  81695. touched: boolean;
  81696. /**
  81697. * If the button/trigger is currently pressed
  81698. */
  81699. pressed: boolean;
  81700. }
  81701. /**
  81702. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81703. * @hidden
  81704. */
  81705. export interface ExtendedGamepadButton extends GamepadButton {
  81706. /**
  81707. * If the button/trigger is currently pressed
  81708. */
  81709. readonly pressed: boolean;
  81710. /**
  81711. * If the button/trigger is currently touched
  81712. */
  81713. readonly touched: boolean;
  81714. /**
  81715. * Value of the button/trigger
  81716. */
  81717. readonly value: number;
  81718. }
  81719. /** @hidden */
  81720. export interface _GamePadFactory {
  81721. /**
  81722. * Returns wether or not the current gamepad can be created for this type of controller.
  81723. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81724. * @returns true if it can be created, otherwise false
  81725. */
  81726. canCreate(gamepadInfo: any): boolean;
  81727. /**
  81728. * Creates a new instance of the Gamepad.
  81729. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81730. * @returns the new gamepad instance
  81731. */
  81732. create(gamepadInfo: any): Gamepad;
  81733. }
  81734. /**
  81735. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81736. */
  81737. export class PoseEnabledControllerHelper {
  81738. /** @hidden */
  81739. static _ControllerFactories: _GamePadFactory[];
  81740. /** @hidden */
  81741. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81742. /**
  81743. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81744. * @param vrGamepad the gamepad to initialized
  81745. * @returns a vr controller of the type the gamepad identified as
  81746. */
  81747. static InitiateController(vrGamepad: any): Gamepad;
  81748. }
  81749. /**
  81750. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81751. */
  81752. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81753. /**
  81754. * If the controller is used in a webXR session
  81755. */
  81756. isXR: boolean;
  81757. private _deviceRoomPosition;
  81758. private _deviceRoomRotationQuaternion;
  81759. /**
  81760. * The device position in babylon space
  81761. */
  81762. devicePosition: Vector3;
  81763. /**
  81764. * The device rotation in babylon space
  81765. */
  81766. deviceRotationQuaternion: Quaternion;
  81767. /**
  81768. * The scale factor of the device in babylon space
  81769. */
  81770. deviceScaleFactor: number;
  81771. /**
  81772. * (Likely devicePosition should be used instead) The device position in its room space
  81773. */
  81774. position: Vector3;
  81775. /**
  81776. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81777. */
  81778. rotationQuaternion: Quaternion;
  81779. /**
  81780. * The type of controller (Eg. Windows mixed reality)
  81781. */
  81782. controllerType: PoseEnabledControllerType;
  81783. protected _calculatedPosition: Vector3;
  81784. private _calculatedRotation;
  81785. /**
  81786. * The raw pose from the device
  81787. */
  81788. rawPose: DevicePose;
  81789. private _trackPosition;
  81790. private _maxRotationDistFromHeadset;
  81791. private _draggedRoomRotation;
  81792. /**
  81793. * @hidden
  81794. */
  81795. _disableTrackPosition(fixedPosition: Vector3): void;
  81796. /**
  81797. * Internal, the mesh attached to the controller
  81798. * @hidden
  81799. */
  81800. _mesh: Nullable<AbstractMesh>;
  81801. private _poseControlledCamera;
  81802. private _leftHandSystemQuaternion;
  81803. /**
  81804. * Internal, matrix used to convert room space to babylon space
  81805. * @hidden
  81806. */
  81807. _deviceToWorld: Matrix;
  81808. /**
  81809. * Node to be used when casting a ray from the controller
  81810. * @hidden
  81811. */
  81812. _pointingPoseNode: Nullable<TransformNode>;
  81813. /**
  81814. * Name of the child mesh that can be used to cast a ray from the controller
  81815. */
  81816. static readonly POINTING_POSE: string;
  81817. /**
  81818. * Creates a new PoseEnabledController from a gamepad
  81819. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81820. */
  81821. constructor(browserGamepad: any);
  81822. private _workingMatrix;
  81823. /**
  81824. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81825. */
  81826. update(): void;
  81827. /**
  81828. * Updates only the pose device and mesh without doing any button event checking
  81829. */
  81830. protected _updatePoseAndMesh(): void;
  81831. /**
  81832. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81833. * @param poseData raw pose fromthe device
  81834. */
  81835. updateFromDevice(poseData: DevicePose): void;
  81836. /**
  81837. * @hidden
  81838. */
  81839. _meshAttachedObservable: Observable<AbstractMesh>;
  81840. /**
  81841. * Attaches a mesh to the controller
  81842. * @param mesh the mesh to be attached
  81843. */
  81844. attachToMesh(mesh: AbstractMesh): void;
  81845. /**
  81846. * Attaches the controllers mesh to a camera
  81847. * @param camera the camera the mesh should be attached to
  81848. */
  81849. attachToPoseControlledCamera(camera: TargetCamera): void;
  81850. /**
  81851. * Disposes of the controller
  81852. */
  81853. dispose(): void;
  81854. /**
  81855. * The mesh that is attached to the controller
  81856. */
  81857. readonly mesh: Nullable<AbstractMesh>;
  81858. /**
  81859. * Gets the ray of the controller in the direction the controller is pointing
  81860. * @param length the length the resulting ray should be
  81861. * @returns a ray in the direction the controller is pointing
  81862. */
  81863. getForwardRay(length?: number): Ray;
  81864. }
  81865. }
  81866. declare module BABYLON {
  81867. /**
  81868. * Defines the WebVRController object that represents controllers tracked in 3D space
  81869. */
  81870. export abstract class WebVRController extends PoseEnabledController {
  81871. /**
  81872. * Internal, the default controller model for the controller
  81873. */
  81874. protected _defaultModel: Nullable<AbstractMesh>;
  81875. /**
  81876. * Fired when the trigger state has changed
  81877. */
  81878. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81879. /**
  81880. * Fired when the main button state has changed
  81881. */
  81882. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81883. /**
  81884. * Fired when the secondary button state has changed
  81885. */
  81886. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81887. /**
  81888. * Fired when the pad state has changed
  81889. */
  81890. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81891. /**
  81892. * Fired when controllers stick values have changed
  81893. */
  81894. onPadValuesChangedObservable: Observable<StickValues>;
  81895. /**
  81896. * Array of button availible on the controller
  81897. */
  81898. protected _buttons: Array<MutableGamepadButton>;
  81899. private _onButtonStateChange;
  81900. /**
  81901. * Fired when a controller button's state has changed
  81902. * @param callback the callback containing the button that was modified
  81903. */
  81904. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81905. /**
  81906. * X and Y axis corresponding to the controllers joystick
  81907. */
  81908. pad: StickValues;
  81909. /**
  81910. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81911. */
  81912. hand: string;
  81913. /**
  81914. * The default controller model for the controller
  81915. */
  81916. readonly defaultModel: Nullable<AbstractMesh>;
  81917. /**
  81918. * Creates a new WebVRController from a gamepad
  81919. * @param vrGamepad the gamepad that the WebVRController should be created from
  81920. */
  81921. constructor(vrGamepad: any);
  81922. /**
  81923. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81924. */
  81925. update(): void;
  81926. /**
  81927. * Function to be called when a button is modified
  81928. */
  81929. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81930. /**
  81931. * Loads a mesh and attaches it to the controller
  81932. * @param scene the scene the mesh should be added to
  81933. * @param meshLoaded callback for when the mesh has been loaded
  81934. */
  81935. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81936. private _setButtonValue;
  81937. private _changes;
  81938. private _checkChanges;
  81939. /**
  81940. * Disposes of th webVRCOntroller
  81941. */
  81942. dispose(): void;
  81943. }
  81944. }
  81945. declare module BABYLON {
  81946. /**
  81947. * The HemisphericLight simulates the ambient environment light,
  81948. * so the passed direction is the light reflection direction, not the incoming direction.
  81949. */
  81950. export class HemisphericLight extends Light {
  81951. /**
  81952. * The groundColor is the light in the opposite direction to the one specified during creation.
  81953. * 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.
  81954. */
  81955. groundColor: Color3;
  81956. /**
  81957. * The light reflection direction, not the incoming direction.
  81958. */
  81959. direction: Vector3;
  81960. /**
  81961. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81962. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81963. * The HemisphericLight can't cast shadows.
  81964. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81965. * @param name The friendly name of the light
  81966. * @param direction The direction of the light reflection
  81967. * @param scene The scene the light belongs to
  81968. */
  81969. constructor(name: string, direction: Vector3, scene: Scene);
  81970. protected _buildUniformLayout(): void;
  81971. /**
  81972. * Returns the string "HemisphericLight".
  81973. * @return The class name
  81974. */
  81975. getClassName(): string;
  81976. /**
  81977. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81978. * Returns the updated direction.
  81979. * @param target The target the direction should point to
  81980. * @return The computed direction
  81981. */
  81982. setDirectionToTarget(target: Vector3): Vector3;
  81983. /**
  81984. * Returns the shadow generator associated to the light.
  81985. * @returns Always null for hemispheric lights because it does not support shadows.
  81986. */
  81987. getShadowGenerator(): Nullable<IShadowGenerator>;
  81988. /**
  81989. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81990. * @param effect The effect to update
  81991. * @param lightIndex The index of the light in the effect to update
  81992. * @returns The hemispheric light
  81993. */
  81994. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81995. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81996. /**
  81997. * Computes the world matrix of the node
  81998. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81999. * @param useWasUpdatedFlag defines a reserved property
  82000. * @returns the world matrix
  82001. */
  82002. computeWorldMatrix(): Matrix;
  82003. /**
  82004. * Returns the integer 3.
  82005. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82006. */
  82007. getTypeID(): number;
  82008. /**
  82009. * Prepares the list of defines specific to the light type.
  82010. * @param defines the list of defines
  82011. * @param lightIndex defines the index of the light for the effect
  82012. */
  82013. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82014. }
  82015. }
  82016. declare module BABYLON {
  82017. /** @hidden */
  82018. export var vrMultiviewToSingleviewPixelShader: {
  82019. name: string;
  82020. shader: string;
  82021. };
  82022. }
  82023. declare module BABYLON {
  82024. /**
  82025. * Renders to multiple views with a single draw call
  82026. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82027. */
  82028. export class MultiviewRenderTarget extends RenderTargetTexture {
  82029. /**
  82030. * Creates a multiview render target
  82031. * @param scene scene used with the render target
  82032. * @param size the size of the render target (used for each view)
  82033. */
  82034. constructor(scene: Scene, size?: number | {
  82035. width: number;
  82036. height: number;
  82037. } | {
  82038. ratio: number;
  82039. });
  82040. /**
  82041. * @hidden
  82042. * @param faceIndex the face index, if its a cube texture
  82043. */
  82044. _bindFrameBuffer(faceIndex?: number): void;
  82045. /**
  82046. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82047. * @returns the view count
  82048. */
  82049. getViewCount(): number;
  82050. }
  82051. }
  82052. declare module BABYLON {
  82053. /**
  82054. * Represents a camera frustum
  82055. */
  82056. export class Frustum {
  82057. /**
  82058. * Gets the planes representing the frustum
  82059. * @param transform matrix to be applied to the returned planes
  82060. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82061. */
  82062. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82063. /**
  82064. * Gets the near frustum plane transformed by the transform matrix
  82065. * @param transform transformation matrix to be applied to the resulting frustum plane
  82066. * @param frustumPlane the resuling frustum plane
  82067. */
  82068. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82069. /**
  82070. * Gets the far frustum plane transformed by the transform matrix
  82071. * @param transform transformation matrix to be applied to the resulting frustum plane
  82072. * @param frustumPlane the resuling frustum plane
  82073. */
  82074. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82075. /**
  82076. * Gets the left frustum plane transformed by the transform matrix
  82077. * @param transform transformation matrix to be applied to the resulting frustum plane
  82078. * @param frustumPlane the resuling frustum plane
  82079. */
  82080. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82081. /**
  82082. * Gets the right frustum plane transformed by the transform matrix
  82083. * @param transform transformation matrix to be applied to the resulting frustum plane
  82084. * @param frustumPlane the resuling frustum plane
  82085. */
  82086. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82087. /**
  82088. * Gets the top frustum plane transformed by the transform matrix
  82089. * @param transform transformation matrix to be applied to the resulting frustum plane
  82090. * @param frustumPlane the resuling frustum plane
  82091. */
  82092. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82093. /**
  82094. * Gets the bottom frustum plane transformed by the transform matrix
  82095. * @param transform transformation matrix to be applied to the resulting frustum plane
  82096. * @param frustumPlane the resuling frustum plane
  82097. */
  82098. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82099. /**
  82100. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82101. * @param transform transformation matrix to be applied to the resulting frustum planes
  82102. * @param frustumPlanes the resuling frustum planes
  82103. */
  82104. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82105. }
  82106. }
  82107. declare module BABYLON {
  82108. interface Engine {
  82109. /**
  82110. * Creates a new multiview render target
  82111. * @param width defines the width of the texture
  82112. * @param height defines the height of the texture
  82113. * @returns the created multiview texture
  82114. */
  82115. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82116. /**
  82117. * Binds a multiview framebuffer to be drawn to
  82118. * @param multiviewTexture texture to bind
  82119. */
  82120. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  82121. }
  82122. interface Camera {
  82123. /**
  82124. * @hidden
  82125. * 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)
  82126. */
  82127. _useMultiviewToSingleView: boolean;
  82128. /**
  82129. * @hidden
  82130. * 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)
  82131. */
  82132. _multiviewTexture: Nullable<RenderTargetTexture>;
  82133. /**
  82134. * @hidden
  82135. * ensures the multiview texture of the camera exists and has the specified width/height
  82136. * @param width height to set on the multiview texture
  82137. * @param height width to set on the multiview texture
  82138. */
  82139. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  82140. }
  82141. interface Scene {
  82142. /** @hidden */
  82143. _transformMatrixR: Matrix;
  82144. /** @hidden */
  82145. _multiviewSceneUbo: Nullable<UniformBuffer>;
  82146. /** @hidden */
  82147. _createMultiviewUbo(): void;
  82148. /** @hidden */
  82149. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  82150. /** @hidden */
  82151. _renderMultiviewToSingleView(camera: Camera): void;
  82152. }
  82153. }
  82154. declare module BABYLON {
  82155. /**
  82156. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  82157. * This will not be used for webXR as it supports displaying texture arrays directly
  82158. */
  82159. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  82160. /**
  82161. * Initializes a VRMultiviewToSingleview
  82162. * @param name name of the post process
  82163. * @param camera camera to be applied to
  82164. * @param scaleFactor scaling factor to the size of the output texture
  82165. */
  82166. constructor(name: string, camera: Camera, scaleFactor: number);
  82167. }
  82168. }
  82169. declare module BABYLON {
  82170. interface Engine {
  82171. /** @hidden */
  82172. _vrDisplay: any;
  82173. /** @hidden */
  82174. _vrSupported: boolean;
  82175. /** @hidden */
  82176. _oldSize: Size;
  82177. /** @hidden */
  82178. _oldHardwareScaleFactor: number;
  82179. /** @hidden */
  82180. _vrExclusivePointerMode: boolean;
  82181. /** @hidden */
  82182. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  82183. /** @hidden */
  82184. _onVRDisplayPointerRestricted: () => void;
  82185. /** @hidden */
  82186. _onVRDisplayPointerUnrestricted: () => void;
  82187. /** @hidden */
  82188. _onVrDisplayConnect: Nullable<(display: any) => void>;
  82189. /** @hidden */
  82190. _onVrDisplayDisconnect: Nullable<() => void>;
  82191. /** @hidden */
  82192. _onVrDisplayPresentChange: Nullable<() => void>;
  82193. /**
  82194. * Observable signaled when VR display mode changes
  82195. */
  82196. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82197. /**
  82198. * Observable signaled when VR request present is complete
  82199. */
  82200. onVRRequestPresentComplete: Observable<boolean>;
  82201. /**
  82202. * Observable signaled when VR request present starts
  82203. */
  82204. onVRRequestPresentStart: Observable<Engine>;
  82205. /**
  82206. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82207. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82208. */
  82209. isInVRExclusivePointerMode: boolean;
  82210. /**
  82211. * Gets a boolean indicating if a webVR device was detected
  82212. * @returns true if a webVR device was detected
  82213. */
  82214. isVRDevicePresent(): boolean;
  82215. /**
  82216. * Gets the current webVR device
  82217. * @returns the current webVR device (or null)
  82218. */
  82219. getVRDevice(): any;
  82220. /**
  82221. * Initializes a webVR display and starts listening to display change events
  82222. * The onVRDisplayChangedObservable will be notified upon these changes
  82223. * @returns A promise containing a VRDisplay and if vr is supported
  82224. */
  82225. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82226. /** @hidden */
  82227. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82228. /**
  82229. * Call this function to switch to webVR mode
  82230. * Will do nothing if webVR is not supported or if there is no webVR device
  82231. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82232. */
  82233. enableVR(): void;
  82234. /** @hidden */
  82235. _onVRFullScreenTriggered(): void;
  82236. }
  82237. }
  82238. declare module BABYLON {
  82239. /**
  82240. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82241. * IMPORTANT!! The data is right-hand data.
  82242. * @export
  82243. * @interface DevicePose
  82244. */
  82245. export interface DevicePose {
  82246. /**
  82247. * The position of the device, values in array are [x,y,z].
  82248. */
  82249. readonly position: Nullable<Float32Array>;
  82250. /**
  82251. * The linearVelocity of the device, values in array are [x,y,z].
  82252. */
  82253. readonly linearVelocity: Nullable<Float32Array>;
  82254. /**
  82255. * The linearAcceleration of the device, values in array are [x,y,z].
  82256. */
  82257. readonly linearAcceleration: Nullable<Float32Array>;
  82258. /**
  82259. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82260. */
  82261. readonly orientation: Nullable<Float32Array>;
  82262. /**
  82263. * The angularVelocity of the device, values in array are [x,y,z].
  82264. */
  82265. readonly angularVelocity: Nullable<Float32Array>;
  82266. /**
  82267. * The angularAcceleration of the device, values in array are [x,y,z].
  82268. */
  82269. readonly angularAcceleration: Nullable<Float32Array>;
  82270. }
  82271. /**
  82272. * Interface representing a pose controlled object in Babylon.
  82273. * A pose controlled object has both regular pose values as well as pose values
  82274. * from an external device such as a VR head mounted display
  82275. */
  82276. export interface PoseControlled {
  82277. /**
  82278. * The position of the object in babylon space.
  82279. */
  82280. position: Vector3;
  82281. /**
  82282. * The rotation quaternion of the object in babylon space.
  82283. */
  82284. rotationQuaternion: Quaternion;
  82285. /**
  82286. * The position of the device in babylon space.
  82287. */
  82288. devicePosition?: Vector3;
  82289. /**
  82290. * The rotation quaternion of the device in babylon space.
  82291. */
  82292. deviceRotationQuaternion: Quaternion;
  82293. /**
  82294. * The raw pose coming from the device.
  82295. */
  82296. rawPose: Nullable<DevicePose>;
  82297. /**
  82298. * The scale of the device to be used when translating from device space to babylon space.
  82299. */
  82300. deviceScaleFactor: number;
  82301. /**
  82302. * Updates the poseControlled values based on the input device pose.
  82303. * @param poseData the pose data to update the object with
  82304. */
  82305. updateFromDevice(poseData: DevicePose): void;
  82306. }
  82307. /**
  82308. * Set of options to customize the webVRCamera
  82309. */
  82310. export interface WebVROptions {
  82311. /**
  82312. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  82313. */
  82314. trackPosition?: boolean;
  82315. /**
  82316. * Sets the scale of the vrDevice in babylon space. (default: 1)
  82317. */
  82318. positionScale?: number;
  82319. /**
  82320. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  82321. */
  82322. displayName?: string;
  82323. /**
  82324. * Should the native controller meshes be initialized. (default: true)
  82325. */
  82326. controllerMeshes?: boolean;
  82327. /**
  82328. * Creating a default HemiLight only on controllers. (default: true)
  82329. */
  82330. defaultLightingOnControllers?: boolean;
  82331. /**
  82332. * If you don't want to use the default VR button of the helper. (default: false)
  82333. */
  82334. useCustomVRButton?: boolean;
  82335. /**
  82336. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  82337. */
  82338. customVRButton?: HTMLButtonElement;
  82339. /**
  82340. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  82341. */
  82342. rayLength?: number;
  82343. /**
  82344. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  82345. */
  82346. defaultHeight?: number;
  82347. /**
  82348. * If multiview should be used if availible (default: false)
  82349. */
  82350. useMultiview?: boolean;
  82351. }
  82352. /**
  82353. * This represents a WebVR camera.
  82354. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  82355. * @example http://doc.babylonjs.com/how_to/webvr_camera
  82356. */
  82357. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  82358. private webVROptions;
  82359. /**
  82360. * @hidden
  82361. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  82362. */
  82363. _vrDevice: any;
  82364. /**
  82365. * The rawPose of the vrDevice.
  82366. */
  82367. rawPose: Nullable<DevicePose>;
  82368. private _onVREnabled;
  82369. private _specsVersion;
  82370. private _attached;
  82371. private _frameData;
  82372. protected _descendants: Array<Node>;
  82373. private _deviceRoomPosition;
  82374. /** @hidden */
  82375. _deviceRoomRotationQuaternion: Quaternion;
  82376. private _standingMatrix;
  82377. /**
  82378. * Represents device position in babylon space.
  82379. */
  82380. devicePosition: Vector3;
  82381. /**
  82382. * Represents device rotation in babylon space.
  82383. */
  82384. deviceRotationQuaternion: Quaternion;
  82385. /**
  82386. * The scale of the device to be used when translating from device space to babylon space.
  82387. */
  82388. deviceScaleFactor: number;
  82389. private _deviceToWorld;
  82390. private _worldToDevice;
  82391. /**
  82392. * References to the webVR controllers for the vrDevice.
  82393. */
  82394. controllers: Array<WebVRController>;
  82395. /**
  82396. * Emits an event when a controller is attached.
  82397. */
  82398. onControllersAttachedObservable: Observable<WebVRController[]>;
  82399. /**
  82400. * Emits an event when a controller's mesh has been loaded;
  82401. */
  82402. onControllerMeshLoadedObservable: Observable<WebVRController>;
  82403. /**
  82404. * Emits an event when the HMD's pose has been updated.
  82405. */
  82406. onPoseUpdatedFromDeviceObservable: Observable<any>;
  82407. private _poseSet;
  82408. /**
  82409. * If the rig cameras be used as parent instead of this camera.
  82410. */
  82411. rigParenting: boolean;
  82412. private _lightOnControllers;
  82413. private _defaultHeight?;
  82414. /**
  82415. * Instantiates a WebVRFreeCamera.
  82416. * @param name The name of the WebVRFreeCamera
  82417. * @param position The starting anchor position for the camera
  82418. * @param scene The scene the camera belongs to
  82419. * @param webVROptions a set of customizable options for the webVRCamera
  82420. */
  82421. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  82422. /**
  82423. * Gets the device distance from the ground in meters.
  82424. * @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.
  82425. */
  82426. deviceDistanceToRoomGround(): number;
  82427. /**
  82428. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82429. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  82430. */
  82431. useStandingMatrix(callback?: (bool: boolean) => void): void;
  82432. /**
  82433. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82434. * @returns A promise with a boolean set to if the standing matrix is supported.
  82435. */
  82436. useStandingMatrixAsync(): Promise<boolean>;
  82437. /**
  82438. * Disposes the camera
  82439. */
  82440. dispose(): void;
  82441. /**
  82442. * Gets a vrController by name.
  82443. * @param name The name of the controller to retreive
  82444. * @returns the controller matching the name specified or null if not found
  82445. */
  82446. getControllerByName(name: string): Nullable<WebVRController>;
  82447. private _leftController;
  82448. /**
  82449. * The controller corresponding to the users left hand.
  82450. */
  82451. readonly leftController: Nullable<WebVRController>;
  82452. private _rightController;
  82453. /**
  82454. * The controller corresponding to the users right hand.
  82455. */
  82456. readonly rightController: Nullable<WebVRController>;
  82457. /**
  82458. * Casts a ray forward from the vrCamera's gaze.
  82459. * @param length Length of the ray (default: 100)
  82460. * @returns the ray corresponding to the gaze
  82461. */
  82462. getForwardRay(length?: number): Ray;
  82463. /**
  82464. * @hidden
  82465. * Updates the camera based on device's frame data
  82466. */
  82467. _checkInputs(): void;
  82468. /**
  82469. * Updates the poseControlled values based on the input device pose.
  82470. * @param poseData Pose coming from the device
  82471. */
  82472. updateFromDevice(poseData: DevicePose): void;
  82473. private _htmlElementAttached;
  82474. private _detachIfAttached;
  82475. /**
  82476. * WebVR's attach control will start broadcasting frames to the device.
  82477. * Note that in certain browsers (chrome for example) this function must be called
  82478. * within a user-interaction callback. Example:
  82479. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  82480. *
  82481. * @param element html element to attach the vrDevice to
  82482. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  82483. */
  82484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82485. /**
  82486. * Detaches the camera from the html element and disables VR
  82487. *
  82488. * @param element html element to detach from
  82489. */
  82490. detachControl(element: HTMLElement): void;
  82491. /**
  82492. * @returns the name of this class
  82493. */
  82494. getClassName(): string;
  82495. /**
  82496. * Calls resetPose on the vrDisplay
  82497. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  82498. */
  82499. resetToCurrentRotation(): void;
  82500. /**
  82501. * @hidden
  82502. * Updates the rig cameras (left and right eye)
  82503. */
  82504. _updateRigCameras(): void;
  82505. private _workingVector;
  82506. private _oneVector;
  82507. private _workingMatrix;
  82508. private updateCacheCalled;
  82509. private _correctPositionIfNotTrackPosition;
  82510. /**
  82511. * @hidden
  82512. * Updates the cached values of the camera
  82513. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  82514. */
  82515. _updateCache(ignoreParentClass?: boolean): void;
  82516. /**
  82517. * @hidden
  82518. * Get current device position in babylon world
  82519. */
  82520. _computeDevicePosition(): void;
  82521. /**
  82522. * Updates the current device position and rotation in the babylon world
  82523. */
  82524. update(): void;
  82525. /**
  82526. * @hidden
  82527. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  82528. * @returns an identity matrix
  82529. */
  82530. _getViewMatrix(): Matrix;
  82531. private _tmpMatrix;
  82532. /**
  82533. * This function is called by the two RIG cameras.
  82534. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  82535. * @hidden
  82536. */
  82537. _getWebVRViewMatrix(): Matrix;
  82538. /** @hidden */
  82539. _getWebVRProjectionMatrix(): Matrix;
  82540. private _onGamepadConnectedObserver;
  82541. private _onGamepadDisconnectedObserver;
  82542. private _updateCacheWhenTrackingDisabledObserver;
  82543. /**
  82544. * Initializes the controllers and their meshes
  82545. */
  82546. initControllers(): void;
  82547. }
  82548. }
  82549. declare module BABYLON {
  82550. /**
  82551. * Size options for a post process
  82552. */
  82553. export type PostProcessOptions = {
  82554. width: number;
  82555. height: number;
  82556. };
  82557. /**
  82558. * PostProcess can be used to apply a shader to a texture after it has been rendered
  82559. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82560. */
  82561. export class PostProcess {
  82562. /** Name of the PostProcess. */
  82563. name: string;
  82564. /**
  82565. * Gets or sets the unique id of the post process
  82566. */
  82567. uniqueId: number;
  82568. /**
  82569. * Width of the texture to apply the post process on
  82570. */
  82571. width: number;
  82572. /**
  82573. * Height of the texture to apply the post process on
  82574. */
  82575. height: number;
  82576. /**
  82577. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  82578. * @hidden
  82579. */
  82580. _outputTexture: Nullable<InternalTexture>;
  82581. /**
  82582. * Sampling mode used by the shader
  82583. * See https://doc.babylonjs.com/classes/3.1/texture
  82584. */
  82585. renderTargetSamplingMode: number;
  82586. /**
  82587. * Clear color to use when screen clearing
  82588. */
  82589. clearColor: Color4;
  82590. /**
  82591. * If the buffer needs to be cleared before applying the post process. (default: true)
  82592. * Should be set to false if shader will overwrite all previous pixels.
  82593. */
  82594. autoClear: boolean;
  82595. /**
  82596. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  82597. */
  82598. alphaMode: number;
  82599. /**
  82600. * Sets the setAlphaBlendConstants of the babylon engine
  82601. */
  82602. alphaConstants: Color4;
  82603. /**
  82604. * Animations to be used for the post processing
  82605. */
  82606. animations: Animation[];
  82607. /**
  82608. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  82609. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  82610. */
  82611. enablePixelPerfectMode: boolean;
  82612. /**
  82613. * Force the postprocess to be applied without taking in account viewport
  82614. */
  82615. forceFullscreenViewport: boolean;
  82616. /**
  82617. * List of inspectable custom properties (used by the Inspector)
  82618. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82619. */
  82620. inspectableCustomProperties: IInspectable[];
  82621. /**
  82622. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  82623. *
  82624. * | Value | Type | Description |
  82625. * | ----- | ----------------------------------- | ----------- |
  82626. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  82627. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  82628. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  82629. *
  82630. */
  82631. scaleMode: number;
  82632. /**
  82633. * Force textures to be a power of two (default: false)
  82634. */
  82635. alwaysForcePOT: boolean;
  82636. private _samples;
  82637. /**
  82638. * Number of sample textures (default: 1)
  82639. */
  82640. samples: number;
  82641. /**
  82642. * Modify the scale of the post process to be the same as the viewport (default: false)
  82643. */
  82644. adaptScaleToCurrentViewport: boolean;
  82645. private _camera;
  82646. private _scene;
  82647. private _engine;
  82648. private _options;
  82649. private _reusable;
  82650. private _textureType;
  82651. /**
  82652. * Smart array of input and output textures for the post process.
  82653. * @hidden
  82654. */
  82655. _textures: SmartArray<InternalTexture>;
  82656. /**
  82657. * The index in _textures that corresponds to the output texture.
  82658. * @hidden
  82659. */
  82660. _currentRenderTextureInd: number;
  82661. private _effect;
  82662. private _samplers;
  82663. private _fragmentUrl;
  82664. private _vertexUrl;
  82665. private _parameters;
  82666. private _scaleRatio;
  82667. protected _indexParameters: any;
  82668. private _shareOutputWithPostProcess;
  82669. private _texelSize;
  82670. private _forcedOutputTexture;
  82671. /**
  82672. * Returns the fragment url or shader name used in the post process.
  82673. * @returns the fragment url or name in the shader store.
  82674. */
  82675. getEffectName(): string;
  82676. /**
  82677. * An event triggered when the postprocess is activated.
  82678. */
  82679. onActivateObservable: Observable<Camera>;
  82680. private _onActivateObserver;
  82681. /**
  82682. * A function that is added to the onActivateObservable
  82683. */
  82684. onActivate: Nullable<(camera: Camera) => void>;
  82685. /**
  82686. * An event triggered when the postprocess changes its size.
  82687. */
  82688. onSizeChangedObservable: Observable<PostProcess>;
  82689. private _onSizeChangedObserver;
  82690. /**
  82691. * A function that is added to the onSizeChangedObservable
  82692. */
  82693. onSizeChanged: (postProcess: PostProcess) => void;
  82694. /**
  82695. * An event triggered when the postprocess applies its effect.
  82696. */
  82697. onApplyObservable: Observable<Effect>;
  82698. private _onApplyObserver;
  82699. /**
  82700. * A function that is added to the onApplyObservable
  82701. */
  82702. onApply: (effect: Effect) => void;
  82703. /**
  82704. * An event triggered before rendering the postprocess
  82705. */
  82706. onBeforeRenderObservable: Observable<Effect>;
  82707. private _onBeforeRenderObserver;
  82708. /**
  82709. * A function that is added to the onBeforeRenderObservable
  82710. */
  82711. onBeforeRender: (effect: Effect) => void;
  82712. /**
  82713. * An event triggered after rendering the postprocess
  82714. */
  82715. onAfterRenderObservable: Observable<Effect>;
  82716. private _onAfterRenderObserver;
  82717. /**
  82718. * A function that is added to the onAfterRenderObservable
  82719. */
  82720. onAfterRender: (efect: Effect) => void;
  82721. /**
  82722. * 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
  82723. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82724. */
  82725. inputTexture: InternalTexture;
  82726. /**
  82727. * Gets the camera which post process is applied to.
  82728. * @returns The camera the post process is applied to.
  82729. */
  82730. getCamera(): Camera;
  82731. /**
  82732. * Gets the texel size of the postprocess.
  82733. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82734. */
  82735. readonly texelSize: Vector2;
  82736. /**
  82737. * Creates a new instance PostProcess
  82738. * @param name The name of the PostProcess.
  82739. * @param fragmentUrl The url of the fragment shader to be used.
  82740. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82741. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82742. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82743. * @param camera The camera to apply the render pass to.
  82744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82745. * @param engine The engine which the post process will be applied. (default: current engine)
  82746. * @param reusable If the post process can be reused on the same frame. (default: false)
  82747. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82748. * @param textureType Type of textures used when performing the post process. (default: 0)
  82749. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82750. * @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
  82751. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82752. */
  82753. constructor(
  82754. /** Name of the PostProcess. */
  82755. 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);
  82756. /**
  82757. * Gets a string idenfifying the name of the class
  82758. * @returns "PostProcess" string
  82759. */
  82760. getClassName(): string;
  82761. /**
  82762. * Gets the engine which this post process belongs to.
  82763. * @returns The engine the post process was enabled with.
  82764. */
  82765. getEngine(): Engine;
  82766. /**
  82767. * The effect that is created when initializing the post process.
  82768. * @returns The created effect corresponding the the postprocess.
  82769. */
  82770. getEffect(): Effect;
  82771. /**
  82772. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82773. * @param postProcess The post process to share the output with.
  82774. * @returns This post process.
  82775. */
  82776. shareOutputWith(postProcess: PostProcess): PostProcess;
  82777. /**
  82778. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82779. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82780. */
  82781. useOwnOutput(): void;
  82782. /**
  82783. * Updates the effect with the current post process compile time values and recompiles the shader.
  82784. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82785. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82786. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82787. * @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
  82788. * @param onCompiled Called when the shader has been compiled.
  82789. * @param onError Called if there is an error when compiling a shader.
  82790. */
  82791. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82792. /**
  82793. * The post process is reusable if it can be used multiple times within one frame.
  82794. * @returns If the post process is reusable
  82795. */
  82796. isReusable(): boolean;
  82797. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82798. markTextureDirty(): void;
  82799. /**
  82800. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82801. * 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.
  82802. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82803. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82804. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82805. * @returns The target texture that was bound to be written to.
  82806. */
  82807. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82808. /**
  82809. * If the post process is supported.
  82810. */
  82811. readonly isSupported: boolean;
  82812. /**
  82813. * The aspect ratio of the output texture.
  82814. */
  82815. readonly aspectRatio: number;
  82816. /**
  82817. * Get a value indicating if the post-process is ready to be used
  82818. * @returns true if the post-process is ready (shader is compiled)
  82819. */
  82820. isReady(): boolean;
  82821. /**
  82822. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82823. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82824. */
  82825. apply(): Nullable<Effect>;
  82826. private _disposeTextures;
  82827. /**
  82828. * Disposes the post process.
  82829. * @param camera The camera to dispose the post process on.
  82830. */
  82831. dispose(camera?: Camera): void;
  82832. }
  82833. }
  82834. declare module BABYLON {
  82835. /** @hidden */
  82836. export var kernelBlurVaryingDeclaration: {
  82837. name: string;
  82838. shader: string;
  82839. };
  82840. }
  82841. declare module BABYLON {
  82842. /** @hidden */
  82843. export var kernelBlurFragment: {
  82844. name: string;
  82845. shader: string;
  82846. };
  82847. }
  82848. declare module BABYLON {
  82849. /** @hidden */
  82850. export var kernelBlurFragment2: {
  82851. name: string;
  82852. shader: string;
  82853. };
  82854. }
  82855. declare module BABYLON {
  82856. /** @hidden */
  82857. export var kernelBlurPixelShader: {
  82858. name: string;
  82859. shader: string;
  82860. };
  82861. }
  82862. declare module BABYLON {
  82863. /** @hidden */
  82864. export var kernelBlurVertex: {
  82865. name: string;
  82866. shader: string;
  82867. };
  82868. }
  82869. declare module BABYLON {
  82870. /** @hidden */
  82871. export var kernelBlurVertexShader: {
  82872. name: string;
  82873. shader: string;
  82874. };
  82875. }
  82876. declare module BABYLON {
  82877. /**
  82878. * The Blur Post Process which blurs an image based on a kernel and direction.
  82879. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82880. */
  82881. export class BlurPostProcess extends PostProcess {
  82882. /** The direction in which to blur the image. */
  82883. direction: Vector2;
  82884. private blockCompilation;
  82885. protected _kernel: number;
  82886. protected _idealKernel: number;
  82887. protected _packedFloat: boolean;
  82888. private _staticDefines;
  82889. /**
  82890. * Sets the length in pixels of the blur sample region
  82891. */
  82892. /**
  82893. * Gets the length in pixels of the blur sample region
  82894. */
  82895. kernel: number;
  82896. /**
  82897. * Sets wether or not the blur needs to unpack/repack floats
  82898. */
  82899. /**
  82900. * Gets wether or not the blur is unpacking/repacking floats
  82901. */
  82902. packedFloat: boolean;
  82903. /**
  82904. * Creates a new instance BlurPostProcess
  82905. * @param name The name of the effect.
  82906. * @param direction The direction in which to blur the image.
  82907. * @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.
  82908. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82909. * @param camera The camera to apply the render pass to.
  82910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82911. * @param engine The engine which the post process will be applied. (default: current engine)
  82912. * @param reusable If the post process can be reused on the same frame. (default: false)
  82913. * @param textureType Type of textures used when performing the post process. (default: 0)
  82914. * @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)
  82915. */
  82916. constructor(name: string,
  82917. /** The direction in which to blur the image. */
  82918. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82919. /**
  82920. * Updates the effect with the current post process compile time values and recompiles the shader.
  82921. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82922. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82923. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82924. * @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
  82925. * @param onCompiled Called when the shader has been compiled.
  82926. * @param onError Called if there is an error when compiling a shader.
  82927. */
  82928. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82929. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82930. /**
  82931. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82932. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82933. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82934. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82935. * The gaps between physical kernels are compensated for in the weighting of the samples
  82936. * @param idealKernel Ideal blur kernel.
  82937. * @return Nearest best kernel.
  82938. */
  82939. protected _nearestBestKernel(idealKernel: number): number;
  82940. /**
  82941. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82942. * @param x The point on the Gaussian distribution to sample.
  82943. * @return the value of the Gaussian function at x.
  82944. */
  82945. protected _gaussianWeight(x: number): number;
  82946. /**
  82947. * Generates a string that can be used as a floating point number in GLSL.
  82948. * @param x Value to print.
  82949. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82950. * @return GLSL float string.
  82951. */
  82952. protected _glslFloat(x: number, decimalFigures?: number): string;
  82953. }
  82954. }
  82955. declare module BABYLON {
  82956. /**
  82957. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82958. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82959. * You can then easily use it as a reflectionTexture on a flat surface.
  82960. * In case the surface is not a plane, please consider relying on reflection probes.
  82961. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82962. */
  82963. export class MirrorTexture extends RenderTargetTexture {
  82964. private scene;
  82965. /**
  82966. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82967. * 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.
  82968. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82969. */
  82970. mirrorPlane: Plane;
  82971. /**
  82972. * Define the blur ratio used to blur the reflection if needed.
  82973. */
  82974. blurRatio: number;
  82975. /**
  82976. * Define the adaptive blur kernel used to blur the reflection if needed.
  82977. * This will autocompute the closest best match for the `blurKernel`
  82978. */
  82979. adaptiveBlurKernel: number;
  82980. /**
  82981. * Define the blur kernel used to blur the reflection if needed.
  82982. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82983. */
  82984. blurKernel: number;
  82985. /**
  82986. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82987. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82988. */
  82989. blurKernelX: number;
  82990. /**
  82991. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82992. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82993. */
  82994. blurKernelY: number;
  82995. private _autoComputeBlurKernel;
  82996. protected _onRatioRescale(): void;
  82997. private _updateGammaSpace;
  82998. private _imageProcessingConfigChangeObserver;
  82999. private _transformMatrix;
  83000. private _mirrorMatrix;
  83001. private _savedViewMatrix;
  83002. private _blurX;
  83003. private _blurY;
  83004. private _adaptiveBlurKernel;
  83005. private _blurKernelX;
  83006. private _blurKernelY;
  83007. private _blurRatio;
  83008. /**
  83009. * Instantiates a Mirror Texture.
  83010. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83011. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83012. * You can then easily use it as a reflectionTexture on a flat surface.
  83013. * In case the surface is not a plane, please consider relying on reflection probes.
  83014. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83015. * @param name
  83016. * @param size
  83017. * @param scene
  83018. * @param generateMipMaps
  83019. * @param type
  83020. * @param samplingMode
  83021. * @param generateDepthBuffer
  83022. */
  83023. constructor(name: string, size: number | {
  83024. width: number;
  83025. height: number;
  83026. } | {
  83027. ratio: number;
  83028. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83029. private _preparePostProcesses;
  83030. /**
  83031. * Clone the mirror texture.
  83032. * @returns the cloned texture
  83033. */
  83034. clone(): MirrorTexture;
  83035. /**
  83036. * Serialize the texture to a JSON representation you could use in Parse later on
  83037. * @returns the serialized JSON representation
  83038. */
  83039. serialize(): any;
  83040. /**
  83041. * Dispose the texture and release its associated resources.
  83042. */
  83043. dispose(): void;
  83044. }
  83045. }
  83046. declare module BABYLON {
  83047. /**
  83048. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83049. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83050. */
  83051. export class Texture extends BaseTexture {
  83052. /**
  83053. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83054. */
  83055. static SerializeBuffers: boolean;
  83056. /** @hidden */
  83057. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83058. /** @hidden */
  83059. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83060. /** @hidden */
  83061. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83062. /** nearest is mag = nearest and min = nearest and mip = linear */
  83063. static readonly NEAREST_SAMPLINGMODE: number;
  83064. /** nearest is mag = nearest and min = nearest and mip = linear */
  83065. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83066. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83067. static readonly BILINEAR_SAMPLINGMODE: number;
  83068. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83069. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83070. /** Trilinear is mag = linear and min = linear and mip = linear */
  83071. static readonly TRILINEAR_SAMPLINGMODE: number;
  83072. /** Trilinear is mag = linear and min = linear and mip = linear */
  83073. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83074. /** mag = nearest and min = nearest and mip = nearest */
  83075. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83076. /** mag = nearest and min = linear and mip = nearest */
  83077. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83078. /** mag = nearest and min = linear and mip = linear */
  83079. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83080. /** mag = nearest and min = linear and mip = none */
  83081. static readonly NEAREST_LINEAR: number;
  83082. /** mag = nearest and min = nearest and mip = none */
  83083. static readonly NEAREST_NEAREST: number;
  83084. /** mag = linear and min = nearest and mip = nearest */
  83085. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83086. /** mag = linear and min = nearest and mip = linear */
  83087. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83088. /** mag = linear and min = linear and mip = none */
  83089. static readonly LINEAR_LINEAR: number;
  83090. /** mag = linear and min = nearest and mip = none */
  83091. static readonly LINEAR_NEAREST: number;
  83092. /** Explicit coordinates mode */
  83093. static readonly EXPLICIT_MODE: number;
  83094. /** Spherical coordinates mode */
  83095. static readonly SPHERICAL_MODE: number;
  83096. /** Planar coordinates mode */
  83097. static readonly PLANAR_MODE: number;
  83098. /** Cubic coordinates mode */
  83099. static readonly CUBIC_MODE: number;
  83100. /** Projection coordinates mode */
  83101. static readonly PROJECTION_MODE: number;
  83102. /** Inverse Cubic coordinates mode */
  83103. static readonly SKYBOX_MODE: number;
  83104. /** Inverse Cubic coordinates mode */
  83105. static readonly INVCUBIC_MODE: number;
  83106. /** Equirectangular coordinates mode */
  83107. static readonly EQUIRECTANGULAR_MODE: number;
  83108. /** Equirectangular Fixed coordinates mode */
  83109. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  83110. /** Equirectangular Fixed Mirrored coordinates mode */
  83111. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83112. /** Texture is not repeating outside of 0..1 UVs */
  83113. static readonly CLAMP_ADDRESSMODE: number;
  83114. /** Texture is repeating outside of 0..1 UVs */
  83115. static readonly WRAP_ADDRESSMODE: number;
  83116. /** Texture is repeating and mirrored */
  83117. static readonly MIRROR_ADDRESSMODE: number;
  83118. /**
  83119. * 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
  83120. */
  83121. static UseSerializedUrlIfAny: boolean;
  83122. /**
  83123. * Define the url of the texture.
  83124. */
  83125. url: Nullable<string>;
  83126. /**
  83127. * Define an offset on the texture to offset the u coordinates of the UVs
  83128. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83129. */
  83130. uOffset: number;
  83131. /**
  83132. * Define an offset on the texture to offset the v coordinates of the UVs
  83133. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83134. */
  83135. vOffset: number;
  83136. /**
  83137. * Define an offset on the texture to scale the u coordinates of the UVs
  83138. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83139. */
  83140. uScale: number;
  83141. /**
  83142. * Define an offset on the texture to scale the v coordinates of the UVs
  83143. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83144. */
  83145. vScale: number;
  83146. /**
  83147. * Define an offset on the texture to rotate around the u coordinates of the UVs
  83148. * @see http://doc.babylonjs.com/how_to/more_materials
  83149. */
  83150. uAng: number;
  83151. /**
  83152. * Define an offset on the texture to rotate around the v coordinates of the UVs
  83153. * @see http://doc.babylonjs.com/how_to/more_materials
  83154. */
  83155. vAng: number;
  83156. /**
  83157. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  83158. * @see http://doc.babylonjs.com/how_to/more_materials
  83159. */
  83160. wAng: number;
  83161. /**
  83162. * Defines the center of rotation (U)
  83163. */
  83164. uRotationCenter: number;
  83165. /**
  83166. * Defines the center of rotation (V)
  83167. */
  83168. vRotationCenter: number;
  83169. /**
  83170. * Defines the center of rotation (W)
  83171. */
  83172. wRotationCenter: number;
  83173. /**
  83174. * Are mip maps generated for this texture or not.
  83175. */
  83176. readonly noMipmap: boolean;
  83177. /**
  83178. * List of inspectable custom properties (used by the Inspector)
  83179. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83180. */
  83181. inspectableCustomProperties: Nullable<IInspectable[]>;
  83182. private _noMipmap;
  83183. /** @hidden */
  83184. _invertY: boolean;
  83185. private _rowGenerationMatrix;
  83186. private _cachedTextureMatrix;
  83187. private _projectionModeMatrix;
  83188. private _t0;
  83189. private _t1;
  83190. private _t2;
  83191. private _cachedUOffset;
  83192. private _cachedVOffset;
  83193. private _cachedUScale;
  83194. private _cachedVScale;
  83195. private _cachedUAng;
  83196. private _cachedVAng;
  83197. private _cachedWAng;
  83198. private _cachedProjectionMatrixId;
  83199. private _cachedCoordinatesMode;
  83200. /** @hidden */
  83201. protected _initialSamplingMode: number;
  83202. /** @hidden */
  83203. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83204. private _deleteBuffer;
  83205. protected _format: Nullable<number>;
  83206. private _delayedOnLoad;
  83207. private _delayedOnError;
  83208. private _mimeType?;
  83209. /**
  83210. * Observable triggered once the texture has been loaded.
  83211. */
  83212. onLoadObservable: Observable<Texture>;
  83213. protected _isBlocking: boolean;
  83214. /**
  83215. * Is the texture preventing material to render while loading.
  83216. * If false, a default texture will be used instead of the loading one during the preparation step.
  83217. */
  83218. isBlocking: boolean;
  83219. /**
  83220. * Get the current sampling mode associated with the texture.
  83221. */
  83222. readonly samplingMode: number;
  83223. /**
  83224. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83225. */
  83226. readonly invertY: boolean;
  83227. /**
  83228. * Instantiates a new texture.
  83229. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83230. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83231. * @param url defines the url of the picture to load as a texture
  83232. * @param scene defines the scene or engine the texture will belong to
  83233. * @param noMipmap defines if the texture will require mip maps or not
  83234. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83235. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83236. * @param onLoad defines a callback triggered when the texture has been loaded
  83237. * @param onError defines a callback triggered when an error occurred during the loading session
  83238. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83239. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83240. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83241. * @param mimeType defines an optional mime type information
  83242. */
  83243. 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);
  83244. /**
  83245. * Update the url (and optional buffer) of this texture if url was null during construction.
  83246. * @param url the url of the texture
  83247. * @param buffer the buffer of the texture (defaults to null)
  83248. * @param onLoad callback called when the texture is loaded (defaults to null)
  83249. */
  83250. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83251. /**
  83252. * Finish the loading sequence of a texture flagged as delayed load.
  83253. * @hidden
  83254. */
  83255. delayLoad(): void;
  83256. private _prepareRowForTextureGeneration;
  83257. /**
  83258. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83259. * @returns the transform matrix of the texture.
  83260. */
  83261. getTextureMatrix(): Matrix;
  83262. /**
  83263. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83264. * @returns The reflection texture transform
  83265. */
  83266. getReflectionTextureMatrix(): Matrix;
  83267. /**
  83268. * Clones the texture.
  83269. * @returns the cloned texture
  83270. */
  83271. clone(): Texture;
  83272. /**
  83273. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83274. * @returns The JSON representation of the texture
  83275. */
  83276. serialize(): any;
  83277. /**
  83278. * Get the current class name of the texture useful for serialization or dynamic coding.
  83279. * @returns "Texture"
  83280. */
  83281. getClassName(): string;
  83282. /**
  83283. * Dispose the texture and release its associated resources.
  83284. */
  83285. dispose(): void;
  83286. /**
  83287. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83288. * @param parsedTexture Define the JSON representation of the texture
  83289. * @param scene Define the scene the parsed texture should be instantiated in
  83290. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83291. * @returns The parsed texture if successful
  83292. */
  83293. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83294. /**
  83295. * Creates a texture from its base 64 representation.
  83296. * @param data Define the base64 payload without the data: prefix
  83297. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83298. * @param scene Define the scene the texture should belong to
  83299. * @param noMipmap Forces the texture to not create mip map information if true
  83300. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83301. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83302. * @param onLoad define a callback triggered when the texture has been loaded
  83303. * @param onError define a callback triggered when an error occurred during the loading session
  83304. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83305. * @returns the created texture
  83306. */
  83307. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  83308. /**
  83309. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  83310. * @param data Define the base64 payload without the data: prefix
  83311. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83312. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  83313. * @param scene Define the scene the texture should belong to
  83314. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  83315. * @param noMipmap Forces the texture to not create mip map information if true
  83316. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83317. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83318. * @param onLoad define a callback triggered when the texture has been loaded
  83319. * @param onError define a callback triggered when an error occurred during the loading session
  83320. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83321. * @returns the created texture
  83322. */
  83323. 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;
  83324. }
  83325. }
  83326. declare module BABYLON {
  83327. /**
  83328. * PostProcessManager is used to manage one or more post processes or post process pipelines
  83329. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83330. */
  83331. export class PostProcessManager {
  83332. private _scene;
  83333. private _indexBuffer;
  83334. private _vertexBuffers;
  83335. /**
  83336. * Creates a new instance PostProcess
  83337. * @param scene The scene that the post process is associated with.
  83338. */
  83339. constructor(scene: Scene);
  83340. private _prepareBuffers;
  83341. private _buildIndexBuffer;
  83342. /**
  83343. * Rebuilds the vertex buffers of the manager.
  83344. * @hidden
  83345. */
  83346. _rebuild(): void;
  83347. /**
  83348. * Prepares a frame to be run through a post process.
  83349. * @param sourceTexture The input texture to the post procesess. (default: null)
  83350. * @param postProcesses An array of post processes to be run. (default: null)
  83351. * @returns True if the post processes were able to be run.
  83352. * @hidden
  83353. */
  83354. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  83355. /**
  83356. * Manually render a set of post processes to a texture.
  83357. * @param postProcesses An array of post processes to be run.
  83358. * @param targetTexture The target texture to render to.
  83359. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  83360. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  83361. * @param lodLevel defines which lod of the texture to render to
  83362. */
  83363. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  83364. /**
  83365. * Finalize the result of the output of the postprocesses.
  83366. * @param doNotPresent If true the result will not be displayed to the screen.
  83367. * @param targetTexture The target texture to render to.
  83368. * @param faceIndex The index of the face to bind the target texture to.
  83369. * @param postProcesses The array of post processes to render.
  83370. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  83371. * @hidden
  83372. */
  83373. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  83374. /**
  83375. * Disposes of the post process manager.
  83376. */
  83377. dispose(): void;
  83378. }
  83379. }
  83380. declare module BABYLON {
  83381. /** Interface used by value gradients (color, factor, ...) */
  83382. export interface IValueGradient {
  83383. /**
  83384. * Gets or sets the gradient value (between 0 and 1)
  83385. */
  83386. gradient: number;
  83387. }
  83388. /** Class used to store color4 gradient */
  83389. export class ColorGradient implements IValueGradient {
  83390. /**
  83391. * Gets or sets the gradient value (between 0 and 1)
  83392. */
  83393. gradient: number;
  83394. /**
  83395. * Gets or sets first associated color
  83396. */
  83397. color1: Color4;
  83398. /**
  83399. * Gets or sets second associated color
  83400. */
  83401. color2?: Color4;
  83402. /**
  83403. * Will get a color picked randomly between color1 and color2.
  83404. * If color2 is undefined then color1 will be used
  83405. * @param result defines the target Color4 to store the result in
  83406. */
  83407. getColorToRef(result: Color4): void;
  83408. }
  83409. /** Class used to store color 3 gradient */
  83410. export class Color3Gradient implements IValueGradient {
  83411. /**
  83412. * Gets or sets the gradient value (between 0 and 1)
  83413. */
  83414. gradient: number;
  83415. /**
  83416. * Gets or sets the associated color
  83417. */
  83418. color: Color3;
  83419. }
  83420. /** Class used to store factor gradient */
  83421. export class FactorGradient implements IValueGradient {
  83422. /**
  83423. * Gets or sets the gradient value (between 0 and 1)
  83424. */
  83425. gradient: number;
  83426. /**
  83427. * Gets or sets first associated factor
  83428. */
  83429. factor1: number;
  83430. /**
  83431. * Gets or sets second associated factor
  83432. */
  83433. factor2?: number;
  83434. /**
  83435. * Will get a number picked randomly between factor1 and factor2.
  83436. * If factor2 is undefined then factor1 will be used
  83437. * @returns the picked number
  83438. */
  83439. getFactor(): number;
  83440. }
  83441. /**
  83442. * Helper used to simplify some generic gradient tasks
  83443. */
  83444. export class GradientHelper {
  83445. /**
  83446. * Gets the current gradient from an array of IValueGradient
  83447. * @param ratio defines the current ratio to get
  83448. * @param gradients defines the array of IValueGradient
  83449. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83450. */
  83451. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83452. }
  83453. }
  83454. declare module BABYLON {
  83455. interface ThinEngine {
  83456. /**
  83457. * Creates a dynamic texture
  83458. * @param width defines the width of the texture
  83459. * @param height defines the height of the texture
  83460. * @param generateMipMaps defines if the engine should generate the mip levels
  83461. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83462. * @returns the dynamic texture inside an InternalTexture
  83463. */
  83464. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83465. /**
  83466. * Update the content of a dynamic texture
  83467. * @param texture defines the texture to update
  83468. * @param canvas defines the canvas containing the source
  83469. * @param invertY defines if data must be stored with Y axis inverted
  83470. * @param premulAlpha defines if alpha is stored as premultiplied
  83471. * @param format defines the format of the data
  83472. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83473. */
  83474. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83475. }
  83476. }
  83477. declare module BABYLON {
  83478. /**
  83479. * Helper class used to generate a canvas to manipulate images
  83480. */
  83481. export class CanvasGenerator {
  83482. /**
  83483. * Create a new canvas (or offscreen canvas depending on the context)
  83484. * @param width defines the expected width
  83485. * @param height defines the expected height
  83486. * @return a new canvas or offscreen canvas
  83487. */
  83488. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83489. }
  83490. }
  83491. declare module BABYLON {
  83492. /**
  83493. * A class extending Texture allowing drawing on a texture
  83494. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83495. */
  83496. export class DynamicTexture extends Texture {
  83497. private _generateMipMaps;
  83498. private _canvas;
  83499. private _context;
  83500. private _engine;
  83501. /**
  83502. * Creates a DynamicTexture
  83503. * @param name defines the name of the texture
  83504. * @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
  83505. * @param scene defines the scene where you want the texture
  83506. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83507. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83508. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83509. */
  83510. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83511. /**
  83512. * Get the current class name of the texture useful for serialization or dynamic coding.
  83513. * @returns "DynamicTexture"
  83514. */
  83515. getClassName(): string;
  83516. /**
  83517. * Gets the current state of canRescale
  83518. */
  83519. readonly canRescale: boolean;
  83520. private _recreate;
  83521. /**
  83522. * Scales the texture
  83523. * @param ratio the scale factor to apply to both width and height
  83524. */
  83525. scale(ratio: number): void;
  83526. /**
  83527. * Resizes the texture
  83528. * @param width the new width
  83529. * @param height the new height
  83530. */
  83531. scaleTo(width: number, height: number): void;
  83532. /**
  83533. * Gets the context of the canvas used by the texture
  83534. * @returns the canvas context of the dynamic texture
  83535. */
  83536. getContext(): CanvasRenderingContext2D;
  83537. /**
  83538. * Clears the texture
  83539. */
  83540. clear(): void;
  83541. /**
  83542. * Updates the texture
  83543. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83544. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83545. */
  83546. update(invertY?: boolean, premulAlpha?: boolean): void;
  83547. /**
  83548. * Draws text onto the texture
  83549. * @param text defines the text to be drawn
  83550. * @param x defines the placement of the text from the left
  83551. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83552. * @param font defines the font to be used with font-style, font-size, font-name
  83553. * @param color defines the color used for the text
  83554. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83555. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83556. * @param update defines whether texture is immediately update (default is true)
  83557. */
  83558. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83559. /**
  83560. * Clones the texture
  83561. * @returns the clone of the texture.
  83562. */
  83563. clone(): DynamicTexture;
  83564. /**
  83565. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83566. * @returns a serialized dynamic texture object
  83567. */
  83568. serialize(): any;
  83569. /** @hidden */
  83570. _rebuild(): void;
  83571. }
  83572. }
  83573. declare module BABYLON {
  83574. interface AbstractScene {
  83575. /**
  83576. * The list of procedural textures added to the scene
  83577. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83578. */
  83579. proceduralTextures: Array<ProceduralTexture>;
  83580. }
  83581. /**
  83582. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83583. * in a given scene.
  83584. */
  83585. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83586. /**
  83587. * The component name helpfull to identify the component in the list of scene components.
  83588. */
  83589. readonly name: string;
  83590. /**
  83591. * The scene the component belongs to.
  83592. */
  83593. scene: Scene;
  83594. /**
  83595. * Creates a new instance of the component for the given scene
  83596. * @param scene Defines the scene to register the component in
  83597. */
  83598. constructor(scene: Scene);
  83599. /**
  83600. * Registers the component in a given scene
  83601. */
  83602. register(): void;
  83603. /**
  83604. * Rebuilds the elements related to this component in case of
  83605. * context lost for instance.
  83606. */
  83607. rebuild(): void;
  83608. /**
  83609. * Disposes the component and the associated ressources.
  83610. */
  83611. dispose(): void;
  83612. private _beforeClear;
  83613. }
  83614. }
  83615. declare module BABYLON {
  83616. interface ThinEngine {
  83617. /**
  83618. * Creates a new render target cube texture
  83619. * @param size defines the size of the texture
  83620. * @param options defines the options used to create the texture
  83621. * @returns a new render target cube texture stored in an InternalTexture
  83622. */
  83623. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83624. }
  83625. }
  83626. declare module BABYLON {
  83627. /** @hidden */
  83628. export var proceduralVertexShader: {
  83629. name: string;
  83630. shader: string;
  83631. };
  83632. }
  83633. declare module BABYLON {
  83634. /**
  83635. * 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.
  83636. * This is the base class of any Procedural texture and contains most of the shareable code.
  83637. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83638. */
  83639. export class ProceduralTexture extends Texture {
  83640. isCube: boolean;
  83641. /**
  83642. * Define if the texture is enabled or not (disabled texture will not render)
  83643. */
  83644. isEnabled: boolean;
  83645. /**
  83646. * Define if the texture must be cleared before rendering (default is true)
  83647. */
  83648. autoClear: boolean;
  83649. /**
  83650. * Callback called when the texture is generated
  83651. */
  83652. onGenerated: () => void;
  83653. /**
  83654. * Event raised when the texture is generated
  83655. */
  83656. onGeneratedObservable: Observable<ProceduralTexture>;
  83657. /** @hidden */
  83658. _generateMipMaps: boolean;
  83659. /** @hidden **/
  83660. _effect: Effect;
  83661. /** @hidden */
  83662. _textures: {
  83663. [key: string]: Texture;
  83664. };
  83665. private _size;
  83666. private _currentRefreshId;
  83667. private _refreshRate;
  83668. private _vertexBuffers;
  83669. private _indexBuffer;
  83670. private _uniforms;
  83671. private _samplers;
  83672. private _fragment;
  83673. private _floats;
  83674. private _ints;
  83675. private _floatsArrays;
  83676. private _colors3;
  83677. private _colors4;
  83678. private _vectors2;
  83679. private _vectors3;
  83680. private _matrices;
  83681. private _fallbackTexture;
  83682. private _fallbackTextureUsed;
  83683. private _engine;
  83684. private _cachedDefines;
  83685. private _contentUpdateId;
  83686. private _contentData;
  83687. /**
  83688. * Instantiates a new procedural texture.
  83689. * 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.
  83690. * This is the base class of any Procedural texture and contains most of the shareable code.
  83691. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83692. * @param name Define the name of the texture
  83693. * @param size Define the size of the texture to create
  83694. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83695. * @param scene Define the scene the texture belongs to
  83696. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83697. * @param generateMipMaps Define if the texture should creates mip maps or not
  83698. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83699. */
  83700. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83701. /**
  83702. * The effect that is created when initializing the post process.
  83703. * @returns The created effect corresponding the the postprocess.
  83704. */
  83705. getEffect(): Effect;
  83706. /**
  83707. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83708. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83709. */
  83710. getContent(): Nullable<ArrayBufferView>;
  83711. private _createIndexBuffer;
  83712. /** @hidden */
  83713. _rebuild(): void;
  83714. /**
  83715. * Resets the texture in order to recreate its associated resources.
  83716. * This can be called in case of context loss
  83717. */
  83718. reset(): void;
  83719. protected _getDefines(): string;
  83720. /**
  83721. * Is the texture ready to be used ? (rendered at least once)
  83722. * @returns true if ready, otherwise, false.
  83723. */
  83724. isReady(): boolean;
  83725. /**
  83726. * Resets the refresh counter of the texture and start bak from scratch.
  83727. * Could be useful to regenerate the texture if it is setup to render only once.
  83728. */
  83729. resetRefreshCounter(): void;
  83730. /**
  83731. * Set the fragment shader to use in order to render the texture.
  83732. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83733. */
  83734. setFragment(fragment: any): void;
  83735. /**
  83736. * Define the refresh rate of the texture or the rendering frequency.
  83737. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83738. */
  83739. refreshRate: number;
  83740. /** @hidden */
  83741. _shouldRender(): boolean;
  83742. /**
  83743. * Get the size the texture is rendering at.
  83744. * @returns the size (texture is always squared)
  83745. */
  83746. getRenderSize(): number;
  83747. /**
  83748. * Resize the texture to new value.
  83749. * @param size Define the new size the texture should have
  83750. * @param generateMipMaps Define whether the new texture should create mip maps
  83751. */
  83752. resize(size: number, generateMipMaps: boolean): void;
  83753. private _checkUniform;
  83754. /**
  83755. * Set a texture in the shader program used to render.
  83756. * @param name Define the name of the uniform samplers as defined in the shader
  83757. * @param texture Define the texture to bind to this sampler
  83758. * @return the texture itself allowing "fluent" like uniform updates
  83759. */
  83760. setTexture(name: string, texture: Texture): ProceduralTexture;
  83761. /**
  83762. * Set a float in the shader.
  83763. * @param name Define the name of the uniform as defined in the shader
  83764. * @param value Define the value to give to the uniform
  83765. * @return the texture itself allowing "fluent" like uniform updates
  83766. */
  83767. setFloat(name: string, value: number): ProceduralTexture;
  83768. /**
  83769. * Set a int in the shader.
  83770. * @param name Define the name of the uniform as defined in the shader
  83771. * @param value Define the value to give to the uniform
  83772. * @return the texture itself allowing "fluent" like uniform updates
  83773. */
  83774. setInt(name: string, value: number): ProceduralTexture;
  83775. /**
  83776. * Set an array of floats in the shader.
  83777. * @param name Define the name of the uniform as defined in the shader
  83778. * @param value Define the value to give to the uniform
  83779. * @return the texture itself allowing "fluent" like uniform updates
  83780. */
  83781. setFloats(name: string, value: number[]): ProceduralTexture;
  83782. /**
  83783. * Set a vec3 in the shader from a Color3.
  83784. * @param name Define the name of the uniform as defined in the shader
  83785. * @param value Define the value to give to the uniform
  83786. * @return the texture itself allowing "fluent" like uniform updates
  83787. */
  83788. setColor3(name: string, value: Color3): ProceduralTexture;
  83789. /**
  83790. * Set a vec4 in the shader from a Color4.
  83791. * @param name Define the name of the uniform as defined in the shader
  83792. * @param value Define the value to give to the uniform
  83793. * @return the texture itself allowing "fluent" like uniform updates
  83794. */
  83795. setColor4(name: string, value: Color4): ProceduralTexture;
  83796. /**
  83797. * Set a vec2 in the shader from a Vector2.
  83798. * @param name Define the name of the uniform as defined in the shader
  83799. * @param value Define the value to give to the uniform
  83800. * @return the texture itself allowing "fluent" like uniform updates
  83801. */
  83802. setVector2(name: string, value: Vector2): ProceduralTexture;
  83803. /**
  83804. * Set a vec3 in the shader from a Vector3.
  83805. * @param name Define the name of the uniform as defined in the shader
  83806. * @param value Define the value to give to the uniform
  83807. * @return the texture itself allowing "fluent" like uniform updates
  83808. */
  83809. setVector3(name: string, value: Vector3): ProceduralTexture;
  83810. /**
  83811. * Set a mat4 in the shader from a MAtrix.
  83812. * @param name Define the name of the uniform as defined in the shader
  83813. * @param value Define the value to give to the uniform
  83814. * @return the texture itself allowing "fluent" like uniform updates
  83815. */
  83816. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83817. /**
  83818. * Render the texture to its associated render target.
  83819. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83820. */
  83821. render(useCameraPostProcess?: boolean): void;
  83822. /**
  83823. * Clone the texture.
  83824. * @returns the cloned texture
  83825. */
  83826. clone(): ProceduralTexture;
  83827. /**
  83828. * Dispose the texture and release its asoociated resources.
  83829. */
  83830. dispose(): void;
  83831. }
  83832. }
  83833. declare module BABYLON {
  83834. /**
  83835. * This represents the base class for particle system in Babylon.
  83836. * 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.
  83837. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83838. * @example https://doc.babylonjs.com/babylon101/particles
  83839. */
  83840. export class BaseParticleSystem {
  83841. /**
  83842. * Source color is added to the destination color without alpha affecting the result
  83843. */
  83844. static BLENDMODE_ONEONE: number;
  83845. /**
  83846. * Blend current color and particle color using particle’s alpha
  83847. */
  83848. static BLENDMODE_STANDARD: number;
  83849. /**
  83850. * Add current color and particle color multiplied by particle’s alpha
  83851. */
  83852. static BLENDMODE_ADD: number;
  83853. /**
  83854. * Multiply current color with particle color
  83855. */
  83856. static BLENDMODE_MULTIPLY: number;
  83857. /**
  83858. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83859. */
  83860. static BLENDMODE_MULTIPLYADD: number;
  83861. /**
  83862. * List of animations used by the particle system.
  83863. */
  83864. animations: Animation[];
  83865. /**
  83866. * The id of the Particle system.
  83867. */
  83868. id: string;
  83869. /**
  83870. * The friendly name of the Particle system.
  83871. */
  83872. name: string;
  83873. /**
  83874. * The rendering group used by the Particle system to chose when to render.
  83875. */
  83876. renderingGroupId: number;
  83877. /**
  83878. * The emitter represents the Mesh or position we are attaching the particle system to.
  83879. */
  83880. emitter: Nullable<AbstractMesh | Vector3>;
  83881. /**
  83882. * The maximum number of particles to emit per frame
  83883. */
  83884. emitRate: number;
  83885. /**
  83886. * If you want to launch only a few particles at once, that can be done, as well.
  83887. */
  83888. manualEmitCount: number;
  83889. /**
  83890. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83891. */
  83892. updateSpeed: number;
  83893. /**
  83894. * The amount of time the particle system is running (depends of the overall update speed).
  83895. */
  83896. targetStopDuration: number;
  83897. /**
  83898. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83899. */
  83900. disposeOnStop: boolean;
  83901. /**
  83902. * Minimum power of emitting particles.
  83903. */
  83904. minEmitPower: number;
  83905. /**
  83906. * Maximum power of emitting particles.
  83907. */
  83908. maxEmitPower: number;
  83909. /**
  83910. * Minimum life time of emitting particles.
  83911. */
  83912. minLifeTime: number;
  83913. /**
  83914. * Maximum life time of emitting particles.
  83915. */
  83916. maxLifeTime: number;
  83917. /**
  83918. * Minimum Size of emitting particles.
  83919. */
  83920. minSize: number;
  83921. /**
  83922. * Maximum Size of emitting particles.
  83923. */
  83924. maxSize: number;
  83925. /**
  83926. * Minimum scale of emitting particles on X axis.
  83927. */
  83928. minScaleX: number;
  83929. /**
  83930. * Maximum scale of emitting particles on X axis.
  83931. */
  83932. maxScaleX: number;
  83933. /**
  83934. * Minimum scale of emitting particles on Y axis.
  83935. */
  83936. minScaleY: number;
  83937. /**
  83938. * Maximum scale of emitting particles on Y axis.
  83939. */
  83940. maxScaleY: number;
  83941. /**
  83942. * Gets or sets the minimal initial rotation in radians.
  83943. */
  83944. minInitialRotation: number;
  83945. /**
  83946. * Gets or sets the maximal initial rotation in radians.
  83947. */
  83948. maxInitialRotation: number;
  83949. /**
  83950. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83951. */
  83952. minAngularSpeed: number;
  83953. /**
  83954. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83955. */
  83956. maxAngularSpeed: number;
  83957. /**
  83958. * The texture used to render each particle. (this can be a spritesheet)
  83959. */
  83960. particleTexture: Nullable<Texture>;
  83961. /**
  83962. * The layer mask we are rendering the particles through.
  83963. */
  83964. layerMask: number;
  83965. /**
  83966. * This can help using your own shader to render the particle system.
  83967. * The according effect will be created
  83968. */
  83969. customShader: any;
  83970. /**
  83971. * By default particle system starts as soon as they are created. This prevents the
  83972. * automatic start to happen and let you decide when to start emitting particles.
  83973. */
  83974. preventAutoStart: boolean;
  83975. private _noiseTexture;
  83976. /**
  83977. * Gets or sets a texture used to add random noise to particle positions
  83978. */
  83979. noiseTexture: Nullable<ProceduralTexture>;
  83980. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83981. noiseStrength: Vector3;
  83982. /**
  83983. * Callback triggered when the particle animation is ending.
  83984. */
  83985. onAnimationEnd: Nullable<() => void>;
  83986. /**
  83987. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83988. */
  83989. blendMode: number;
  83990. /**
  83991. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83992. * to override the particles.
  83993. */
  83994. forceDepthWrite: boolean;
  83995. /** 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 */
  83996. preWarmCycles: number;
  83997. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83998. preWarmStepOffset: number;
  83999. /**
  84000. * 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)
  84001. */
  84002. spriteCellChangeSpeed: number;
  84003. /**
  84004. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84005. */
  84006. startSpriteCellID: number;
  84007. /**
  84008. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84009. */
  84010. endSpriteCellID: number;
  84011. /**
  84012. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84013. */
  84014. spriteCellWidth: number;
  84015. /**
  84016. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84017. */
  84018. spriteCellHeight: number;
  84019. /**
  84020. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84021. */
  84022. spriteRandomStartCell: boolean;
  84023. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84024. translationPivot: Vector2;
  84025. /** @hidden */
  84026. protected _isAnimationSheetEnabled: boolean;
  84027. /**
  84028. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84029. */
  84030. beginAnimationOnStart: boolean;
  84031. /**
  84032. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84033. */
  84034. beginAnimationFrom: number;
  84035. /**
  84036. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84037. */
  84038. beginAnimationTo: number;
  84039. /**
  84040. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84041. */
  84042. beginAnimationLoop: boolean;
  84043. /**
  84044. * Gets or sets a world offset applied to all particles
  84045. */
  84046. worldOffset: Vector3;
  84047. /**
  84048. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84049. */
  84050. isAnimationSheetEnabled: boolean;
  84051. /**
  84052. * Get hosting scene
  84053. * @returns the scene
  84054. */
  84055. getScene(): Scene;
  84056. /**
  84057. * You can use gravity if you want to give an orientation to your particles.
  84058. */
  84059. gravity: Vector3;
  84060. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84061. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84062. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84063. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84064. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84065. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84066. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84067. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84068. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84069. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84070. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84071. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84072. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84073. /**
  84074. * Defines the delay in milliseconds before starting the system (0 by default)
  84075. */
  84076. startDelay: number;
  84077. /**
  84078. * Gets the current list of drag gradients.
  84079. * You must use addDragGradient and removeDragGradient to udpate this list
  84080. * @returns the list of drag gradients
  84081. */
  84082. getDragGradients(): Nullable<Array<FactorGradient>>;
  84083. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84084. limitVelocityDamping: number;
  84085. /**
  84086. * Gets the current list of limit velocity gradients.
  84087. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84088. * @returns the list of limit velocity gradients
  84089. */
  84090. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84091. /**
  84092. * Gets the current list of color gradients.
  84093. * You must use addColorGradient and removeColorGradient to udpate this list
  84094. * @returns the list of color gradients
  84095. */
  84096. getColorGradients(): Nullable<Array<ColorGradient>>;
  84097. /**
  84098. * Gets the current list of size gradients.
  84099. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84100. * @returns the list of size gradients
  84101. */
  84102. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84103. /**
  84104. * Gets the current list of color remap gradients.
  84105. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84106. * @returns the list of color remap gradients
  84107. */
  84108. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84109. /**
  84110. * Gets the current list of alpha remap gradients.
  84111. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84112. * @returns the list of alpha remap gradients
  84113. */
  84114. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84115. /**
  84116. * Gets the current list of life time gradients.
  84117. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84118. * @returns the list of life time gradients
  84119. */
  84120. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84121. /**
  84122. * Gets the current list of angular speed gradients.
  84123. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84124. * @returns the list of angular speed gradients
  84125. */
  84126. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84127. /**
  84128. * Gets the current list of velocity gradients.
  84129. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84130. * @returns the list of velocity gradients
  84131. */
  84132. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84133. /**
  84134. * Gets the current list of start size gradients.
  84135. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84136. * @returns the list of start size gradients
  84137. */
  84138. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84139. /**
  84140. * Gets the current list of emit rate gradients.
  84141. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84142. * @returns the list of emit rate gradients
  84143. */
  84144. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84145. /**
  84146. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84147. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84148. */
  84149. direction1: Vector3;
  84150. /**
  84151. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84152. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84153. */
  84154. direction2: Vector3;
  84155. /**
  84156. * 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.
  84157. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84158. */
  84159. minEmitBox: Vector3;
  84160. /**
  84161. * 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.
  84162. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84163. */
  84164. maxEmitBox: Vector3;
  84165. /**
  84166. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84167. */
  84168. color1: Color4;
  84169. /**
  84170. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84171. */
  84172. color2: Color4;
  84173. /**
  84174. * Color the particle will have at the end of its lifetime
  84175. */
  84176. colorDead: Color4;
  84177. /**
  84178. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84179. */
  84180. textureMask: Color4;
  84181. /**
  84182. * The particle emitter type defines the emitter used by the particle system.
  84183. * It can be for example box, sphere, or cone...
  84184. */
  84185. particleEmitterType: IParticleEmitterType;
  84186. /** @hidden */
  84187. _isSubEmitter: boolean;
  84188. /**
  84189. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84190. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84191. */
  84192. billboardMode: number;
  84193. protected _isBillboardBased: boolean;
  84194. /**
  84195. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84196. */
  84197. isBillboardBased: boolean;
  84198. /**
  84199. * The scene the particle system belongs to.
  84200. */
  84201. protected _scene: Scene;
  84202. /**
  84203. * Local cache of defines for image processing.
  84204. */
  84205. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84206. /**
  84207. * Default configuration related to image processing available in the standard Material.
  84208. */
  84209. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84210. /**
  84211. * Gets the image processing configuration used either in this material.
  84212. */
  84213. /**
  84214. * Sets the Default image processing configuration used either in the this material.
  84215. *
  84216. * If sets to null, the scene one is in use.
  84217. */
  84218. imageProcessingConfiguration: ImageProcessingConfiguration;
  84219. /**
  84220. * Attaches a new image processing configuration to the Standard Material.
  84221. * @param configuration
  84222. */
  84223. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84224. /** @hidden */
  84225. protected _reset(): void;
  84226. /** @hidden */
  84227. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84228. /**
  84229. * Instantiates a particle system.
  84230. * 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.
  84231. * @param name The name of the particle system
  84232. */
  84233. constructor(name: string);
  84234. /**
  84235. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84236. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84237. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84238. * @returns the emitter
  84239. */
  84240. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84241. /**
  84242. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84243. * @param radius The radius of the hemisphere to emit from
  84244. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84245. * @returns the emitter
  84246. */
  84247. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84248. /**
  84249. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84250. * @param radius The radius of the sphere to emit from
  84251. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84252. * @returns the emitter
  84253. */
  84254. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84255. /**
  84256. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84257. * @param radius The radius of the sphere to emit from
  84258. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84259. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84260. * @returns the emitter
  84261. */
  84262. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84263. /**
  84264. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84265. * @param radius The radius of the emission cylinder
  84266. * @param height The height of the emission cylinder
  84267. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84268. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84269. * @returns the emitter
  84270. */
  84271. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84272. /**
  84273. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84274. * @param radius The radius of the cylinder to emit from
  84275. * @param height The height of the emission cylinder
  84276. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84277. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84278. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84279. * @returns the emitter
  84280. */
  84281. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84282. /**
  84283. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84284. * @param radius The radius of the cone to emit from
  84285. * @param angle The base angle of the cone
  84286. * @returns the emitter
  84287. */
  84288. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84289. /**
  84290. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84291. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84292. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84293. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84294. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84295. * @returns the emitter
  84296. */
  84297. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84298. }
  84299. }
  84300. declare module BABYLON {
  84301. /**
  84302. * Type of sub emitter
  84303. */
  84304. export enum SubEmitterType {
  84305. /**
  84306. * Attached to the particle over it's lifetime
  84307. */
  84308. ATTACHED = 0,
  84309. /**
  84310. * Created when the particle dies
  84311. */
  84312. END = 1
  84313. }
  84314. /**
  84315. * Sub emitter class used to emit particles from an existing particle
  84316. */
  84317. export class SubEmitter {
  84318. /**
  84319. * the particle system to be used by the sub emitter
  84320. */
  84321. particleSystem: ParticleSystem;
  84322. /**
  84323. * Type of the submitter (Default: END)
  84324. */
  84325. type: SubEmitterType;
  84326. /**
  84327. * 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)
  84328. * Note: This only is supported when using an emitter of type Mesh
  84329. */
  84330. inheritDirection: boolean;
  84331. /**
  84332. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84333. */
  84334. inheritedVelocityAmount: number;
  84335. /**
  84336. * Creates a sub emitter
  84337. * @param particleSystem the particle system to be used by the sub emitter
  84338. */
  84339. constructor(
  84340. /**
  84341. * the particle system to be used by the sub emitter
  84342. */
  84343. particleSystem: ParticleSystem);
  84344. /**
  84345. * Clones the sub emitter
  84346. * @returns the cloned sub emitter
  84347. */
  84348. clone(): SubEmitter;
  84349. /**
  84350. * Serialize current object to a JSON object
  84351. * @returns the serialized object
  84352. */
  84353. serialize(): any;
  84354. /** @hidden */
  84355. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84356. /**
  84357. * Creates a new SubEmitter from a serialized JSON version
  84358. * @param serializationObject defines the JSON object to read from
  84359. * @param scene defines the hosting scene
  84360. * @param rootUrl defines the rootUrl for data loading
  84361. * @returns a new SubEmitter
  84362. */
  84363. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84364. /** Release associated resources */
  84365. dispose(): void;
  84366. }
  84367. }
  84368. declare module BABYLON {
  84369. /** @hidden */
  84370. export var clipPlaneFragmentDeclaration: {
  84371. name: string;
  84372. shader: string;
  84373. };
  84374. }
  84375. declare module BABYLON {
  84376. /** @hidden */
  84377. export var imageProcessingDeclaration: {
  84378. name: string;
  84379. shader: string;
  84380. };
  84381. }
  84382. declare module BABYLON {
  84383. /** @hidden */
  84384. export var imageProcessingFunctions: {
  84385. name: string;
  84386. shader: string;
  84387. };
  84388. }
  84389. declare module BABYLON {
  84390. /** @hidden */
  84391. export var clipPlaneFragment: {
  84392. name: string;
  84393. shader: string;
  84394. };
  84395. }
  84396. declare module BABYLON {
  84397. /** @hidden */
  84398. export var particlesPixelShader: {
  84399. name: string;
  84400. shader: string;
  84401. };
  84402. }
  84403. declare module BABYLON {
  84404. /** @hidden */
  84405. export var clipPlaneVertexDeclaration: {
  84406. name: string;
  84407. shader: string;
  84408. };
  84409. }
  84410. declare module BABYLON {
  84411. /** @hidden */
  84412. export var clipPlaneVertex: {
  84413. name: string;
  84414. shader: string;
  84415. };
  84416. }
  84417. declare module BABYLON {
  84418. /** @hidden */
  84419. export var particlesVertexShader: {
  84420. name: string;
  84421. shader: string;
  84422. };
  84423. }
  84424. declare module BABYLON {
  84425. /**
  84426. * This represents a particle system in Babylon.
  84427. * 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.
  84428. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84429. * @example https://doc.babylonjs.com/babylon101/particles
  84430. */
  84431. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84432. /**
  84433. * Billboard mode will only apply to Y axis
  84434. */
  84435. static readonly BILLBOARDMODE_Y: number;
  84436. /**
  84437. * Billboard mode will apply to all axes
  84438. */
  84439. static readonly BILLBOARDMODE_ALL: number;
  84440. /**
  84441. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84442. */
  84443. static readonly BILLBOARDMODE_STRETCHED: number;
  84444. /**
  84445. * This function can be defined to provide custom update for active particles.
  84446. * This function will be called instead of regular update (age, position, color, etc.).
  84447. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84448. */
  84449. updateFunction: (particles: Particle[]) => void;
  84450. private _emitterWorldMatrix;
  84451. /**
  84452. * This function can be defined to specify initial direction for every new particle.
  84453. * It by default use the emitterType defined function
  84454. */
  84455. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84456. /**
  84457. * This function can be defined to specify initial position for every new particle.
  84458. * It by default use the emitterType defined function
  84459. */
  84460. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84461. /**
  84462. * @hidden
  84463. */
  84464. _inheritedVelocityOffset: Vector3;
  84465. /**
  84466. * An event triggered when the system is disposed
  84467. */
  84468. onDisposeObservable: Observable<ParticleSystem>;
  84469. private _onDisposeObserver;
  84470. /**
  84471. * Sets a callback that will be triggered when the system is disposed
  84472. */
  84473. onDispose: () => void;
  84474. private _particles;
  84475. private _epsilon;
  84476. private _capacity;
  84477. private _stockParticles;
  84478. private _newPartsExcess;
  84479. private _vertexData;
  84480. private _vertexBuffer;
  84481. private _vertexBuffers;
  84482. private _spriteBuffer;
  84483. private _indexBuffer;
  84484. private _effect;
  84485. private _customEffect;
  84486. private _cachedDefines;
  84487. private _scaledColorStep;
  84488. private _colorDiff;
  84489. private _scaledDirection;
  84490. private _scaledGravity;
  84491. private _currentRenderId;
  84492. private _alive;
  84493. private _useInstancing;
  84494. private _started;
  84495. private _stopped;
  84496. private _actualFrame;
  84497. private _scaledUpdateSpeed;
  84498. private _vertexBufferSize;
  84499. /** @hidden */
  84500. _currentEmitRateGradient: Nullable<FactorGradient>;
  84501. /** @hidden */
  84502. _currentEmitRate1: number;
  84503. /** @hidden */
  84504. _currentEmitRate2: number;
  84505. /** @hidden */
  84506. _currentStartSizeGradient: Nullable<FactorGradient>;
  84507. /** @hidden */
  84508. _currentStartSize1: number;
  84509. /** @hidden */
  84510. _currentStartSize2: number;
  84511. private readonly _rawTextureWidth;
  84512. private _rampGradientsTexture;
  84513. private _useRampGradients;
  84514. /** Gets or sets a boolean indicating that ramp gradients must be used
  84515. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84516. */
  84517. useRampGradients: boolean;
  84518. /**
  84519. * 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.
  84520. * 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: [])
  84521. */
  84522. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84523. private _subEmitters;
  84524. /**
  84525. * @hidden
  84526. * If the particle systems emitter should be disposed when the particle system is disposed
  84527. */
  84528. _disposeEmitterOnDispose: boolean;
  84529. /**
  84530. * The current active Sub-systems, this property is used by the root particle system only.
  84531. */
  84532. activeSubSystems: Array<ParticleSystem>;
  84533. private _rootParticleSystem;
  84534. /**
  84535. * Gets the current list of active particles
  84536. */
  84537. readonly particles: Particle[];
  84538. /**
  84539. * Returns the string "ParticleSystem"
  84540. * @returns a string containing the class name
  84541. */
  84542. getClassName(): string;
  84543. /**
  84544. * Instantiates a particle system.
  84545. * 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.
  84546. * @param name The name of the particle system
  84547. * @param capacity The max number of particles alive at the same time
  84548. * @param scene The scene the particle system belongs to
  84549. * @param customEffect a custom effect used to change the way particles are rendered by default
  84550. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84551. * @param epsilon Offset used to render the particles
  84552. */
  84553. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84554. private _addFactorGradient;
  84555. private _removeFactorGradient;
  84556. /**
  84557. * Adds a new life time gradient
  84558. * @param gradient defines the gradient to use (between 0 and 1)
  84559. * @param factor defines the life time factor to affect to the specified gradient
  84560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84561. * @returns the current particle system
  84562. */
  84563. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84564. /**
  84565. * Remove a specific life time gradient
  84566. * @param gradient defines the gradient to remove
  84567. * @returns the current particle system
  84568. */
  84569. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84570. /**
  84571. * Adds a new size gradient
  84572. * @param gradient defines the gradient to use (between 0 and 1)
  84573. * @param factor defines the size factor to affect to the specified gradient
  84574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84575. * @returns the current particle system
  84576. */
  84577. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84578. /**
  84579. * Remove a specific size gradient
  84580. * @param gradient defines the gradient to remove
  84581. * @returns the current particle system
  84582. */
  84583. removeSizeGradient(gradient: number): IParticleSystem;
  84584. /**
  84585. * Adds a new color remap gradient
  84586. * @param gradient defines the gradient to use (between 0 and 1)
  84587. * @param min defines the color remap minimal range
  84588. * @param max defines the color remap maximal range
  84589. * @returns the current particle system
  84590. */
  84591. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84592. /**
  84593. * Remove a specific color remap gradient
  84594. * @param gradient defines the gradient to remove
  84595. * @returns the current particle system
  84596. */
  84597. removeColorRemapGradient(gradient: number): IParticleSystem;
  84598. /**
  84599. * Adds a new alpha remap gradient
  84600. * @param gradient defines the gradient to use (between 0 and 1)
  84601. * @param min defines the alpha remap minimal range
  84602. * @param max defines the alpha remap maximal range
  84603. * @returns the current particle system
  84604. */
  84605. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84606. /**
  84607. * Remove a specific alpha remap gradient
  84608. * @param gradient defines the gradient to remove
  84609. * @returns the current particle system
  84610. */
  84611. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84612. /**
  84613. * Adds a new angular speed gradient
  84614. * @param gradient defines the gradient to use (between 0 and 1)
  84615. * @param factor defines the angular speed to affect to the specified gradient
  84616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84617. * @returns the current particle system
  84618. */
  84619. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84620. /**
  84621. * Remove a specific angular speed gradient
  84622. * @param gradient defines the gradient to remove
  84623. * @returns the current particle system
  84624. */
  84625. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84626. /**
  84627. * Adds a new velocity gradient
  84628. * @param gradient defines the gradient to use (between 0 and 1)
  84629. * @param factor defines the velocity to affect to the specified gradient
  84630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84631. * @returns the current particle system
  84632. */
  84633. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84634. /**
  84635. * Remove a specific velocity gradient
  84636. * @param gradient defines the gradient to remove
  84637. * @returns the current particle system
  84638. */
  84639. removeVelocityGradient(gradient: number): IParticleSystem;
  84640. /**
  84641. * Adds a new limit velocity gradient
  84642. * @param gradient defines the gradient to use (between 0 and 1)
  84643. * @param factor defines the limit velocity value to affect to the specified gradient
  84644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84645. * @returns the current particle system
  84646. */
  84647. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84648. /**
  84649. * Remove a specific limit velocity gradient
  84650. * @param gradient defines the gradient to remove
  84651. * @returns the current particle system
  84652. */
  84653. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84654. /**
  84655. * Adds a new drag gradient
  84656. * @param gradient defines the gradient to use (between 0 and 1)
  84657. * @param factor defines the drag value to affect to the specified gradient
  84658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84659. * @returns the current particle system
  84660. */
  84661. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84662. /**
  84663. * Remove a specific drag gradient
  84664. * @param gradient defines the gradient to remove
  84665. * @returns the current particle system
  84666. */
  84667. removeDragGradient(gradient: number): IParticleSystem;
  84668. /**
  84669. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84670. * @param gradient defines the gradient to use (between 0 and 1)
  84671. * @param factor defines the emit rate value to affect to the specified gradient
  84672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84673. * @returns the current particle system
  84674. */
  84675. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84676. /**
  84677. * Remove a specific emit rate gradient
  84678. * @param gradient defines the gradient to remove
  84679. * @returns the current particle system
  84680. */
  84681. removeEmitRateGradient(gradient: number): IParticleSystem;
  84682. /**
  84683. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84684. * @param gradient defines the gradient to use (between 0 and 1)
  84685. * @param factor defines the start size value to affect to the specified gradient
  84686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84687. * @returns the current particle system
  84688. */
  84689. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84690. /**
  84691. * Remove a specific start size gradient
  84692. * @param gradient defines the gradient to remove
  84693. * @returns the current particle system
  84694. */
  84695. removeStartSizeGradient(gradient: number): IParticleSystem;
  84696. private _createRampGradientTexture;
  84697. /**
  84698. * Gets the current list of ramp gradients.
  84699. * You must use addRampGradient and removeRampGradient to udpate this list
  84700. * @returns the list of ramp gradients
  84701. */
  84702. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84703. /**
  84704. * Adds a new ramp gradient used to remap particle colors
  84705. * @param gradient defines the gradient to use (between 0 and 1)
  84706. * @param color defines the color to affect to the specified gradient
  84707. * @returns the current particle system
  84708. */
  84709. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84710. /**
  84711. * Remove a specific ramp gradient
  84712. * @param gradient defines the gradient to remove
  84713. * @returns the current particle system
  84714. */
  84715. removeRampGradient(gradient: number): ParticleSystem;
  84716. /**
  84717. * Adds a new color gradient
  84718. * @param gradient defines the gradient to use (between 0 and 1)
  84719. * @param color1 defines the color to affect to the specified gradient
  84720. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84721. * @returns this particle system
  84722. */
  84723. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84724. /**
  84725. * Remove a specific color gradient
  84726. * @param gradient defines the gradient to remove
  84727. * @returns this particle system
  84728. */
  84729. removeColorGradient(gradient: number): IParticleSystem;
  84730. private _fetchR;
  84731. protected _reset(): void;
  84732. private _resetEffect;
  84733. private _createVertexBuffers;
  84734. private _createIndexBuffer;
  84735. /**
  84736. * Gets the maximum number of particles active at the same time.
  84737. * @returns The max number of active particles.
  84738. */
  84739. getCapacity(): number;
  84740. /**
  84741. * Gets whether there are still active particles in the system.
  84742. * @returns True if it is alive, otherwise false.
  84743. */
  84744. isAlive(): boolean;
  84745. /**
  84746. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84747. * @returns True if it has been started, otherwise false.
  84748. */
  84749. isStarted(): boolean;
  84750. private _prepareSubEmitterInternalArray;
  84751. /**
  84752. * Starts the particle system and begins to emit
  84753. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84754. */
  84755. start(delay?: number): void;
  84756. /**
  84757. * Stops the particle system.
  84758. * @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.
  84759. */
  84760. stop(stopSubEmitters?: boolean): void;
  84761. /**
  84762. * Remove all active particles
  84763. */
  84764. reset(): void;
  84765. /**
  84766. * @hidden (for internal use only)
  84767. */
  84768. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84769. /**
  84770. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84771. * Its lifetime will start back at 0.
  84772. */
  84773. recycleParticle: (particle: Particle) => void;
  84774. private _stopSubEmitters;
  84775. private _createParticle;
  84776. private _removeFromRoot;
  84777. private _emitFromParticle;
  84778. private _update;
  84779. /** @hidden */
  84780. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84781. /** @hidden */
  84782. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84783. /** @hidden */
  84784. private _getEffect;
  84785. /**
  84786. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84787. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84788. */
  84789. animate(preWarmOnly?: boolean): void;
  84790. private _appendParticleVertices;
  84791. /**
  84792. * Rebuilds the particle system.
  84793. */
  84794. rebuild(): void;
  84795. /**
  84796. * Is this system ready to be used/rendered
  84797. * @return true if the system is ready
  84798. */
  84799. isReady(): boolean;
  84800. private _render;
  84801. /**
  84802. * Renders the particle system in its current state.
  84803. * @returns the current number of particles
  84804. */
  84805. render(): number;
  84806. /**
  84807. * Disposes the particle system and free the associated resources
  84808. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84809. */
  84810. dispose(disposeTexture?: boolean): void;
  84811. /**
  84812. * Clones the particle system.
  84813. * @param name The name of the cloned object
  84814. * @param newEmitter The new emitter to use
  84815. * @returns the cloned particle system
  84816. */
  84817. clone(name: string, newEmitter: any): ParticleSystem;
  84818. /**
  84819. * Serializes the particle system to a JSON object.
  84820. * @returns the JSON object
  84821. */
  84822. serialize(): any;
  84823. /** @hidden */
  84824. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84825. /** @hidden */
  84826. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84827. /**
  84828. * Parses a JSON object to create a particle system.
  84829. * @param parsedParticleSystem The JSON object to parse
  84830. * @param scene The scene to create the particle system in
  84831. * @param rootUrl The root url to use to load external dependencies like texture
  84832. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84833. * @returns the Parsed particle system
  84834. */
  84835. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84836. }
  84837. }
  84838. declare module BABYLON {
  84839. /**
  84840. * A particle represents one of the element emitted by a particle system.
  84841. * This is mainly define by its coordinates, direction, velocity and age.
  84842. */
  84843. export class Particle {
  84844. /**
  84845. * The particle system the particle belongs to.
  84846. */
  84847. particleSystem: ParticleSystem;
  84848. private static _Count;
  84849. /**
  84850. * Unique ID of the particle
  84851. */
  84852. id: number;
  84853. /**
  84854. * The world position of the particle in the scene.
  84855. */
  84856. position: Vector3;
  84857. /**
  84858. * The world direction of the particle in the scene.
  84859. */
  84860. direction: Vector3;
  84861. /**
  84862. * The color of the particle.
  84863. */
  84864. color: Color4;
  84865. /**
  84866. * The color change of the particle per step.
  84867. */
  84868. colorStep: Color4;
  84869. /**
  84870. * Defines how long will the life of the particle be.
  84871. */
  84872. lifeTime: number;
  84873. /**
  84874. * The current age of the particle.
  84875. */
  84876. age: number;
  84877. /**
  84878. * The current size of the particle.
  84879. */
  84880. size: number;
  84881. /**
  84882. * The current scale of the particle.
  84883. */
  84884. scale: Vector2;
  84885. /**
  84886. * The current angle of the particle.
  84887. */
  84888. angle: number;
  84889. /**
  84890. * Defines how fast is the angle changing.
  84891. */
  84892. angularSpeed: number;
  84893. /**
  84894. * Defines the cell index used by the particle to be rendered from a sprite.
  84895. */
  84896. cellIndex: number;
  84897. /**
  84898. * The information required to support color remapping
  84899. */
  84900. remapData: Vector4;
  84901. /** @hidden */
  84902. _randomCellOffset?: number;
  84903. /** @hidden */
  84904. _initialDirection: Nullable<Vector3>;
  84905. /** @hidden */
  84906. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84907. /** @hidden */
  84908. _initialStartSpriteCellID: number;
  84909. /** @hidden */
  84910. _initialEndSpriteCellID: number;
  84911. /** @hidden */
  84912. _currentColorGradient: Nullable<ColorGradient>;
  84913. /** @hidden */
  84914. _currentColor1: Color4;
  84915. /** @hidden */
  84916. _currentColor2: Color4;
  84917. /** @hidden */
  84918. _currentSizeGradient: Nullable<FactorGradient>;
  84919. /** @hidden */
  84920. _currentSize1: number;
  84921. /** @hidden */
  84922. _currentSize2: number;
  84923. /** @hidden */
  84924. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84925. /** @hidden */
  84926. _currentAngularSpeed1: number;
  84927. /** @hidden */
  84928. _currentAngularSpeed2: number;
  84929. /** @hidden */
  84930. _currentVelocityGradient: Nullable<FactorGradient>;
  84931. /** @hidden */
  84932. _currentVelocity1: number;
  84933. /** @hidden */
  84934. _currentVelocity2: number;
  84935. /** @hidden */
  84936. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84937. /** @hidden */
  84938. _currentLimitVelocity1: number;
  84939. /** @hidden */
  84940. _currentLimitVelocity2: number;
  84941. /** @hidden */
  84942. _currentDragGradient: Nullable<FactorGradient>;
  84943. /** @hidden */
  84944. _currentDrag1: number;
  84945. /** @hidden */
  84946. _currentDrag2: number;
  84947. /** @hidden */
  84948. _randomNoiseCoordinates1: Vector3;
  84949. /** @hidden */
  84950. _randomNoiseCoordinates2: Vector3;
  84951. /**
  84952. * Creates a new instance Particle
  84953. * @param particleSystem the particle system the particle belongs to
  84954. */
  84955. constructor(
  84956. /**
  84957. * The particle system the particle belongs to.
  84958. */
  84959. particleSystem: ParticleSystem);
  84960. private updateCellInfoFromSystem;
  84961. /**
  84962. * Defines how the sprite cell index is updated for the particle
  84963. */
  84964. updateCellIndex(): void;
  84965. /** @hidden */
  84966. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84967. /** @hidden */
  84968. _inheritParticleInfoToSubEmitters(): void;
  84969. /** @hidden */
  84970. _reset(): void;
  84971. /**
  84972. * Copy the properties of particle to another one.
  84973. * @param other the particle to copy the information to.
  84974. */
  84975. copyTo(other: Particle): void;
  84976. }
  84977. }
  84978. declare module BABYLON {
  84979. /**
  84980. * Particle emitter represents a volume emitting particles.
  84981. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84982. */
  84983. export interface IParticleEmitterType {
  84984. /**
  84985. * Called by the particle System when the direction is computed for the created particle.
  84986. * @param worldMatrix is the world matrix of the particle system
  84987. * @param directionToUpdate is the direction vector to update with the result
  84988. * @param particle is the particle we are computed the direction for
  84989. */
  84990. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84991. /**
  84992. * Called by the particle System when the position is computed for the created particle.
  84993. * @param worldMatrix is the world matrix of the particle system
  84994. * @param positionToUpdate is the position vector to update with the result
  84995. * @param particle is the particle we are computed the position for
  84996. */
  84997. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84998. /**
  84999. * Clones the current emitter and returns a copy of it
  85000. * @returns the new emitter
  85001. */
  85002. clone(): IParticleEmitterType;
  85003. /**
  85004. * Called by the GPUParticleSystem to setup the update shader
  85005. * @param effect defines the update shader
  85006. */
  85007. applyToShader(effect: Effect): void;
  85008. /**
  85009. * Returns a string to use to update the GPU particles update shader
  85010. * @returns the effect defines string
  85011. */
  85012. getEffectDefines(): string;
  85013. /**
  85014. * Returns a string representing the class name
  85015. * @returns a string containing the class name
  85016. */
  85017. getClassName(): string;
  85018. /**
  85019. * Serializes the particle system to a JSON object.
  85020. * @returns the JSON object
  85021. */
  85022. serialize(): any;
  85023. /**
  85024. * Parse properties from a JSON object
  85025. * @param serializationObject defines the JSON object
  85026. */
  85027. parse(serializationObject: any): void;
  85028. }
  85029. }
  85030. declare module BABYLON {
  85031. /**
  85032. * Particle emitter emitting particles from the inside of a box.
  85033. * It emits the particles randomly between 2 given directions.
  85034. */
  85035. export class BoxParticleEmitter implements IParticleEmitterType {
  85036. /**
  85037. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85038. */
  85039. direction1: Vector3;
  85040. /**
  85041. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85042. */
  85043. direction2: Vector3;
  85044. /**
  85045. * 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.
  85046. */
  85047. minEmitBox: Vector3;
  85048. /**
  85049. * 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.
  85050. */
  85051. maxEmitBox: Vector3;
  85052. /**
  85053. * Creates a new instance BoxParticleEmitter
  85054. */
  85055. constructor();
  85056. /**
  85057. * Called by the particle System when the direction is computed for the created particle.
  85058. * @param worldMatrix is the world matrix of the particle system
  85059. * @param directionToUpdate is the direction vector to update with the result
  85060. * @param particle is the particle we are computed the direction for
  85061. */
  85062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85063. /**
  85064. * Called by the particle System when the position is computed for the created particle.
  85065. * @param worldMatrix is the world matrix of the particle system
  85066. * @param positionToUpdate is the position vector to update with the result
  85067. * @param particle is the particle we are computed the position for
  85068. */
  85069. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85070. /**
  85071. * Clones the current emitter and returns a copy of it
  85072. * @returns the new emitter
  85073. */
  85074. clone(): BoxParticleEmitter;
  85075. /**
  85076. * Called by the GPUParticleSystem to setup the update shader
  85077. * @param effect defines the update shader
  85078. */
  85079. applyToShader(effect: Effect): void;
  85080. /**
  85081. * Returns a string to use to update the GPU particles update shader
  85082. * @returns a string containng the defines string
  85083. */
  85084. getEffectDefines(): string;
  85085. /**
  85086. * Returns the string "BoxParticleEmitter"
  85087. * @returns a string containing the class name
  85088. */
  85089. getClassName(): string;
  85090. /**
  85091. * Serializes the particle system to a JSON object.
  85092. * @returns the JSON object
  85093. */
  85094. serialize(): any;
  85095. /**
  85096. * Parse properties from a JSON object
  85097. * @param serializationObject defines the JSON object
  85098. */
  85099. parse(serializationObject: any): void;
  85100. }
  85101. }
  85102. declare module BABYLON {
  85103. /**
  85104. * Particle emitter emitting particles from the inside of a cone.
  85105. * It emits the particles alongside the cone volume from the base to the particle.
  85106. * The emission direction might be randomized.
  85107. */
  85108. export class ConeParticleEmitter implements IParticleEmitterType {
  85109. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85110. directionRandomizer: number;
  85111. private _radius;
  85112. private _angle;
  85113. private _height;
  85114. /**
  85115. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85116. */
  85117. radiusRange: number;
  85118. /**
  85119. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85120. */
  85121. heightRange: number;
  85122. /**
  85123. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85124. */
  85125. emitFromSpawnPointOnly: boolean;
  85126. /**
  85127. * Gets or sets the radius of the emission cone
  85128. */
  85129. radius: number;
  85130. /**
  85131. * Gets or sets the angle of the emission cone
  85132. */
  85133. angle: number;
  85134. private _buildHeight;
  85135. /**
  85136. * Creates a new instance ConeParticleEmitter
  85137. * @param radius the radius of the emission cone (1 by default)
  85138. * @param angle the cone base angle (PI by default)
  85139. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85140. */
  85141. constructor(radius?: number, angle?: number,
  85142. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85143. directionRandomizer?: number);
  85144. /**
  85145. * Called by the particle System when the direction is computed for the created particle.
  85146. * @param worldMatrix is the world matrix of the particle system
  85147. * @param directionToUpdate is the direction vector to update with the result
  85148. * @param particle is the particle we are computed the direction for
  85149. */
  85150. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85151. /**
  85152. * Called by the particle System when the position is computed for the created particle.
  85153. * @param worldMatrix is the world matrix of the particle system
  85154. * @param positionToUpdate is the position vector to update with the result
  85155. * @param particle is the particle we are computed the position for
  85156. */
  85157. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85158. /**
  85159. * Clones the current emitter and returns a copy of it
  85160. * @returns the new emitter
  85161. */
  85162. clone(): ConeParticleEmitter;
  85163. /**
  85164. * Called by the GPUParticleSystem to setup the update shader
  85165. * @param effect defines the update shader
  85166. */
  85167. applyToShader(effect: Effect): void;
  85168. /**
  85169. * Returns a string to use to update the GPU particles update shader
  85170. * @returns a string containng the defines string
  85171. */
  85172. getEffectDefines(): string;
  85173. /**
  85174. * Returns the string "ConeParticleEmitter"
  85175. * @returns a string containing the class name
  85176. */
  85177. getClassName(): string;
  85178. /**
  85179. * Serializes the particle system to a JSON object.
  85180. * @returns the JSON object
  85181. */
  85182. serialize(): any;
  85183. /**
  85184. * Parse properties from a JSON object
  85185. * @param serializationObject defines the JSON object
  85186. */
  85187. parse(serializationObject: any): void;
  85188. }
  85189. }
  85190. declare module BABYLON {
  85191. /**
  85192. * Particle emitter emitting particles from the inside of a cylinder.
  85193. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85194. */
  85195. export class CylinderParticleEmitter implements IParticleEmitterType {
  85196. /**
  85197. * The radius of the emission cylinder.
  85198. */
  85199. radius: number;
  85200. /**
  85201. * The height of the emission cylinder.
  85202. */
  85203. height: number;
  85204. /**
  85205. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85206. */
  85207. radiusRange: number;
  85208. /**
  85209. * How much to randomize the particle direction [0-1].
  85210. */
  85211. directionRandomizer: number;
  85212. /**
  85213. * Creates a new instance CylinderParticleEmitter
  85214. * @param radius the radius of the emission cylinder (1 by default)
  85215. * @param height the height of the emission cylinder (1 by default)
  85216. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85217. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85218. */
  85219. constructor(
  85220. /**
  85221. * The radius of the emission cylinder.
  85222. */
  85223. radius?: number,
  85224. /**
  85225. * The height of the emission cylinder.
  85226. */
  85227. height?: number,
  85228. /**
  85229. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85230. */
  85231. radiusRange?: number,
  85232. /**
  85233. * How much to randomize the particle direction [0-1].
  85234. */
  85235. directionRandomizer?: number);
  85236. /**
  85237. * Called by the particle System when the direction is computed for the created particle.
  85238. * @param worldMatrix is the world matrix of the particle system
  85239. * @param directionToUpdate is the direction vector to update with the result
  85240. * @param particle is the particle we are computed the direction for
  85241. */
  85242. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85243. /**
  85244. * Called by the particle System when the position is computed for the created particle.
  85245. * @param worldMatrix is the world matrix of the particle system
  85246. * @param positionToUpdate is the position vector to update with the result
  85247. * @param particle is the particle we are computed the position for
  85248. */
  85249. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85250. /**
  85251. * Clones the current emitter and returns a copy of it
  85252. * @returns the new emitter
  85253. */
  85254. clone(): CylinderParticleEmitter;
  85255. /**
  85256. * Called by the GPUParticleSystem to setup the update shader
  85257. * @param effect defines the update shader
  85258. */
  85259. applyToShader(effect: Effect): void;
  85260. /**
  85261. * Returns a string to use to update the GPU particles update shader
  85262. * @returns a string containng the defines string
  85263. */
  85264. getEffectDefines(): string;
  85265. /**
  85266. * Returns the string "CylinderParticleEmitter"
  85267. * @returns a string containing the class name
  85268. */
  85269. getClassName(): string;
  85270. /**
  85271. * Serializes the particle system to a JSON object.
  85272. * @returns the JSON object
  85273. */
  85274. serialize(): any;
  85275. /**
  85276. * Parse properties from a JSON object
  85277. * @param serializationObject defines the JSON object
  85278. */
  85279. parse(serializationObject: any): void;
  85280. }
  85281. /**
  85282. * Particle emitter emitting particles from the inside of a cylinder.
  85283. * It emits the particles randomly between two vectors.
  85284. */
  85285. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85286. /**
  85287. * The min limit of the emission direction.
  85288. */
  85289. direction1: Vector3;
  85290. /**
  85291. * The max limit of the emission direction.
  85292. */
  85293. direction2: Vector3;
  85294. /**
  85295. * Creates a new instance CylinderDirectedParticleEmitter
  85296. * @param radius the radius of the emission cylinder (1 by default)
  85297. * @param height the height of the emission cylinder (1 by default)
  85298. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85299. * @param direction1 the min limit of the emission direction (up vector by default)
  85300. * @param direction2 the max limit of the emission direction (up vector by default)
  85301. */
  85302. constructor(radius?: number, height?: number, radiusRange?: number,
  85303. /**
  85304. * The min limit of the emission direction.
  85305. */
  85306. direction1?: Vector3,
  85307. /**
  85308. * The max limit of the emission direction.
  85309. */
  85310. direction2?: Vector3);
  85311. /**
  85312. * Called by the particle System when the direction is computed for the created particle.
  85313. * @param worldMatrix is the world matrix of the particle system
  85314. * @param directionToUpdate is the direction vector to update with the result
  85315. * @param particle is the particle we are computed the direction for
  85316. */
  85317. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85318. /**
  85319. * Clones the current emitter and returns a copy of it
  85320. * @returns the new emitter
  85321. */
  85322. clone(): CylinderDirectedParticleEmitter;
  85323. /**
  85324. * Called by the GPUParticleSystem to setup the update shader
  85325. * @param effect defines the update shader
  85326. */
  85327. applyToShader(effect: Effect): void;
  85328. /**
  85329. * Returns a string to use to update the GPU particles update shader
  85330. * @returns a string containng the defines string
  85331. */
  85332. getEffectDefines(): string;
  85333. /**
  85334. * Returns the string "CylinderDirectedParticleEmitter"
  85335. * @returns a string containing the class name
  85336. */
  85337. getClassName(): string;
  85338. /**
  85339. * Serializes the particle system to a JSON object.
  85340. * @returns the JSON object
  85341. */
  85342. serialize(): any;
  85343. /**
  85344. * Parse properties from a JSON object
  85345. * @param serializationObject defines the JSON object
  85346. */
  85347. parse(serializationObject: any): void;
  85348. }
  85349. }
  85350. declare module BABYLON {
  85351. /**
  85352. * Particle emitter emitting particles from the inside of a hemisphere.
  85353. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85354. */
  85355. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85356. /**
  85357. * The radius of the emission hemisphere.
  85358. */
  85359. radius: number;
  85360. /**
  85361. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85362. */
  85363. radiusRange: number;
  85364. /**
  85365. * How much to randomize the particle direction [0-1].
  85366. */
  85367. directionRandomizer: number;
  85368. /**
  85369. * Creates a new instance HemisphericParticleEmitter
  85370. * @param radius the radius of the emission hemisphere (1 by default)
  85371. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85372. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85373. */
  85374. constructor(
  85375. /**
  85376. * The radius of the emission hemisphere.
  85377. */
  85378. radius?: number,
  85379. /**
  85380. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85381. */
  85382. radiusRange?: number,
  85383. /**
  85384. * How much to randomize the particle direction [0-1].
  85385. */
  85386. directionRandomizer?: number);
  85387. /**
  85388. * Called by the particle System when the direction is computed for the created particle.
  85389. * @param worldMatrix is the world matrix of the particle system
  85390. * @param directionToUpdate is the direction vector to update with the result
  85391. * @param particle is the particle we are computed the direction for
  85392. */
  85393. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85394. /**
  85395. * Called by the particle System when the position is computed for the created particle.
  85396. * @param worldMatrix is the world matrix of the particle system
  85397. * @param positionToUpdate is the position vector to update with the result
  85398. * @param particle is the particle we are computed the position for
  85399. */
  85400. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85401. /**
  85402. * Clones the current emitter and returns a copy of it
  85403. * @returns the new emitter
  85404. */
  85405. clone(): HemisphericParticleEmitter;
  85406. /**
  85407. * Called by the GPUParticleSystem to setup the update shader
  85408. * @param effect defines the update shader
  85409. */
  85410. applyToShader(effect: Effect): void;
  85411. /**
  85412. * Returns a string to use to update the GPU particles update shader
  85413. * @returns a string containng the defines string
  85414. */
  85415. getEffectDefines(): string;
  85416. /**
  85417. * Returns the string "HemisphericParticleEmitter"
  85418. * @returns a string containing the class name
  85419. */
  85420. getClassName(): string;
  85421. /**
  85422. * Serializes the particle system to a JSON object.
  85423. * @returns the JSON object
  85424. */
  85425. serialize(): any;
  85426. /**
  85427. * Parse properties from a JSON object
  85428. * @param serializationObject defines the JSON object
  85429. */
  85430. parse(serializationObject: any): void;
  85431. }
  85432. }
  85433. declare module BABYLON {
  85434. /**
  85435. * Particle emitter emitting particles from a point.
  85436. * It emits the particles randomly between 2 given directions.
  85437. */
  85438. export class PointParticleEmitter implements IParticleEmitterType {
  85439. /**
  85440. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85441. */
  85442. direction1: Vector3;
  85443. /**
  85444. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85445. */
  85446. direction2: Vector3;
  85447. /**
  85448. * Creates a new instance PointParticleEmitter
  85449. */
  85450. constructor();
  85451. /**
  85452. * Called by the particle System when the direction is computed for the created particle.
  85453. * @param worldMatrix is the world matrix of the particle system
  85454. * @param directionToUpdate is the direction vector to update with the result
  85455. * @param particle is the particle we are computed the direction for
  85456. */
  85457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85458. /**
  85459. * Called by the particle System when the position is computed for the created particle.
  85460. * @param worldMatrix is the world matrix of the particle system
  85461. * @param positionToUpdate is the position vector to update with the result
  85462. * @param particle is the particle we are computed the position for
  85463. */
  85464. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85465. /**
  85466. * Clones the current emitter and returns a copy of it
  85467. * @returns the new emitter
  85468. */
  85469. clone(): PointParticleEmitter;
  85470. /**
  85471. * Called by the GPUParticleSystem to setup the update shader
  85472. * @param effect defines the update shader
  85473. */
  85474. applyToShader(effect: Effect): void;
  85475. /**
  85476. * Returns a string to use to update the GPU particles update shader
  85477. * @returns a string containng the defines string
  85478. */
  85479. getEffectDefines(): string;
  85480. /**
  85481. * Returns the string "PointParticleEmitter"
  85482. * @returns a string containing the class name
  85483. */
  85484. getClassName(): string;
  85485. /**
  85486. * Serializes the particle system to a JSON object.
  85487. * @returns the JSON object
  85488. */
  85489. serialize(): any;
  85490. /**
  85491. * Parse properties from a JSON object
  85492. * @param serializationObject defines the JSON object
  85493. */
  85494. parse(serializationObject: any): void;
  85495. }
  85496. }
  85497. declare module BABYLON {
  85498. /**
  85499. * Particle emitter emitting particles from the inside of a sphere.
  85500. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85501. */
  85502. export class SphereParticleEmitter implements IParticleEmitterType {
  85503. /**
  85504. * The radius of the emission sphere.
  85505. */
  85506. radius: number;
  85507. /**
  85508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85509. */
  85510. radiusRange: number;
  85511. /**
  85512. * How much to randomize the particle direction [0-1].
  85513. */
  85514. directionRandomizer: number;
  85515. /**
  85516. * Creates a new instance SphereParticleEmitter
  85517. * @param radius the radius of the emission sphere (1 by default)
  85518. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85519. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85520. */
  85521. constructor(
  85522. /**
  85523. * The radius of the emission sphere.
  85524. */
  85525. radius?: number,
  85526. /**
  85527. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85528. */
  85529. radiusRange?: number,
  85530. /**
  85531. * How much to randomize the particle direction [0-1].
  85532. */
  85533. directionRandomizer?: number);
  85534. /**
  85535. * Called by the particle System when the direction is computed for the created particle.
  85536. * @param worldMatrix is the world matrix of the particle system
  85537. * @param directionToUpdate is the direction vector to update with the result
  85538. * @param particle is the particle we are computed the direction for
  85539. */
  85540. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85541. /**
  85542. * Called by the particle System when the position is computed for the created particle.
  85543. * @param worldMatrix is the world matrix of the particle system
  85544. * @param positionToUpdate is the position vector to update with the result
  85545. * @param particle is the particle we are computed the position for
  85546. */
  85547. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85548. /**
  85549. * Clones the current emitter and returns a copy of it
  85550. * @returns the new emitter
  85551. */
  85552. clone(): SphereParticleEmitter;
  85553. /**
  85554. * Called by the GPUParticleSystem to setup the update shader
  85555. * @param effect defines the update shader
  85556. */
  85557. applyToShader(effect: Effect): void;
  85558. /**
  85559. * Returns a string to use to update the GPU particles update shader
  85560. * @returns a string containng the defines string
  85561. */
  85562. getEffectDefines(): string;
  85563. /**
  85564. * Returns the string "SphereParticleEmitter"
  85565. * @returns a string containing the class name
  85566. */
  85567. getClassName(): string;
  85568. /**
  85569. * Serializes the particle system to a JSON object.
  85570. * @returns the JSON object
  85571. */
  85572. serialize(): any;
  85573. /**
  85574. * Parse properties from a JSON object
  85575. * @param serializationObject defines the JSON object
  85576. */
  85577. parse(serializationObject: any): void;
  85578. }
  85579. /**
  85580. * Particle emitter emitting particles from the inside of a sphere.
  85581. * It emits the particles randomly between two vectors.
  85582. */
  85583. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85584. /**
  85585. * The min limit of the emission direction.
  85586. */
  85587. direction1: Vector3;
  85588. /**
  85589. * The max limit of the emission direction.
  85590. */
  85591. direction2: Vector3;
  85592. /**
  85593. * Creates a new instance SphereDirectedParticleEmitter
  85594. * @param radius the radius of the emission sphere (1 by default)
  85595. * @param direction1 the min limit of the emission direction (up vector by default)
  85596. * @param direction2 the max limit of the emission direction (up vector by default)
  85597. */
  85598. constructor(radius?: number,
  85599. /**
  85600. * The min limit of the emission direction.
  85601. */
  85602. direction1?: Vector3,
  85603. /**
  85604. * The max limit of the emission direction.
  85605. */
  85606. direction2?: Vector3);
  85607. /**
  85608. * Called by the particle System when the direction is computed for the created particle.
  85609. * @param worldMatrix is the world matrix of the particle system
  85610. * @param directionToUpdate is the direction vector to update with the result
  85611. * @param particle is the particle we are computed the direction for
  85612. */
  85613. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85614. /**
  85615. * Clones the current emitter and returns a copy of it
  85616. * @returns the new emitter
  85617. */
  85618. clone(): SphereDirectedParticleEmitter;
  85619. /**
  85620. * Called by the GPUParticleSystem to setup the update shader
  85621. * @param effect defines the update shader
  85622. */
  85623. applyToShader(effect: Effect): void;
  85624. /**
  85625. * Returns a string to use to update the GPU particles update shader
  85626. * @returns a string containng the defines string
  85627. */
  85628. getEffectDefines(): string;
  85629. /**
  85630. * Returns the string "SphereDirectedParticleEmitter"
  85631. * @returns a string containing the class name
  85632. */
  85633. getClassName(): string;
  85634. /**
  85635. * Serializes the particle system to a JSON object.
  85636. * @returns the JSON object
  85637. */
  85638. serialize(): any;
  85639. /**
  85640. * Parse properties from a JSON object
  85641. * @param serializationObject defines the JSON object
  85642. */
  85643. parse(serializationObject: any): void;
  85644. }
  85645. }
  85646. declare module BABYLON {
  85647. /**
  85648. * Interface representing a particle system in Babylon.js.
  85649. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  85650. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  85651. */
  85652. export interface IParticleSystem {
  85653. /**
  85654. * List of animations used by the particle system.
  85655. */
  85656. animations: Animation[];
  85657. /**
  85658. * The id of the Particle system.
  85659. */
  85660. id: string;
  85661. /**
  85662. * The name of the Particle system.
  85663. */
  85664. name: string;
  85665. /**
  85666. * The emitter represents the Mesh or position we are attaching the particle system to.
  85667. */
  85668. emitter: Nullable<AbstractMesh | Vector3>;
  85669. /**
  85670. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85671. */
  85672. isBillboardBased: boolean;
  85673. /**
  85674. * The rendering group used by the Particle system to chose when to render.
  85675. */
  85676. renderingGroupId: number;
  85677. /**
  85678. * The layer mask we are rendering the particles through.
  85679. */
  85680. layerMask: number;
  85681. /**
  85682. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85683. */
  85684. updateSpeed: number;
  85685. /**
  85686. * The amount of time the particle system is running (depends of the overall update speed).
  85687. */
  85688. targetStopDuration: number;
  85689. /**
  85690. * The texture used to render each particle. (this can be a spritesheet)
  85691. */
  85692. particleTexture: Nullable<Texture>;
  85693. /**
  85694. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85695. */
  85696. blendMode: number;
  85697. /**
  85698. * Minimum life time of emitting particles.
  85699. */
  85700. minLifeTime: number;
  85701. /**
  85702. * Maximum life time of emitting particles.
  85703. */
  85704. maxLifeTime: number;
  85705. /**
  85706. * Minimum Size of emitting particles.
  85707. */
  85708. minSize: number;
  85709. /**
  85710. * Maximum Size of emitting particles.
  85711. */
  85712. maxSize: number;
  85713. /**
  85714. * Minimum scale of emitting particles on X axis.
  85715. */
  85716. minScaleX: number;
  85717. /**
  85718. * Maximum scale of emitting particles on X axis.
  85719. */
  85720. maxScaleX: number;
  85721. /**
  85722. * Minimum scale of emitting particles on Y axis.
  85723. */
  85724. minScaleY: number;
  85725. /**
  85726. * Maximum scale of emitting particles on Y axis.
  85727. */
  85728. maxScaleY: number;
  85729. /**
  85730. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85731. */
  85732. color1: Color4;
  85733. /**
  85734. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85735. */
  85736. color2: Color4;
  85737. /**
  85738. * Color the particle will have at the end of its lifetime.
  85739. */
  85740. colorDead: Color4;
  85741. /**
  85742. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85743. */
  85744. emitRate: number;
  85745. /**
  85746. * You can use gravity if you want to give an orientation to your particles.
  85747. */
  85748. gravity: Vector3;
  85749. /**
  85750. * Minimum power of emitting particles.
  85751. */
  85752. minEmitPower: number;
  85753. /**
  85754. * Maximum power of emitting particles.
  85755. */
  85756. maxEmitPower: number;
  85757. /**
  85758. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85759. */
  85760. minAngularSpeed: number;
  85761. /**
  85762. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85763. */
  85764. maxAngularSpeed: number;
  85765. /**
  85766. * Gets or sets the minimal initial rotation in radians.
  85767. */
  85768. minInitialRotation: number;
  85769. /**
  85770. * Gets or sets the maximal initial rotation in radians.
  85771. */
  85772. maxInitialRotation: number;
  85773. /**
  85774. * The particle emitter type defines the emitter used by the particle system.
  85775. * It can be for example box, sphere, or cone...
  85776. */
  85777. particleEmitterType: Nullable<IParticleEmitterType>;
  85778. /**
  85779. * Defines the delay in milliseconds before starting the system (0 by default)
  85780. */
  85781. startDelay: number;
  85782. /**
  85783. * 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
  85784. */
  85785. preWarmCycles: number;
  85786. /**
  85787. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85788. */
  85789. preWarmStepOffset: number;
  85790. /**
  85791. * 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)
  85792. */
  85793. spriteCellChangeSpeed: number;
  85794. /**
  85795. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85796. */
  85797. startSpriteCellID: number;
  85798. /**
  85799. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85800. */
  85801. endSpriteCellID: number;
  85802. /**
  85803. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85804. */
  85805. spriteCellWidth: number;
  85806. /**
  85807. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85808. */
  85809. spriteCellHeight: number;
  85810. /**
  85811. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85812. */
  85813. spriteRandomStartCell: boolean;
  85814. /**
  85815. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85816. */
  85817. isAnimationSheetEnabled: boolean;
  85818. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85819. translationPivot: Vector2;
  85820. /**
  85821. * Gets or sets a texture used to add random noise to particle positions
  85822. */
  85823. noiseTexture: Nullable<BaseTexture>;
  85824. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85825. noiseStrength: Vector3;
  85826. /**
  85827. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85828. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85829. */
  85830. billboardMode: number;
  85831. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85832. limitVelocityDamping: number;
  85833. /**
  85834. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85835. */
  85836. beginAnimationOnStart: boolean;
  85837. /**
  85838. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85839. */
  85840. beginAnimationFrom: number;
  85841. /**
  85842. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85843. */
  85844. beginAnimationTo: number;
  85845. /**
  85846. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85847. */
  85848. beginAnimationLoop: boolean;
  85849. /**
  85850. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85851. */
  85852. disposeOnStop: boolean;
  85853. /**
  85854. * Gets the maximum number of particles active at the same time.
  85855. * @returns The max number of active particles.
  85856. */
  85857. getCapacity(): number;
  85858. /**
  85859. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85860. * @returns True if it has been started, otherwise false.
  85861. */
  85862. isStarted(): boolean;
  85863. /**
  85864. * Animates the particle system for this frame.
  85865. */
  85866. animate(): void;
  85867. /**
  85868. * Renders the particle system in its current state.
  85869. * @returns the current number of particles
  85870. */
  85871. render(): number;
  85872. /**
  85873. * Dispose the particle system and frees its associated resources.
  85874. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85875. */
  85876. dispose(disposeTexture?: boolean): void;
  85877. /**
  85878. * Clones the particle system.
  85879. * @param name The name of the cloned object
  85880. * @param newEmitter The new emitter to use
  85881. * @returns the cloned particle system
  85882. */
  85883. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85884. /**
  85885. * Serializes the particle system to a JSON object.
  85886. * @returns the JSON object
  85887. */
  85888. serialize(): any;
  85889. /**
  85890. * Rebuild the particle system
  85891. */
  85892. rebuild(): void;
  85893. /**
  85894. * Starts the particle system and begins to emit
  85895. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85896. */
  85897. start(delay?: number): void;
  85898. /**
  85899. * Stops the particle system.
  85900. */
  85901. stop(): void;
  85902. /**
  85903. * Remove all active particles
  85904. */
  85905. reset(): void;
  85906. /**
  85907. * Is this system ready to be used/rendered
  85908. * @return true if the system is ready
  85909. */
  85910. isReady(): boolean;
  85911. /**
  85912. * Adds a new color gradient
  85913. * @param gradient defines the gradient to use (between 0 and 1)
  85914. * @param color1 defines the color to affect to the specified gradient
  85915. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85916. * @returns the current particle system
  85917. */
  85918. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85919. /**
  85920. * Remove a specific color gradient
  85921. * @param gradient defines the gradient to remove
  85922. * @returns the current particle system
  85923. */
  85924. removeColorGradient(gradient: number): IParticleSystem;
  85925. /**
  85926. * Adds a new size gradient
  85927. * @param gradient defines the gradient to use (between 0 and 1)
  85928. * @param factor defines the size factor to affect to the specified gradient
  85929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85930. * @returns the current particle system
  85931. */
  85932. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85933. /**
  85934. * Remove a specific size gradient
  85935. * @param gradient defines the gradient to remove
  85936. * @returns the current particle system
  85937. */
  85938. removeSizeGradient(gradient: number): IParticleSystem;
  85939. /**
  85940. * Gets the current list of color gradients.
  85941. * You must use addColorGradient and removeColorGradient to udpate this list
  85942. * @returns the list of color gradients
  85943. */
  85944. getColorGradients(): Nullable<Array<ColorGradient>>;
  85945. /**
  85946. * Gets the current list of size gradients.
  85947. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85948. * @returns the list of size gradients
  85949. */
  85950. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85951. /**
  85952. * Gets the current list of angular speed gradients.
  85953. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85954. * @returns the list of angular speed gradients
  85955. */
  85956. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85957. /**
  85958. * Adds a new angular speed gradient
  85959. * @param gradient defines the gradient to use (between 0 and 1)
  85960. * @param factor defines the angular speed to affect to the specified gradient
  85961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85962. * @returns the current particle system
  85963. */
  85964. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85965. /**
  85966. * Remove a specific angular speed gradient
  85967. * @param gradient defines the gradient to remove
  85968. * @returns the current particle system
  85969. */
  85970. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85971. /**
  85972. * Gets the current list of velocity gradients.
  85973. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85974. * @returns the list of velocity gradients
  85975. */
  85976. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85977. /**
  85978. * Adds a new velocity gradient
  85979. * @param gradient defines the gradient to use (between 0 and 1)
  85980. * @param factor defines the velocity to affect to the specified gradient
  85981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85982. * @returns the current particle system
  85983. */
  85984. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85985. /**
  85986. * Remove a specific velocity gradient
  85987. * @param gradient defines the gradient to remove
  85988. * @returns the current particle system
  85989. */
  85990. removeVelocityGradient(gradient: number): IParticleSystem;
  85991. /**
  85992. * Gets the current list of limit velocity gradients.
  85993. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85994. * @returns the list of limit velocity gradients
  85995. */
  85996. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85997. /**
  85998. * Adds a new limit velocity gradient
  85999. * @param gradient defines the gradient to use (between 0 and 1)
  86000. * @param factor defines the limit velocity to affect to the specified gradient
  86001. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86002. * @returns the current particle system
  86003. */
  86004. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86005. /**
  86006. * Remove a specific limit velocity gradient
  86007. * @param gradient defines the gradient to remove
  86008. * @returns the current particle system
  86009. */
  86010. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86011. /**
  86012. * Adds a new drag gradient
  86013. * @param gradient defines the gradient to use (between 0 and 1)
  86014. * @param factor defines the drag to affect to the specified gradient
  86015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86016. * @returns the current particle system
  86017. */
  86018. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86019. /**
  86020. * Remove a specific drag gradient
  86021. * @param gradient defines the gradient to remove
  86022. * @returns the current particle system
  86023. */
  86024. removeDragGradient(gradient: number): IParticleSystem;
  86025. /**
  86026. * Gets the current list of drag gradients.
  86027. * You must use addDragGradient and removeDragGradient to udpate this list
  86028. * @returns the list of drag gradients
  86029. */
  86030. getDragGradients(): Nullable<Array<FactorGradient>>;
  86031. /**
  86032. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86033. * @param gradient defines the gradient to use (between 0 and 1)
  86034. * @param factor defines the emit rate to affect to the specified gradient
  86035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86036. * @returns the current particle system
  86037. */
  86038. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86039. /**
  86040. * Remove a specific emit rate gradient
  86041. * @param gradient defines the gradient to remove
  86042. * @returns the current particle system
  86043. */
  86044. removeEmitRateGradient(gradient: number): IParticleSystem;
  86045. /**
  86046. * Gets the current list of emit rate gradients.
  86047. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86048. * @returns the list of emit rate gradients
  86049. */
  86050. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86051. /**
  86052. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86053. * @param gradient defines the gradient to use (between 0 and 1)
  86054. * @param factor defines the start size to affect to the specified gradient
  86055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86056. * @returns the current particle system
  86057. */
  86058. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86059. /**
  86060. * Remove a specific start size gradient
  86061. * @param gradient defines the gradient to remove
  86062. * @returns the current particle system
  86063. */
  86064. removeStartSizeGradient(gradient: number): IParticleSystem;
  86065. /**
  86066. * Gets the current list of start size gradients.
  86067. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86068. * @returns the list of start size gradients
  86069. */
  86070. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86071. /**
  86072. * Adds a new life time gradient
  86073. * @param gradient defines the gradient to use (between 0 and 1)
  86074. * @param factor defines the life time factor to affect to the specified gradient
  86075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86076. * @returns the current particle system
  86077. */
  86078. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86079. /**
  86080. * Remove a specific life time gradient
  86081. * @param gradient defines the gradient to remove
  86082. * @returns the current particle system
  86083. */
  86084. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86085. /**
  86086. * Gets the current list of life time gradients.
  86087. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86088. * @returns the list of life time gradients
  86089. */
  86090. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86091. /**
  86092. * Gets the current list of color gradients.
  86093. * You must use addColorGradient and removeColorGradient to udpate this list
  86094. * @returns the list of color gradients
  86095. */
  86096. getColorGradients(): Nullable<Array<ColorGradient>>;
  86097. /**
  86098. * Adds a new ramp gradient used to remap particle colors
  86099. * @param gradient defines the gradient to use (between 0 and 1)
  86100. * @param color defines the color to affect to the specified gradient
  86101. * @returns the current particle system
  86102. */
  86103. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86104. /**
  86105. * Gets the current list of ramp gradients.
  86106. * You must use addRampGradient and removeRampGradient to udpate this list
  86107. * @returns the list of ramp gradients
  86108. */
  86109. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86110. /** Gets or sets a boolean indicating that ramp gradients must be used
  86111. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86112. */
  86113. useRampGradients: boolean;
  86114. /**
  86115. * Adds a new color remap gradient
  86116. * @param gradient defines the gradient to use (between 0 and 1)
  86117. * @param min defines the color remap minimal range
  86118. * @param max defines the color remap maximal range
  86119. * @returns the current particle system
  86120. */
  86121. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86122. /**
  86123. * Gets the current list of color remap gradients.
  86124. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86125. * @returns the list of color remap gradients
  86126. */
  86127. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86128. /**
  86129. * Adds a new alpha remap gradient
  86130. * @param gradient defines the gradient to use (between 0 and 1)
  86131. * @param min defines the alpha remap minimal range
  86132. * @param max defines the alpha remap maximal range
  86133. * @returns the current particle system
  86134. */
  86135. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86136. /**
  86137. * Gets the current list of alpha remap gradients.
  86138. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86139. * @returns the list of alpha remap gradients
  86140. */
  86141. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86142. /**
  86143. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86144. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86145. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86146. * @returns the emitter
  86147. */
  86148. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86149. /**
  86150. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86151. * @param radius The radius of the hemisphere to emit from
  86152. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86153. * @returns the emitter
  86154. */
  86155. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86156. /**
  86157. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86158. * @param radius The radius of the sphere to emit from
  86159. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86160. * @returns the emitter
  86161. */
  86162. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86163. /**
  86164. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86165. * @param radius The radius of the sphere to emit from
  86166. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86167. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86168. * @returns the emitter
  86169. */
  86170. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86171. /**
  86172. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86173. * @param radius The radius of the emission cylinder
  86174. * @param height The height of the emission cylinder
  86175. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86176. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86177. * @returns the emitter
  86178. */
  86179. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86180. /**
  86181. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86182. * @param radius The radius of the cylinder to emit from
  86183. * @param height The height of the emission cylinder
  86184. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86185. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86186. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86187. * @returns the emitter
  86188. */
  86189. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86190. /**
  86191. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86192. * @param radius The radius of the cone to emit from
  86193. * @param angle The base angle of the cone
  86194. * @returns the emitter
  86195. */
  86196. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86197. /**
  86198. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86199. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86200. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86201. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86202. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86203. * @returns the emitter
  86204. */
  86205. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86206. /**
  86207. * Get hosting scene
  86208. * @returns the scene
  86209. */
  86210. getScene(): Scene;
  86211. }
  86212. }
  86213. declare module BABYLON {
  86214. /**
  86215. * Creates an instance based on a source mesh.
  86216. */
  86217. export class InstancedMesh extends AbstractMesh {
  86218. private _sourceMesh;
  86219. private _currentLOD;
  86220. /** @hidden */
  86221. _indexInSourceMeshInstanceArray: number;
  86222. constructor(name: string, source: Mesh);
  86223. /**
  86224. * Returns the string "InstancedMesh".
  86225. */
  86226. getClassName(): string;
  86227. /** Gets the list of lights affecting that mesh */
  86228. readonly lightSources: Light[];
  86229. _resyncLightSources(): void;
  86230. _resyncLighSource(light: Light): void;
  86231. _removeLightSource(light: Light, dispose: boolean): void;
  86232. /**
  86233. * If the source mesh receives shadows
  86234. */
  86235. readonly receiveShadows: boolean;
  86236. /**
  86237. * The material of the source mesh
  86238. */
  86239. readonly material: Nullable<Material>;
  86240. /**
  86241. * Visibility of the source mesh
  86242. */
  86243. readonly visibility: number;
  86244. /**
  86245. * Skeleton of the source mesh
  86246. */
  86247. readonly skeleton: Nullable<Skeleton>;
  86248. /**
  86249. * Rendering ground id of the source mesh
  86250. */
  86251. renderingGroupId: number;
  86252. /**
  86253. * Returns the total number of vertices (integer).
  86254. */
  86255. getTotalVertices(): number;
  86256. /**
  86257. * Returns a positive integer : the total number of indices in this mesh geometry.
  86258. * @returns the numner of indices or zero if the mesh has no geometry.
  86259. */
  86260. getTotalIndices(): number;
  86261. /**
  86262. * The source mesh of the instance
  86263. */
  86264. readonly sourceMesh: Mesh;
  86265. /**
  86266. * Is this node ready to be used/rendered
  86267. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86268. * @return {boolean} is it ready
  86269. */
  86270. isReady(completeCheck?: boolean): boolean;
  86271. /**
  86272. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86273. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86274. * @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.
  86275. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86276. */
  86277. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86278. /**
  86279. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86280. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86281. * The `data` are either a numeric array either a Float32Array.
  86282. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86283. * 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).
  86284. * Note that a new underlying VertexBuffer object is created each call.
  86285. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86286. *
  86287. * Possible `kind` values :
  86288. * - VertexBuffer.PositionKind
  86289. * - VertexBuffer.UVKind
  86290. * - VertexBuffer.UV2Kind
  86291. * - VertexBuffer.UV3Kind
  86292. * - VertexBuffer.UV4Kind
  86293. * - VertexBuffer.UV5Kind
  86294. * - VertexBuffer.UV6Kind
  86295. * - VertexBuffer.ColorKind
  86296. * - VertexBuffer.MatricesIndicesKind
  86297. * - VertexBuffer.MatricesIndicesExtraKind
  86298. * - VertexBuffer.MatricesWeightsKind
  86299. * - VertexBuffer.MatricesWeightsExtraKind
  86300. *
  86301. * Returns the Mesh.
  86302. */
  86303. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86304. /**
  86305. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86306. * If the mesh has no geometry, it is simply returned as it is.
  86307. * The `data` are either a numeric array either a Float32Array.
  86308. * No new underlying VertexBuffer object is created.
  86309. * 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.
  86310. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86311. *
  86312. * Possible `kind` values :
  86313. * - VertexBuffer.PositionKind
  86314. * - VertexBuffer.UVKind
  86315. * - VertexBuffer.UV2Kind
  86316. * - VertexBuffer.UV3Kind
  86317. * - VertexBuffer.UV4Kind
  86318. * - VertexBuffer.UV5Kind
  86319. * - VertexBuffer.UV6Kind
  86320. * - VertexBuffer.ColorKind
  86321. * - VertexBuffer.MatricesIndicesKind
  86322. * - VertexBuffer.MatricesIndicesExtraKind
  86323. * - VertexBuffer.MatricesWeightsKind
  86324. * - VertexBuffer.MatricesWeightsExtraKind
  86325. *
  86326. * Returns the Mesh.
  86327. */
  86328. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  86329. /**
  86330. * Sets the mesh indices.
  86331. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86332. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86333. * This method creates a new index buffer each call.
  86334. * Returns the Mesh.
  86335. */
  86336. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  86337. /**
  86338. * Boolean : True if the mesh owns the requested kind of data.
  86339. */
  86340. isVerticesDataPresent(kind: string): boolean;
  86341. /**
  86342. * Returns an array of indices (IndicesArray).
  86343. */
  86344. getIndices(): Nullable<IndicesArray>;
  86345. readonly _positions: Nullable<Vector3[]>;
  86346. /**
  86347. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86348. * This means the mesh underlying bounding box and sphere are recomputed.
  86349. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86350. * @returns the current mesh
  86351. */
  86352. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  86353. /** @hidden */
  86354. _preActivate(): InstancedMesh;
  86355. /** @hidden */
  86356. _activate(renderId: number, intermediateRendering: boolean): boolean;
  86357. /** @hidden */
  86358. _postActivate(): void;
  86359. getWorldMatrix(): Matrix;
  86360. readonly isAnInstance: boolean;
  86361. /**
  86362. * Returns the current associated LOD AbstractMesh.
  86363. */
  86364. getLOD(camera: Camera): AbstractMesh;
  86365. /** @hidden */
  86366. _syncSubMeshes(): InstancedMesh;
  86367. /** @hidden */
  86368. _generatePointsArray(): boolean;
  86369. /**
  86370. * Creates a new InstancedMesh from the current mesh.
  86371. * - name (string) : the cloned mesh name
  86372. * - newParent (optional Node) : the optional Node to parent the clone to.
  86373. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  86374. *
  86375. * Returns the clone.
  86376. */
  86377. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86378. /**
  86379. * Disposes the InstancedMesh.
  86380. * Returns nothing.
  86381. */
  86382. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86383. }
  86384. interface Mesh {
  86385. /**
  86386. * Register a custom buffer that will be instanced
  86387. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86388. * @param kind defines the buffer kind
  86389. * @param stride defines the stride in floats
  86390. */
  86391. registerInstancedBuffer(kind: string, stride: number): void;
  86392. /** @hidden */
  86393. _userInstancedBuffersStorage: {
  86394. data: {
  86395. [key: string]: Float32Array;
  86396. };
  86397. sizes: {
  86398. [key: string]: number;
  86399. };
  86400. vertexBuffers: {
  86401. [key: string]: Nullable<VertexBuffer>;
  86402. };
  86403. strides: {
  86404. [key: string]: number;
  86405. };
  86406. };
  86407. }
  86408. interface AbstractMesh {
  86409. /**
  86410. * Object used to store instanced buffers defined by user
  86411. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86412. */
  86413. instancedBuffers: {
  86414. [key: string]: any;
  86415. };
  86416. }
  86417. }
  86418. declare module BABYLON {
  86419. /**
  86420. * Defines the options associated with the creation of a shader material.
  86421. */
  86422. export interface IShaderMaterialOptions {
  86423. /**
  86424. * Does the material work in alpha blend mode
  86425. */
  86426. needAlphaBlending: boolean;
  86427. /**
  86428. * Does the material work in alpha test mode
  86429. */
  86430. needAlphaTesting: boolean;
  86431. /**
  86432. * The list of attribute names used in the shader
  86433. */
  86434. attributes: string[];
  86435. /**
  86436. * The list of unifrom names used in the shader
  86437. */
  86438. uniforms: string[];
  86439. /**
  86440. * The list of UBO names used in the shader
  86441. */
  86442. uniformBuffers: string[];
  86443. /**
  86444. * The list of sampler names used in the shader
  86445. */
  86446. samplers: string[];
  86447. /**
  86448. * The list of defines used in the shader
  86449. */
  86450. defines: string[];
  86451. }
  86452. /**
  86453. * 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.
  86454. *
  86455. * This returned material effects how the mesh will look based on the code in the shaders.
  86456. *
  86457. * @see http://doc.babylonjs.com/how_to/shader_material
  86458. */
  86459. export class ShaderMaterial extends Material {
  86460. private _shaderPath;
  86461. private _options;
  86462. private _textures;
  86463. private _textureArrays;
  86464. private _floats;
  86465. private _ints;
  86466. private _floatsArrays;
  86467. private _colors3;
  86468. private _colors3Arrays;
  86469. private _colors4;
  86470. private _colors4Arrays;
  86471. private _vectors2;
  86472. private _vectors3;
  86473. private _vectors4;
  86474. private _matrices;
  86475. private _matrices3x3;
  86476. private _matrices2x2;
  86477. private _vectors2Arrays;
  86478. private _vectors3Arrays;
  86479. private _vectors4Arrays;
  86480. private _cachedWorldViewMatrix;
  86481. private _cachedWorldViewProjectionMatrix;
  86482. private _renderId;
  86483. /**
  86484. * Instantiate a new shader material.
  86485. * 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.
  86486. * This returned material effects how the mesh will look based on the code in the shaders.
  86487. * @see http://doc.babylonjs.com/how_to/shader_material
  86488. * @param name Define the name of the material in the scene
  86489. * @param scene Define the scene the material belongs to
  86490. * @param shaderPath Defines the route to the shader code in one of three ways:
  86491. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  86492. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  86493. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  86494. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  86495. * @param options Define the options used to create the shader
  86496. */
  86497. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  86498. /**
  86499. * Gets the options used to compile the shader.
  86500. * They can be modified to trigger a new compilation
  86501. */
  86502. readonly options: IShaderMaterialOptions;
  86503. /**
  86504. * Gets the current class name of the material e.g. "ShaderMaterial"
  86505. * Mainly use in serialization.
  86506. * @returns the class name
  86507. */
  86508. getClassName(): string;
  86509. /**
  86510. * Specifies if the material will require alpha blending
  86511. * @returns a boolean specifying if alpha blending is needed
  86512. */
  86513. needAlphaBlending(): boolean;
  86514. /**
  86515. * Specifies if this material should be rendered in alpha test mode
  86516. * @returns a boolean specifying if an alpha test is needed.
  86517. */
  86518. needAlphaTesting(): boolean;
  86519. private _checkUniform;
  86520. /**
  86521. * Set a texture in the shader.
  86522. * @param name Define the name of the uniform samplers as defined in the shader
  86523. * @param texture Define the texture to bind to this sampler
  86524. * @return the material itself allowing "fluent" like uniform updates
  86525. */
  86526. setTexture(name: string, texture: Texture): ShaderMaterial;
  86527. /**
  86528. * Set a texture array in the shader.
  86529. * @param name Define the name of the uniform sampler array as defined in the shader
  86530. * @param textures Define the list of textures to bind to this sampler
  86531. * @return the material itself allowing "fluent" like uniform updates
  86532. */
  86533. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  86534. /**
  86535. * Set a float in the shader.
  86536. * @param name Define the name of the uniform as defined in the shader
  86537. * @param value Define the value to give to the uniform
  86538. * @return the material itself allowing "fluent" like uniform updates
  86539. */
  86540. setFloat(name: string, value: number): ShaderMaterial;
  86541. /**
  86542. * Set a int in the shader.
  86543. * @param name Define the name of the uniform as defined in the shader
  86544. * @param value Define the value to give to the uniform
  86545. * @return the material itself allowing "fluent" like uniform updates
  86546. */
  86547. setInt(name: string, value: number): ShaderMaterial;
  86548. /**
  86549. * Set an array of floats in the shader.
  86550. * @param name Define the name of the uniform as defined in the shader
  86551. * @param value Define the value to give to the uniform
  86552. * @return the material itself allowing "fluent" like uniform updates
  86553. */
  86554. setFloats(name: string, value: number[]): ShaderMaterial;
  86555. /**
  86556. * Set a vec3 in the shader from a Color3.
  86557. * @param name Define the name of the uniform as defined in the shader
  86558. * @param value Define the value to give to the uniform
  86559. * @return the material itself allowing "fluent" like uniform updates
  86560. */
  86561. setColor3(name: string, value: Color3): ShaderMaterial;
  86562. /**
  86563. * Set a vec3 array in the shader from a Color3 array.
  86564. * @param name Define the name of the uniform as defined in the shader
  86565. * @param value Define the value to give to the uniform
  86566. * @return the material itself allowing "fluent" like uniform updates
  86567. */
  86568. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  86569. /**
  86570. * Set a vec4 in the shader from a Color4.
  86571. * @param name Define the name of the uniform as defined in the shader
  86572. * @param value Define the value to give to the uniform
  86573. * @return the material itself allowing "fluent" like uniform updates
  86574. */
  86575. setColor4(name: string, value: Color4): ShaderMaterial;
  86576. /**
  86577. * Set a vec4 array in the shader from a Color4 array.
  86578. * @param name Define the name of the uniform as defined in the shader
  86579. * @param value Define the value to give to the uniform
  86580. * @return the material itself allowing "fluent" like uniform updates
  86581. */
  86582. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  86583. /**
  86584. * Set a vec2 in the shader from a Vector2.
  86585. * @param name Define the name of the uniform as defined in the shader
  86586. * @param value Define the value to give to the uniform
  86587. * @return the material itself allowing "fluent" like uniform updates
  86588. */
  86589. setVector2(name: string, value: Vector2): ShaderMaterial;
  86590. /**
  86591. * Set a vec3 in the shader from a Vector3.
  86592. * @param name Define the name of the uniform as defined in the shader
  86593. * @param value Define the value to give to the uniform
  86594. * @return the material itself allowing "fluent" like uniform updates
  86595. */
  86596. setVector3(name: string, value: Vector3): ShaderMaterial;
  86597. /**
  86598. * Set a vec4 in the shader from a Vector4.
  86599. * @param name Define the name of the uniform as defined in the shader
  86600. * @param value Define the value to give to the uniform
  86601. * @return the material itself allowing "fluent" like uniform updates
  86602. */
  86603. setVector4(name: string, value: Vector4): ShaderMaterial;
  86604. /**
  86605. * Set a mat4 in the shader from a Matrix.
  86606. * @param name Define the name of the uniform as defined in the shader
  86607. * @param value Define the value to give to the uniform
  86608. * @return the material itself allowing "fluent" like uniform updates
  86609. */
  86610. setMatrix(name: string, value: Matrix): ShaderMaterial;
  86611. /**
  86612. * Set a mat3 in the shader from a Float32Array.
  86613. * @param name Define the name of the uniform as defined in the shader
  86614. * @param value Define the value to give to the uniform
  86615. * @return the material itself allowing "fluent" like uniform updates
  86616. */
  86617. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  86618. /**
  86619. * Set a mat2 in the shader from a Float32Array.
  86620. * @param name Define the name of the uniform as defined in the shader
  86621. * @param value Define the value to give to the uniform
  86622. * @return the material itself allowing "fluent" like uniform updates
  86623. */
  86624. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  86625. /**
  86626. * Set a vec2 array in the shader from a number array.
  86627. * @param name Define the name of the uniform as defined in the shader
  86628. * @param value Define the value to give to the uniform
  86629. * @return the material itself allowing "fluent" like uniform updates
  86630. */
  86631. setArray2(name: string, value: number[]): ShaderMaterial;
  86632. /**
  86633. * Set a vec3 array in the shader from a number array.
  86634. * @param name Define the name of the uniform as defined in the shader
  86635. * @param value Define the value to give to the uniform
  86636. * @return the material itself allowing "fluent" like uniform updates
  86637. */
  86638. setArray3(name: string, value: number[]): ShaderMaterial;
  86639. /**
  86640. * Set a vec4 array in the shader from a number array.
  86641. * @param name Define the name of the uniform as defined in the shader
  86642. * @param value Define the value to give to the uniform
  86643. * @return the material itself allowing "fluent" like uniform updates
  86644. */
  86645. setArray4(name: string, value: number[]): ShaderMaterial;
  86646. private _checkCache;
  86647. /**
  86648. * Specifies that the submesh is ready to be used
  86649. * @param mesh defines the mesh to check
  86650. * @param subMesh defines which submesh to check
  86651. * @param useInstances specifies that instances should be used
  86652. * @returns a boolean indicating that the submesh is ready or not
  86653. */
  86654. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86655. /**
  86656. * Checks if the material is ready to render the requested mesh
  86657. * @param mesh Define the mesh to render
  86658. * @param useInstances Define whether or not the material is used with instances
  86659. * @returns true if ready, otherwise false
  86660. */
  86661. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86662. /**
  86663. * Binds the world matrix to the material
  86664. * @param world defines the world transformation matrix
  86665. */
  86666. bindOnlyWorldMatrix(world: Matrix): void;
  86667. /**
  86668. * Binds the material to the mesh
  86669. * @param world defines the world transformation matrix
  86670. * @param mesh defines the mesh to bind the material to
  86671. */
  86672. bind(world: Matrix, mesh?: Mesh): void;
  86673. /**
  86674. * Gets the active textures from the material
  86675. * @returns an array of textures
  86676. */
  86677. getActiveTextures(): BaseTexture[];
  86678. /**
  86679. * Specifies if the material uses a texture
  86680. * @param texture defines the texture to check against the material
  86681. * @returns a boolean specifying if the material uses the texture
  86682. */
  86683. hasTexture(texture: BaseTexture): boolean;
  86684. /**
  86685. * Makes a duplicate of the material, and gives it a new name
  86686. * @param name defines the new name for the duplicated material
  86687. * @returns the cloned material
  86688. */
  86689. clone(name: string): ShaderMaterial;
  86690. /**
  86691. * Disposes the material
  86692. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86693. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86694. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86695. */
  86696. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86697. /**
  86698. * Serializes this material in a JSON representation
  86699. * @returns the serialized material object
  86700. */
  86701. serialize(): any;
  86702. /**
  86703. * Creates a shader material from parsed shader material data
  86704. * @param source defines the JSON represnetation of the material
  86705. * @param scene defines the hosting scene
  86706. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86707. * @returns a new material
  86708. */
  86709. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86710. }
  86711. }
  86712. declare module BABYLON {
  86713. /** @hidden */
  86714. export var colorPixelShader: {
  86715. name: string;
  86716. shader: string;
  86717. };
  86718. }
  86719. declare module BABYLON {
  86720. /** @hidden */
  86721. export var colorVertexShader: {
  86722. name: string;
  86723. shader: string;
  86724. };
  86725. }
  86726. declare module BABYLON {
  86727. /**
  86728. * Line mesh
  86729. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86730. */
  86731. export class LinesMesh extends Mesh {
  86732. /**
  86733. * If vertex color should be applied to the mesh
  86734. */
  86735. readonly useVertexColor?: boolean | undefined;
  86736. /**
  86737. * If vertex alpha should be applied to the mesh
  86738. */
  86739. readonly useVertexAlpha?: boolean | undefined;
  86740. /**
  86741. * Color of the line (Default: White)
  86742. */
  86743. color: Color3;
  86744. /**
  86745. * Alpha of the line (Default: 1)
  86746. */
  86747. alpha: number;
  86748. /**
  86749. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86750. * This margin is expressed in world space coordinates, so its value may vary.
  86751. * Default value is 0.1
  86752. */
  86753. intersectionThreshold: number;
  86754. private _colorShader;
  86755. private color4;
  86756. /**
  86757. * Creates a new LinesMesh
  86758. * @param name defines the name
  86759. * @param scene defines the hosting scene
  86760. * @param parent defines the parent mesh if any
  86761. * @param source defines the optional source LinesMesh used to clone data from
  86762. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86763. * When false, achieved by calling a clone(), also passing False.
  86764. * This will make creation of children, recursive.
  86765. * @param useVertexColor defines if this LinesMesh supports vertex color
  86766. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86767. */
  86768. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86769. /**
  86770. * If vertex color should be applied to the mesh
  86771. */
  86772. useVertexColor?: boolean | undefined,
  86773. /**
  86774. * If vertex alpha should be applied to the mesh
  86775. */
  86776. useVertexAlpha?: boolean | undefined);
  86777. private _addClipPlaneDefine;
  86778. private _removeClipPlaneDefine;
  86779. isReady(): boolean;
  86780. /**
  86781. * Returns the string "LineMesh"
  86782. */
  86783. getClassName(): string;
  86784. /**
  86785. * @hidden
  86786. */
  86787. /**
  86788. * @hidden
  86789. */
  86790. material: Material;
  86791. /**
  86792. * @hidden
  86793. */
  86794. readonly checkCollisions: boolean;
  86795. /** @hidden */
  86796. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86797. /** @hidden */
  86798. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86799. /**
  86800. * Disposes of the line mesh
  86801. * @param doNotRecurse If children should be disposed
  86802. */
  86803. dispose(doNotRecurse?: boolean): void;
  86804. /**
  86805. * Returns a new LineMesh object cloned from the current one.
  86806. */
  86807. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86808. /**
  86809. * Creates a new InstancedLinesMesh object from the mesh model.
  86810. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86811. * @param name defines the name of the new instance
  86812. * @returns a new InstancedLinesMesh
  86813. */
  86814. createInstance(name: string): InstancedLinesMesh;
  86815. }
  86816. /**
  86817. * Creates an instance based on a source LinesMesh
  86818. */
  86819. export class InstancedLinesMesh extends InstancedMesh {
  86820. /**
  86821. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86822. * This margin is expressed in world space coordinates, so its value may vary.
  86823. * Initilized with the intersectionThreshold value of the source LinesMesh
  86824. */
  86825. intersectionThreshold: number;
  86826. constructor(name: string, source: LinesMesh);
  86827. /**
  86828. * Returns the string "InstancedLinesMesh".
  86829. */
  86830. getClassName(): string;
  86831. }
  86832. }
  86833. declare module BABYLON {
  86834. /** @hidden */
  86835. export var linePixelShader: {
  86836. name: string;
  86837. shader: string;
  86838. };
  86839. }
  86840. declare module BABYLON {
  86841. /** @hidden */
  86842. export var lineVertexShader: {
  86843. name: string;
  86844. shader: string;
  86845. };
  86846. }
  86847. declare module BABYLON {
  86848. interface AbstractMesh {
  86849. /**
  86850. * Gets the edgesRenderer associated with the mesh
  86851. */
  86852. edgesRenderer: Nullable<EdgesRenderer>;
  86853. }
  86854. interface LinesMesh {
  86855. /**
  86856. * Enables the edge rendering mode on the mesh.
  86857. * This mode makes the mesh edges visible
  86858. * @param epsilon defines the maximal distance between two angles to detect a face
  86859. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86860. * @returns the currentAbstractMesh
  86861. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86862. */
  86863. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86864. }
  86865. interface InstancedLinesMesh {
  86866. /**
  86867. * Enables the edge rendering mode on the mesh.
  86868. * This mode makes the mesh edges visible
  86869. * @param epsilon defines the maximal distance between two angles to detect a face
  86870. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86871. * @returns the current InstancedLinesMesh
  86872. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86873. */
  86874. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86875. }
  86876. /**
  86877. * Defines the minimum contract an Edges renderer should follow.
  86878. */
  86879. export interface IEdgesRenderer extends IDisposable {
  86880. /**
  86881. * Gets or sets a boolean indicating if the edgesRenderer is active
  86882. */
  86883. isEnabled: boolean;
  86884. /**
  86885. * Renders the edges of the attached mesh,
  86886. */
  86887. render(): void;
  86888. /**
  86889. * Checks wether or not the edges renderer is ready to render.
  86890. * @return true if ready, otherwise false.
  86891. */
  86892. isReady(): boolean;
  86893. }
  86894. /**
  86895. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86896. */
  86897. export class EdgesRenderer implements IEdgesRenderer {
  86898. /**
  86899. * Define the size of the edges with an orthographic camera
  86900. */
  86901. edgesWidthScalerForOrthographic: number;
  86902. /**
  86903. * Define the size of the edges with a perspective camera
  86904. */
  86905. edgesWidthScalerForPerspective: number;
  86906. protected _source: AbstractMesh;
  86907. protected _linesPositions: number[];
  86908. protected _linesNormals: number[];
  86909. protected _linesIndices: number[];
  86910. protected _epsilon: number;
  86911. protected _indicesCount: number;
  86912. protected _lineShader: ShaderMaterial;
  86913. protected _ib: DataBuffer;
  86914. protected _buffers: {
  86915. [key: string]: Nullable<VertexBuffer>;
  86916. };
  86917. protected _checkVerticesInsteadOfIndices: boolean;
  86918. private _meshRebuildObserver;
  86919. private _meshDisposeObserver;
  86920. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86921. isEnabled: boolean;
  86922. /**
  86923. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86924. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86925. * @param source Mesh used to create edges
  86926. * @param epsilon sum of angles in adjacency to check for edge
  86927. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86928. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86929. */
  86930. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86931. protected _prepareRessources(): void;
  86932. /** @hidden */
  86933. _rebuild(): void;
  86934. /**
  86935. * Releases the required resources for the edges renderer
  86936. */
  86937. dispose(): void;
  86938. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86939. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86940. /**
  86941. * Checks if the pair of p0 and p1 is en edge
  86942. * @param faceIndex
  86943. * @param edge
  86944. * @param faceNormals
  86945. * @param p0
  86946. * @param p1
  86947. * @private
  86948. */
  86949. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86950. /**
  86951. * push line into the position, normal and index buffer
  86952. * @protected
  86953. */
  86954. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86955. /**
  86956. * Generates lines edges from adjacencjes
  86957. * @private
  86958. */
  86959. _generateEdgesLines(): void;
  86960. /**
  86961. * Checks wether or not the edges renderer is ready to render.
  86962. * @return true if ready, otherwise false.
  86963. */
  86964. isReady(): boolean;
  86965. /**
  86966. * Renders the edges of the attached mesh,
  86967. */
  86968. render(): void;
  86969. }
  86970. /**
  86971. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86972. */
  86973. export class LineEdgesRenderer extends EdgesRenderer {
  86974. /**
  86975. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86976. * @param source LineMesh used to generate edges
  86977. * @param epsilon not important (specified angle for edge detection)
  86978. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86979. */
  86980. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86981. /**
  86982. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86983. */
  86984. _generateEdgesLines(): void;
  86985. }
  86986. }
  86987. declare module BABYLON {
  86988. /**
  86989. * This represents the object necessary to create a rendering group.
  86990. * This is exclusively used and created by the rendering manager.
  86991. * To modify the behavior, you use the available helpers in your scene or meshes.
  86992. * @hidden
  86993. */
  86994. export class RenderingGroup {
  86995. index: number;
  86996. private static _zeroVector;
  86997. private _scene;
  86998. private _opaqueSubMeshes;
  86999. private _transparentSubMeshes;
  87000. private _alphaTestSubMeshes;
  87001. private _depthOnlySubMeshes;
  87002. private _particleSystems;
  87003. private _spriteManagers;
  87004. private _opaqueSortCompareFn;
  87005. private _alphaTestSortCompareFn;
  87006. private _transparentSortCompareFn;
  87007. private _renderOpaque;
  87008. private _renderAlphaTest;
  87009. private _renderTransparent;
  87010. /** @hidden */
  87011. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87012. onBeforeTransparentRendering: () => void;
  87013. /**
  87014. * Set the opaque sort comparison function.
  87015. * If null the sub meshes will be render in the order they were created
  87016. */
  87017. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87018. /**
  87019. * Set the alpha test sort comparison function.
  87020. * If null the sub meshes will be render in the order they were created
  87021. */
  87022. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87023. /**
  87024. * Set the transparent sort comparison function.
  87025. * If null the sub meshes will be render in the order they were created
  87026. */
  87027. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87028. /**
  87029. * Creates a new rendering group.
  87030. * @param index The rendering group index
  87031. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87032. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87033. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87034. */
  87035. 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>);
  87036. /**
  87037. * Render all the sub meshes contained in the group.
  87038. * @param customRenderFunction Used to override the default render behaviour of the group.
  87039. * @returns true if rendered some submeshes.
  87040. */
  87041. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87042. /**
  87043. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87044. * @param subMeshes The submeshes to render
  87045. */
  87046. private renderOpaqueSorted;
  87047. /**
  87048. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87049. * @param subMeshes The submeshes to render
  87050. */
  87051. private renderAlphaTestSorted;
  87052. /**
  87053. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87054. * @param subMeshes The submeshes to render
  87055. */
  87056. private renderTransparentSorted;
  87057. /**
  87058. * Renders the submeshes in a specified order.
  87059. * @param subMeshes The submeshes to sort before render
  87060. * @param sortCompareFn The comparison function use to sort
  87061. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87062. * @param transparent Specifies to activate blending if true
  87063. */
  87064. private static renderSorted;
  87065. /**
  87066. * Renders the submeshes in the order they were dispatched (no sort applied).
  87067. * @param subMeshes The submeshes to render
  87068. */
  87069. private static renderUnsorted;
  87070. /**
  87071. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87072. * are rendered back to front if in the same alpha index.
  87073. *
  87074. * @param a The first submesh
  87075. * @param b The second submesh
  87076. * @returns The result of the comparison
  87077. */
  87078. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87079. /**
  87080. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87081. * are rendered back to front.
  87082. *
  87083. * @param a The first submesh
  87084. * @param b The second submesh
  87085. * @returns The result of the comparison
  87086. */
  87087. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  87088. /**
  87089. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87090. * are rendered front to back (prevent overdraw).
  87091. *
  87092. * @param a The first submesh
  87093. * @param b The second submesh
  87094. * @returns The result of the comparison
  87095. */
  87096. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  87097. /**
  87098. * Resets the different lists of submeshes to prepare a new frame.
  87099. */
  87100. prepare(): void;
  87101. dispose(): void;
  87102. /**
  87103. * Inserts the submesh in its correct queue depending on its material.
  87104. * @param subMesh The submesh to dispatch
  87105. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87106. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87107. */
  87108. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87109. dispatchSprites(spriteManager: ISpriteManager): void;
  87110. dispatchParticles(particleSystem: IParticleSystem): void;
  87111. private _renderParticles;
  87112. private _renderSprites;
  87113. }
  87114. }
  87115. declare module BABYLON {
  87116. /**
  87117. * Interface describing the different options available in the rendering manager
  87118. * regarding Auto Clear between groups.
  87119. */
  87120. export interface IRenderingManagerAutoClearSetup {
  87121. /**
  87122. * Defines whether or not autoclear is enable.
  87123. */
  87124. autoClear: boolean;
  87125. /**
  87126. * Defines whether or not to autoclear the depth buffer.
  87127. */
  87128. depth: boolean;
  87129. /**
  87130. * Defines whether or not to autoclear the stencil buffer.
  87131. */
  87132. stencil: boolean;
  87133. }
  87134. /**
  87135. * This class is used by the onRenderingGroupObservable
  87136. */
  87137. export class RenderingGroupInfo {
  87138. /**
  87139. * The Scene that being rendered
  87140. */
  87141. scene: Scene;
  87142. /**
  87143. * The camera currently used for the rendering pass
  87144. */
  87145. camera: Nullable<Camera>;
  87146. /**
  87147. * The ID of the renderingGroup being processed
  87148. */
  87149. renderingGroupId: number;
  87150. }
  87151. /**
  87152. * This is the manager responsible of all the rendering for meshes sprites and particles.
  87153. * It is enable to manage the different groups as well as the different necessary sort functions.
  87154. * This should not be used directly aside of the few static configurations
  87155. */
  87156. export class RenderingManager {
  87157. /**
  87158. * The max id used for rendering groups (not included)
  87159. */
  87160. static MAX_RENDERINGGROUPS: number;
  87161. /**
  87162. * The min id used for rendering groups (included)
  87163. */
  87164. static MIN_RENDERINGGROUPS: number;
  87165. /**
  87166. * Used to globally prevent autoclearing scenes.
  87167. */
  87168. static AUTOCLEAR: boolean;
  87169. /**
  87170. * @hidden
  87171. */
  87172. _useSceneAutoClearSetup: boolean;
  87173. private _scene;
  87174. private _renderingGroups;
  87175. private _depthStencilBufferAlreadyCleaned;
  87176. private _autoClearDepthStencil;
  87177. private _customOpaqueSortCompareFn;
  87178. private _customAlphaTestSortCompareFn;
  87179. private _customTransparentSortCompareFn;
  87180. private _renderingGroupInfo;
  87181. /**
  87182. * Instantiates a new rendering group for a particular scene
  87183. * @param scene Defines the scene the groups belongs to
  87184. */
  87185. constructor(scene: Scene);
  87186. private _clearDepthStencilBuffer;
  87187. /**
  87188. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  87189. * @hidden
  87190. */
  87191. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  87192. /**
  87193. * Resets the different information of the group to prepare a new frame
  87194. * @hidden
  87195. */
  87196. reset(): void;
  87197. /**
  87198. * Dispose and release the group and its associated resources.
  87199. * @hidden
  87200. */
  87201. dispose(): void;
  87202. /**
  87203. * Clear the info related to rendering groups preventing retention points during dispose.
  87204. */
  87205. freeRenderingGroups(): void;
  87206. private _prepareRenderingGroup;
  87207. /**
  87208. * Add a sprite manager to the rendering manager in order to render it this frame.
  87209. * @param spriteManager Define the sprite manager to render
  87210. */
  87211. dispatchSprites(spriteManager: ISpriteManager): void;
  87212. /**
  87213. * Add a particle system to the rendering manager in order to render it this frame.
  87214. * @param particleSystem Define the particle system to render
  87215. */
  87216. dispatchParticles(particleSystem: IParticleSystem): void;
  87217. /**
  87218. * Add a submesh to the manager in order to render it this frame
  87219. * @param subMesh The submesh to dispatch
  87220. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87221. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87222. */
  87223. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87224. /**
  87225. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87226. * This allowed control for front to back rendering or reversly depending of the special needs.
  87227. *
  87228. * @param renderingGroupId The rendering group id corresponding to its index
  87229. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87230. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87231. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87232. */
  87233. 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;
  87234. /**
  87235. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87236. *
  87237. * @param renderingGroupId The rendering group id corresponding to its index
  87238. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87239. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87240. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87241. */
  87242. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87243. /**
  87244. * Gets the current auto clear configuration for one rendering group of the rendering
  87245. * manager.
  87246. * @param index the rendering group index to get the information for
  87247. * @returns The auto clear setup for the requested rendering group
  87248. */
  87249. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87250. }
  87251. }
  87252. declare module BABYLON {
  87253. /**
  87254. * This Helps creating a texture that will be created from a camera in your scene.
  87255. * It is basically a dynamic texture that could be used to create special effects for instance.
  87256. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87257. */
  87258. export class RenderTargetTexture extends Texture {
  87259. isCube: boolean;
  87260. /**
  87261. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87262. */
  87263. static readonly REFRESHRATE_RENDER_ONCE: number;
  87264. /**
  87265. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87266. */
  87267. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87268. /**
  87269. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87270. * the central point of your effect and can save a lot of performances.
  87271. */
  87272. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87273. /**
  87274. * Use this predicate to dynamically define the list of mesh you want to render.
  87275. * If set, the renderList property will be overwritten.
  87276. */
  87277. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87278. private _renderList;
  87279. /**
  87280. * Use this list to define the list of mesh you want to render.
  87281. */
  87282. renderList: Nullable<Array<AbstractMesh>>;
  87283. private _hookArray;
  87284. /**
  87285. * Define if particles should be rendered in your texture.
  87286. */
  87287. renderParticles: boolean;
  87288. /**
  87289. * Define if sprites should be rendered in your texture.
  87290. */
  87291. renderSprites: boolean;
  87292. /**
  87293. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  87294. */
  87295. coordinatesMode: number;
  87296. /**
  87297. * Define the camera used to render the texture.
  87298. */
  87299. activeCamera: Nullable<Camera>;
  87300. /**
  87301. * Override the render function of the texture with your own one.
  87302. */
  87303. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  87304. /**
  87305. * Define if camera post processes should be use while rendering the texture.
  87306. */
  87307. useCameraPostProcesses: boolean;
  87308. /**
  87309. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  87310. */
  87311. ignoreCameraViewport: boolean;
  87312. private _postProcessManager;
  87313. private _postProcesses;
  87314. private _resizeObserver;
  87315. /**
  87316. * An event triggered when the texture is unbind.
  87317. */
  87318. onBeforeBindObservable: Observable<RenderTargetTexture>;
  87319. /**
  87320. * An event triggered when the texture is unbind.
  87321. */
  87322. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  87323. private _onAfterUnbindObserver;
  87324. /**
  87325. * Set a after unbind callback in the texture.
  87326. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  87327. */
  87328. onAfterUnbind: () => void;
  87329. /**
  87330. * An event triggered before rendering the texture
  87331. */
  87332. onBeforeRenderObservable: Observable<number>;
  87333. private _onBeforeRenderObserver;
  87334. /**
  87335. * Set a before render callback in the texture.
  87336. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  87337. */
  87338. onBeforeRender: (faceIndex: number) => void;
  87339. /**
  87340. * An event triggered after rendering the texture
  87341. */
  87342. onAfterRenderObservable: Observable<number>;
  87343. private _onAfterRenderObserver;
  87344. /**
  87345. * Set a after render callback in the texture.
  87346. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  87347. */
  87348. onAfterRender: (faceIndex: number) => void;
  87349. /**
  87350. * An event triggered after the texture clear
  87351. */
  87352. onClearObservable: Observable<Engine>;
  87353. private _onClearObserver;
  87354. /**
  87355. * Set a clear callback in the texture.
  87356. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  87357. */
  87358. onClear: (Engine: Engine) => void;
  87359. /**
  87360. * An event triggered when the texture is resized.
  87361. */
  87362. onResizeObservable: Observable<RenderTargetTexture>;
  87363. /**
  87364. * Define the clear color of the Render Target if it should be different from the scene.
  87365. */
  87366. clearColor: Color4;
  87367. protected _size: number | {
  87368. width: number;
  87369. height: number;
  87370. };
  87371. protected _initialSizeParameter: number | {
  87372. width: number;
  87373. height: number;
  87374. } | {
  87375. ratio: number;
  87376. };
  87377. protected _sizeRatio: Nullable<number>;
  87378. /** @hidden */
  87379. _generateMipMaps: boolean;
  87380. protected _renderingManager: RenderingManager;
  87381. /** @hidden */
  87382. _waitingRenderList: string[];
  87383. protected _doNotChangeAspectRatio: boolean;
  87384. protected _currentRefreshId: number;
  87385. protected _refreshRate: number;
  87386. protected _textureMatrix: Matrix;
  87387. protected _samples: number;
  87388. protected _renderTargetOptions: RenderTargetCreationOptions;
  87389. /**
  87390. * Gets render target creation options that were used.
  87391. */
  87392. readonly renderTargetOptions: RenderTargetCreationOptions;
  87393. protected _engine: Engine;
  87394. protected _onRatioRescale(): void;
  87395. /**
  87396. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  87397. * It must define where the camera used to render the texture is set
  87398. */
  87399. boundingBoxPosition: Vector3;
  87400. private _boundingBoxSize;
  87401. /**
  87402. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  87403. * When defined, the cubemap will switch to local mode
  87404. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87405. * @example https://www.babylonjs-playground.com/#RNASML
  87406. */
  87407. boundingBoxSize: Vector3;
  87408. /**
  87409. * In case the RTT has been created with a depth texture, get the associated
  87410. * depth texture.
  87411. * Otherwise, return null.
  87412. */
  87413. depthStencilTexture: Nullable<InternalTexture>;
  87414. /**
  87415. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  87416. * or used a shadow, depth texture...
  87417. * @param name The friendly name of the texture
  87418. * @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)
  87419. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  87420. * @param generateMipMaps True if mip maps need to be generated after render.
  87421. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  87422. * @param type The type of the buffer in the RTT (int, half float, float...)
  87423. * @param isCube True if a cube texture needs to be created
  87424. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  87425. * @param generateDepthBuffer True to generate a depth buffer
  87426. * @param generateStencilBuffer True to generate a stencil buffer
  87427. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  87428. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  87429. * @param delayAllocation if the texture allocation should be delayed (default: false)
  87430. */
  87431. constructor(name: string, size: number | {
  87432. width: number;
  87433. height: number;
  87434. } | {
  87435. ratio: number;
  87436. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  87437. /**
  87438. * Creates a depth stencil texture.
  87439. * This is only available in WebGL 2 or with the depth texture extension available.
  87440. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  87441. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  87442. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  87443. */
  87444. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  87445. private _processSizeParameter;
  87446. /**
  87447. * Define the number of samples to use in case of MSAA.
  87448. * It defaults to one meaning no MSAA has been enabled.
  87449. */
  87450. samples: number;
  87451. /**
  87452. * Resets the refresh counter of the texture and start bak from scratch.
  87453. * Could be useful to regenerate the texture if it is setup to render only once.
  87454. */
  87455. resetRefreshCounter(): void;
  87456. /**
  87457. * Define the refresh rate of the texture or the rendering frequency.
  87458. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87459. */
  87460. refreshRate: number;
  87461. /**
  87462. * Adds a post process to the render target rendering passes.
  87463. * @param postProcess define the post process to add
  87464. */
  87465. addPostProcess(postProcess: PostProcess): void;
  87466. /**
  87467. * Clear all the post processes attached to the render target
  87468. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  87469. */
  87470. clearPostProcesses(dispose?: boolean): void;
  87471. /**
  87472. * Remove one of the post process from the list of attached post processes to the texture
  87473. * @param postProcess define the post process to remove from the list
  87474. */
  87475. removePostProcess(postProcess: PostProcess): void;
  87476. /** @hidden */
  87477. _shouldRender(): boolean;
  87478. /**
  87479. * Gets the actual render size of the texture.
  87480. * @returns the width of the render size
  87481. */
  87482. getRenderSize(): number;
  87483. /**
  87484. * Gets the actual render width of the texture.
  87485. * @returns the width of the render size
  87486. */
  87487. getRenderWidth(): number;
  87488. /**
  87489. * Gets the actual render height of the texture.
  87490. * @returns the height of the render size
  87491. */
  87492. getRenderHeight(): number;
  87493. /**
  87494. * Get if the texture can be rescaled or not.
  87495. */
  87496. readonly canRescale: boolean;
  87497. /**
  87498. * Resize the texture using a ratio.
  87499. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  87500. */
  87501. scale(ratio: number): void;
  87502. /**
  87503. * Get the texture reflection matrix used to rotate/transform the reflection.
  87504. * @returns the reflection matrix
  87505. */
  87506. getReflectionTextureMatrix(): Matrix;
  87507. /**
  87508. * Resize the texture to a new desired size.
  87509. * Be carrefull as it will recreate all the data in the new texture.
  87510. * @param size Define the new size. It can be:
  87511. * - a number for squared texture,
  87512. * - an object containing { width: number, height: number }
  87513. * - or an object containing a ratio { ratio: number }
  87514. */
  87515. resize(size: number | {
  87516. width: number;
  87517. height: number;
  87518. } | {
  87519. ratio: number;
  87520. }): void;
  87521. /**
  87522. * Renders all the objects from the render list into the texture.
  87523. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  87524. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  87525. */
  87526. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  87527. private _bestReflectionRenderTargetDimension;
  87528. /**
  87529. * @hidden
  87530. * @param faceIndex face index to bind to if this is a cubetexture
  87531. */
  87532. _bindFrameBuffer(faceIndex?: number): void;
  87533. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  87534. private renderToTarget;
  87535. /**
  87536. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87537. * This allowed control for front to back rendering or reversly depending of the special needs.
  87538. *
  87539. * @param renderingGroupId The rendering group id corresponding to its index
  87540. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87541. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87542. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87543. */
  87544. 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;
  87545. /**
  87546. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87547. *
  87548. * @param renderingGroupId The rendering group id corresponding to its index
  87549. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87550. */
  87551. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  87552. /**
  87553. * Clones the texture.
  87554. * @returns the cloned texture
  87555. */
  87556. clone(): RenderTargetTexture;
  87557. /**
  87558. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  87559. * @returns The JSON representation of the texture
  87560. */
  87561. serialize(): any;
  87562. /**
  87563. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  87564. */
  87565. disposeFramebufferObjects(): void;
  87566. /**
  87567. * Dispose the texture and release its associated resources.
  87568. */
  87569. dispose(): void;
  87570. /** @hidden */
  87571. _rebuild(): void;
  87572. /**
  87573. * Clear the info related to rendering groups preventing retention point in material dispose.
  87574. */
  87575. freeRenderingGroups(): void;
  87576. /**
  87577. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87578. * @returns the view count
  87579. */
  87580. getViewCount(): number;
  87581. }
  87582. }
  87583. declare module BABYLON {
  87584. /**
  87585. * Options for compiling materials.
  87586. */
  87587. export interface IMaterialCompilationOptions {
  87588. /**
  87589. * Defines whether clip planes are enabled.
  87590. */
  87591. clipPlane: boolean;
  87592. /**
  87593. * Defines whether instances are enabled.
  87594. */
  87595. useInstances: boolean;
  87596. }
  87597. /**
  87598. * Base class for the main features of a material in Babylon.js
  87599. */
  87600. export class Material implements IAnimatable {
  87601. /**
  87602. * Returns the triangle fill mode
  87603. */
  87604. static readonly TriangleFillMode: number;
  87605. /**
  87606. * Returns the wireframe mode
  87607. */
  87608. static readonly WireFrameFillMode: number;
  87609. /**
  87610. * Returns the point fill mode
  87611. */
  87612. static readonly PointFillMode: number;
  87613. /**
  87614. * Returns the point list draw mode
  87615. */
  87616. static readonly PointListDrawMode: number;
  87617. /**
  87618. * Returns the line list draw mode
  87619. */
  87620. static readonly LineListDrawMode: number;
  87621. /**
  87622. * Returns the line loop draw mode
  87623. */
  87624. static readonly LineLoopDrawMode: number;
  87625. /**
  87626. * Returns the line strip draw mode
  87627. */
  87628. static readonly LineStripDrawMode: number;
  87629. /**
  87630. * Returns the triangle strip draw mode
  87631. */
  87632. static readonly TriangleStripDrawMode: number;
  87633. /**
  87634. * Returns the triangle fan draw mode
  87635. */
  87636. static readonly TriangleFanDrawMode: number;
  87637. /**
  87638. * Stores the clock-wise side orientation
  87639. */
  87640. static readonly ClockWiseSideOrientation: number;
  87641. /**
  87642. * Stores the counter clock-wise side orientation
  87643. */
  87644. static readonly CounterClockWiseSideOrientation: number;
  87645. /**
  87646. * The dirty texture flag value
  87647. */
  87648. static readonly TextureDirtyFlag: number;
  87649. /**
  87650. * The dirty light flag value
  87651. */
  87652. static readonly LightDirtyFlag: number;
  87653. /**
  87654. * The dirty fresnel flag value
  87655. */
  87656. static readonly FresnelDirtyFlag: number;
  87657. /**
  87658. * The dirty attribute flag value
  87659. */
  87660. static readonly AttributesDirtyFlag: number;
  87661. /**
  87662. * The dirty misc flag value
  87663. */
  87664. static readonly MiscDirtyFlag: number;
  87665. /**
  87666. * The all dirty flag value
  87667. */
  87668. static readonly AllDirtyFlag: number;
  87669. /**
  87670. * The ID of the material
  87671. */
  87672. id: string;
  87673. /**
  87674. * Gets or sets the unique id of the material
  87675. */
  87676. uniqueId: number;
  87677. /**
  87678. * The name of the material
  87679. */
  87680. name: string;
  87681. /**
  87682. * Gets or sets user defined metadata
  87683. */
  87684. metadata: any;
  87685. /**
  87686. * For internal use only. Please do not use.
  87687. */
  87688. reservedDataStore: any;
  87689. /**
  87690. * Specifies if the ready state should be checked on each call
  87691. */
  87692. checkReadyOnEveryCall: boolean;
  87693. /**
  87694. * Specifies if the ready state should be checked once
  87695. */
  87696. checkReadyOnlyOnce: boolean;
  87697. /**
  87698. * The state of the material
  87699. */
  87700. state: string;
  87701. /**
  87702. * The alpha value of the material
  87703. */
  87704. protected _alpha: number;
  87705. /**
  87706. * List of inspectable custom properties (used by the Inspector)
  87707. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87708. */
  87709. inspectableCustomProperties: IInspectable[];
  87710. /**
  87711. * Sets the alpha value of the material
  87712. */
  87713. /**
  87714. * Gets the alpha value of the material
  87715. */
  87716. alpha: number;
  87717. /**
  87718. * Specifies if back face culling is enabled
  87719. */
  87720. protected _backFaceCulling: boolean;
  87721. /**
  87722. * Sets the back-face culling state
  87723. */
  87724. /**
  87725. * Gets the back-face culling state
  87726. */
  87727. backFaceCulling: boolean;
  87728. /**
  87729. * Stores the value for side orientation
  87730. */
  87731. sideOrientation: number;
  87732. /**
  87733. * Callback triggered when the material is compiled
  87734. */
  87735. onCompiled: Nullable<(effect: Effect) => void>;
  87736. /**
  87737. * Callback triggered when an error occurs
  87738. */
  87739. onError: Nullable<(effect: Effect, errors: string) => void>;
  87740. /**
  87741. * Callback triggered to get the render target textures
  87742. */
  87743. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87744. /**
  87745. * Gets a boolean indicating that current material needs to register RTT
  87746. */
  87747. readonly hasRenderTargetTextures: boolean;
  87748. /**
  87749. * Specifies if the material should be serialized
  87750. */
  87751. doNotSerialize: boolean;
  87752. /**
  87753. * @hidden
  87754. */
  87755. _storeEffectOnSubMeshes: boolean;
  87756. /**
  87757. * Stores the animations for the material
  87758. */
  87759. animations: Nullable<Array<Animation>>;
  87760. /**
  87761. * An event triggered when the material is disposed
  87762. */
  87763. onDisposeObservable: Observable<Material>;
  87764. /**
  87765. * An observer which watches for dispose events
  87766. */
  87767. private _onDisposeObserver;
  87768. private _onUnBindObservable;
  87769. /**
  87770. * Called during a dispose event
  87771. */
  87772. onDispose: () => void;
  87773. private _onBindObservable;
  87774. /**
  87775. * An event triggered when the material is bound
  87776. */
  87777. readonly onBindObservable: Observable<AbstractMesh>;
  87778. /**
  87779. * An observer which watches for bind events
  87780. */
  87781. private _onBindObserver;
  87782. /**
  87783. * Called during a bind event
  87784. */
  87785. onBind: (Mesh: AbstractMesh) => void;
  87786. /**
  87787. * An event triggered when the material is unbound
  87788. */
  87789. readonly onUnBindObservable: Observable<Material>;
  87790. /**
  87791. * Stores the value of the alpha mode
  87792. */
  87793. private _alphaMode;
  87794. /**
  87795. * Sets the value of the alpha mode.
  87796. *
  87797. * | Value | Type | Description |
  87798. * | --- | --- | --- |
  87799. * | 0 | ALPHA_DISABLE | |
  87800. * | 1 | ALPHA_ADD | |
  87801. * | 2 | ALPHA_COMBINE | |
  87802. * | 3 | ALPHA_SUBTRACT | |
  87803. * | 4 | ALPHA_MULTIPLY | |
  87804. * | 5 | ALPHA_MAXIMIZED | |
  87805. * | 6 | ALPHA_ONEONE | |
  87806. * | 7 | ALPHA_PREMULTIPLIED | |
  87807. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87808. * | 9 | ALPHA_INTERPOLATE | |
  87809. * | 10 | ALPHA_SCREENMODE | |
  87810. *
  87811. */
  87812. /**
  87813. * Gets the value of the alpha mode
  87814. */
  87815. alphaMode: number;
  87816. /**
  87817. * Stores the state of the need depth pre-pass value
  87818. */
  87819. private _needDepthPrePass;
  87820. /**
  87821. * Sets the need depth pre-pass value
  87822. */
  87823. /**
  87824. * Gets the depth pre-pass value
  87825. */
  87826. needDepthPrePass: boolean;
  87827. /**
  87828. * Specifies if depth writing should be disabled
  87829. */
  87830. disableDepthWrite: boolean;
  87831. /**
  87832. * Specifies if depth writing should be forced
  87833. */
  87834. forceDepthWrite: boolean;
  87835. /**
  87836. * Specifies if there should be a separate pass for culling
  87837. */
  87838. separateCullingPass: boolean;
  87839. /**
  87840. * Stores the state specifing if fog should be enabled
  87841. */
  87842. private _fogEnabled;
  87843. /**
  87844. * Sets the state for enabling fog
  87845. */
  87846. /**
  87847. * Gets the value of the fog enabled state
  87848. */
  87849. fogEnabled: boolean;
  87850. /**
  87851. * Stores the size of points
  87852. */
  87853. pointSize: number;
  87854. /**
  87855. * Stores the z offset value
  87856. */
  87857. zOffset: number;
  87858. /**
  87859. * Gets a value specifying if wireframe mode is enabled
  87860. */
  87861. /**
  87862. * Sets the state of wireframe mode
  87863. */
  87864. wireframe: boolean;
  87865. /**
  87866. * Gets the value specifying if point clouds are enabled
  87867. */
  87868. /**
  87869. * Sets the state of point cloud mode
  87870. */
  87871. pointsCloud: boolean;
  87872. /**
  87873. * Gets the material fill mode
  87874. */
  87875. /**
  87876. * Sets the material fill mode
  87877. */
  87878. fillMode: number;
  87879. /**
  87880. * @hidden
  87881. * Stores the effects for the material
  87882. */
  87883. _effect: Nullable<Effect>;
  87884. /**
  87885. * @hidden
  87886. * Specifies if the material was previously ready
  87887. */
  87888. _wasPreviouslyReady: boolean;
  87889. /**
  87890. * Specifies if uniform buffers should be used
  87891. */
  87892. private _useUBO;
  87893. /**
  87894. * Stores a reference to the scene
  87895. */
  87896. private _scene;
  87897. /**
  87898. * Stores the fill mode state
  87899. */
  87900. private _fillMode;
  87901. /**
  87902. * Specifies if the depth write state should be cached
  87903. */
  87904. private _cachedDepthWriteState;
  87905. /**
  87906. * Stores the uniform buffer
  87907. */
  87908. protected _uniformBuffer: UniformBuffer;
  87909. /** @hidden */
  87910. _indexInSceneMaterialArray: number;
  87911. /** @hidden */
  87912. meshMap: Nullable<{
  87913. [id: string]: AbstractMesh | undefined;
  87914. }>;
  87915. /**
  87916. * Creates a material instance
  87917. * @param name defines the name of the material
  87918. * @param scene defines the scene to reference
  87919. * @param doNotAdd specifies if the material should be added to the scene
  87920. */
  87921. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87922. /**
  87923. * Returns a string representation of the current material
  87924. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87925. * @returns a string with material information
  87926. */
  87927. toString(fullDetails?: boolean): string;
  87928. /**
  87929. * Gets the class name of the material
  87930. * @returns a string with the class name of the material
  87931. */
  87932. getClassName(): string;
  87933. /**
  87934. * Specifies if updates for the material been locked
  87935. */
  87936. readonly isFrozen: boolean;
  87937. /**
  87938. * Locks updates for the material
  87939. */
  87940. freeze(): void;
  87941. /**
  87942. * Unlocks updates for the material
  87943. */
  87944. unfreeze(): void;
  87945. /**
  87946. * Specifies if the material is ready to be used
  87947. * @param mesh defines the mesh to check
  87948. * @param useInstances specifies if instances should be used
  87949. * @returns a boolean indicating if the material is ready to be used
  87950. */
  87951. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87952. /**
  87953. * Specifies that the submesh is ready to be used
  87954. * @param mesh defines the mesh to check
  87955. * @param subMesh defines which submesh to check
  87956. * @param useInstances specifies that instances should be used
  87957. * @returns a boolean indicating that the submesh is ready or not
  87958. */
  87959. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87960. /**
  87961. * Returns the material effect
  87962. * @returns the effect associated with the material
  87963. */
  87964. getEffect(): Nullable<Effect>;
  87965. /**
  87966. * Returns the current scene
  87967. * @returns a Scene
  87968. */
  87969. getScene(): Scene;
  87970. /**
  87971. * Specifies if the material will require alpha blending
  87972. * @returns a boolean specifying if alpha blending is needed
  87973. */
  87974. needAlphaBlending(): boolean;
  87975. /**
  87976. * Specifies if the mesh will require alpha blending
  87977. * @param mesh defines the mesh to check
  87978. * @returns a boolean specifying if alpha blending is needed for the mesh
  87979. */
  87980. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87981. /**
  87982. * Specifies if this material should be rendered in alpha test mode
  87983. * @returns a boolean specifying if an alpha test is needed.
  87984. */
  87985. needAlphaTesting(): boolean;
  87986. /**
  87987. * Gets the texture used for the alpha test
  87988. * @returns the texture to use for alpha testing
  87989. */
  87990. getAlphaTestTexture(): Nullable<BaseTexture>;
  87991. /**
  87992. * Marks the material to indicate that it needs to be re-calculated
  87993. */
  87994. markDirty(): void;
  87995. /** @hidden */
  87996. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87997. /**
  87998. * Binds the material to the mesh
  87999. * @param world defines the world transformation matrix
  88000. * @param mesh defines the mesh to bind the material to
  88001. */
  88002. bind(world: Matrix, mesh?: Mesh): void;
  88003. /**
  88004. * Binds the submesh to the material
  88005. * @param world defines the world transformation matrix
  88006. * @param mesh defines the mesh containing the submesh
  88007. * @param subMesh defines the submesh to bind the material to
  88008. */
  88009. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88010. /**
  88011. * Binds the world matrix to the material
  88012. * @param world defines the world transformation matrix
  88013. */
  88014. bindOnlyWorldMatrix(world: Matrix): void;
  88015. /**
  88016. * Binds the scene's uniform buffer to the effect.
  88017. * @param effect defines the effect to bind to the scene uniform buffer
  88018. * @param sceneUbo defines the uniform buffer storing scene data
  88019. */
  88020. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88021. /**
  88022. * Binds the view matrix to the effect
  88023. * @param effect defines the effect to bind the view matrix to
  88024. */
  88025. bindView(effect: Effect): void;
  88026. /**
  88027. * Binds the view projection matrix to the effect
  88028. * @param effect defines the effect to bind the view projection matrix to
  88029. */
  88030. bindViewProjection(effect: Effect): void;
  88031. /**
  88032. * Specifies if material alpha testing should be turned on for the mesh
  88033. * @param mesh defines the mesh to check
  88034. */
  88035. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88036. /**
  88037. * Processes to execute after binding the material to a mesh
  88038. * @param mesh defines the rendered mesh
  88039. */
  88040. protected _afterBind(mesh?: Mesh): void;
  88041. /**
  88042. * Unbinds the material from the mesh
  88043. */
  88044. unbind(): void;
  88045. /**
  88046. * Gets the active textures from the material
  88047. * @returns an array of textures
  88048. */
  88049. getActiveTextures(): BaseTexture[];
  88050. /**
  88051. * Specifies if the material uses a texture
  88052. * @param texture defines the texture to check against the material
  88053. * @returns a boolean specifying if the material uses the texture
  88054. */
  88055. hasTexture(texture: BaseTexture): boolean;
  88056. /**
  88057. * Makes a duplicate of the material, and gives it a new name
  88058. * @param name defines the new name for the duplicated material
  88059. * @returns the cloned material
  88060. */
  88061. clone(name: string): Nullable<Material>;
  88062. /**
  88063. * Gets the meshes bound to the material
  88064. * @returns an array of meshes bound to the material
  88065. */
  88066. getBindedMeshes(): AbstractMesh[];
  88067. /**
  88068. * Force shader compilation
  88069. * @param mesh defines the mesh associated with this material
  88070. * @param onCompiled defines a function to execute once the material is compiled
  88071. * @param options defines the options to configure the compilation
  88072. * @param onError defines a function to execute if the material fails compiling
  88073. */
  88074. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  88075. /**
  88076. * Force shader compilation
  88077. * @param mesh defines the mesh that will use this material
  88078. * @param options defines additional options for compiling the shaders
  88079. * @returns a promise that resolves when the compilation completes
  88080. */
  88081. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  88082. private static readonly _AllDirtyCallBack;
  88083. private static readonly _ImageProcessingDirtyCallBack;
  88084. private static readonly _TextureDirtyCallBack;
  88085. private static readonly _FresnelDirtyCallBack;
  88086. private static readonly _MiscDirtyCallBack;
  88087. private static readonly _LightsDirtyCallBack;
  88088. private static readonly _AttributeDirtyCallBack;
  88089. private static _FresnelAndMiscDirtyCallBack;
  88090. private static _TextureAndMiscDirtyCallBack;
  88091. private static readonly _DirtyCallbackArray;
  88092. private static readonly _RunDirtyCallBacks;
  88093. /**
  88094. * Marks a define in the material to indicate that it needs to be re-computed
  88095. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  88096. */
  88097. markAsDirty(flag: number): void;
  88098. /**
  88099. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  88100. * @param func defines a function which checks material defines against the submeshes
  88101. */
  88102. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  88103. /**
  88104. * Indicates that we need to re-calculated for all submeshes
  88105. */
  88106. protected _markAllSubMeshesAsAllDirty(): void;
  88107. /**
  88108. * Indicates that image processing needs to be re-calculated for all submeshes
  88109. */
  88110. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  88111. /**
  88112. * Indicates that textures need to be re-calculated for all submeshes
  88113. */
  88114. protected _markAllSubMeshesAsTexturesDirty(): void;
  88115. /**
  88116. * Indicates that fresnel needs to be re-calculated for all submeshes
  88117. */
  88118. protected _markAllSubMeshesAsFresnelDirty(): void;
  88119. /**
  88120. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  88121. */
  88122. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  88123. /**
  88124. * Indicates that lights need to be re-calculated for all submeshes
  88125. */
  88126. protected _markAllSubMeshesAsLightsDirty(): void;
  88127. /**
  88128. * Indicates that attributes need to be re-calculated for all submeshes
  88129. */
  88130. protected _markAllSubMeshesAsAttributesDirty(): void;
  88131. /**
  88132. * Indicates that misc needs to be re-calculated for all submeshes
  88133. */
  88134. protected _markAllSubMeshesAsMiscDirty(): void;
  88135. /**
  88136. * Indicates that textures and misc need to be re-calculated for all submeshes
  88137. */
  88138. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  88139. /**
  88140. * Disposes the material
  88141. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88142. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88143. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88144. */
  88145. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88146. /** @hidden */
  88147. private releaseVertexArrayObject;
  88148. /**
  88149. * Serializes this material
  88150. * @returns the serialized material object
  88151. */
  88152. serialize(): any;
  88153. /**
  88154. * Creates a material from parsed material data
  88155. * @param parsedMaterial defines parsed material data
  88156. * @param scene defines the hosting scene
  88157. * @param rootUrl defines the root URL to use to load textures
  88158. * @returns a new material
  88159. */
  88160. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  88161. }
  88162. }
  88163. declare module BABYLON {
  88164. /**
  88165. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88166. * separate meshes. This can be use to improve performances.
  88167. * @see http://doc.babylonjs.com/how_to/multi_materials
  88168. */
  88169. export class MultiMaterial extends Material {
  88170. private _subMaterials;
  88171. /**
  88172. * Gets or Sets the list of Materials used within the multi material.
  88173. * They need to be ordered according to the submeshes order in the associated mesh
  88174. */
  88175. subMaterials: Nullable<Material>[];
  88176. /**
  88177. * Function used to align with Node.getChildren()
  88178. * @returns the list of Materials used within the multi material
  88179. */
  88180. getChildren(): Nullable<Material>[];
  88181. /**
  88182. * Instantiates a new Multi Material
  88183. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88184. * separate meshes. This can be use to improve performances.
  88185. * @see http://doc.babylonjs.com/how_to/multi_materials
  88186. * @param name Define the name in the scene
  88187. * @param scene Define the scene the material belongs to
  88188. */
  88189. constructor(name: string, scene: Scene);
  88190. private _hookArray;
  88191. /**
  88192. * Get one of the submaterial by its index in the submaterials array
  88193. * @param index The index to look the sub material at
  88194. * @returns The Material if the index has been defined
  88195. */
  88196. getSubMaterial(index: number): Nullable<Material>;
  88197. /**
  88198. * Get the list of active textures for the whole sub materials list.
  88199. * @returns All the textures that will be used during the rendering
  88200. */
  88201. getActiveTextures(): BaseTexture[];
  88202. /**
  88203. * Gets the current class name of the material e.g. "MultiMaterial"
  88204. * Mainly use in serialization.
  88205. * @returns the class name
  88206. */
  88207. getClassName(): string;
  88208. /**
  88209. * Checks if the material is ready to render the requested sub mesh
  88210. * @param mesh Define the mesh the submesh belongs to
  88211. * @param subMesh Define the sub mesh to look readyness for
  88212. * @param useInstances Define whether or not the material is used with instances
  88213. * @returns true if ready, otherwise false
  88214. */
  88215. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88216. /**
  88217. * Clones the current material and its related sub materials
  88218. * @param name Define the name of the newly cloned material
  88219. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  88220. * @returns the cloned material
  88221. */
  88222. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  88223. /**
  88224. * Serializes the materials into a JSON representation.
  88225. * @returns the JSON representation
  88226. */
  88227. serialize(): any;
  88228. /**
  88229. * Dispose the material and release its associated resources
  88230. * @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)
  88231. * @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)
  88232. * @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)
  88233. */
  88234. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  88235. /**
  88236. * Creates a MultiMaterial from parsed MultiMaterial data.
  88237. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  88238. * @param scene defines the hosting scene
  88239. * @returns a new MultiMaterial
  88240. */
  88241. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88242. }
  88243. }
  88244. declare module BABYLON {
  88245. /**
  88246. * Base class for submeshes
  88247. */
  88248. export class BaseSubMesh {
  88249. /** @hidden */
  88250. _materialDefines: Nullable<MaterialDefines>;
  88251. /** @hidden */
  88252. _materialEffect: Nullable<Effect>;
  88253. /**
  88254. * Gets associated effect
  88255. */
  88256. readonly effect: Nullable<Effect>;
  88257. /**
  88258. * Sets associated effect (effect used to render this submesh)
  88259. * @param effect defines the effect to associate with
  88260. * @param defines defines the set of defines used to compile this effect
  88261. */
  88262. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88263. }
  88264. /**
  88265. * Defines a subdivision inside a mesh
  88266. */
  88267. export class SubMesh extends BaseSubMesh implements ICullable {
  88268. /** the material index to use */
  88269. materialIndex: number;
  88270. /** vertex index start */
  88271. verticesStart: number;
  88272. /** vertices count */
  88273. verticesCount: number;
  88274. /** index start */
  88275. indexStart: number;
  88276. /** indices count */
  88277. indexCount: number;
  88278. /** @hidden */
  88279. _linesIndexCount: number;
  88280. private _mesh;
  88281. private _renderingMesh;
  88282. private _boundingInfo;
  88283. private _linesIndexBuffer;
  88284. /** @hidden */
  88285. _lastColliderWorldVertices: Nullable<Vector3[]>;
  88286. /** @hidden */
  88287. _trianglePlanes: Plane[];
  88288. /** @hidden */
  88289. _lastColliderTransformMatrix: Nullable<Matrix>;
  88290. /** @hidden */
  88291. _renderId: number;
  88292. /** @hidden */
  88293. _alphaIndex: number;
  88294. /** @hidden */
  88295. _distanceToCamera: number;
  88296. /** @hidden */
  88297. _id: number;
  88298. private _currentMaterial;
  88299. /**
  88300. * Add a new submesh to a mesh
  88301. * @param materialIndex defines the material index to use
  88302. * @param verticesStart defines vertex index start
  88303. * @param verticesCount defines vertices count
  88304. * @param indexStart defines index start
  88305. * @param indexCount defines indices count
  88306. * @param mesh defines the parent mesh
  88307. * @param renderingMesh defines an optional rendering mesh
  88308. * @param createBoundingBox defines if bounding box should be created for this submesh
  88309. * @returns the new submesh
  88310. */
  88311. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  88312. /**
  88313. * Creates a new submesh
  88314. * @param materialIndex defines the material index to use
  88315. * @param verticesStart defines vertex index start
  88316. * @param verticesCount defines vertices count
  88317. * @param indexStart defines index start
  88318. * @param indexCount defines indices count
  88319. * @param mesh defines the parent mesh
  88320. * @param renderingMesh defines an optional rendering mesh
  88321. * @param createBoundingBox defines if bounding box should be created for this submesh
  88322. */
  88323. constructor(
  88324. /** the material index to use */
  88325. materialIndex: number,
  88326. /** vertex index start */
  88327. verticesStart: number,
  88328. /** vertices count */
  88329. verticesCount: number,
  88330. /** index start */
  88331. indexStart: number,
  88332. /** indices count */
  88333. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  88334. /**
  88335. * Returns true if this submesh covers the entire parent mesh
  88336. * @ignorenaming
  88337. */
  88338. readonly IsGlobal: boolean;
  88339. /**
  88340. * Returns the submesh BoudingInfo object
  88341. * @returns current bounding info (or mesh's one if the submesh is global)
  88342. */
  88343. getBoundingInfo(): BoundingInfo;
  88344. /**
  88345. * Sets the submesh BoundingInfo
  88346. * @param boundingInfo defines the new bounding info to use
  88347. * @returns the SubMesh
  88348. */
  88349. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  88350. /**
  88351. * Returns the mesh of the current submesh
  88352. * @return the parent mesh
  88353. */
  88354. getMesh(): AbstractMesh;
  88355. /**
  88356. * Returns the rendering mesh of the submesh
  88357. * @returns the rendering mesh (could be different from parent mesh)
  88358. */
  88359. getRenderingMesh(): Mesh;
  88360. /**
  88361. * Returns the submesh material
  88362. * @returns null or the current material
  88363. */
  88364. getMaterial(): Nullable<Material>;
  88365. /**
  88366. * Sets a new updated BoundingInfo object to the submesh
  88367. * @param data defines an optional position array to use to determine the bounding info
  88368. * @returns the SubMesh
  88369. */
  88370. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  88371. /** @hidden */
  88372. _checkCollision(collider: Collider): boolean;
  88373. /**
  88374. * Updates the submesh BoundingInfo
  88375. * @param world defines the world matrix to use to update the bounding info
  88376. * @returns the submesh
  88377. */
  88378. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  88379. /**
  88380. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88381. * @param frustumPlanes defines the frustum planes
  88382. * @returns true if the submesh is intersecting with the frustum
  88383. */
  88384. isInFrustum(frustumPlanes: Plane[]): boolean;
  88385. /**
  88386. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88387. * @param frustumPlanes defines the frustum planes
  88388. * @returns true if the submesh is inside the frustum
  88389. */
  88390. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88391. /**
  88392. * Renders the submesh
  88393. * @param enableAlphaMode defines if alpha needs to be used
  88394. * @returns the submesh
  88395. */
  88396. render(enableAlphaMode: boolean): SubMesh;
  88397. /**
  88398. * @hidden
  88399. */
  88400. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  88401. /**
  88402. * Checks if the submesh intersects with a ray
  88403. * @param ray defines the ray to test
  88404. * @returns true is the passed ray intersects the submesh bounding box
  88405. */
  88406. canIntersects(ray: Ray): boolean;
  88407. /**
  88408. * Intersects current submesh with a ray
  88409. * @param ray defines the ray to test
  88410. * @param positions defines mesh's positions array
  88411. * @param indices defines mesh's indices array
  88412. * @param fastCheck defines if only bounding info should be used
  88413. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88414. * @returns intersection info or null if no intersection
  88415. */
  88416. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  88417. /** @hidden */
  88418. private _intersectLines;
  88419. /** @hidden */
  88420. private _intersectUnIndexedLines;
  88421. /** @hidden */
  88422. private _intersectTriangles;
  88423. /** @hidden */
  88424. private _intersectUnIndexedTriangles;
  88425. /** @hidden */
  88426. _rebuild(): void;
  88427. /**
  88428. * Creates a new submesh from the passed mesh
  88429. * @param newMesh defines the new hosting mesh
  88430. * @param newRenderingMesh defines an optional rendering mesh
  88431. * @returns the new submesh
  88432. */
  88433. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  88434. /**
  88435. * Release associated resources
  88436. */
  88437. dispose(): void;
  88438. /**
  88439. * Gets the class name
  88440. * @returns the string "SubMesh".
  88441. */
  88442. getClassName(): string;
  88443. /**
  88444. * Creates a new submesh from indices data
  88445. * @param materialIndex the index of the main mesh material
  88446. * @param startIndex the index where to start the copy in the mesh indices array
  88447. * @param indexCount the number of indices to copy then from the startIndex
  88448. * @param mesh the main mesh to create the submesh from
  88449. * @param renderingMesh the optional rendering mesh
  88450. * @returns a new submesh
  88451. */
  88452. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  88453. }
  88454. }
  88455. declare module BABYLON {
  88456. /**
  88457. * Class used to represent data loading progression
  88458. */
  88459. export class SceneLoaderFlags {
  88460. private static _ForceFullSceneLoadingForIncremental;
  88461. private static _ShowLoadingScreen;
  88462. private static _CleanBoneMatrixWeights;
  88463. private static _loggingLevel;
  88464. /**
  88465. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  88466. */
  88467. static ForceFullSceneLoadingForIncremental: boolean;
  88468. /**
  88469. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  88470. */
  88471. static ShowLoadingScreen: boolean;
  88472. /**
  88473. * Defines the current logging level (while loading the scene)
  88474. * @ignorenaming
  88475. */
  88476. static loggingLevel: number;
  88477. /**
  88478. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  88479. */
  88480. static CleanBoneMatrixWeights: boolean;
  88481. }
  88482. }
  88483. declare module BABYLON {
  88484. /**
  88485. * Class used to store geometry data (vertex buffers + index buffer)
  88486. */
  88487. export class Geometry implements IGetSetVerticesData {
  88488. /**
  88489. * Gets or sets the ID of the geometry
  88490. */
  88491. id: string;
  88492. /**
  88493. * Gets or sets the unique ID of the geometry
  88494. */
  88495. uniqueId: number;
  88496. /**
  88497. * Gets the delay loading state of the geometry (none by default which means not delayed)
  88498. */
  88499. delayLoadState: number;
  88500. /**
  88501. * Gets the file containing the data to load when running in delay load state
  88502. */
  88503. delayLoadingFile: Nullable<string>;
  88504. /**
  88505. * Callback called when the geometry is updated
  88506. */
  88507. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  88508. private _scene;
  88509. private _engine;
  88510. private _meshes;
  88511. private _totalVertices;
  88512. /** @hidden */
  88513. _indices: IndicesArray;
  88514. /** @hidden */
  88515. _vertexBuffers: {
  88516. [key: string]: VertexBuffer;
  88517. };
  88518. private _isDisposed;
  88519. private _extend;
  88520. private _boundingBias;
  88521. /** @hidden */
  88522. _delayInfo: Array<string>;
  88523. private _indexBuffer;
  88524. private _indexBufferIsUpdatable;
  88525. /** @hidden */
  88526. _boundingInfo: Nullable<BoundingInfo>;
  88527. /** @hidden */
  88528. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  88529. /** @hidden */
  88530. _softwareSkinningFrameId: number;
  88531. private _vertexArrayObjects;
  88532. private _updatable;
  88533. /** @hidden */
  88534. _positions: Nullable<Vector3[]>;
  88535. /**
  88536. * 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
  88537. */
  88538. /**
  88539. * 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
  88540. */
  88541. boundingBias: Vector2;
  88542. /**
  88543. * Static function used to attach a new empty geometry to a mesh
  88544. * @param mesh defines the mesh to attach the geometry to
  88545. * @returns the new Geometry
  88546. */
  88547. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  88548. /**
  88549. * Creates a new geometry
  88550. * @param id defines the unique ID
  88551. * @param scene defines the hosting scene
  88552. * @param vertexData defines the VertexData used to get geometry data
  88553. * @param updatable defines if geometry must be updatable (false by default)
  88554. * @param mesh defines the mesh that will be associated with the geometry
  88555. */
  88556. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  88557. /**
  88558. * Gets the current extend of the geometry
  88559. */
  88560. readonly extend: {
  88561. minimum: Vector3;
  88562. maximum: Vector3;
  88563. };
  88564. /**
  88565. * Gets the hosting scene
  88566. * @returns the hosting Scene
  88567. */
  88568. getScene(): Scene;
  88569. /**
  88570. * Gets the hosting engine
  88571. * @returns the hosting Engine
  88572. */
  88573. getEngine(): Engine;
  88574. /**
  88575. * Defines if the geometry is ready to use
  88576. * @returns true if the geometry is ready to be used
  88577. */
  88578. isReady(): boolean;
  88579. /**
  88580. * Gets a value indicating that the geometry should not be serialized
  88581. */
  88582. readonly doNotSerialize: boolean;
  88583. /** @hidden */
  88584. _rebuild(): void;
  88585. /**
  88586. * Affects all geometry data in one call
  88587. * @param vertexData defines the geometry data
  88588. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  88589. */
  88590. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  88591. /**
  88592. * Set specific vertex data
  88593. * @param kind defines the data kind (Position, normal, etc...)
  88594. * @param data defines the vertex data to use
  88595. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88596. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88597. */
  88598. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  88599. /**
  88600. * Removes a specific vertex data
  88601. * @param kind defines the data kind (Position, normal, etc...)
  88602. */
  88603. removeVerticesData(kind: string): void;
  88604. /**
  88605. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  88606. * @param buffer defines the vertex buffer to use
  88607. * @param totalVertices defines the total number of vertices for position kind (could be null)
  88608. */
  88609. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  88610. /**
  88611. * Update a specific vertex buffer
  88612. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  88613. * It will do nothing if the buffer is not updatable
  88614. * @param kind defines the data kind (Position, normal, etc...)
  88615. * @param data defines the data to use
  88616. * @param offset defines the offset in the target buffer where to store the data
  88617. * @param useBytes set to true if the offset is in bytes
  88618. */
  88619. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  88620. /**
  88621. * Update a specific vertex buffer
  88622. * This function will create a new buffer if the current one is not updatable
  88623. * @param kind defines the data kind (Position, normal, etc...)
  88624. * @param data defines the data to use
  88625. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  88626. */
  88627. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  88628. private _updateBoundingInfo;
  88629. /** @hidden */
  88630. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  88631. /**
  88632. * Gets total number of vertices
  88633. * @returns the total number of vertices
  88634. */
  88635. getTotalVertices(): number;
  88636. /**
  88637. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88638. * @param kind defines the data kind (Position, normal, etc...)
  88639. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88640. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88641. * @returns a float array containing vertex data
  88642. */
  88643. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88644. /**
  88645. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  88646. * @param kind defines the data kind (Position, normal, etc...)
  88647. * @returns true if the vertex buffer with the specified kind is updatable
  88648. */
  88649. isVertexBufferUpdatable(kind: string): boolean;
  88650. /**
  88651. * Gets a specific vertex buffer
  88652. * @param kind defines the data kind (Position, normal, etc...)
  88653. * @returns a VertexBuffer
  88654. */
  88655. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88656. /**
  88657. * Returns all vertex buffers
  88658. * @return an object holding all vertex buffers indexed by kind
  88659. */
  88660. getVertexBuffers(): Nullable<{
  88661. [key: string]: VertexBuffer;
  88662. }>;
  88663. /**
  88664. * Gets a boolean indicating if specific vertex buffer is present
  88665. * @param kind defines the data kind (Position, normal, etc...)
  88666. * @returns true if data is present
  88667. */
  88668. isVerticesDataPresent(kind: string): boolean;
  88669. /**
  88670. * Gets a list of all attached data kinds (Position, normal, etc...)
  88671. * @returns a list of string containing all kinds
  88672. */
  88673. getVerticesDataKinds(): string[];
  88674. /**
  88675. * Update index buffer
  88676. * @param indices defines the indices to store in the index buffer
  88677. * @param offset defines the offset in the target buffer where to store the data
  88678. * @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)
  88679. */
  88680. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  88681. /**
  88682. * Creates a new index buffer
  88683. * @param indices defines the indices to store in the index buffer
  88684. * @param totalVertices defines the total number of vertices (could be null)
  88685. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88686. */
  88687. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  88688. /**
  88689. * Return the total number of indices
  88690. * @returns the total number of indices
  88691. */
  88692. getTotalIndices(): number;
  88693. /**
  88694. * Gets the index buffer array
  88695. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88696. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88697. * @returns the index buffer array
  88698. */
  88699. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88700. /**
  88701. * Gets the index buffer
  88702. * @return the index buffer
  88703. */
  88704. getIndexBuffer(): Nullable<DataBuffer>;
  88705. /** @hidden */
  88706. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88707. /**
  88708. * Release the associated resources for a specific mesh
  88709. * @param mesh defines the source mesh
  88710. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88711. */
  88712. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88713. /**
  88714. * Apply current geometry to a given mesh
  88715. * @param mesh defines the mesh to apply geometry to
  88716. */
  88717. applyToMesh(mesh: Mesh): void;
  88718. private _updateExtend;
  88719. private _applyToMesh;
  88720. private notifyUpdate;
  88721. /**
  88722. * Load the geometry if it was flagged as delay loaded
  88723. * @param scene defines the hosting scene
  88724. * @param onLoaded defines a callback called when the geometry is loaded
  88725. */
  88726. load(scene: Scene, onLoaded?: () => void): void;
  88727. private _queueLoad;
  88728. /**
  88729. * Invert the geometry to move from a right handed system to a left handed one.
  88730. */
  88731. toLeftHanded(): void;
  88732. /** @hidden */
  88733. _resetPointsArrayCache(): void;
  88734. /** @hidden */
  88735. _generatePointsArray(): boolean;
  88736. /**
  88737. * Gets a value indicating if the geometry is disposed
  88738. * @returns true if the geometry was disposed
  88739. */
  88740. isDisposed(): boolean;
  88741. private _disposeVertexArrayObjects;
  88742. /**
  88743. * Free all associated resources
  88744. */
  88745. dispose(): void;
  88746. /**
  88747. * Clone the current geometry into a new geometry
  88748. * @param id defines the unique ID of the new geometry
  88749. * @returns a new geometry object
  88750. */
  88751. copy(id: string): Geometry;
  88752. /**
  88753. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88754. * @return a JSON representation of the current geometry data (without the vertices data)
  88755. */
  88756. serialize(): any;
  88757. private toNumberArray;
  88758. /**
  88759. * Serialize all vertices data into a JSON oject
  88760. * @returns a JSON representation of the current geometry data
  88761. */
  88762. serializeVerticeData(): any;
  88763. /**
  88764. * Extracts a clone of a mesh geometry
  88765. * @param mesh defines the source mesh
  88766. * @param id defines the unique ID of the new geometry object
  88767. * @returns the new geometry object
  88768. */
  88769. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88770. /**
  88771. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88772. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88773. * Be aware Math.random() could cause collisions, but:
  88774. * "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"
  88775. * @returns a string containing a new GUID
  88776. */
  88777. static RandomId(): string;
  88778. /** @hidden */
  88779. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88780. private static _CleanMatricesWeights;
  88781. /**
  88782. * Create a new geometry from persisted data (Using .babylon file format)
  88783. * @param parsedVertexData defines the persisted data
  88784. * @param scene defines the hosting scene
  88785. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88786. * @returns the new geometry object
  88787. */
  88788. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88789. }
  88790. }
  88791. declare module BABYLON {
  88792. /**
  88793. * Define an interface for all classes that will get and set the data on vertices
  88794. */
  88795. export interface IGetSetVerticesData {
  88796. /**
  88797. * Gets a boolean indicating if specific vertex data is present
  88798. * @param kind defines the vertex data kind to use
  88799. * @returns true is data kind is present
  88800. */
  88801. isVerticesDataPresent(kind: string): boolean;
  88802. /**
  88803. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88804. * @param kind defines the data kind (Position, normal, etc...)
  88805. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88806. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88807. * @returns a float array containing vertex data
  88808. */
  88809. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88810. /**
  88811. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88812. * @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.
  88813. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88814. * @returns the indices array or an empty array if the mesh has no geometry
  88815. */
  88816. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88817. /**
  88818. * Set specific vertex data
  88819. * @param kind defines the data kind (Position, normal, etc...)
  88820. * @param data defines the vertex data to use
  88821. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88822. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88823. */
  88824. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88825. /**
  88826. * Update a specific associated vertex buffer
  88827. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88828. * - VertexBuffer.PositionKind
  88829. * - VertexBuffer.UVKind
  88830. * - VertexBuffer.UV2Kind
  88831. * - VertexBuffer.UV3Kind
  88832. * - VertexBuffer.UV4Kind
  88833. * - VertexBuffer.UV5Kind
  88834. * - VertexBuffer.UV6Kind
  88835. * - VertexBuffer.ColorKind
  88836. * - VertexBuffer.MatricesIndicesKind
  88837. * - VertexBuffer.MatricesIndicesExtraKind
  88838. * - VertexBuffer.MatricesWeightsKind
  88839. * - VertexBuffer.MatricesWeightsExtraKind
  88840. * @param data defines the data source
  88841. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88842. * @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)
  88843. */
  88844. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88845. /**
  88846. * Creates a new index buffer
  88847. * @param indices defines the indices to store in the index buffer
  88848. * @param totalVertices defines the total number of vertices (could be null)
  88849. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88850. */
  88851. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88852. }
  88853. /**
  88854. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88855. */
  88856. export class VertexData {
  88857. /**
  88858. * Mesh side orientation : usually the external or front surface
  88859. */
  88860. static readonly FRONTSIDE: number;
  88861. /**
  88862. * Mesh side orientation : usually the internal or back surface
  88863. */
  88864. static readonly BACKSIDE: number;
  88865. /**
  88866. * Mesh side orientation : both internal and external or front and back surfaces
  88867. */
  88868. static readonly DOUBLESIDE: number;
  88869. /**
  88870. * Mesh side orientation : by default, `FRONTSIDE`
  88871. */
  88872. static readonly DEFAULTSIDE: number;
  88873. /**
  88874. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88875. */
  88876. positions: Nullable<FloatArray>;
  88877. /**
  88878. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88879. */
  88880. normals: Nullable<FloatArray>;
  88881. /**
  88882. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88883. */
  88884. tangents: Nullable<FloatArray>;
  88885. /**
  88886. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88887. */
  88888. uvs: Nullable<FloatArray>;
  88889. /**
  88890. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88891. */
  88892. uvs2: Nullable<FloatArray>;
  88893. /**
  88894. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88895. */
  88896. uvs3: Nullable<FloatArray>;
  88897. /**
  88898. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88899. */
  88900. uvs4: Nullable<FloatArray>;
  88901. /**
  88902. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88903. */
  88904. uvs5: Nullable<FloatArray>;
  88905. /**
  88906. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88907. */
  88908. uvs6: Nullable<FloatArray>;
  88909. /**
  88910. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88911. */
  88912. colors: Nullable<FloatArray>;
  88913. /**
  88914. * 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).
  88915. */
  88916. matricesIndices: Nullable<FloatArray>;
  88917. /**
  88918. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88919. */
  88920. matricesWeights: Nullable<FloatArray>;
  88921. /**
  88922. * An array extending the number of possible indices
  88923. */
  88924. matricesIndicesExtra: Nullable<FloatArray>;
  88925. /**
  88926. * An array extending the number of possible weights when the number of indices is extended
  88927. */
  88928. matricesWeightsExtra: Nullable<FloatArray>;
  88929. /**
  88930. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88931. */
  88932. indices: Nullable<IndicesArray>;
  88933. /**
  88934. * Uses the passed data array to set the set the values for the specified kind of data
  88935. * @param data a linear array of floating numbers
  88936. * @param kind the type of data that is being set, eg positions, colors etc
  88937. */
  88938. set(data: FloatArray, kind: string): void;
  88939. /**
  88940. * Associates the vertexData to the passed Mesh.
  88941. * Sets it as updatable or not (default `false`)
  88942. * @param mesh the mesh the vertexData is applied to
  88943. * @param updatable when used and having the value true allows new data to update the vertexData
  88944. * @returns the VertexData
  88945. */
  88946. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88947. /**
  88948. * Associates the vertexData to the passed Geometry.
  88949. * Sets it as updatable or not (default `false`)
  88950. * @param geometry the geometry the vertexData is applied to
  88951. * @param updatable when used and having the value true allows new data to update the vertexData
  88952. * @returns VertexData
  88953. */
  88954. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88955. /**
  88956. * Updates the associated mesh
  88957. * @param mesh the mesh to be updated
  88958. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88959. * @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
  88960. * @returns VertexData
  88961. */
  88962. updateMesh(mesh: Mesh): VertexData;
  88963. /**
  88964. * Updates the associated geometry
  88965. * @param geometry the geometry to be updated
  88966. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88967. * @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
  88968. * @returns VertexData.
  88969. */
  88970. updateGeometry(geometry: Geometry): VertexData;
  88971. private _applyTo;
  88972. private _update;
  88973. /**
  88974. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88975. * @param matrix the transforming matrix
  88976. * @returns the VertexData
  88977. */
  88978. transform(matrix: Matrix): VertexData;
  88979. /**
  88980. * Merges the passed VertexData into the current one
  88981. * @param other the VertexData to be merged into the current one
  88982. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88983. * @returns the modified VertexData
  88984. */
  88985. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88986. private _mergeElement;
  88987. private _validate;
  88988. /**
  88989. * Serializes the VertexData
  88990. * @returns a serialized object
  88991. */
  88992. serialize(): any;
  88993. /**
  88994. * Extracts the vertexData from a mesh
  88995. * @param mesh the mesh from which to extract the VertexData
  88996. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88997. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88998. * @returns the object VertexData associated to the passed mesh
  88999. */
  89000. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89001. /**
  89002. * Extracts the vertexData from the geometry
  89003. * @param geometry the geometry from which to extract the VertexData
  89004. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89005. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89006. * @returns the object VertexData associated to the passed mesh
  89007. */
  89008. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89009. private static _ExtractFrom;
  89010. /**
  89011. * Creates the VertexData for a Ribbon
  89012. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89013. * * pathArray array of paths, each of which an array of successive Vector3
  89014. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89015. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89016. * * 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
  89017. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89018. * * 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)
  89019. * * 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)
  89020. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89021. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89022. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89023. * @returns the VertexData of the ribbon
  89024. */
  89025. static CreateRibbon(options: {
  89026. pathArray: Vector3[][];
  89027. closeArray?: boolean;
  89028. closePath?: boolean;
  89029. offset?: number;
  89030. sideOrientation?: number;
  89031. frontUVs?: Vector4;
  89032. backUVs?: Vector4;
  89033. invertUV?: boolean;
  89034. uvs?: Vector2[];
  89035. colors?: Color4[];
  89036. }): VertexData;
  89037. /**
  89038. * Creates the VertexData for a box
  89039. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89040. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89041. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89042. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89043. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89044. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89045. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89046. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89047. * * 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)
  89048. * * 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)
  89049. * @returns the VertexData of the box
  89050. */
  89051. static CreateBox(options: {
  89052. size?: number;
  89053. width?: number;
  89054. height?: number;
  89055. depth?: number;
  89056. faceUV?: Vector4[];
  89057. faceColors?: Color4[];
  89058. sideOrientation?: number;
  89059. frontUVs?: Vector4;
  89060. backUVs?: Vector4;
  89061. }): VertexData;
  89062. /**
  89063. * Creates the VertexData for a tiled box
  89064. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89065. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89066. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89067. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89068. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89069. * @returns the VertexData of the box
  89070. */
  89071. static CreateTiledBox(options: {
  89072. pattern?: number;
  89073. width?: number;
  89074. height?: number;
  89075. depth?: number;
  89076. tileSize?: number;
  89077. tileWidth?: number;
  89078. tileHeight?: number;
  89079. alignHorizontal?: number;
  89080. alignVertical?: number;
  89081. faceUV?: Vector4[];
  89082. faceColors?: Color4[];
  89083. sideOrientation?: number;
  89084. }): VertexData;
  89085. /**
  89086. * Creates the VertexData for a tiled plane
  89087. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89088. * * pattern a limited pattern arrangement depending on the number
  89089. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  89090. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  89091. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  89092. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89093. * * 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)
  89094. * * 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)
  89095. * @returns the VertexData of the tiled plane
  89096. */
  89097. static CreateTiledPlane(options: {
  89098. pattern?: number;
  89099. tileSize?: number;
  89100. tileWidth?: number;
  89101. tileHeight?: number;
  89102. size?: number;
  89103. width?: number;
  89104. height?: number;
  89105. alignHorizontal?: number;
  89106. alignVertical?: number;
  89107. sideOrientation?: number;
  89108. frontUVs?: Vector4;
  89109. backUVs?: Vector4;
  89110. }): VertexData;
  89111. /**
  89112. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89113. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89114. * * segments sets the number of horizontal strips optional, default 32
  89115. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89116. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89117. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89118. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89119. * * 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
  89120. * * 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
  89121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89122. * * 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)
  89123. * * 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)
  89124. * @returns the VertexData of the ellipsoid
  89125. */
  89126. static CreateSphere(options: {
  89127. segments?: number;
  89128. diameter?: number;
  89129. diameterX?: number;
  89130. diameterY?: number;
  89131. diameterZ?: number;
  89132. arc?: number;
  89133. slice?: number;
  89134. sideOrientation?: number;
  89135. frontUVs?: Vector4;
  89136. backUVs?: Vector4;
  89137. }): VertexData;
  89138. /**
  89139. * Creates the VertexData for a cylinder, cone or prism
  89140. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89141. * * height sets the height (y direction) of the cylinder, optional, default 2
  89142. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89143. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89144. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89145. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89146. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89147. * * 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
  89148. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89149. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89150. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89151. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89152. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89153. * * 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)
  89154. * * 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)
  89155. * @returns the VertexData of the cylinder, cone or prism
  89156. */
  89157. static CreateCylinder(options: {
  89158. height?: number;
  89159. diameterTop?: number;
  89160. diameterBottom?: number;
  89161. diameter?: number;
  89162. tessellation?: number;
  89163. subdivisions?: number;
  89164. arc?: number;
  89165. faceColors?: Color4[];
  89166. faceUV?: Vector4[];
  89167. hasRings?: boolean;
  89168. enclose?: boolean;
  89169. sideOrientation?: number;
  89170. frontUVs?: Vector4;
  89171. backUVs?: Vector4;
  89172. }): VertexData;
  89173. /**
  89174. * Creates the VertexData for a torus
  89175. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89176. * * diameter the diameter of the torus, optional default 1
  89177. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89178. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89179. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89180. * * 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)
  89181. * * 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)
  89182. * @returns the VertexData of the torus
  89183. */
  89184. static CreateTorus(options: {
  89185. diameter?: number;
  89186. thickness?: number;
  89187. tessellation?: number;
  89188. sideOrientation?: number;
  89189. frontUVs?: Vector4;
  89190. backUVs?: Vector4;
  89191. }): VertexData;
  89192. /**
  89193. * Creates the VertexData of the LineSystem
  89194. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89195. * - lines an array of lines, each line being an array of successive Vector3
  89196. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89197. * @returns the VertexData of the LineSystem
  89198. */
  89199. static CreateLineSystem(options: {
  89200. lines: Vector3[][];
  89201. colors?: Nullable<Color4[][]>;
  89202. }): VertexData;
  89203. /**
  89204. * Create the VertexData for a DashedLines
  89205. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89206. * - points an array successive Vector3
  89207. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89208. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89209. * - dashNb the intended total number of dashes, optional, default 200
  89210. * @returns the VertexData for the DashedLines
  89211. */
  89212. static CreateDashedLines(options: {
  89213. points: Vector3[];
  89214. dashSize?: number;
  89215. gapSize?: number;
  89216. dashNb?: number;
  89217. }): VertexData;
  89218. /**
  89219. * Creates the VertexData for a Ground
  89220. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89221. * - width the width (x direction) of the ground, optional, default 1
  89222. * - height the height (z direction) of the ground, optional, default 1
  89223. * - subdivisions the number of subdivisions per side, optional, default 1
  89224. * @returns the VertexData of the Ground
  89225. */
  89226. static CreateGround(options: {
  89227. width?: number;
  89228. height?: number;
  89229. subdivisions?: number;
  89230. subdivisionsX?: number;
  89231. subdivisionsY?: number;
  89232. }): VertexData;
  89233. /**
  89234. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89235. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89236. * * xmin the ground minimum X coordinate, optional, default -1
  89237. * * zmin the ground minimum Z coordinate, optional, default -1
  89238. * * xmax the ground maximum X coordinate, optional, default 1
  89239. * * zmax the ground maximum Z coordinate, optional, default 1
  89240. * * 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}
  89241. * * 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}
  89242. * @returns the VertexData of the TiledGround
  89243. */
  89244. static CreateTiledGround(options: {
  89245. xmin: number;
  89246. zmin: number;
  89247. xmax: number;
  89248. zmax: number;
  89249. subdivisions?: {
  89250. w: number;
  89251. h: number;
  89252. };
  89253. precision?: {
  89254. w: number;
  89255. h: number;
  89256. };
  89257. }): VertexData;
  89258. /**
  89259. * Creates the VertexData of the Ground designed from a heightmap
  89260. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89261. * * width the width (x direction) of the ground
  89262. * * height the height (z direction) of the ground
  89263. * * subdivisions the number of subdivisions per side
  89264. * * minHeight the minimum altitude on the ground, optional, default 0
  89265. * * maxHeight the maximum altitude on the ground, optional default 1
  89266. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89267. * * buffer the array holding the image color data
  89268. * * bufferWidth the width of image
  89269. * * bufferHeight the height of image
  89270. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89271. * @returns the VertexData of the Ground designed from a heightmap
  89272. */
  89273. static CreateGroundFromHeightMap(options: {
  89274. width: number;
  89275. height: number;
  89276. subdivisions: number;
  89277. minHeight: number;
  89278. maxHeight: number;
  89279. colorFilter: Color3;
  89280. buffer: Uint8Array;
  89281. bufferWidth: number;
  89282. bufferHeight: number;
  89283. alphaFilter: number;
  89284. }): VertexData;
  89285. /**
  89286. * Creates the VertexData for a Plane
  89287. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89288. * * size sets the width and height of the plane to the value of size, optional default 1
  89289. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89290. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89291. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89292. * * 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)
  89293. * * 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)
  89294. * @returns the VertexData of the box
  89295. */
  89296. static CreatePlane(options: {
  89297. size?: number;
  89298. width?: number;
  89299. height?: number;
  89300. sideOrientation?: number;
  89301. frontUVs?: Vector4;
  89302. backUVs?: Vector4;
  89303. }): VertexData;
  89304. /**
  89305. * Creates the VertexData of the Disc or regular Polygon
  89306. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89307. * * radius the radius of the disc, optional default 0.5
  89308. * * tessellation the number of polygon sides, optional, default 64
  89309. * * 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
  89310. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89311. * * 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)
  89312. * * 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)
  89313. * @returns the VertexData of the box
  89314. */
  89315. static CreateDisc(options: {
  89316. radius?: number;
  89317. tessellation?: number;
  89318. arc?: number;
  89319. sideOrientation?: number;
  89320. frontUVs?: Vector4;
  89321. backUVs?: Vector4;
  89322. }): VertexData;
  89323. /**
  89324. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  89325. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  89326. * @param polygon a mesh built from polygonTriangulation.build()
  89327. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89328. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89329. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89330. * @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)
  89331. * @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)
  89332. * @returns the VertexData of the Polygon
  89333. */
  89334. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  89335. /**
  89336. * Creates the VertexData of the IcoSphere
  89337. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  89338. * * radius the radius of the IcoSphere, optional default 1
  89339. * * radiusX allows stretching in the x direction, optional, default radius
  89340. * * radiusY allows stretching in the y direction, optional, default radius
  89341. * * radiusZ allows stretching in the z direction, optional, default radius
  89342. * * flat when true creates a flat shaded mesh, optional, default true
  89343. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89344. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89345. * * 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)
  89346. * * 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)
  89347. * @returns the VertexData of the IcoSphere
  89348. */
  89349. static CreateIcoSphere(options: {
  89350. radius?: number;
  89351. radiusX?: number;
  89352. radiusY?: number;
  89353. radiusZ?: number;
  89354. flat?: boolean;
  89355. subdivisions?: number;
  89356. sideOrientation?: number;
  89357. frontUVs?: Vector4;
  89358. backUVs?: Vector4;
  89359. }): VertexData;
  89360. /**
  89361. * Creates the VertexData for a Polyhedron
  89362. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  89363. * * type provided types are:
  89364. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  89365. * * 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)
  89366. * * size the size of the IcoSphere, optional default 1
  89367. * * sizeX allows stretching in the x direction, optional, default size
  89368. * * sizeY allows stretching in the y direction, optional, default size
  89369. * * sizeZ allows stretching in the z direction, optional, default size
  89370. * * 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
  89371. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89372. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89373. * * flat when true creates a flat shaded mesh, optional, default true
  89374. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89375. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89376. * * 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)
  89377. * * 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)
  89378. * @returns the VertexData of the Polyhedron
  89379. */
  89380. static CreatePolyhedron(options: {
  89381. type?: number;
  89382. size?: number;
  89383. sizeX?: number;
  89384. sizeY?: number;
  89385. sizeZ?: number;
  89386. custom?: any;
  89387. faceUV?: Vector4[];
  89388. faceColors?: Color4[];
  89389. flat?: boolean;
  89390. sideOrientation?: number;
  89391. frontUVs?: Vector4;
  89392. backUVs?: Vector4;
  89393. }): VertexData;
  89394. /**
  89395. * Creates the VertexData for a TorusKnot
  89396. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  89397. * * radius the radius of the torus knot, optional, default 2
  89398. * * tube the thickness of the tube, optional, default 0.5
  89399. * * radialSegments the number of sides on each tube segments, optional, default 32
  89400. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  89401. * * p the number of windings around the z axis, optional, default 2
  89402. * * q the number of windings around the x axis, optional, default 3
  89403. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89404. * * 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)
  89405. * * 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)
  89406. * @returns the VertexData of the Torus Knot
  89407. */
  89408. static CreateTorusKnot(options: {
  89409. radius?: number;
  89410. tube?: number;
  89411. radialSegments?: number;
  89412. tubularSegments?: number;
  89413. p?: number;
  89414. q?: number;
  89415. sideOrientation?: number;
  89416. frontUVs?: Vector4;
  89417. backUVs?: Vector4;
  89418. }): VertexData;
  89419. /**
  89420. * Compute normals for given positions and indices
  89421. * @param positions an array of vertex positions, [...., x, y, z, ......]
  89422. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  89423. * @param normals an array of vertex normals, [...., x, y, z, ......]
  89424. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  89425. * * facetNormals : optional array of facet normals (vector3)
  89426. * * facetPositions : optional array of facet positions (vector3)
  89427. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  89428. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  89429. * * bInfo : optional bounding info, required for facetPartitioning computation
  89430. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  89431. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  89432. * * useRightHandedSystem: optional boolean to for right handed system computation
  89433. * * depthSort : optional boolean to enable the facet depth sort computation
  89434. * * distanceTo : optional Vector3 to compute the facet depth from this location
  89435. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  89436. */
  89437. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  89438. facetNormals?: any;
  89439. facetPositions?: any;
  89440. facetPartitioning?: any;
  89441. ratio?: number;
  89442. bInfo?: any;
  89443. bbSize?: Vector3;
  89444. subDiv?: any;
  89445. useRightHandedSystem?: boolean;
  89446. depthSort?: boolean;
  89447. distanceTo?: Vector3;
  89448. depthSortedFacets?: any;
  89449. }): void;
  89450. /** @hidden */
  89451. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  89452. /**
  89453. * Applies VertexData created from the imported parameters to the geometry
  89454. * @param parsedVertexData the parsed data from an imported file
  89455. * @param geometry the geometry to apply the VertexData to
  89456. */
  89457. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  89458. }
  89459. }
  89460. declare module BABYLON {
  89461. /**
  89462. * Defines a target to use with MorphTargetManager
  89463. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89464. */
  89465. export class MorphTarget implements IAnimatable {
  89466. /** defines the name of the target */
  89467. name: string;
  89468. /**
  89469. * Gets or sets the list of animations
  89470. */
  89471. animations: Animation[];
  89472. private _scene;
  89473. private _positions;
  89474. private _normals;
  89475. private _tangents;
  89476. private _uvs;
  89477. private _influence;
  89478. /**
  89479. * Observable raised when the influence changes
  89480. */
  89481. onInfluenceChanged: Observable<boolean>;
  89482. /** @hidden */
  89483. _onDataLayoutChanged: Observable<void>;
  89484. /**
  89485. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  89486. */
  89487. influence: number;
  89488. /**
  89489. * Gets or sets the id of the morph Target
  89490. */
  89491. id: string;
  89492. private _animationPropertiesOverride;
  89493. /**
  89494. * Gets or sets the animation properties override
  89495. */
  89496. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89497. /**
  89498. * Creates a new MorphTarget
  89499. * @param name defines the name of the target
  89500. * @param influence defines the influence to use
  89501. * @param scene defines the scene the morphtarget belongs to
  89502. */
  89503. constructor(
  89504. /** defines the name of the target */
  89505. name: string, influence?: number, scene?: Nullable<Scene>);
  89506. /**
  89507. * Gets a boolean defining if the target contains position data
  89508. */
  89509. readonly hasPositions: boolean;
  89510. /**
  89511. * Gets a boolean defining if the target contains normal data
  89512. */
  89513. readonly hasNormals: boolean;
  89514. /**
  89515. * Gets a boolean defining if the target contains tangent data
  89516. */
  89517. readonly hasTangents: boolean;
  89518. /**
  89519. * Gets a boolean defining if the target contains texture coordinates data
  89520. */
  89521. readonly hasUVs: boolean;
  89522. /**
  89523. * Affects position data to this target
  89524. * @param data defines the position data to use
  89525. */
  89526. setPositions(data: Nullable<FloatArray>): void;
  89527. /**
  89528. * Gets the position data stored in this target
  89529. * @returns a FloatArray containing the position data (or null if not present)
  89530. */
  89531. getPositions(): Nullable<FloatArray>;
  89532. /**
  89533. * Affects normal data to this target
  89534. * @param data defines the normal data to use
  89535. */
  89536. setNormals(data: Nullable<FloatArray>): void;
  89537. /**
  89538. * Gets the normal data stored in this target
  89539. * @returns a FloatArray containing the normal data (or null if not present)
  89540. */
  89541. getNormals(): Nullable<FloatArray>;
  89542. /**
  89543. * Affects tangent data to this target
  89544. * @param data defines the tangent data to use
  89545. */
  89546. setTangents(data: Nullable<FloatArray>): void;
  89547. /**
  89548. * Gets the tangent data stored in this target
  89549. * @returns a FloatArray containing the tangent data (or null if not present)
  89550. */
  89551. getTangents(): Nullable<FloatArray>;
  89552. /**
  89553. * Affects texture coordinates data to this target
  89554. * @param data defines the texture coordinates data to use
  89555. */
  89556. setUVs(data: Nullable<FloatArray>): void;
  89557. /**
  89558. * Gets the texture coordinates data stored in this target
  89559. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  89560. */
  89561. getUVs(): Nullable<FloatArray>;
  89562. /**
  89563. * Serializes the current target into a Serialization object
  89564. * @returns the serialized object
  89565. */
  89566. serialize(): any;
  89567. /**
  89568. * Returns the string "MorphTarget"
  89569. * @returns "MorphTarget"
  89570. */
  89571. getClassName(): string;
  89572. /**
  89573. * Creates a new target from serialized data
  89574. * @param serializationObject defines the serialized data to use
  89575. * @returns a new MorphTarget
  89576. */
  89577. static Parse(serializationObject: any): MorphTarget;
  89578. /**
  89579. * Creates a MorphTarget from mesh data
  89580. * @param mesh defines the source mesh
  89581. * @param name defines the name to use for the new target
  89582. * @param influence defines the influence to attach to the target
  89583. * @returns a new MorphTarget
  89584. */
  89585. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  89586. }
  89587. }
  89588. declare module BABYLON {
  89589. /**
  89590. * This class is used to deform meshes using morphing between different targets
  89591. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89592. */
  89593. export class MorphTargetManager {
  89594. private _targets;
  89595. private _targetInfluenceChangedObservers;
  89596. private _targetDataLayoutChangedObservers;
  89597. private _activeTargets;
  89598. private _scene;
  89599. private _influences;
  89600. private _supportsNormals;
  89601. private _supportsTangents;
  89602. private _supportsUVs;
  89603. private _vertexCount;
  89604. private _uniqueId;
  89605. private _tempInfluences;
  89606. /**
  89607. * Gets or sets a boolean indicating if normals must be morphed
  89608. */
  89609. enableNormalMorphing: boolean;
  89610. /**
  89611. * Gets or sets a boolean indicating if tangents must be morphed
  89612. */
  89613. enableTangentMorphing: boolean;
  89614. /**
  89615. * Gets or sets a boolean indicating if UV must be morphed
  89616. */
  89617. enableUVMorphing: boolean;
  89618. /**
  89619. * Creates a new MorphTargetManager
  89620. * @param scene defines the current scene
  89621. */
  89622. constructor(scene?: Nullable<Scene>);
  89623. /**
  89624. * Gets the unique ID of this manager
  89625. */
  89626. readonly uniqueId: number;
  89627. /**
  89628. * Gets the number of vertices handled by this manager
  89629. */
  89630. readonly vertexCount: number;
  89631. /**
  89632. * Gets a boolean indicating if this manager supports morphing of normals
  89633. */
  89634. readonly supportsNormals: boolean;
  89635. /**
  89636. * Gets a boolean indicating if this manager supports morphing of tangents
  89637. */
  89638. readonly supportsTangents: boolean;
  89639. /**
  89640. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  89641. */
  89642. readonly supportsUVs: boolean;
  89643. /**
  89644. * Gets the number of targets stored in this manager
  89645. */
  89646. readonly numTargets: number;
  89647. /**
  89648. * Gets the number of influencers (ie. the number of targets with influences > 0)
  89649. */
  89650. readonly numInfluencers: number;
  89651. /**
  89652. * Gets the list of influences (one per target)
  89653. */
  89654. readonly influences: Float32Array;
  89655. /**
  89656. * Gets the active target at specified index. An active target is a target with an influence > 0
  89657. * @param index defines the index to check
  89658. * @returns the requested target
  89659. */
  89660. getActiveTarget(index: number): MorphTarget;
  89661. /**
  89662. * Gets the target at specified index
  89663. * @param index defines the index to check
  89664. * @returns the requested target
  89665. */
  89666. getTarget(index: number): MorphTarget;
  89667. /**
  89668. * Add a new target to this manager
  89669. * @param target defines the target to add
  89670. */
  89671. addTarget(target: MorphTarget): void;
  89672. /**
  89673. * Removes a target from the manager
  89674. * @param target defines the target to remove
  89675. */
  89676. removeTarget(target: MorphTarget): void;
  89677. /**
  89678. * Serializes the current manager into a Serialization object
  89679. * @returns the serialized object
  89680. */
  89681. serialize(): any;
  89682. private _syncActiveTargets;
  89683. /**
  89684. * Syncrhonize the targets with all the meshes using this morph target manager
  89685. */
  89686. synchronize(): void;
  89687. /**
  89688. * Creates a new MorphTargetManager from serialized data
  89689. * @param serializationObject defines the serialized data
  89690. * @param scene defines the hosting scene
  89691. * @returns the new MorphTargetManager
  89692. */
  89693. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  89694. }
  89695. }
  89696. declare module BABYLON {
  89697. /**
  89698. * Class used to represent a specific level of detail of a mesh
  89699. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89700. */
  89701. export class MeshLODLevel {
  89702. /** Defines the distance where this level should start being displayed */
  89703. distance: number;
  89704. /** Defines the mesh to use to render this level */
  89705. mesh: Nullable<Mesh>;
  89706. /**
  89707. * Creates a new LOD level
  89708. * @param distance defines the distance where this level should star being displayed
  89709. * @param mesh defines the mesh to use to render this level
  89710. */
  89711. constructor(
  89712. /** Defines the distance where this level should start being displayed */
  89713. distance: number,
  89714. /** Defines the mesh to use to render this level */
  89715. mesh: Nullable<Mesh>);
  89716. }
  89717. }
  89718. declare module BABYLON {
  89719. /**
  89720. * Mesh representing the gorund
  89721. */
  89722. export class GroundMesh extends Mesh {
  89723. /** If octree should be generated */
  89724. generateOctree: boolean;
  89725. private _heightQuads;
  89726. /** @hidden */
  89727. _subdivisionsX: number;
  89728. /** @hidden */
  89729. _subdivisionsY: number;
  89730. /** @hidden */
  89731. _width: number;
  89732. /** @hidden */
  89733. _height: number;
  89734. /** @hidden */
  89735. _minX: number;
  89736. /** @hidden */
  89737. _maxX: number;
  89738. /** @hidden */
  89739. _minZ: number;
  89740. /** @hidden */
  89741. _maxZ: number;
  89742. constructor(name: string, scene: Scene);
  89743. /**
  89744. * "GroundMesh"
  89745. * @returns "GroundMesh"
  89746. */
  89747. getClassName(): string;
  89748. /**
  89749. * The minimum of x and y subdivisions
  89750. */
  89751. readonly subdivisions: number;
  89752. /**
  89753. * X subdivisions
  89754. */
  89755. readonly subdivisionsX: number;
  89756. /**
  89757. * Y subdivisions
  89758. */
  89759. readonly subdivisionsY: number;
  89760. /**
  89761. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89762. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89763. * @param chunksCount the number of subdivisions for x and y
  89764. * @param octreeBlocksSize (Default: 32)
  89765. */
  89766. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89767. /**
  89768. * Returns a height (y) value in the Worl system :
  89769. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89770. * @param x x coordinate
  89771. * @param z z coordinate
  89772. * @returns the ground y position if (x, z) are outside the ground surface.
  89773. */
  89774. getHeightAtCoordinates(x: number, z: number): number;
  89775. /**
  89776. * Returns a normalized vector (Vector3) orthogonal to the ground
  89777. * at the ground coordinates (x, z) expressed in the World system.
  89778. * @param x x coordinate
  89779. * @param z z coordinate
  89780. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89781. */
  89782. getNormalAtCoordinates(x: number, z: number): Vector3;
  89783. /**
  89784. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89785. * at the ground coordinates (x, z) expressed in the World system.
  89786. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89787. * @param x x coordinate
  89788. * @param z z coordinate
  89789. * @param ref vector to store the result
  89790. * @returns the GroundMesh.
  89791. */
  89792. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89793. /**
  89794. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89795. * if the ground has been updated.
  89796. * This can be used in the render loop.
  89797. * @returns the GroundMesh.
  89798. */
  89799. updateCoordinateHeights(): GroundMesh;
  89800. private _getFacetAt;
  89801. private _initHeightQuads;
  89802. private _computeHeightQuads;
  89803. /**
  89804. * Serializes this ground mesh
  89805. * @param serializationObject object to write serialization to
  89806. */
  89807. serialize(serializationObject: any): void;
  89808. /**
  89809. * Parses a serialized ground mesh
  89810. * @param parsedMesh the serialized mesh
  89811. * @param scene the scene to create the ground mesh in
  89812. * @returns the created ground mesh
  89813. */
  89814. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89815. }
  89816. }
  89817. declare module BABYLON {
  89818. /**
  89819. * Interface for Physics-Joint data
  89820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89821. */
  89822. export interface PhysicsJointData {
  89823. /**
  89824. * The main pivot of the joint
  89825. */
  89826. mainPivot?: Vector3;
  89827. /**
  89828. * The connected pivot of the joint
  89829. */
  89830. connectedPivot?: Vector3;
  89831. /**
  89832. * The main axis of the joint
  89833. */
  89834. mainAxis?: Vector3;
  89835. /**
  89836. * The connected axis of the joint
  89837. */
  89838. connectedAxis?: Vector3;
  89839. /**
  89840. * The collision of the joint
  89841. */
  89842. collision?: boolean;
  89843. /**
  89844. * Native Oimo/Cannon/Energy data
  89845. */
  89846. nativeParams?: any;
  89847. }
  89848. /**
  89849. * This is a holder class for the physics joint created by the physics plugin
  89850. * It holds a set of functions to control the underlying joint
  89851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89852. */
  89853. export class PhysicsJoint {
  89854. /**
  89855. * The type of the physics joint
  89856. */
  89857. type: number;
  89858. /**
  89859. * The data for the physics joint
  89860. */
  89861. jointData: PhysicsJointData;
  89862. private _physicsJoint;
  89863. protected _physicsPlugin: IPhysicsEnginePlugin;
  89864. /**
  89865. * Initializes the physics joint
  89866. * @param type The type of the physics joint
  89867. * @param jointData The data for the physics joint
  89868. */
  89869. constructor(
  89870. /**
  89871. * The type of the physics joint
  89872. */
  89873. type: number,
  89874. /**
  89875. * The data for the physics joint
  89876. */
  89877. jointData: PhysicsJointData);
  89878. /**
  89879. * Gets the physics joint
  89880. */
  89881. /**
  89882. * Sets the physics joint
  89883. */
  89884. physicsJoint: any;
  89885. /**
  89886. * Sets the physics plugin
  89887. */
  89888. physicsPlugin: IPhysicsEnginePlugin;
  89889. /**
  89890. * Execute a function that is physics-plugin specific.
  89891. * @param {Function} func the function that will be executed.
  89892. * It accepts two parameters: the physics world and the physics joint
  89893. */
  89894. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89895. /**
  89896. * Distance-Joint type
  89897. */
  89898. static DistanceJoint: number;
  89899. /**
  89900. * Hinge-Joint type
  89901. */
  89902. static HingeJoint: number;
  89903. /**
  89904. * Ball-and-Socket joint type
  89905. */
  89906. static BallAndSocketJoint: number;
  89907. /**
  89908. * Wheel-Joint type
  89909. */
  89910. static WheelJoint: number;
  89911. /**
  89912. * Slider-Joint type
  89913. */
  89914. static SliderJoint: number;
  89915. /**
  89916. * Prismatic-Joint type
  89917. */
  89918. static PrismaticJoint: number;
  89919. /**
  89920. * Universal-Joint type
  89921. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89922. */
  89923. static UniversalJoint: number;
  89924. /**
  89925. * Hinge-Joint 2 type
  89926. */
  89927. static Hinge2Joint: number;
  89928. /**
  89929. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89930. */
  89931. static PointToPointJoint: number;
  89932. /**
  89933. * Spring-Joint type
  89934. */
  89935. static SpringJoint: number;
  89936. /**
  89937. * Lock-Joint type
  89938. */
  89939. static LockJoint: number;
  89940. }
  89941. /**
  89942. * A class representing a physics distance joint
  89943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89944. */
  89945. export class DistanceJoint extends PhysicsJoint {
  89946. /**
  89947. *
  89948. * @param jointData The data for the Distance-Joint
  89949. */
  89950. constructor(jointData: DistanceJointData);
  89951. /**
  89952. * Update the predefined distance.
  89953. * @param maxDistance The maximum preferred distance
  89954. * @param minDistance The minimum preferred distance
  89955. */
  89956. updateDistance(maxDistance: number, minDistance?: number): void;
  89957. }
  89958. /**
  89959. * Represents a Motor-Enabled Joint
  89960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89961. */
  89962. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89963. /**
  89964. * Initializes the Motor-Enabled Joint
  89965. * @param type The type of the joint
  89966. * @param jointData The physica joint data for the joint
  89967. */
  89968. constructor(type: number, jointData: PhysicsJointData);
  89969. /**
  89970. * Set the motor values.
  89971. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89972. * @param force the force to apply
  89973. * @param maxForce max force for this motor.
  89974. */
  89975. setMotor(force?: number, maxForce?: number): void;
  89976. /**
  89977. * Set the motor's limits.
  89978. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89979. * @param upperLimit The upper limit of the motor
  89980. * @param lowerLimit The lower limit of the motor
  89981. */
  89982. setLimit(upperLimit: number, lowerLimit?: number): void;
  89983. }
  89984. /**
  89985. * This class represents a single physics Hinge-Joint
  89986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89987. */
  89988. export class HingeJoint extends MotorEnabledJoint {
  89989. /**
  89990. * Initializes the Hinge-Joint
  89991. * @param jointData The joint data for the Hinge-Joint
  89992. */
  89993. constructor(jointData: PhysicsJointData);
  89994. /**
  89995. * Set the motor values.
  89996. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89997. * @param {number} force the force to apply
  89998. * @param {number} maxForce max force for this motor.
  89999. */
  90000. setMotor(force?: number, maxForce?: number): void;
  90001. /**
  90002. * Set the motor's limits.
  90003. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90004. * @param upperLimit The upper limit of the motor
  90005. * @param lowerLimit The lower limit of the motor
  90006. */
  90007. setLimit(upperLimit: number, lowerLimit?: number): void;
  90008. }
  90009. /**
  90010. * This class represents a dual hinge physics joint (same as wheel joint)
  90011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90012. */
  90013. export class Hinge2Joint extends MotorEnabledJoint {
  90014. /**
  90015. * Initializes the Hinge2-Joint
  90016. * @param jointData The joint data for the Hinge2-Joint
  90017. */
  90018. constructor(jointData: PhysicsJointData);
  90019. /**
  90020. * Set the motor values.
  90021. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90022. * @param {number} targetSpeed the speed the motor is to reach
  90023. * @param {number} maxForce max force for this motor.
  90024. * @param {motorIndex} the motor's index, 0 or 1.
  90025. */
  90026. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90027. /**
  90028. * Set the motor limits.
  90029. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90030. * @param {number} upperLimit the upper limit
  90031. * @param {number} lowerLimit lower limit
  90032. * @param {motorIndex} the motor's index, 0 or 1.
  90033. */
  90034. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90035. }
  90036. /**
  90037. * Interface for a motor enabled joint
  90038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90039. */
  90040. export interface IMotorEnabledJoint {
  90041. /**
  90042. * Physics joint
  90043. */
  90044. physicsJoint: any;
  90045. /**
  90046. * Sets the motor of the motor-enabled joint
  90047. * @param force The force of the motor
  90048. * @param maxForce The maximum force of the motor
  90049. * @param motorIndex The index of the motor
  90050. */
  90051. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90052. /**
  90053. * Sets the limit of the motor
  90054. * @param upperLimit The upper limit of the motor
  90055. * @param lowerLimit The lower limit of the motor
  90056. * @param motorIndex The index of the motor
  90057. */
  90058. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90059. }
  90060. /**
  90061. * Joint data for a Distance-Joint
  90062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90063. */
  90064. export interface DistanceJointData extends PhysicsJointData {
  90065. /**
  90066. * Max distance the 2 joint objects can be apart
  90067. */
  90068. maxDistance: number;
  90069. }
  90070. /**
  90071. * Joint data from a spring joint
  90072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90073. */
  90074. export interface SpringJointData extends PhysicsJointData {
  90075. /**
  90076. * Length of the spring
  90077. */
  90078. length: number;
  90079. /**
  90080. * Stiffness of the spring
  90081. */
  90082. stiffness: number;
  90083. /**
  90084. * Damping of the spring
  90085. */
  90086. damping: number;
  90087. /** this callback will be called when applying the force to the impostors. */
  90088. forceApplicationCallback: () => void;
  90089. }
  90090. }
  90091. declare module BABYLON {
  90092. /**
  90093. * Holds the data for the raycast result
  90094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90095. */
  90096. export class PhysicsRaycastResult {
  90097. private _hasHit;
  90098. private _hitDistance;
  90099. private _hitNormalWorld;
  90100. private _hitPointWorld;
  90101. private _rayFromWorld;
  90102. private _rayToWorld;
  90103. /**
  90104. * Gets if there was a hit
  90105. */
  90106. readonly hasHit: boolean;
  90107. /**
  90108. * Gets the distance from the hit
  90109. */
  90110. readonly hitDistance: number;
  90111. /**
  90112. * Gets the hit normal/direction in the world
  90113. */
  90114. readonly hitNormalWorld: Vector3;
  90115. /**
  90116. * Gets the hit point in the world
  90117. */
  90118. readonly hitPointWorld: Vector3;
  90119. /**
  90120. * Gets the ray "start point" of the ray in the world
  90121. */
  90122. readonly rayFromWorld: Vector3;
  90123. /**
  90124. * Gets the ray "end point" of the ray in the world
  90125. */
  90126. readonly rayToWorld: Vector3;
  90127. /**
  90128. * Sets the hit data (normal & point in world space)
  90129. * @param hitNormalWorld defines the normal in world space
  90130. * @param hitPointWorld defines the point in world space
  90131. */
  90132. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  90133. /**
  90134. * Sets the distance from the start point to the hit point
  90135. * @param distance
  90136. */
  90137. setHitDistance(distance: number): void;
  90138. /**
  90139. * Calculates the distance manually
  90140. */
  90141. calculateHitDistance(): void;
  90142. /**
  90143. * Resets all the values to default
  90144. * @param from The from point on world space
  90145. * @param to The to point on world space
  90146. */
  90147. reset(from?: Vector3, to?: Vector3): void;
  90148. }
  90149. /**
  90150. * Interface for the size containing width and height
  90151. */
  90152. interface IXYZ {
  90153. /**
  90154. * X
  90155. */
  90156. x: number;
  90157. /**
  90158. * Y
  90159. */
  90160. y: number;
  90161. /**
  90162. * Z
  90163. */
  90164. z: number;
  90165. }
  90166. }
  90167. declare module BABYLON {
  90168. /**
  90169. * Interface used to describe a physics joint
  90170. */
  90171. export interface PhysicsImpostorJoint {
  90172. /** Defines the main impostor to which the joint is linked */
  90173. mainImpostor: PhysicsImpostor;
  90174. /** Defines the impostor that is connected to the main impostor using this joint */
  90175. connectedImpostor: PhysicsImpostor;
  90176. /** Defines the joint itself */
  90177. joint: PhysicsJoint;
  90178. }
  90179. /** @hidden */
  90180. export interface IPhysicsEnginePlugin {
  90181. world: any;
  90182. name: string;
  90183. setGravity(gravity: Vector3): void;
  90184. setTimeStep(timeStep: number): void;
  90185. getTimeStep(): number;
  90186. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  90187. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90188. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90189. generatePhysicsBody(impostor: PhysicsImpostor): void;
  90190. removePhysicsBody(impostor: PhysicsImpostor): void;
  90191. generateJoint(joint: PhysicsImpostorJoint): void;
  90192. removeJoint(joint: PhysicsImpostorJoint): void;
  90193. isSupported(): boolean;
  90194. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  90195. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  90196. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90197. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90198. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90199. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90200. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  90201. getBodyMass(impostor: PhysicsImpostor): number;
  90202. getBodyFriction(impostor: PhysicsImpostor): number;
  90203. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  90204. getBodyRestitution(impostor: PhysicsImpostor): number;
  90205. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  90206. getBodyPressure?(impostor: PhysicsImpostor): number;
  90207. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  90208. getBodyStiffness?(impostor: PhysicsImpostor): number;
  90209. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  90210. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  90211. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  90212. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  90213. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  90214. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90215. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90216. sleepBody(impostor: PhysicsImpostor): void;
  90217. wakeUpBody(impostor: PhysicsImpostor): void;
  90218. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90219. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  90220. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  90221. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90222. getRadius(impostor: PhysicsImpostor): number;
  90223. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  90224. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  90225. dispose(): void;
  90226. }
  90227. /**
  90228. * Interface used to define a physics engine
  90229. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  90230. */
  90231. export interface IPhysicsEngine {
  90232. /**
  90233. * Gets the gravity vector used by the simulation
  90234. */
  90235. gravity: Vector3;
  90236. /**
  90237. * Sets the gravity vector used by the simulation
  90238. * @param gravity defines the gravity vector to use
  90239. */
  90240. setGravity(gravity: Vector3): void;
  90241. /**
  90242. * Set the time step of the physics engine.
  90243. * Default is 1/60.
  90244. * To slow it down, enter 1/600 for example.
  90245. * To speed it up, 1/30
  90246. * @param newTimeStep the new timestep to apply to this world.
  90247. */
  90248. setTimeStep(newTimeStep: number): void;
  90249. /**
  90250. * Get the time step of the physics engine.
  90251. * @returns the current time step
  90252. */
  90253. getTimeStep(): number;
  90254. /**
  90255. * Release all resources
  90256. */
  90257. dispose(): void;
  90258. /**
  90259. * Gets the name of the current physics plugin
  90260. * @returns the name of the plugin
  90261. */
  90262. getPhysicsPluginName(): string;
  90263. /**
  90264. * Adding a new impostor for the impostor tracking.
  90265. * This will be done by the impostor itself.
  90266. * @param impostor the impostor to add
  90267. */
  90268. addImpostor(impostor: PhysicsImpostor): void;
  90269. /**
  90270. * Remove an impostor from the engine.
  90271. * This impostor and its mesh will not longer be updated by the physics engine.
  90272. * @param impostor the impostor to remove
  90273. */
  90274. removeImpostor(impostor: PhysicsImpostor): void;
  90275. /**
  90276. * Add a joint to the physics engine
  90277. * @param mainImpostor defines the main impostor to which the joint is added.
  90278. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  90279. * @param joint defines the joint that will connect both impostors.
  90280. */
  90281. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90282. /**
  90283. * Removes a joint from the simulation
  90284. * @param mainImpostor defines the impostor used with the joint
  90285. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  90286. * @param joint defines the joint to remove
  90287. */
  90288. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90289. /**
  90290. * Gets the current plugin used to run the simulation
  90291. * @returns current plugin
  90292. */
  90293. getPhysicsPlugin(): IPhysicsEnginePlugin;
  90294. /**
  90295. * Gets the list of physic impostors
  90296. * @returns an array of PhysicsImpostor
  90297. */
  90298. getImpostors(): Array<PhysicsImpostor>;
  90299. /**
  90300. * Gets the impostor for a physics enabled object
  90301. * @param object defines the object impersonated by the impostor
  90302. * @returns the PhysicsImpostor or null if not found
  90303. */
  90304. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90305. /**
  90306. * Gets the impostor for a physics body object
  90307. * @param body defines physics body used by the impostor
  90308. * @returns the PhysicsImpostor or null if not found
  90309. */
  90310. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  90311. /**
  90312. * Does a raycast in the physics world
  90313. * @param from when should the ray start?
  90314. * @param to when should the ray end?
  90315. * @returns PhysicsRaycastResult
  90316. */
  90317. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90318. /**
  90319. * Called by the scene. No need to call it.
  90320. * @param delta defines the timespam between frames
  90321. */
  90322. _step(delta: number): void;
  90323. }
  90324. }
  90325. declare module BABYLON {
  90326. /**
  90327. * The interface for the physics imposter parameters
  90328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90329. */
  90330. export interface PhysicsImpostorParameters {
  90331. /**
  90332. * The mass of the physics imposter
  90333. */
  90334. mass: number;
  90335. /**
  90336. * The friction of the physics imposter
  90337. */
  90338. friction?: number;
  90339. /**
  90340. * The coefficient of restitution of the physics imposter
  90341. */
  90342. restitution?: number;
  90343. /**
  90344. * The native options of the physics imposter
  90345. */
  90346. nativeOptions?: any;
  90347. /**
  90348. * Specifies if the parent should be ignored
  90349. */
  90350. ignoreParent?: boolean;
  90351. /**
  90352. * Specifies if bi-directional transformations should be disabled
  90353. */
  90354. disableBidirectionalTransformation?: boolean;
  90355. /**
  90356. * The pressure inside the physics imposter, soft object only
  90357. */
  90358. pressure?: number;
  90359. /**
  90360. * The stiffness the physics imposter, soft object only
  90361. */
  90362. stiffness?: number;
  90363. /**
  90364. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  90365. */
  90366. velocityIterations?: number;
  90367. /**
  90368. * The number of iterations used in maintaining consistent vertex positions, soft object only
  90369. */
  90370. positionIterations?: number;
  90371. /**
  90372. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  90373. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  90374. * Add to fix multiple points
  90375. */
  90376. fixedPoints?: number;
  90377. /**
  90378. * The collision margin around a soft object
  90379. */
  90380. margin?: number;
  90381. /**
  90382. * The collision margin around a soft object
  90383. */
  90384. damping?: number;
  90385. /**
  90386. * The path for a rope based on an extrusion
  90387. */
  90388. path?: any;
  90389. /**
  90390. * The shape of an extrusion used for a rope based on an extrusion
  90391. */
  90392. shape?: any;
  90393. }
  90394. /**
  90395. * Interface for a physics-enabled object
  90396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90397. */
  90398. export interface IPhysicsEnabledObject {
  90399. /**
  90400. * The position of the physics-enabled object
  90401. */
  90402. position: Vector3;
  90403. /**
  90404. * The rotation of the physics-enabled object
  90405. */
  90406. rotationQuaternion: Nullable<Quaternion>;
  90407. /**
  90408. * The scale of the physics-enabled object
  90409. */
  90410. scaling: Vector3;
  90411. /**
  90412. * The rotation of the physics-enabled object
  90413. */
  90414. rotation?: Vector3;
  90415. /**
  90416. * The parent of the physics-enabled object
  90417. */
  90418. parent?: any;
  90419. /**
  90420. * The bounding info of the physics-enabled object
  90421. * @returns The bounding info of the physics-enabled object
  90422. */
  90423. getBoundingInfo(): BoundingInfo;
  90424. /**
  90425. * Computes the world matrix
  90426. * @param force Specifies if the world matrix should be computed by force
  90427. * @returns A world matrix
  90428. */
  90429. computeWorldMatrix(force: boolean): Matrix;
  90430. /**
  90431. * Gets the world matrix
  90432. * @returns A world matrix
  90433. */
  90434. getWorldMatrix?(): Matrix;
  90435. /**
  90436. * Gets the child meshes
  90437. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  90438. * @returns An array of abstract meshes
  90439. */
  90440. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  90441. /**
  90442. * Gets the vertex data
  90443. * @param kind The type of vertex data
  90444. * @returns A nullable array of numbers, or a float32 array
  90445. */
  90446. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  90447. /**
  90448. * Gets the indices from the mesh
  90449. * @returns A nullable array of index arrays
  90450. */
  90451. getIndices?(): Nullable<IndicesArray>;
  90452. /**
  90453. * Gets the scene from the mesh
  90454. * @returns the indices array or null
  90455. */
  90456. getScene?(): Scene;
  90457. /**
  90458. * Gets the absolute position from the mesh
  90459. * @returns the absolute position
  90460. */
  90461. getAbsolutePosition(): Vector3;
  90462. /**
  90463. * Gets the absolute pivot point from the mesh
  90464. * @returns the absolute pivot point
  90465. */
  90466. getAbsolutePivotPoint(): Vector3;
  90467. /**
  90468. * Rotates the mesh
  90469. * @param axis The axis of rotation
  90470. * @param amount The amount of rotation
  90471. * @param space The space of the rotation
  90472. * @returns The rotation transform node
  90473. */
  90474. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  90475. /**
  90476. * Translates the mesh
  90477. * @param axis The axis of translation
  90478. * @param distance The distance of translation
  90479. * @param space The space of the translation
  90480. * @returns The transform node
  90481. */
  90482. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90483. /**
  90484. * Sets the absolute position of the mesh
  90485. * @param absolutePosition The absolute position of the mesh
  90486. * @returns The transform node
  90487. */
  90488. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  90489. /**
  90490. * Gets the class name of the mesh
  90491. * @returns The class name
  90492. */
  90493. getClassName(): string;
  90494. }
  90495. /**
  90496. * Represents a physics imposter
  90497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90498. */
  90499. export class PhysicsImpostor {
  90500. /**
  90501. * The physics-enabled object used as the physics imposter
  90502. */
  90503. object: IPhysicsEnabledObject;
  90504. /**
  90505. * The type of the physics imposter
  90506. */
  90507. type: number;
  90508. private _options;
  90509. private _scene?;
  90510. /**
  90511. * The default object size of the imposter
  90512. */
  90513. static DEFAULT_OBJECT_SIZE: Vector3;
  90514. /**
  90515. * The identity quaternion of the imposter
  90516. */
  90517. static IDENTITY_QUATERNION: Quaternion;
  90518. /** @hidden */
  90519. _pluginData: any;
  90520. private _physicsEngine;
  90521. private _physicsBody;
  90522. private _bodyUpdateRequired;
  90523. private _onBeforePhysicsStepCallbacks;
  90524. private _onAfterPhysicsStepCallbacks;
  90525. /** @hidden */
  90526. _onPhysicsCollideCallbacks: Array<{
  90527. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  90528. otherImpostors: Array<PhysicsImpostor>;
  90529. }>;
  90530. private _deltaPosition;
  90531. private _deltaRotation;
  90532. private _deltaRotationConjugated;
  90533. /** @hidden */
  90534. _isFromLine: boolean;
  90535. private _parent;
  90536. private _isDisposed;
  90537. private static _tmpVecs;
  90538. private static _tmpQuat;
  90539. /**
  90540. * Specifies if the physics imposter is disposed
  90541. */
  90542. readonly isDisposed: boolean;
  90543. /**
  90544. * Gets the mass of the physics imposter
  90545. */
  90546. mass: number;
  90547. /**
  90548. * Gets the coefficient of friction
  90549. */
  90550. /**
  90551. * Sets the coefficient of friction
  90552. */
  90553. friction: number;
  90554. /**
  90555. * Gets the coefficient of restitution
  90556. */
  90557. /**
  90558. * Sets the coefficient of restitution
  90559. */
  90560. restitution: number;
  90561. /**
  90562. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  90563. */
  90564. /**
  90565. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  90566. */
  90567. pressure: number;
  90568. /**
  90569. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90570. */
  90571. /**
  90572. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90573. */
  90574. stiffness: number;
  90575. /**
  90576. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90577. */
  90578. /**
  90579. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90580. */
  90581. velocityIterations: number;
  90582. /**
  90583. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90584. */
  90585. /**
  90586. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90587. */
  90588. positionIterations: number;
  90589. /**
  90590. * The unique id of the physics imposter
  90591. * set by the physics engine when adding this impostor to the array
  90592. */
  90593. uniqueId: number;
  90594. /**
  90595. * @hidden
  90596. */
  90597. soft: boolean;
  90598. /**
  90599. * @hidden
  90600. */
  90601. segments: number;
  90602. private _joints;
  90603. /**
  90604. * Initializes the physics imposter
  90605. * @param object The physics-enabled object used as the physics imposter
  90606. * @param type The type of the physics imposter
  90607. * @param _options The options for the physics imposter
  90608. * @param _scene The Babylon scene
  90609. */
  90610. constructor(
  90611. /**
  90612. * The physics-enabled object used as the physics imposter
  90613. */
  90614. object: IPhysicsEnabledObject,
  90615. /**
  90616. * The type of the physics imposter
  90617. */
  90618. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  90619. /**
  90620. * This function will completly initialize this impostor.
  90621. * It will create a new body - but only if this mesh has no parent.
  90622. * If it has, this impostor will not be used other than to define the impostor
  90623. * of the child mesh.
  90624. * @hidden
  90625. */
  90626. _init(): void;
  90627. private _getPhysicsParent;
  90628. /**
  90629. * Should a new body be generated.
  90630. * @returns boolean specifying if body initialization is required
  90631. */
  90632. isBodyInitRequired(): boolean;
  90633. /**
  90634. * Sets the updated scaling
  90635. * @param updated Specifies if the scaling is updated
  90636. */
  90637. setScalingUpdated(): void;
  90638. /**
  90639. * Force a regeneration of this or the parent's impostor's body.
  90640. * Use under cautious - This will remove all joints already implemented.
  90641. */
  90642. forceUpdate(): void;
  90643. /**
  90644. * Gets the body that holds this impostor. Either its own, or its parent.
  90645. */
  90646. /**
  90647. * Set the physics body. Used mainly by the physics engine/plugin
  90648. */
  90649. physicsBody: any;
  90650. /**
  90651. * Get the parent of the physics imposter
  90652. * @returns Physics imposter or null
  90653. */
  90654. /**
  90655. * Sets the parent of the physics imposter
  90656. */
  90657. parent: Nullable<PhysicsImpostor>;
  90658. /**
  90659. * Resets the update flags
  90660. */
  90661. resetUpdateFlags(): void;
  90662. /**
  90663. * Gets the object extend size
  90664. * @returns the object extend size
  90665. */
  90666. getObjectExtendSize(): Vector3;
  90667. /**
  90668. * Gets the object center
  90669. * @returns The object center
  90670. */
  90671. getObjectCenter(): Vector3;
  90672. /**
  90673. * Get a specific parametes from the options parameter
  90674. * @param paramName The object parameter name
  90675. * @returns The object parameter
  90676. */
  90677. getParam(paramName: string): any;
  90678. /**
  90679. * Sets a specific parameter in the options given to the physics plugin
  90680. * @param paramName The parameter name
  90681. * @param value The value of the parameter
  90682. */
  90683. setParam(paramName: string, value: number): void;
  90684. /**
  90685. * Specifically change the body's mass option. Won't recreate the physics body object
  90686. * @param mass The mass of the physics imposter
  90687. */
  90688. setMass(mass: number): void;
  90689. /**
  90690. * Gets the linear velocity
  90691. * @returns linear velocity or null
  90692. */
  90693. getLinearVelocity(): Nullable<Vector3>;
  90694. /**
  90695. * Sets the linear velocity
  90696. * @param velocity linear velocity or null
  90697. */
  90698. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90699. /**
  90700. * Gets the angular velocity
  90701. * @returns angular velocity or null
  90702. */
  90703. getAngularVelocity(): Nullable<Vector3>;
  90704. /**
  90705. * Sets the angular velocity
  90706. * @param velocity The velocity or null
  90707. */
  90708. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90709. /**
  90710. * Execute a function with the physics plugin native code
  90711. * Provide a function the will have two variables - the world object and the physics body object
  90712. * @param func The function to execute with the physics plugin native code
  90713. */
  90714. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90715. /**
  90716. * Register a function that will be executed before the physics world is stepping forward
  90717. * @param func The function to execute before the physics world is stepped forward
  90718. */
  90719. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90720. /**
  90721. * Unregister a function that will be executed before the physics world is stepping forward
  90722. * @param func The function to execute before the physics world is stepped forward
  90723. */
  90724. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90725. /**
  90726. * Register a function that will be executed after the physics step
  90727. * @param func The function to execute after physics step
  90728. */
  90729. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90730. /**
  90731. * Unregisters a function that will be executed after the physics step
  90732. * @param func The function to execute after physics step
  90733. */
  90734. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90735. /**
  90736. * register a function that will be executed when this impostor collides against a different body
  90737. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90738. * @param func Callback that is executed on collision
  90739. */
  90740. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90741. /**
  90742. * Unregisters the physics imposter on contact
  90743. * @param collideAgainst The physics object to collide against
  90744. * @param func Callback to execute on collision
  90745. */
  90746. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90747. private _tmpQuat;
  90748. private _tmpQuat2;
  90749. /**
  90750. * Get the parent rotation
  90751. * @returns The parent rotation
  90752. */
  90753. getParentsRotation(): Quaternion;
  90754. /**
  90755. * this function is executed by the physics engine.
  90756. */
  90757. beforeStep: () => void;
  90758. /**
  90759. * this function is executed by the physics engine
  90760. */
  90761. afterStep: () => void;
  90762. /**
  90763. * Legacy collision detection event support
  90764. */
  90765. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90766. /**
  90767. * event and body object due to cannon's event-based architecture.
  90768. */
  90769. onCollide: (e: {
  90770. body: any;
  90771. }) => void;
  90772. /**
  90773. * Apply a force
  90774. * @param force The force to apply
  90775. * @param contactPoint The contact point for the force
  90776. * @returns The physics imposter
  90777. */
  90778. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90779. /**
  90780. * Apply an impulse
  90781. * @param force The impulse force
  90782. * @param contactPoint The contact point for the impulse force
  90783. * @returns The physics imposter
  90784. */
  90785. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90786. /**
  90787. * A help function to create a joint
  90788. * @param otherImpostor A physics imposter used to create a joint
  90789. * @param jointType The type of joint
  90790. * @param jointData The data for the joint
  90791. * @returns The physics imposter
  90792. */
  90793. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90794. /**
  90795. * Add a joint to this impostor with a different impostor
  90796. * @param otherImpostor A physics imposter used to add a joint
  90797. * @param joint The joint to add
  90798. * @returns The physics imposter
  90799. */
  90800. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90801. /**
  90802. * Add an anchor to a cloth impostor
  90803. * @param otherImpostor rigid impostor to anchor to
  90804. * @param width ratio across width from 0 to 1
  90805. * @param height ratio up height from 0 to 1
  90806. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90807. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90808. * @returns impostor the soft imposter
  90809. */
  90810. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90811. /**
  90812. * Add a hook to a rope impostor
  90813. * @param otherImpostor rigid impostor to anchor to
  90814. * @param length ratio across rope from 0 to 1
  90815. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90816. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90817. * @returns impostor the rope imposter
  90818. */
  90819. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90820. /**
  90821. * Will keep this body still, in a sleep mode.
  90822. * @returns the physics imposter
  90823. */
  90824. sleep(): PhysicsImpostor;
  90825. /**
  90826. * Wake the body up.
  90827. * @returns The physics imposter
  90828. */
  90829. wakeUp(): PhysicsImpostor;
  90830. /**
  90831. * Clones the physics imposter
  90832. * @param newObject The physics imposter clones to this physics-enabled object
  90833. * @returns A nullable physics imposter
  90834. */
  90835. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90836. /**
  90837. * Disposes the physics imposter
  90838. */
  90839. dispose(): void;
  90840. /**
  90841. * Sets the delta position
  90842. * @param position The delta position amount
  90843. */
  90844. setDeltaPosition(position: Vector3): void;
  90845. /**
  90846. * Sets the delta rotation
  90847. * @param rotation The delta rotation amount
  90848. */
  90849. setDeltaRotation(rotation: Quaternion): void;
  90850. /**
  90851. * Gets the box size of the physics imposter and stores the result in the input parameter
  90852. * @param result Stores the box size
  90853. * @returns The physics imposter
  90854. */
  90855. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90856. /**
  90857. * Gets the radius of the physics imposter
  90858. * @returns Radius of the physics imposter
  90859. */
  90860. getRadius(): number;
  90861. /**
  90862. * Sync a bone with this impostor
  90863. * @param bone The bone to sync to the impostor.
  90864. * @param boneMesh The mesh that the bone is influencing.
  90865. * @param jointPivot The pivot of the joint / bone in local space.
  90866. * @param distToJoint Optional distance from the impostor to the joint.
  90867. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90868. */
  90869. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90870. /**
  90871. * Sync impostor to a bone
  90872. * @param bone The bone that the impostor will be synced to.
  90873. * @param boneMesh The mesh that the bone is influencing.
  90874. * @param jointPivot The pivot of the joint / bone in local space.
  90875. * @param distToJoint Optional distance from the impostor to the joint.
  90876. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90877. * @param boneAxis Optional vector3 axis the bone is aligned with
  90878. */
  90879. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90880. /**
  90881. * No-Imposter type
  90882. */
  90883. static NoImpostor: number;
  90884. /**
  90885. * Sphere-Imposter type
  90886. */
  90887. static SphereImpostor: number;
  90888. /**
  90889. * Box-Imposter type
  90890. */
  90891. static BoxImpostor: number;
  90892. /**
  90893. * Plane-Imposter type
  90894. */
  90895. static PlaneImpostor: number;
  90896. /**
  90897. * Mesh-imposter type
  90898. */
  90899. static MeshImpostor: number;
  90900. /**
  90901. * Capsule-Impostor type (Ammo.js plugin only)
  90902. */
  90903. static CapsuleImpostor: number;
  90904. /**
  90905. * Cylinder-Imposter type
  90906. */
  90907. static CylinderImpostor: number;
  90908. /**
  90909. * Particle-Imposter type
  90910. */
  90911. static ParticleImpostor: number;
  90912. /**
  90913. * Heightmap-Imposter type
  90914. */
  90915. static HeightmapImpostor: number;
  90916. /**
  90917. * ConvexHull-Impostor type (Ammo.js plugin only)
  90918. */
  90919. static ConvexHullImpostor: number;
  90920. /**
  90921. * Rope-Imposter type
  90922. */
  90923. static RopeImpostor: number;
  90924. /**
  90925. * Cloth-Imposter type
  90926. */
  90927. static ClothImpostor: number;
  90928. /**
  90929. * Softbody-Imposter type
  90930. */
  90931. static SoftbodyImpostor: number;
  90932. }
  90933. }
  90934. declare module BABYLON {
  90935. /**
  90936. * @hidden
  90937. **/
  90938. export class _CreationDataStorage {
  90939. closePath?: boolean;
  90940. closeArray?: boolean;
  90941. idx: number[];
  90942. dashSize: number;
  90943. gapSize: number;
  90944. path3D: Path3D;
  90945. pathArray: Vector3[][];
  90946. arc: number;
  90947. radius: number;
  90948. cap: number;
  90949. tessellation: number;
  90950. }
  90951. /**
  90952. * @hidden
  90953. **/
  90954. class _InstanceDataStorage {
  90955. visibleInstances: any;
  90956. batchCache: _InstancesBatch;
  90957. instancesBufferSize: number;
  90958. instancesBuffer: Nullable<Buffer>;
  90959. instancesData: Float32Array;
  90960. overridenInstanceCount: number;
  90961. isFrozen: boolean;
  90962. previousBatch: Nullable<_InstancesBatch>;
  90963. hardwareInstancedRendering: boolean;
  90964. sideOrientation: number;
  90965. }
  90966. /**
  90967. * @hidden
  90968. **/
  90969. export class _InstancesBatch {
  90970. mustReturn: boolean;
  90971. visibleInstances: Nullable<InstancedMesh[]>[];
  90972. renderSelf: boolean[];
  90973. hardwareInstancedRendering: boolean[];
  90974. }
  90975. /**
  90976. * Class used to represent renderable models
  90977. */
  90978. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90979. /**
  90980. * Mesh side orientation : usually the external or front surface
  90981. */
  90982. static readonly FRONTSIDE: number;
  90983. /**
  90984. * Mesh side orientation : usually the internal or back surface
  90985. */
  90986. static readonly BACKSIDE: number;
  90987. /**
  90988. * Mesh side orientation : both internal and external or front and back surfaces
  90989. */
  90990. static readonly DOUBLESIDE: number;
  90991. /**
  90992. * Mesh side orientation : by default, `FRONTSIDE`
  90993. */
  90994. static readonly DEFAULTSIDE: number;
  90995. /**
  90996. * Mesh cap setting : no cap
  90997. */
  90998. static readonly NO_CAP: number;
  90999. /**
  91000. * Mesh cap setting : one cap at the beginning of the mesh
  91001. */
  91002. static readonly CAP_START: number;
  91003. /**
  91004. * Mesh cap setting : one cap at the end of the mesh
  91005. */
  91006. static readonly CAP_END: number;
  91007. /**
  91008. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91009. */
  91010. static readonly CAP_ALL: number;
  91011. /**
  91012. * Mesh pattern setting : no flip or rotate
  91013. */
  91014. static readonly NO_FLIP: number;
  91015. /**
  91016. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91017. */
  91018. static readonly FLIP_TILE: number;
  91019. /**
  91020. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91021. */
  91022. static readonly ROTATE_TILE: number;
  91023. /**
  91024. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91025. */
  91026. static readonly FLIP_ROW: number;
  91027. /**
  91028. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91029. */
  91030. static readonly ROTATE_ROW: number;
  91031. /**
  91032. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91033. */
  91034. static readonly FLIP_N_ROTATE_TILE: number;
  91035. /**
  91036. * Mesh pattern setting : rotate pattern and rotate
  91037. */
  91038. static readonly FLIP_N_ROTATE_ROW: number;
  91039. /**
  91040. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91041. */
  91042. static readonly CENTER: number;
  91043. /**
  91044. * Mesh tile positioning : part tiles on left
  91045. */
  91046. static readonly LEFT: number;
  91047. /**
  91048. * Mesh tile positioning : part tiles on right
  91049. */
  91050. static readonly RIGHT: number;
  91051. /**
  91052. * Mesh tile positioning : part tiles on top
  91053. */
  91054. static readonly TOP: number;
  91055. /**
  91056. * Mesh tile positioning : part tiles on bottom
  91057. */
  91058. static readonly BOTTOM: number;
  91059. /**
  91060. * Gets the default side orientation.
  91061. * @param orientation the orientation to value to attempt to get
  91062. * @returns the default orientation
  91063. * @hidden
  91064. */
  91065. static _GetDefaultSideOrientation(orientation?: number): number;
  91066. private _internalMeshDataInfo;
  91067. /**
  91068. * An event triggered before rendering the mesh
  91069. */
  91070. readonly onBeforeRenderObservable: Observable<Mesh>;
  91071. /**
  91072. * An event triggered before binding the mesh
  91073. */
  91074. readonly onBeforeBindObservable: Observable<Mesh>;
  91075. /**
  91076. * An event triggered after rendering the mesh
  91077. */
  91078. readonly onAfterRenderObservable: Observable<Mesh>;
  91079. /**
  91080. * An event triggered before drawing the mesh
  91081. */
  91082. readonly onBeforeDrawObservable: Observable<Mesh>;
  91083. private _onBeforeDrawObserver;
  91084. /**
  91085. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  91086. */
  91087. onBeforeDraw: () => void;
  91088. readonly hasInstances: boolean;
  91089. /**
  91090. * Gets the delay loading state of the mesh (when delay loading is turned on)
  91091. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  91092. */
  91093. delayLoadState: number;
  91094. /**
  91095. * Gets the list of instances created from this mesh
  91096. * it is not supposed to be modified manually.
  91097. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  91098. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91099. */
  91100. instances: InstancedMesh[];
  91101. /**
  91102. * Gets the file containing delay loading data for this mesh
  91103. */
  91104. delayLoadingFile: string;
  91105. /** @hidden */
  91106. _binaryInfo: any;
  91107. /**
  91108. * User defined function used to change how LOD level selection is done
  91109. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91110. */
  91111. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  91112. /**
  91113. * Gets or sets the morph target manager
  91114. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91115. */
  91116. morphTargetManager: Nullable<MorphTargetManager>;
  91117. /** @hidden */
  91118. _creationDataStorage: Nullable<_CreationDataStorage>;
  91119. /** @hidden */
  91120. _geometry: Nullable<Geometry>;
  91121. /** @hidden */
  91122. _delayInfo: Array<string>;
  91123. /** @hidden */
  91124. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  91125. /** @hidden */
  91126. _instanceDataStorage: _InstanceDataStorage;
  91127. private _effectiveMaterial;
  91128. /** @hidden */
  91129. _shouldGenerateFlatShading: boolean;
  91130. /** @hidden */
  91131. _originalBuilderSideOrientation: number;
  91132. /**
  91133. * Use this property to change the original side orientation defined at construction time
  91134. */
  91135. overrideMaterialSideOrientation: Nullable<number>;
  91136. /**
  91137. * Gets the source mesh (the one used to clone this one from)
  91138. */
  91139. readonly source: Nullable<Mesh>;
  91140. /**
  91141. * Gets or sets a boolean indicating that this mesh does not use index buffer
  91142. */
  91143. isUnIndexed: boolean;
  91144. /**
  91145. * @constructor
  91146. * @param name The value used by scene.getMeshByName() to do a lookup.
  91147. * @param scene The scene to add this mesh to.
  91148. * @param parent The parent of this mesh, if it has one
  91149. * @param source An optional Mesh from which geometry is shared, cloned.
  91150. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91151. * When false, achieved by calling a clone(), also passing False.
  91152. * This will make creation of children, recursive.
  91153. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  91154. */
  91155. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  91156. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  91157. /**
  91158. * Gets the class name
  91159. * @returns the string "Mesh".
  91160. */
  91161. getClassName(): string;
  91162. /** @hidden */
  91163. readonly _isMesh: boolean;
  91164. /**
  91165. * Returns a description of this mesh
  91166. * @param fullDetails define if full details about this mesh must be used
  91167. * @returns a descriptive string representing this mesh
  91168. */
  91169. toString(fullDetails?: boolean): string;
  91170. /** @hidden */
  91171. _unBindEffect(): void;
  91172. /**
  91173. * Gets a boolean indicating if this mesh has LOD
  91174. */
  91175. readonly hasLODLevels: boolean;
  91176. /**
  91177. * Gets the list of MeshLODLevel associated with the current mesh
  91178. * @returns an array of MeshLODLevel
  91179. */
  91180. getLODLevels(): MeshLODLevel[];
  91181. private _sortLODLevels;
  91182. /**
  91183. * Add a mesh as LOD level triggered at the given distance.
  91184. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91185. * @param distance The distance from the center of the object to show this level
  91186. * @param mesh The mesh to be added as LOD level (can be null)
  91187. * @return This mesh (for chaining)
  91188. */
  91189. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  91190. /**
  91191. * Returns the LOD level mesh at the passed distance or null if not found.
  91192. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91193. * @param distance The distance from the center of the object to show this level
  91194. * @returns a Mesh or `null`
  91195. */
  91196. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  91197. /**
  91198. * Remove a mesh from the LOD array
  91199. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91200. * @param mesh defines the mesh to be removed
  91201. * @return This mesh (for chaining)
  91202. */
  91203. removeLODLevel(mesh: Mesh): Mesh;
  91204. /**
  91205. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  91206. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91207. * @param camera defines the camera to use to compute distance
  91208. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  91209. * @return This mesh (for chaining)
  91210. */
  91211. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  91212. /**
  91213. * Gets the mesh internal Geometry object
  91214. */
  91215. readonly geometry: Nullable<Geometry>;
  91216. /**
  91217. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  91218. * @returns the total number of vertices
  91219. */
  91220. getTotalVertices(): number;
  91221. /**
  91222. * Returns the content of an associated vertex buffer
  91223. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91224. * - VertexBuffer.PositionKind
  91225. * - VertexBuffer.UVKind
  91226. * - VertexBuffer.UV2Kind
  91227. * - VertexBuffer.UV3Kind
  91228. * - VertexBuffer.UV4Kind
  91229. * - VertexBuffer.UV5Kind
  91230. * - VertexBuffer.UV6Kind
  91231. * - VertexBuffer.ColorKind
  91232. * - VertexBuffer.MatricesIndicesKind
  91233. * - VertexBuffer.MatricesIndicesExtraKind
  91234. * - VertexBuffer.MatricesWeightsKind
  91235. * - VertexBuffer.MatricesWeightsExtraKind
  91236. * @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
  91237. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  91238. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91239. */
  91240. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91241. /**
  91242. * Returns the mesh VertexBuffer object from the requested `kind`
  91243. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91244. * - VertexBuffer.PositionKind
  91245. * - VertexBuffer.NormalKind
  91246. * - VertexBuffer.UVKind
  91247. * - VertexBuffer.UV2Kind
  91248. * - VertexBuffer.UV3Kind
  91249. * - VertexBuffer.UV4Kind
  91250. * - VertexBuffer.UV5Kind
  91251. * - VertexBuffer.UV6Kind
  91252. * - VertexBuffer.ColorKind
  91253. * - VertexBuffer.MatricesIndicesKind
  91254. * - VertexBuffer.MatricesIndicesExtraKind
  91255. * - VertexBuffer.MatricesWeightsKind
  91256. * - VertexBuffer.MatricesWeightsExtraKind
  91257. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  91258. */
  91259. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91260. /**
  91261. * Tests if a specific vertex buffer is associated with this mesh
  91262. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91263. * - VertexBuffer.PositionKind
  91264. * - VertexBuffer.NormalKind
  91265. * - VertexBuffer.UVKind
  91266. * - VertexBuffer.UV2Kind
  91267. * - VertexBuffer.UV3Kind
  91268. * - VertexBuffer.UV4Kind
  91269. * - VertexBuffer.UV5Kind
  91270. * - VertexBuffer.UV6Kind
  91271. * - VertexBuffer.ColorKind
  91272. * - VertexBuffer.MatricesIndicesKind
  91273. * - VertexBuffer.MatricesIndicesExtraKind
  91274. * - VertexBuffer.MatricesWeightsKind
  91275. * - VertexBuffer.MatricesWeightsExtraKind
  91276. * @returns a boolean
  91277. */
  91278. isVerticesDataPresent(kind: string): boolean;
  91279. /**
  91280. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  91281. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91282. * - VertexBuffer.PositionKind
  91283. * - VertexBuffer.UVKind
  91284. * - VertexBuffer.UV2Kind
  91285. * - VertexBuffer.UV3Kind
  91286. * - VertexBuffer.UV4Kind
  91287. * - VertexBuffer.UV5Kind
  91288. * - VertexBuffer.UV6Kind
  91289. * - VertexBuffer.ColorKind
  91290. * - VertexBuffer.MatricesIndicesKind
  91291. * - VertexBuffer.MatricesIndicesExtraKind
  91292. * - VertexBuffer.MatricesWeightsKind
  91293. * - VertexBuffer.MatricesWeightsExtraKind
  91294. * @returns a boolean
  91295. */
  91296. isVertexBufferUpdatable(kind: string): boolean;
  91297. /**
  91298. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  91299. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91300. * - VertexBuffer.PositionKind
  91301. * - VertexBuffer.NormalKind
  91302. * - VertexBuffer.UVKind
  91303. * - VertexBuffer.UV2Kind
  91304. * - VertexBuffer.UV3Kind
  91305. * - VertexBuffer.UV4Kind
  91306. * - VertexBuffer.UV5Kind
  91307. * - VertexBuffer.UV6Kind
  91308. * - VertexBuffer.ColorKind
  91309. * - VertexBuffer.MatricesIndicesKind
  91310. * - VertexBuffer.MatricesIndicesExtraKind
  91311. * - VertexBuffer.MatricesWeightsKind
  91312. * - VertexBuffer.MatricesWeightsExtraKind
  91313. * @returns an array of strings
  91314. */
  91315. getVerticesDataKinds(): string[];
  91316. /**
  91317. * Returns a positive integer : the total number of indices in this mesh geometry.
  91318. * @returns the numner of indices or zero if the mesh has no geometry.
  91319. */
  91320. getTotalIndices(): number;
  91321. /**
  91322. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91323. * @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.
  91324. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91325. * @returns the indices array or an empty array if the mesh has no geometry
  91326. */
  91327. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91328. readonly isBlocked: boolean;
  91329. /**
  91330. * Determine if the current mesh is ready to be rendered
  91331. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91332. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  91333. * @returns true if all associated assets are ready (material, textures, shaders)
  91334. */
  91335. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  91336. /**
  91337. * 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.
  91338. */
  91339. readonly areNormalsFrozen: boolean;
  91340. /**
  91341. * 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.
  91342. * @returns the current mesh
  91343. */
  91344. freezeNormals(): Mesh;
  91345. /**
  91346. * 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
  91347. * @returns the current mesh
  91348. */
  91349. unfreezeNormals(): Mesh;
  91350. /**
  91351. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  91352. */
  91353. overridenInstanceCount: number;
  91354. /** @hidden */
  91355. _preActivate(): Mesh;
  91356. /** @hidden */
  91357. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91358. /** @hidden */
  91359. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  91360. /**
  91361. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91362. * This means the mesh underlying bounding box and sphere are recomputed.
  91363. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91364. * @returns the current mesh
  91365. */
  91366. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  91367. /** @hidden */
  91368. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  91369. /**
  91370. * This function will subdivide the mesh into multiple submeshes
  91371. * @param count defines the expected number of submeshes
  91372. */
  91373. subdivide(count: number): void;
  91374. /**
  91375. * Copy a FloatArray into a specific associated vertex buffer
  91376. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91377. * - VertexBuffer.PositionKind
  91378. * - VertexBuffer.UVKind
  91379. * - VertexBuffer.UV2Kind
  91380. * - VertexBuffer.UV3Kind
  91381. * - VertexBuffer.UV4Kind
  91382. * - VertexBuffer.UV5Kind
  91383. * - VertexBuffer.UV6Kind
  91384. * - VertexBuffer.ColorKind
  91385. * - VertexBuffer.MatricesIndicesKind
  91386. * - VertexBuffer.MatricesIndicesExtraKind
  91387. * - VertexBuffer.MatricesWeightsKind
  91388. * - VertexBuffer.MatricesWeightsExtraKind
  91389. * @param data defines the data source
  91390. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91391. * @param stride defines the data stride size (can be null)
  91392. * @returns the current mesh
  91393. */
  91394. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91395. /**
  91396. * Delete a vertex buffer associated with this mesh
  91397. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  91398. * - VertexBuffer.PositionKind
  91399. * - VertexBuffer.UVKind
  91400. * - VertexBuffer.UV2Kind
  91401. * - VertexBuffer.UV3Kind
  91402. * - VertexBuffer.UV4Kind
  91403. * - VertexBuffer.UV5Kind
  91404. * - VertexBuffer.UV6Kind
  91405. * - VertexBuffer.ColorKind
  91406. * - VertexBuffer.MatricesIndicesKind
  91407. * - VertexBuffer.MatricesIndicesExtraKind
  91408. * - VertexBuffer.MatricesWeightsKind
  91409. * - VertexBuffer.MatricesWeightsExtraKind
  91410. */
  91411. removeVerticesData(kind: string): void;
  91412. /**
  91413. * Flags an associated vertex buffer as updatable
  91414. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  91415. * - VertexBuffer.PositionKind
  91416. * - VertexBuffer.UVKind
  91417. * - VertexBuffer.UV2Kind
  91418. * - VertexBuffer.UV3Kind
  91419. * - VertexBuffer.UV4Kind
  91420. * - VertexBuffer.UV5Kind
  91421. * - VertexBuffer.UV6Kind
  91422. * - VertexBuffer.ColorKind
  91423. * - VertexBuffer.MatricesIndicesKind
  91424. * - VertexBuffer.MatricesIndicesExtraKind
  91425. * - VertexBuffer.MatricesWeightsKind
  91426. * - VertexBuffer.MatricesWeightsExtraKind
  91427. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91428. */
  91429. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  91430. /**
  91431. * Sets the mesh global Vertex Buffer
  91432. * @param buffer defines the buffer to use
  91433. * @returns the current mesh
  91434. */
  91435. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  91436. /**
  91437. * Update a specific associated vertex buffer
  91438. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91439. * - VertexBuffer.PositionKind
  91440. * - VertexBuffer.UVKind
  91441. * - VertexBuffer.UV2Kind
  91442. * - VertexBuffer.UV3Kind
  91443. * - VertexBuffer.UV4Kind
  91444. * - VertexBuffer.UV5Kind
  91445. * - VertexBuffer.UV6Kind
  91446. * - VertexBuffer.ColorKind
  91447. * - VertexBuffer.MatricesIndicesKind
  91448. * - VertexBuffer.MatricesIndicesExtraKind
  91449. * - VertexBuffer.MatricesWeightsKind
  91450. * - VertexBuffer.MatricesWeightsExtraKind
  91451. * @param data defines the data source
  91452. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  91453. * @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)
  91454. * @returns the current mesh
  91455. */
  91456. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91457. /**
  91458. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  91459. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  91460. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  91461. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  91462. * @returns the current mesh
  91463. */
  91464. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  91465. /**
  91466. * Creates a un-shared specific occurence of the geometry for the mesh.
  91467. * @returns the current mesh
  91468. */
  91469. makeGeometryUnique(): Mesh;
  91470. /**
  91471. * Set the index buffer of this mesh
  91472. * @param indices defines the source data
  91473. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  91474. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  91475. * @returns the current mesh
  91476. */
  91477. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  91478. /**
  91479. * Update the current index buffer
  91480. * @param indices defines the source data
  91481. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91482. * @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)
  91483. * @returns the current mesh
  91484. */
  91485. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91486. /**
  91487. * Invert the geometry to move from a right handed system to a left handed one.
  91488. * @returns the current mesh
  91489. */
  91490. toLeftHanded(): Mesh;
  91491. /** @hidden */
  91492. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91493. /** @hidden */
  91494. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91495. /**
  91496. * Registers for this mesh a javascript function called just before the rendering process
  91497. * @param func defines the function to call before rendering this mesh
  91498. * @returns the current mesh
  91499. */
  91500. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91501. /**
  91502. * Disposes a previously registered javascript function called before the rendering
  91503. * @param func defines the function to remove
  91504. * @returns the current mesh
  91505. */
  91506. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91507. /**
  91508. * Registers for this mesh a javascript function called just after the rendering is complete
  91509. * @param func defines the function to call after rendering this mesh
  91510. * @returns the current mesh
  91511. */
  91512. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91513. /**
  91514. * Disposes a previously registered javascript function called after the rendering.
  91515. * @param func defines the function to remove
  91516. * @returns the current mesh
  91517. */
  91518. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91519. /** @hidden */
  91520. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  91521. /** @hidden */
  91522. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  91523. /** @hidden */
  91524. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  91525. /** @hidden */
  91526. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  91527. /** @hidden */
  91528. _rebuild(): void;
  91529. /** @hidden */
  91530. _freeze(): void;
  91531. /** @hidden */
  91532. _unFreeze(): void;
  91533. /**
  91534. * 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
  91535. * @param subMesh defines the subMesh to render
  91536. * @param enableAlphaMode defines if alpha mode can be changed
  91537. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  91538. * @returns the current mesh
  91539. */
  91540. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  91541. private _onBeforeDraw;
  91542. /**
  91543. * Renormalize the mesh and patch it up if there are no weights
  91544. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  91545. * However in the case of zero weights then we set just a single influence to 1.
  91546. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  91547. */
  91548. cleanMatrixWeights(): void;
  91549. private normalizeSkinFourWeights;
  91550. private normalizeSkinWeightsAndExtra;
  91551. /**
  91552. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  91553. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  91554. * the user know there was an issue with importing the mesh
  91555. * @returns a validation object with skinned, valid and report string
  91556. */
  91557. validateSkinning(): {
  91558. skinned: boolean;
  91559. valid: boolean;
  91560. report: string;
  91561. };
  91562. /** @hidden */
  91563. _checkDelayState(): Mesh;
  91564. private _queueLoad;
  91565. /**
  91566. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91567. * A mesh is in the frustum if its bounding box intersects the frustum
  91568. * @param frustumPlanes defines the frustum to test
  91569. * @returns true if the mesh is in the frustum planes
  91570. */
  91571. isInFrustum(frustumPlanes: Plane[]): boolean;
  91572. /**
  91573. * Sets the mesh material by the material or multiMaterial `id` property
  91574. * @param id is a string identifying the material or the multiMaterial
  91575. * @returns the current mesh
  91576. */
  91577. setMaterialByID(id: string): Mesh;
  91578. /**
  91579. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  91580. * @returns an array of IAnimatable
  91581. */
  91582. getAnimatables(): IAnimatable[];
  91583. /**
  91584. * Modifies the mesh geometry according to the passed transformation matrix.
  91585. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  91586. * The mesh normals are modified using the same transformation.
  91587. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91588. * @param transform defines the transform matrix to use
  91589. * @see http://doc.babylonjs.com/resources/baking_transformations
  91590. * @returns the current mesh
  91591. */
  91592. bakeTransformIntoVertices(transform: Matrix): Mesh;
  91593. /**
  91594. * Modifies the mesh geometry according to its own current World Matrix.
  91595. * The mesh World Matrix is then reset.
  91596. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  91597. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91598. * @see http://doc.babylonjs.com/resources/baking_transformations
  91599. * @returns the current mesh
  91600. */
  91601. bakeCurrentTransformIntoVertices(): Mesh;
  91602. /** @hidden */
  91603. readonly _positions: Nullable<Vector3[]>;
  91604. /** @hidden */
  91605. _resetPointsArrayCache(): Mesh;
  91606. /** @hidden */
  91607. _generatePointsArray(): boolean;
  91608. /**
  91609. * Returns a new Mesh object generated from the current mesh properties.
  91610. * This method must not get confused with createInstance()
  91611. * @param name is a string, the name given to the new mesh
  91612. * @param newParent can be any Node object (default `null`)
  91613. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  91614. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  91615. * @returns a new mesh
  91616. */
  91617. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  91618. /**
  91619. * Releases resources associated with this mesh.
  91620. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91621. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91622. */
  91623. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91624. /** @hidden */
  91625. _disposeInstanceSpecificData(): void;
  91626. /**
  91627. * Modifies the mesh geometry according to a displacement map.
  91628. * 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.
  91629. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91630. * @param url is a string, the URL from the image file is to be downloaded.
  91631. * @param minHeight is the lower limit of the displacement.
  91632. * @param maxHeight is the upper limit of the displacement.
  91633. * @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.
  91634. * @param uvOffset is an optional vector2 used to offset UV.
  91635. * @param uvScale is an optional vector2 used to scale UV.
  91636. * @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.
  91637. * @returns the Mesh.
  91638. */
  91639. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91640. /**
  91641. * Modifies the mesh geometry according to a displacementMap buffer.
  91642. * 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.
  91643. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91644. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  91645. * @param heightMapWidth is the width of the buffer image.
  91646. * @param heightMapHeight is the height of the buffer image.
  91647. * @param minHeight is the lower limit of the displacement.
  91648. * @param maxHeight is the upper limit of the displacement.
  91649. * @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.
  91650. * @param uvOffset is an optional vector2 used to offset UV.
  91651. * @param uvScale is an optional vector2 used to scale UV.
  91652. * @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.
  91653. * @returns the Mesh.
  91654. */
  91655. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91656. /**
  91657. * Modify the mesh to get a flat shading rendering.
  91658. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  91659. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  91660. * @returns current mesh
  91661. */
  91662. convertToFlatShadedMesh(): Mesh;
  91663. /**
  91664. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  91665. * In other words, more vertices, no more indices and a single bigger VBO.
  91666. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  91667. * @returns current mesh
  91668. */
  91669. convertToUnIndexedMesh(): Mesh;
  91670. /**
  91671. * Inverses facet orientations.
  91672. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91673. * @param flipNormals will also inverts the normals
  91674. * @returns current mesh
  91675. */
  91676. flipFaces(flipNormals?: boolean): Mesh;
  91677. /**
  91678. * Increase the number of facets and hence vertices in a mesh
  91679. * Vertex normals are interpolated from existing vertex normals
  91680. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91681. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  91682. */
  91683. increaseVertices(numberPerEdge: number): void;
  91684. /**
  91685. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  91686. * This will undo any application of covertToFlatShadedMesh
  91687. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91688. */
  91689. forceSharedVertices(): void;
  91690. /** @hidden */
  91691. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  91692. /** @hidden */
  91693. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  91694. /**
  91695. * Creates a new InstancedMesh object from the mesh model.
  91696. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91697. * @param name defines the name of the new instance
  91698. * @returns a new InstancedMesh
  91699. */
  91700. createInstance(name: string): InstancedMesh;
  91701. /**
  91702. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  91703. * After this call, all the mesh instances have the same submeshes than the current mesh.
  91704. * @returns the current mesh
  91705. */
  91706. synchronizeInstances(): Mesh;
  91707. /**
  91708. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  91709. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  91710. * This should be used together with the simplification to avoid disappearing triangles.
  91711. * @param successCallback an optional success callback to be called after the optimization finished.
  91712. * @returns the current mesh
  91713. */
  91714. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  91715. /**
  91716. * Serialize current mesh
  91717. * @param serializationObject defines the object which will receive the serialization data
  91718. */
  91719. serialize(serializationObject: any): void;
  91720. /** @hidden */
  91721. _syncGeometryWithMorphTargetManager(): void;
  91722. /** @hidden */
  91723. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91724. /**
  91725. * Returns a new Mesh object parsed from the source provided.
  91726. * @param parsedMesh is the source
  91727. * @param scene defines the hosting scene
  91728. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91729. * @returns a new Mesh
  91730. */
  91731. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91732. /**
  91733. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91734. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91735. * @param name defines the name of the mesh to create
  91736. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91737. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91738. * @param closePath creates a seam between the first and the last points of each path of the path array
  91739. * @param offset is taken in account only if the `pathArray` is containing a single path
  91740. * @param scene defines the hosting scene
  91741. * @param updatable defines if the mesh must be flagged as updatable
  91742. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91743. * @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)
  91744. * @returns a new Mesh
  91745. */
  91746. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91747. /**
  91748. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91749. * @param name defines the name of the mesh to create
  91750. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91751. * @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
  91752. * @param scene defines the hosting scene
  91753. * @param updatable defines if the mesh must be flagged as updatable
  91754. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91755. * @returns a new Mesh
  91756. */
  91757. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91758. /**
  91759. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91760. * @param name defines the name of the mesh to create
  91761. * @param size sets the size (float) of each box side (default 1)
  91762. * @param scene defines the hosting scene
  91763. * @param updatable defines if the mesh must be flagged as updatable
  91764. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91765. * @returns a new Mesh
  91766. */
  91767. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91768. /**
  91769. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91770. * @param name defines the name of the mesh to create
  91771. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91772. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91773. * @param scene defines the hosting scene
  91774. * @param updatable defines if the mesh must be flagged as updatable
  91775. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91776. * @returns a new Mesh
  91777. */
  91778. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91779. /**
  91780. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91781. * @param name defines the name of the mesh to create
  91782. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91783. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91784. * @param scene defines the hosting scene
  91785. * @returns a new Mesh
  91786. */
  91787. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91788. /**
  91789. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91790. * @param name defines the name of the mesh to create
  91791. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91792. * @param diameterTop set the top cap diameter (floats, default 1)
  91793. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91794. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91795. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91796. * @param scene defines the hosting scene
  91797. * @param updatable defines if the mesh must be flagged as updatable
  91798. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91799. * @returns a new Mesh
  91800. */
  91801. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91802. /**
  91803. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91804. * @param name defines the name of the mesh to create
  91805. * @param diameter sets the diameter size (float) of the torus (default 1)
  91806. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91807. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91808. * @param scene defines the hosting scene
  91809. * @param updatable defines if the mesh must be flagged as updatable
  91810. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91811. * @returns a new Mesh
  91812. */
  91813. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91814. /**
  91815. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91816. * @param name defines the name of the mesh to create
  91817. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91818. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91819. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91820. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91821. * @param p the number of windings on X axis (positive integers, default 2)
  91822. * @param q the number of windings on Y axis (positive integers, default 3)
  91823. * @param scene defines the hosting scene
  91824. * @param updatable defines if the mesh must be flagged as updatable
  91825. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91826. * @returns a new Mesh
  91827. */
  91828. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91829. /**
  91830. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91831. * @param name defines the name of the mesh to create
  91832. * @param points is an array successive Vector3
  91833. * @param scene defines the hosting scene
  91834. * @param updatable defines if the mesh must be flagged as updatable
  91835. * @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).
  91836. * @returns a new Mesh
  91837. */
  91838. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91839. /**
  91840. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91841. * @param name defines the name of the mesh to create
  91842. * @param points is an array successive Vector3
  91843. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91844. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91845. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91846. * @param scene defines the hosting scene
  91847. * @param updatable defines if the mesh must be flagged as updatable
  91848. * @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)
  91849. * @returns a new Mesh
  91850. */
  91851. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91852. /**
  91853. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91854. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91855. * 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.
  91856. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91857. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91858. * Remember you can only change the shape positions, not their number when updating a polygon.
  91859. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91860. * @param name defines the name of the mesh to create
  91861. * @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
  91862. * @param scene defines the hosting scene
  91863. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91864. * @param updatable defines if the mesh must be flagged as updatable
  91865. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91866. * @param earcutInjection can be used to inject your own earcut reference
  91867. * @returns a new Mesh
  91868. */
  91869. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91870. /**
  91871. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91872. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91873. * @param name defines the name of the mesh to create
  91874. * @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
  91875. * @param depth defines the height of extrusion
  91876. * @param scene defines the hosting scene
  91877. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91878. * @param updatable defines if the mesh must be flagged as updatable
  91879. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91880. * @param earcutInjection can be used to inject your own earcut reference
  91881. * @returns a new Mesh
  91882. */
  91883. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91884. /**
  91885. * Creates an extruded shape mesh.
  91886. * 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
  91887. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91888. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91889. * @param name defines the name of the mesh to create
  91890. * @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
  91891. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91892. * @param scale is the value to scale the shape
  91893. * @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
  91894. * @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
  91895. * @param scene defines the hosting scene
  91896. * @param updatable defines if the mesh must be flagged as updatable
  91897. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91898. * @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)
  91899. * @returns a new Mesh
  91900. */
  91901. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91902. /**
  91903. * Creates an custom extruded shape mesh.
  91904. * The custom extrusion is a parametric shape.
  91905. * It has no predefined shape. Its final shape will depend on the input parameters.
  91906. * Please consider using the same method from the MeshBuilder class instead
  91907. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91908. * @param name defines the name of the mesh to create
  91909. * @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
  91910. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91911. * @param scaleFunction is a custom Javascript function called on each path point
  91912. * @param rotationFunction is a custom Javascript function called on each path point
  91913. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91914. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91915. * @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
  91916. * @param scene defines the hosting scene
  91917. * @param updatable defines if the mesh must be flagged as updatable
  91918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91919. * @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)
  91920. * @returns a new Mesh
  91921. */
  91922. 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;
  91923. /**
  91924. * Creates lathe mesh.
  91925. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91926. * Please consider using the same method from the MeshBuilder class instead
  91927. * @param name defines the name of the mesh to create
  91928. * @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
  91929. * @param radius is the radius value of the lathe
  91930. * @param tessellation is the side number of the lathe.
  91931. * @param scene defines the hosting scene
  91932. * @param updatable defines if the mesh must be flagged as updatable
  91933. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91934. * @returns a new Mesh
  91935. */
  91936. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91937. /**
  91938. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91939. * @param name defines the name of the mesh to create
  91940. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91941. * @param scene defines the hosting scene
  91942. * @param updatable defines if the mesh must be flagged as updatable
  91943. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91944. * @returns a new Mesh
  91945. */
  91946. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91947. /**
  91948. * Creates a ground mesh.
  91949. * Please consider using the same method from the MeshBuilder class instead
  91950. * @param name defines the name of the mesh to create
  91951. * @param width set the width of the ground
  91952. * @param height set the height of the ground
  91953. * @param subdivisions sets the number of subdivisions per side
  91954. * @param scene defines the hosting scene
  91955. * @param updatable defines if the mesh must be flagged as updatable
  91956. * @returns a new Mesh
  91957. */
  91958. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91959. /**
  91960. * Creates a tiled ground mesh.
  91961. * Please consider using the same method from the MeshBuilder class instead
  91962. * @param name defines the name of the mesh to create
  91963. * @param xmin set the ground minimum X coordinate
  91964. * @param zmin set the ground minimum Y coordinate
  91965. * @param xmax set the ground maximum X coordinate
  91966. * @param zmax set the ground maximum Z coordinate
  91967. * @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
  91968. * @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
  91969. * @param scene defines the hosting scene
  91970. * @param updatable defines if the mesh must be flagged as updatable
  91971. * @returns a new Mesh
  91972. */
  91973. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91974. w: number;
  91975. h: number;
  91976. }, precision: {
  91977. w: number;
  91978. h: number;
  91979. }, scene: Scene, updatable?: boolean): Mesh;
  91980. /**
  91981. * Creates a ground mesh from a height map.
  91982. * Please consider using the same method from the MeshBuilder class instead
  91983. * @see http://doc.babylonjs.com/babylon101/height_map
  91984. * @param name defines the name of the mesh to create
  91985. * @param url sets the URL of the height map image resource
  91986. * @param width set the ground width size
  91987. * @param height set the ground height size
  91988. * @param subdivisions sets the number of subdivision per side
  91989. * @param minHeight is the minimum altitude on the ground
  91990. * @param maxHeight is the maximum altitude on the ground
  91991. * @param scene defines the hosting scene
  91992. * @param updatable defines if the mesh must be flagged as updatable
  91993. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91994. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91995. * @returns a new Mesh
  91996. */
  91997. 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;
  91998. /**
  91999. * Creates a tube mesh.
  92000. * The tube is a parametric shape.
  92001. * It has no predefined shape. Its final shape will depend on the input parameters.
  92002. * Please consider using the same method from the MeshBuilder class instead
  92003. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92004. * @param name defines the name of the mesh to create
  92005. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92006. * @param radius sets the tube radius size
  92007. * @param tessellation is the number of sides on the tubular surface
  92008. * @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
  92009. * @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
  92010. * @param scene defines the hosting scene
  92011. * @param updatable defines if the mesh must be flagged as updatable
  92012. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92013. * @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)
  92014. * @returns a new Mesh
  92015. */
  92016. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92017. (i: number, distance: number): number;
  92018. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92019. /**
  92020. * Creates a polyhedron mesh.
  92021. * Please consider using the same method from the MeshBuilder class instead.
  92022. * * 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
  92023. * * The parameter `size` (positive float, default 1) sets the polygon size
  92024. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92025. * * 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`
  92026. * * 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
  92027. * * 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)`)
  92028. * * 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
  92029. * * 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
  92030. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92031. * * If you create a double-sided mesh, you can choose what parts of 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
  92032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92033. * @param name defines the name of the mesh to create
  92034. * @param options defines the options used to create the mesh
  92035. * @param scene defines the hosting scene
  92036. * @returns a new Mesh
  92037. */
  92038. static CreatePolyhedron(name: string, options: {
  92039. type?: number;
  92040. size?: number;
  92041. sizeX?: number;
  92042. sizeY?: number;
  92043. sizeZ?: number;
  92044. custom?: any;
  92045. faceUV?: Vector4[];
  92046. faceColors?: Color4[];
  92047. updatable?: boolean;
  92048. sideOrientation?: number;
  92049. }, scene: Scene): Mesh;
  92050. /**
  92051. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92052. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92053. * * 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`)
  92054. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92055. * * 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
  92056. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92057. * * If you create a double-sided mesh, you can choose what parts of 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
  92058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92059. * @param name defines the name of the mesh
  92060. * @param options defines the options used to create the mesh
  92061. * @param scene defines the hosting scene
  92062. * @returns a new Mesh
  92063. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92064. */
  92065. static CreateIcoSphere(name: string, options: {
  92066. radius?: number;
  92067. flat?: boolean;
  92068. subdivisions?: number;
  92069. sideOrientation?: number;
  92070. updatable?: boolean;
  92071. }, scene: Scene): Mesh;
  92072. /**
  92073. * Creates a decal mesh.
  92074. * Please consider using the same method from the MeshBuilder class instead.
  92075. * A decal is a mesh usually applied as a model onto the surface of another mesh
  92076. * @param name defines the name of the mesh
  92077. * @param sourceMesh defines the mesh receiving the decal
  92078. * @param position sets the position of the decal in world coordinates
  92079. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  92080. * @param size sets the decal scaling
  92081. * @param angle sets the angle to rotate the decal
  92082. * @returns a new Mesh
  92083. */
  92084. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  92085. /**
  92086. * Prepare internal position array for software CPU skinning
  92087. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  92088. */
  92089. setPositionsForCPUSkinning(): Float32Array;
  92090. /**
  92091. * Prepare internal normal array for software CPU skinning
  92092. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  92093. */
  92094. setNormalsForCPUSkinning(): Float32Array;
  92095. /**
  92096. * Updates the vertex buffer by applying transformation from the bones
  92097. * @param skeleton defines the skeleton to apply to current mesh
  92098. * @returns the current mesh
  92099. */
  92100. applySkeleton(skeleton: Skeleton): Mesh;
  92101. /**
  92102. * 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
  92103. * @param meshes defines the list of meshes to scan
  92104. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  92105. */
  92106. static MinMax(meshes: AbstractMesh[]): {
  92107. min: Vector3;
  92108. max: Vector3;
  92109. };
  92110. /**
  92111. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  92112. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  92113. * @returns a vector3
  92114. */
  92115. static Center(meshesOrMinMaxVector: {
  92116. min: Vector3;
  92117. max: Vector3;
  92118. } | AbstractMesh[]): Vector3;
  92119. /**
  92120. * Merge the array of meshes into a single mesh for performance reasons.
  92121. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  92122. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  92123. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  92124. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  92125. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  92126. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  92127. * @returns a new mesh
  92128. */
  92129. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  92130. /** @hidden */
  92131. addInstance(instance: InstancedMesh): void;
  92132. /** @hidden */
  92133. removeInstance(instance: InstancedMesh): void;
  92134. }
  92135. }
  92136. declare module BABYLON {
  92137. /**
  92138. * This is the base class of all the camera used in the application.
  92139. * @see http://doc.babylonjs.com/features/cameras
  92140. */
  92141. export class Camera extends Node {
  92142. /** @hidden */
  92143. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92144. /**
  92145. * This is the default projection mode used by the cameras.
  92146. * It helps recreating a feeling of perspective and better appreciate depth.
  92147. * This is the best way to simulate real life cameras.
  92148. */
  92149. static readonly PERSPECTIVE_CAMERA: number;
  92150. /**
  92151. * This helps creating camera with an orthographic mode.
  92152. * 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.
  92153. */
  92154. static readonly ORTHOGRAPHIC_CAMERA: number;
  92155. /**
  92156. * This is the default FOV mode for perspective cameras.
  92157. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92158. */
  92159. static readonly FOVMODE_VERTICAL_FIXED: number;
  92160. /**
  92161. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92162. */
  92163. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92164. /**
  92165. * This specifies ther is no need for a camera rig.
  92166. * Basically only one eye is rendered corresponding to the camera.
  92167. */
  92168. static readonly RIG_MODE_NONE: number;
  92169. /**
  92170. * Simulates a camera Rig with one blue eye and one red eye.
  92171. * This can be use with 3d blue and red glasses.
  92172. */
  92173. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92174. /**
  92175. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92176. */
  92177. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92178. /**
  92179. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92180. */
  92181. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92182. /**
  92183. * Defines that both eyes of the camera will be rendered over under each other.
  92184. */
  92185. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92186. /**
  92187. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92188. */
  92189. static readonly RIG_MODE_VR: number;
  92190. /**
  92191. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92192. */
  92193. static readonly RIG_MODE_WEBVR: number;
  92194. /**
  92195. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92196. */
  92197. static readonly RIG_MODE_CUSTOM: number;
  92198. /**
  92199. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92200. */
  92201. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92202. /**
  92203. * Define the input manager associated with the camera.
  92204. */
  92205. inputs: CameraInputsManager<Camera>;
  92206. /** @hidden */
  92207. _position: Vector3;
  92208. /**
  92209. * Define the current local position of the camera in the scene
  92210. */
  92211. position: Vector3;
  92212. /**
  92213. * The vector the camera should consider as up.
  92214. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92215. */
  92216. upVector: Vector3;
  92217. /**
  92218. * Define the current limit on the left side for an orthographic camera
  92219. * In scene unit
  92220. */
  92221. orthoLeft: Nullable<number>;
  92222. /**
  92223. * Define the current limit on the right side for an orthographic camera
  92224. * In scene unit
  92225. */
  92226. orthoRight: Nullable<number>;
  92227. /**
  92228. * Define the current limit on the bottom side for an orthographic camera
  92229. * In scene unit
  92230. */
  92231. orthoBottom: Nullable<number>;
  92232. /**
  92233. * Define the current limit on the top side for an orthographic camera
  92234. * In scene unit
  92235. */
  92236. orthoTop: Nullable<number>;
  92237. /**
  92238. * Field Of View is set in Radians. (default is 0.8)
  92239. */
  92240. fov: number;
  92241. /**
  92242. * Define the minimum distance the camera can see from.
  92243. * This is important to note that the depth buffer are not infinite and the closer it starts
  92244. * the more your scene might encounter depth fighting issue.
  92245. */
  92246. minZ: number;
  92247. /**
  92248. * Define the maximum distance the camera can see to.
  92249. * This is important to note that the depth buffer are not infinite and the further it end
  92250. * the more your scene might encounter depth fighting issue.
  92251. */
  92252. maxZ: number;
  92253. /**
  92254. * Define the default inertia of the camera.
  92255. * This helps giving a smooth feeling to the camera movement.
  92256. */
  92257. inertia: number;
  92258. /**
  92259. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  92260. */
  92261. mode: number;
  92262. /**
  92263. * Define wether the camera is intermediate.
  92264. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92265. */
  92266. isIntermediate: boolean;
  92267. /**
  92268. * Define the viewport of the camera.
  92269. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92270. */
  92271. viewport: Viewport;
  92272. /**
  92273. * Restricts the camera to viewing objects with the same layerMask.
  92274. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92275. */
  92276. layerMask: number;
  92277. /**
  92278. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92279. */
  92280. fovMode: number;
  92281. /**
  92282. * Rig mode of the camera.
  92283. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92284. * This is normally controlled byt the camera themselves as internal use.
  92285. */
  92286. cameraRigMode: number;
  92287. /**
  92288. * Defines the distance between both "eyes" in case of a RIG
  92289. */
  92290. interaxialDistance: number;
  92291. /**
  92292. * Defines if stereoscopic rendering is done side by side or over under.
  92293. */
  92294. isStereoscopicSideBySide: boolean;
  92295. /**
  92296. * 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
  92297. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92298. * else in the scene. (Eg. security camera)
  92299. *
  92300. * 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)
  92301. */
  92302. customRenderTargets: RenderTargetTexture[];
  92303. /**
  92304. * When set, the camera will render to this render target instead of the default canvas
  92305. *
  92306. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  92307. */
  92308. outputRenderTarget: Nullable<RenderTargetTexture>;
  92309. /**
  92310. * Observable triggered when the camera view matrix has changed.
  92311. */
  92312. onViewMatrixChangedObservable: Observable<Camera>;
  92313. /**
  92314. * Observable triggered when the camera Projection matrix has changed.
  92315. */
  92316. onProjectionMatrixChangedObservable: Observable<Camera>;
  92317. /**
  92318. * Observable triggered when the inputs have been processed.
  92319. */
  92320. onAfterCheckInputsObservable: Observable<Camera>;
  92321. /**
  92322. * Observable triggered when reset has been called and applied to the camera.
  92323. */
  92324. onRestoreStateObservable: Observable<Camera>;
  92325. /** @hidden */
  92326. _cameraRigParams: any;
  92327. /** @hidden */
  92328. _rigCameras: Camera[];
  92329. /** @hidden */
  92330. _rigPostProcess: Nullable<PostProcess>;
  92331. protected _webvrViewMatrix: Matrix;
  92332. /** @hidden */
  92333. _skipRendering: boolean;
  92334. /** @hidden */
  92335. _projectionMatrix: Matrix;
  92336. /** @hidden */
  92337. _postProcesses: Nullable<PostProcess>[];
  92338. /** @hidden */
  92339. _activeMeshes: SmartArray<AbstractMesh>;
  92340. protected _globalPosition: Vector3;
  92341. /** @hidden */
  92342. _computedViewMatrix: Matrix;
  92343. private _doNotComputeProjectionMatrix;
  92344. private _transformMatrix;
  92345. private _frustumPlanes;
  92346. private _refreshFrustumPlanes;
  92347. private _storedFov;
  92348. private _stateStored;
  92349. /**
  92350. * Instantiates a new camera object.
  92351. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92352. * @see http://doc.babylonjs.com/features/cameras
  92353. * @param name Defines the name of the camera in the scene
  92354. * @param position Defines the position of the camera
  92355. * @param scene Defines the scene the camera belongs too
  92356. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92357. */
  92358. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92359. /**
  92360. * Store current camera state (fov, position, etc..)
  92361. * @returns the camera
  92362. */
  92363. storeState(): Camera;
  92364. /**
  92365. * Restores the camera state values if it has been stored. You must call storeState() first
  92366. */
  92367. protected _restoreStateValues(): boolean;
  92368. /**
  92369. * Restored camera state. You must call storeState() first.
  92370. * @returns true if restored and false otherwise
  92371. */
  92372. restoreState(): boolean;
  92373. /**
  92374. * Gets the class name of the camera.
  92375. * @returns the class name
  92376. */
  92377. getClassName(): string;
  92378. /** @hidden */
  92379. readonly _isCamera: boolean;
  92380. /**
  92381. * Gets a string representation of the camera useful for debug purpose.
  92382. * @param fullDetails Defines that a more verboe level of logging is required
  92383. * @returns the string representation
  92384. */
  92385. toString(fullDetails?: boolean): string;
  92386. /**
  92387. * Gets the current world space position of the camera.
  92388. */
  92389. readonly globalPosition: Vector3;
  92390. /**
  92391. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92392. * @returns the active meshe list
  92393. */
  92394. getActiveMeshes(): SmartArray<AbstractMesh>;
  92395. /**
  92396. * Check wether a mesh is part of the current active mesh list of the camera
  92397. * @param mesh Defines the mesh to check
  92398. * @returns true if active, false otherwise
  92399. */
  92400. isActiveMesh(mesh: Mesh): boolean;
  92401. /**
  92402. * Is this camera ready to be used/rendered
  92403. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92404. * @return true if the camera is ready
  92405. */
  92406. isReady(completeCheck?: boolean): boolean;
  92407. /** @hidden */
  92408. _initCache(): void;
  92409. /** @hidden */
  92410. _updateCache(ignoreParentClass?: boolean): void;
  92411. /** @hidden */
  92412. _isSynchronized(): boolean;
  92413. /** @hidden */
  92414. _isSynchronizedViewMatrix(): boolean;
  92415. /** @hidden */
  92416. _isSynchronizedProjectionMatrix(): boolean;
  92417. /**
  92418. * Attach the input controls to a specific dom element to get the input from.
  92419. * @param element Defines the element the controls should be listened from
  92420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92421. */
  92422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92423. /**
  92424. * Detach the current controls from the specified dom element.
  92425. * @param element Defines the element to stop listening the inputs from
  92426. */
  92427. detachControl(element: HTMLElement): void;
  92428. /**
  92429. * Update the camera state according to the different inputs gathered during the frame.
  92430. */
  92431. update(): void;
  92432. /** @hidden */
  92433. _checkInputs(): void;
  92434. /** @hidden */
  92435. readonly rigCameras: Camera[];
  92436. /**
  92437. * Gets the post process used by the rig cameras
  92438. */
  92439. readonly rigPostProcess: Nullable<PostProcess>;
  92440. /**
  92441. * Internal, gets the first post proces.
  92442. * @returns the first post process to be run on this camera.
  92443. */
  92444. _getFirstPostProcess(): Nullable<PostProcess>;
  92445. private _cascadePostProcessesToRigCams;
  92446. /**
  92447. * Attach a post process to the camera.
  92448. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92449. * @param postProcess The post process to attach to the camera
  92450. * @param insertAt The position of the post process in case several of them are in use in the scene
  92451. * @returns the position the post process has been inserted at
  92452. */
  92453. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  92454. /**
  92455. * Detach a post process to the camera.
  92456. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92457. * @param postProcess The post process to detach from the camera
  92458. */
  92459. detachPostProcess(postProcess: PostProcess): void;
  92460. /**
  92461. * Gets the current world matrix of the camera
  92462. */
  92463. getWorldMatrix(): Matrix;
  92464. /** @hidden */
  92465. _getViewMatrix(): Matrix;
  92466. /**
  92467. * Gets the current view matrix of the camera.
  92468. * @param force forces the camera to recompute the matrix without looking at the cached state
  92469. * @returns the view matrix
  92470. */
  92471. getViewMatrix(force?: boolean): Matrix;
  92472. /**
  92473. * Freeze the projection matrix.
  92474. * It will prevent the cache check of the camera projection compute and can speed up perf
  92475. * if no parameter of the camera are meant to change
  92476. * @param projection Defines manually a projection if necessary
  92477. */
  92478. freezeProjectionMatrix(projection?: Matrix): void;
  92479. /**
  92480. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  92481. */
  92482. unfreezeProjectionMatrix(): void;
  92483. /**
  92484. * Gets the current projection matrix of the camera.
  92485. * @param force forces the camera to recompute the matrix without looking at the cached state
  92486. * @returns the projection matrix
  92487. */
  92488. getProjectionMatrix(force?: boolean): Matrix;
  92489. /**
  92490. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  92491. * @returns a Matrix
  92492. */
  92493. getTransformationMatrix(): Matrix;
  92494. private _updateFrustumPlanes;
  92495. /**
  92496. * Checks if a cullable object (mesh...) is in the camera frustum
  92497. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  92498. * @param target The object to check
  92499. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  92500. * @returns true if the object is in frustum otherwise false
  92501. */
  92502. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  92503. /**
  92504. * Checks if a cullable object (mesh...) is in the camera frustum
  92505. * Unlike isInFrustum this cheks the full bounding box
  92506. * @param target The object to check
  92507. * @returns true if the object is in frustum otherwise false
  92508. */
  92509. isCompletelyInFrustum(target: ICullable): boolean;
  92510. /**
  92511. * Gets a ray in the forward direction from the camera.
  92512. * @param length Defines the length of the ray to create
  92513. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  92514. * @param origin Defines the start point of the ray which defaults to the camera position
  92515. * @returns the forward ray
  92516. */
  92517. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  92518. /**
  92519. * Releases resources associated with this node.
  92520. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92521. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92522. */
  92523. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92524. /** @hidden */
  92525. _isLeftCamera: boolean;
  92526. /**
  92527. * Gets the left camera of a rig setup in case of Rigged Camera
  92528. */
  92529. readonly isLeftCamera: boolean;
  92530. /** @hidden */
  92531. _isRightCamera: boolean;
  92532. /**
  92533. * Gets the right camera of a rig setup in case of Rigged Camera
  92534. */
  92535. readonly isRightCamera: boolean;
  92536. /**
  92537. * Gets the left camera of a rig setup in case of Rigged Camera
  92538. */
  92539. readonly leftCamera: Nullable<FreeCamera>;
  92540. /**
  92541. * Gets the right camera of a rig setup in case of Rigged Camera
  92542. */
  92543. readonly rightCamera: Nullable<FreeCamera>;
  92544. /**
  92545. * Gets the left camera target of a rig setup in case of Rigged Camera
  92546. * @returns the target position
  92547. */
  92548. getLeftTarget(): Nullable<Vector3>;
  92549. /**
  92550. * Gets the right camera target of a rig setup in case of Rigged Camera
  92551. * @returns the target position
  92552. */
  92553. getRightTarget(): Nullable<Vector3>;
  92554. /**
  92555. * @hidden
  92556. */
  92557. setCameraRigMode(mode: number, rigParams: any): void;
  92558. /** @hidden */
  92559. static _setStereoscopicRigMode(camera: Camera): void;
  92560. /** @hidden */
  92561. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  92562. /** @hidden */
  92563. static _setVRRigMode(camera: Camera, rigParams: any): void;
  92564. /** @hidden */
  92565. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  92566. /** @hidden */
  92567. _getVRProjectionMatrix(): Matrix;
  92568. protected _updateCameraRotationMatrix(): void;
  92569. protected _updateWebVRCameraRotationMatrix(): void;
  92570. /**
  92571. * This function MUST be overwritten by the different WebVR cameras available.
  92572. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92573. * @hidden
  92574. */
  92575. _getWebVRProjectionMatrix(): Matrix;
  92576. /**
  92577. * This function MUST be overwritten by the different WebVR cameras available.
  92578. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92579. * @hidden
  92580. */
  92581. _getWebVRViewMatrix(): Matrix;
  92582. /** @hidden */
  92583. setCameraRigParameter(name: string, value: any): void;
  92584. /**
  92585. * needs to be overridden by children so sub has required properties to be copied
  92586. * @hidden
  92587. */
  92588. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  92589. /**
  92590. * May need to be overridden by children
  92591. * @hidden
  92592. */
  92593. _updateRigCameras(): void;
  92594. /** @hidden */
  92595. _setupInputs(): void;
  92596. /**
  92597. * Serialiaze the camera setup to a json represention
  92598. * @returns the JSON representation
  92599. */
  92600. serialize(): any;
  92601. /**
  92602. * Clones the current camera.
  92603. * @param name The cloned camera name
  92604. * @returns the cloned camera
  92605. */
  92606. clone(name: string): Camera;
  92607. /**
  92608. * Gets the direction of the camera relative to a given local axis.
  92609. * @param localAxis Defines the reference axis to provide a relative direction.
  92610. * @return the direction
  92611. */
  92612. getDirection(localAxis: Vector3): Vector3;
  92613. /**
  92614. * Returns the current camera absolute rotation
  92615. */
  92616. readonly absoluteRotation: Quaternion;
  92617. /**
  92618. * Gets the direction of the camera relative to a given local axis into a passed vector.
  92619. * @param localAxis Defines the reference axis to provide a relative direction.
  92620. * @param result Defines the vector to store the result in
  92621. */
  92622. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  92623. /**
  92624. * Gets a camera constructor for a given camera type
  92625. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  92626. * @param name The name of the camera the result will be able to instantiate
  92627. * @param scene The scene the result will construct the camera in
  92628. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  92629. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  92630. * @returns a factory method to construc the camera
  92631. */
  92632. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  92633. /**
  92634. * Compute the world matrix of the camera.
  92635. * @returns the camera world matrix
  92636. */
  92637. computeWorldMatrix(): Matrix;
  92638. /**
  92639. * Parse a JSON and creates the camera from the parsed information
  92640. * @param parsedCamera The JSON to parse
  92641. * @param scene The scene to instantiate the camera in
  92642. * @returns the newly constructed camera
  92643. */
  92644. static Parse(parsedCamera: any, scene: Scene): Camera;
  92645. }
  92646. }
  92647. declare module BABYLON {
  92648. /**
  92649. * Class containing static functions to help procedurally build meshes
  92650. */
  92651. export class DiscBuilder {
  92652. /**
  92653. * Creates a plane polygonal mesh. By default, this is a disc
  92654. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  92655. * * 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
  92656. * * 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
  92657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92660. * @param name defines the name of the mesh
  92661. * @param options defines the options used to create the mesh
  92662. * @param scene defines the hosting scene
  92663. * @returns the plane polygonal mesh
  92664. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  92665. */
  92666. static CreateDisc(name: string, options: {
  92667. radius?: number;
  92668. tessellation?: number;
  92669. arc?: number;
  92670. updatable?: boolean;
  92671. sideOrientation?: number;
  92672. frontUVs?: Vector4;
  92673. backUVs?: Vector4;
  92674. }, scene?: Nullable<Scene>): Mesh;
  92675. }
  92676. }
  92677. declare module BABYLON {
  92678. /**
  92679. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  92680. *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.
  92681. * The SPS is also a particle system. It provides some methods to manage the particles.
  92682. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  92683. *
  92684. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  92685. */
  92686. export class SolidParticleSystem implements IDisposable {
  92687. /**
  92688. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  92689. * Example : var p = SPS.particles[i];
  92690. */
  92691. particles: SolidParticle[];
  92692. /**
  92693. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  92694. */
  92695. nbParticles: number;
  92696. /**
  92697. * If the particles must ever face the camera (default false). Useful for planar particles.
  92698. */
  92699. billboard: boolean;
  92700. /**
  92701. * Recompute normals when adding a shape
  92702. */
  92703. recomputeNormals: boolean;
  92704. /**
  92705. * This a counter ofr your own usage. It's not set by any SPS functions.
  92706. */
  92707. counter: number;
  92708. /**
  92709. * The SPS name. This name is also given to the underlying mesh.
  92710. */
  92711. name: string;
  92712. /**
  92713. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  92714. */
  92715. mesh: Mesh;
  92716. /**
  92717. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  92718. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92719. */
  92720. vars: any;
  92721. /**
  92722. * This array is populated when the SPS is set as 'pickable'.
  92723. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92724. * Each element of this array is an object `{idx: int, faceId: int}`.
  92725. * `idx` is the picked particle index in the `SPS.particles` array
  92726. * `faceId` is the picked face index counted within this particle.
  92727. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92728. */
  92729. pickedParticles: {
  92730. idx: number;
  92731. faceId: number;
  92732. }[];
  92733. /**
  92734. * This array is populated when `enableDepthSort` is set to true.
  92735. * Each element of this array is an instance of the class DepthSortedParticle.
  92736. */
  92737. depthSortedParticles: DepthSortedParticle[];
  92738. /**
  92739. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92740. * @hidden
  92741. */
  92742. _bSphereOnly: boolean;
  92743. /**
  92744. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92745. * @hidden
  92746. */
  92747. _bSphereRadiusFactor: number;
  92748. private _scene;
  92749. private _positions;
  92750. private _indices;
  92751. private _normals;
  92752. private _colors;
  92753. private _uvs;
  92754. private _indices32;
  92755. private _positions32;
  92756. private _normals32;
  92757. private _fixedNormal32;
  92758. private _colors32;
  92759. private _uvs32;
  92760. private _index;
  92761. private _updatable;
  92762. private _pickable;
  92763. private _isVisibilityBoxLocked;
  92764. private _alwaysVisible;
  92765. private _depthSort;
  92766. private _expandable;
  92767. private _shapeCounter;
  92768. private _copy;
  92769. private _color;
  92770. private _computeParticleColor;
  92771. private _computeParticleTexture;
  92772. private _computeParticleRotation;
  92773. private _computeParticleVertex;
  92774. private _computeBoundingBox;
  92775. private _depthSortParticles;
  92776. private _camera;
  92777. private _mustUnrotateFixedNormals;
  92778. private _particlesIntersect;
  92779. private _needs32Bits;
  92780. private _isNotBuilt;
  92781. /**
  92782. * Creates a SPS (Solid Particle System) object.
  92783. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92784. * @param scene (Scene) is the scene in which the SPS is added.
  92785. * @param options defines the options of the sps e.g.
  92786. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92787. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92788. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92789. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  92790. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92791. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92792. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92793. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92794. */
  92795. constructor(name: string, scene: Scene, options?: {
  92796. updatable?: boolean;
  92797. isPickable?: boolean;
  92798. enableDepthSort?: boolean;
  92799. particleIntersection?: boolean;
  92800. boundingSphereOnly?: boolean;
  92801. bSphereRadiusFactor?: number;
  92802. expandable?: boolean;
  92803. });
  92804. /**
  92805. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92806. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92807. * @returns the created mesh
  92808. */
  92809. buildMesh(): Mesh;
  92810. /**
  92811. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92812. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92813. * Thus the particles generated from `digest()` have their property `position` set yet.
  92814. * @param mesh ( Mesh ) is the mesh to be digested
  92815. * @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
  92816. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92817. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92818. * @returns the current SPS
  92819. */
  92820. digest(mesh: Mesh, options?: {
  92821. facetNb?: number;
  92822. number?: number;
  92823. delta?: number;
  92824. }): SolidParticleSystem;
  92825. private _unrotateFixedNormals;
  92826. private _resetCopy;
  92827. private _meshBuilder;
  92828. private _posToShape;
  92829. private _uvsToShapeUV;
  92830. private _addParticle;
  92831. /**
  92832. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92833. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92834. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92835. * @param nb (positive integer) the number of particles to be created from this model
  92836. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92837. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92838. * @returns the number of shapes in the system
  92839. */
  92840. addShape(mesh: Mesh, nb: number, options?: {
  92841. positionFunction?: any;
  92842. vertexFunction?: any;
  92843. }): number;
  92844. private _rebuildParticle;
  92845. /**
  92846. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92847. * @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.
  92848. * @returns the SPS.
  92849. */
  92850. rebuildMesh(reset?: boolean): SolidParticleSystem;
  92851. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  92852. * Returns an array with the removed particles.
  92853. * 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.
  92854. * The SPS can't be empty so at least one particle needs to remain in place.
  92855. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  92856. * @param start index of the first particle to remove
  92857. * @param end index of the last particle to remove (included)
  92858. * @returns an array populated with the removed particles
  92859. */
  92860. removeParticles(start: number, end: number): SolidParticle[];
  92861. /**
  92862. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92863. * This method calls `updateParticle()` for each particle of the SPS.
  92864. * For an animated SPS, it is usually called within the render loop.
  92865. * 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.
  92866. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92867. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92868. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92869. * @returns the SPS.
  92870. */
  92871. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92872. /**
  92873. * Disposes the SPS.
  92874. */
  92875. dispose(): void;
  92876. /**
  92877. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92878. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92879. * @returns the SPS.
  92880. */
  92881. refreshVisibleSize(): SolidParticleSystem;
  92882. /**
  92883. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92884. * @param size the size (float) of the visibility box
  92885. * note : this doesn't lock the SPS mesh bounding box.
  92886. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92887. */
  92888. setVisibilityBox(size: number): void;
  92889. /**
  92890. * Gets whether the SPS as always visible or not
  92891. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92892. */
  92893. /**
  92894. * Sets the SPS as always visible or not
  92895. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92896. */
  92897. isAlwaysVisible: boolean;
  92898. /**
  92899. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92900. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92901. */
  92902. /**
  92903. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92904. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92905. */
  92906. isVisibilityBoxLocked: boolean;
  92907. /**
  92908. * Tells to `setParticles()` to compute the particle rotations or not.
  92909. * Default value : true. The SPS is faster when it's set to false.
  92910. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92911. */
  92912. /**
  92913. * Gets if `setParticles()` computes the particle rotations or not.
  92914. * Default value : true. The SPS is faster when it's set to false.
  92915. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92916. */
  92917. computeParticleRotation: boolean;
  92918. /**
  92919. * Tells to `setParticles()` to compute the particle colors or not.
  92920. * Default value : true. The SPS is faster when it's set to false.
  92921. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92922. */
  92923. /**
  92924. * Gets if `setParticles()` computes the particle colors or not.
  92925. * Default value : true. The SPS is faster when it's set to false.
  92926. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92927. */
  92928. computeParticleColor: boolean;
  92929. /**
  92930. * Gets if `setParticles()` computes the particle textures or not.
  92931. * Default value : true. The SPS is faster when it's set to false.
  92932. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92933. */
  92934. computeParticleTexture: boolean;
  92935. /**
  92936. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92937. * Default value : false. The SPS is faster when it's set to false.
  92938. * Note : the particle custom vertex positions aren't stored values.
  92939. */
  92940. /**
  92941. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92942. * Default value : false. The SPS is faster when it's set to false.
  92943. * Note : the particle custom vertex positions aren't stored values.
  92944. */
  92945. computeParticleVertex: boolean;
  92946. /**
  92947. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92948. */
  92949. /**
  92950. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92951. */
  92952. computeBoundingBox: boolean;
  92953. /**
  92954. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92955. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92956. * Default : `true`
  92957. */
  92958. /**
  92959. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92960. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92961. * Default : `true`
  92962. */
  92963. depthSortParticles: boolean;
  92964. /**
  92965. * Gets if the SPS is created as expandable at construction time.
  92966. * Default : `false`
  92967. */
  92968. readonly expandable: boolean;
  92969. /**
  92970. * This function does nothing. It may be overwritten to set all the particle first values.
  92971. * The SPS doesn't call this function, you may have to call it by your own.
  92972. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92973. */
  92974. initParticles(): void;
  92975. /**
  92976. * This function does nothing. It may be overwritten to recycle a particle.
  92977. * The SPS doesn't call this function, you may have to call it by your own.
  92978. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92979. * @param particle The particle to recycle
  92980. * @returns the recycled particle
  92981. */
  92982. recycleParticle(particle: SolidParticle): SolidParticle;
  92983. /**
  92984. * Updates a particle : this function should be overwritten by the user.
  92985. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92986. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92987. * @example : just set a particle position or velocity and recycle conditions
  92988. * @param particle The particle to update
  92989. * @returns the updated particle
  92990. */
  92991. updateParticle(particle: SolidParticle): SolidParticle;
  92992. /**
  92993. * Updates a vertex of a particle : it can be overwritten by the user.
  92994. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92995. * @param particle the current particle
  92996. * @param vertex the current index of the current particle
  92997. * @param pt the index of the current vertex in the particle shape
  92998. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92999. * @example : just set a vertex particle position
  93000. * @returns the updated vertex
  93001. */
  93002. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  93003. /**
  93004. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  93005. * This does nothing and may be overwritten by the user.
  93006. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93007. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93008. * @param update the boolean update value actually passed to setParticles()
  93009. */
  93010. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93011. /**
  93012. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  93013. * This will be passed three parameters.
  93014. * This does nothing and may be overwritten by the user.
  93015. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93016. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93017. * @param update the boolean update value actually passed to setParticles()
  93018. */
  93019. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93020. }
  93021. }
  93022. declare module BABYLON {
  93023. /**
  93024. * Represents one particle of a solid particle system.
  93025. */
  93026. export class SolidParticle {
  93027. /**
  93028. * particle global index
  93029. */
  93030. idx: number;
  93031. /**
  93032. * The color of the particle
  93033. */
  93034. color: Nullable<Color4>;
  93035. /**
  93036. * The world space position of the particle.
  93037. */
  93038. position: Vector3;
  93039. /**
  93040. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  93041. */
  93042. rotation: Vector3;
  93043. /**
  93044. * The world space rotation quaternion of the particle.
  93045. */
  93046. rotationQuaternion: Nullable<Quaternion>;
  93047. /**
  93048. * The scaling of the particle.
  93049. */
  93050. scaling: Vector3;
  93051. /**
  93052. * The uvs of the particle.
  93053. */
  93054. uvs: Vector4;
  93055. /**
  93056. * The current speed of the particle.
  93057. */
  93058. velocity: Vector3;
  93059. /**
  93060. * The pivot point in the particle local space.
  93061. */
  93062. pivot: Vector3;
  93063. /**
  93064. * Must the particle be translated from its pivot point in its local space ?
  93065. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  93066. * Default : false
  93067. */
  93068. translateFromPivot: boolean;
  93069. /**
  93070. * Is the particle active or not ?
  93071. */
  93072. alive: boolean;
  93073. /**
  93074. * Is the particle visible or not ?
  93075. */
  93076. isVisible: boolean;
  93077. /**
  93078. * Index of this particle in the global "positions" array (Internal use)
  93079. * @hidden
  93080. */
  93081. _pos: number;
  93082. /**
  93083. * @hidden Index of this particle in the global "indices" array (Internal use)
  93084. */
  93085. _ind: number;
  93086. /**
  93087. * @hidden ModelShape of this particle (Internal use)
  93088. */
  93089. _model: ModelShape;
  93090. /**
  93091. * ModelShape id of this particle
  93092. */
  93093. shapeId: number;
  93094. /**
  93095. * Index of the particle in its shape id
  93096. */
  93097. idxInShape: number;
  93098. /**
  93099. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  93100. */
  93101. _modelBoundingInfo: BoundingInfo;
  93102. /**
  93103. * @hidden Particle BoundingInfo object (Internal use)
  93104. */
  93105. _boundingInfo: BoundingInfo;
  93106. /**
  93107. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  93108. */
  93109. _sps: SolidParticleSystem;
  93110. /**
  93111. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  93112. */
  93113. _stillInvisible: boolean;
  93114. /**
  93115. * @hidden Last computed particle rotation matrix
  93116. */
  93117. _rotationMatrix: number[];
  93118. /**
  93119. * Parent particle Id, if any.
  93120. * Default null.
  93121. */
  93122. parentId: Nullable<number>;
  93123. /**
  93124. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  93125. * The possible values are :
  93126. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93127. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93128. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93129. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93130. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93131. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  93132. * */
  93133. cullingStrategy: number;
  93134. /**
  93135. * @hidden Internal global position in the SPS.
  93136. */
  93137. _globalPosition: Vector3;
  93138. /**
  93139. * Creates a Solid Particle object.
  93140. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  93141. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  93142. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  93143. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  93144. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  93145. * @param shapeId (integer) is the model shape identifier in the SPS.
  93146. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  93147. * @param sps defines the sps it is associated to
  93148. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  93149. */
  93150. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  93151. /**
  93152. * Legacy support, changed scale to scaling
  93153. */
  93154. /**
  93155. * Legacy support, changed scale to scaling
  93156. */
  93157. scale: Vector3;
  93158. /**
  93159. * Legacy support, changed quaternion to rotationQuaternion
  93160. */
  93161. /**
  93162. * Legacy support, changed quaternion to rotationQuaternion
  93163. */
  93164. quaternion: Nullable<Quaternion>;
  93165. /**
  93166. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  93167. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  93168. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  93169. * @returns true if it intersects
  93170. */
  93171. intersectsMesh(target: Mesh | SolidParticle): boolean;
  93172. /**
  93173. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  93174. * A particle is in the frustum if its bounding box intersects the frustum
  93175. * @param frustumPlanes defines the frustum to test
  93176. * @returns true if the particle is in the frustum planes
  93177. */
  93178. isInFrustum(frustumPlanes: Plane[]): boolean;
  93179. /**
  93180. * get the rotation matrix of the particle
  93181. * @hidden
  93182. */
  93183. getRotationMatrix(m: Matrix): void;
  93184. }
  93185. /**
  93186. * Represents the shape of the model used by one particle of a solid particle system.
  93187. * SPS internal tool, don't use it manually.
  93188. */
  93189. export class ModelShape {
  93190. /**
  93191. * The shape id
  93192. * @hidden
  93193. */
  93194. shapeID: number;
  93195. /**
  93196. * flat array of model positions (internal use)
  93197. * @hidden
  93198. */
  93199. _shape: Vector3[];
  93200. /**
  93201. * flat array of model UVs (internal use)
  93202. * @hidden
  93203. */
  93204. _shapeUV: number[];
  93205. /**
  93206. * color array of the model
  93207. * @hidden
  93208. */
  93209. _shapeColors: number[];
  93210. /**
  93211. * indices array of the model
  93212. * @hidden
  93213. */
  93214. _indices: number[];
  93215. /**
  93216. * normals array of the model
  93217. * @hidden
  93218. */
  93219. _normals: number[];
  93220. /**
  93221. * length of the shape in the model indices array (internal use)
  93222. * @hidden
  93223. */
  93224. _indicesLength: number;
  93225. /**
  93226. * Custom position function (internal use)
  93227. * @hidden
  93228. */
  93229. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  93230. /**
  93231. * Custom vertex function (internal use)
  93232. * @hidden
  93233. */
  93234. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  93235. /**
  93236. * 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.
  93237. * SPS internal tool, don't use it manually.
  93238. * @hidden
  93239. */
  93240. 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>);
  93241. }
  93242. /**
  93243. * Represents a Depth Sorted Particle in the solid particle system.
  93244. */
  93245. export class DepthSortedParticle {
  93246. /**
  93247. * Index of the particle in the "indices" array
  93248. */
  93249. ind: number;
  93250. /**
  93251. * Length of the particle shape in the "indices" array
  93252. */
  93253. indicesLength: number;
  93254. /**
  93255. * Squared distance from the particle to the camera
  93256. */
  93257. sqDistance: number;
  93258. }
  93259. }
  93260. declare module BABYLON {
  93261. /**
  93262. * @hidden
  93263. */
  93264. export class _MeshCollisionData {
  93265. _checkCollisions: boolean;
  93266. _collisionMask: number;
  93267. _collisionGroup: number;
  93268. _collider: Nullable<Collider>;
  93269. _oldPositionForCollisions: Vector3;
  93270. _diffPositionForCollisions: Vector3;
  93271. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  93272. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  93273. }
  93274. }
  93275. declare module BABYLON {
  93276. /** @hidden */
  93277. class _FacetDataStorage {
  93278. facetPositions: Vector3[];
  93279. facetNormals: Vector3[];
  93280. facetPartitioning: number[][];
  93281. facetNb: number;
  93282. partitioningSubdivisions: number;
  93283. partitioningBBoxRatio: number;
  93284. facetDataEnabled: boolean;
  93285. facetParameters: any;
  93286. bbSize: Vector3;
  93287. subDiv: {
  93288. max: number;
  93289. X: number;
  93290. Y: number;
  93291. Z: number;
  93292. };
  93293. facetDepthSort: boolean;
  93294. facetDepthSortEnabled: boolean;
  93295. depthSortedIndices: IndicesArray;
  93296. depthSortedFacets: {
  93297. ind: number;
  93298. sqDistance: number;
  93299. }[];
  93300. facetDepthSortFunction: (f1: {
  93301. ind: number;
  93302. sqDistance: number;
  93303. }, f2: {
  93304. ind: number;
  93305. sqDistance: number;
  93306. }) => number;
  93307. facetDepthSortFrom: Vector3;
  93308. facetDepthSortOrigin: Vector3;
  93309. invertedMatrix: Matrix;
  93310. }
  93311. /**
  93312. * @hidden
  93313. **/
  93314. class _InternalAbstractMeshDataInfo {
  93315. _hasVertexAlpha: boolean;
  93316. _useVertexColors: boolean;
  93317. _numBoneInfluencers: number;
  93318. _applyFog: boolean;
  93319. _receiveShadows: boolean;
  93320. _facetData: _FacetDataStorage;
  93321. _visibility: number;
  93322. _skeleton: Nullable<Skeleton>;
  93323. _layerMask: number;
  93324. _computeBonesUsingShaders: boolean;
  93325. _isActive: boolean;
  93326. _onlyForInstances: boolean;
  93327. _isActiveIntermediate: boolean;
  93328. _onlyForInstancesIntermediate: boolean;
  93329. _actAsRegularMesh: boolean;
  93330. }
  93331. /**
  93332. * Class used to store all common mesh properties
  93333. */
  93334. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  93335. /** No occlusion */
  93336. static OCCLUSION_TYPE_NONE: number;
  93337. /** Occlusion set to optimisitic */
  93338. static OCCLUSION_TYPE_OPTIMISTIC: number;
  93339. /** Occlusion set to strict */
  93340. static OCCLUSION_TYPE_STRICT: number;
  93341. /** Use an accurante occlusion algorithm */
  93342. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  93343. /** Use a conservative occlusion algorithm */
  93344. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  93345. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  93346. * Test order :
  93347. * Is the bounding sphere outside the frustum ?
  93348. * If not, are the bounding box vertices outside the frustum ?
  93349. * It not, then the cullable object is in the frustum.
  93350. */
  93351. static readonly CULLINGSTRATEGY_STANDARD: number;
  93352. /** Culling strategy : Bounding Sphere Only.
  93353. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  93354. * It's also less accurate than the standard because some not visible objects can still be selected.
  93355. * Test : is the bounding sphere outside the frustum ?
  93356. * If not, then the cullable object is in the frustum.
  93357. */
  93358. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  93359. /** Culling strategy : Optimistic Inclusion.
  93360. * This in an inclusion test first, then the standard exclusion test.
  93361. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  93362. * 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.
  93363. * Anyway, it's as accurate as the standard strategy.
  93364. * Test :
  93365. * Is the cullable object bounding sphere center in the frustum ?
  93366. * If not, apply the default culling strategy.
  93367. */
  93368. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  93369. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  93370. * This in an inclusion test first, then the bounding sphere only exclusion test.
  93371. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  93372. * 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.
  93373. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  93374. * Test :
  93375. * Is the cullable object bounding sphere center in the frustum ?
  93376. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  93377. */
  93378. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  93379. /**
  93380. * No billboard
  93381. */
  93382. static readonly BILLBOARDMODE_NONE: number;
  93383. /** Billboard on X axis */
  93384. static readonly BILLBOARDMODE_X: number;
  93385. /** Billboard on Y axis */
  93386. static readonly BILLBOARDMODE_Y: number;
  93387. /** Billboard on Z axis */
  93388. static readonly BILLBOARDMODE_Z: number;
  93389. /** Billboard on all axes */
  93390. static readonly BILLBOARDMODE_ALL: number;
  93391. /** Billboard on using position instead of orientation */
  93392. static readonly BILLBOARDMODE_USE_POSITION: number;
  93393. /** @hidden */
  93394. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  93395. /**
  93396. * The culling strategy to use to check whether the mesh must be rendered or not.
  93397. * This value can be changed at any time and will be used on the next render mesh selection.
  93398. * The possible values are :
  93399. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93400. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93401. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93402. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93403. * Please read each static variable documentation to get details about the culling process.
  93404. * */
  93405. cullingStrategy: number;
  93406. /**
  93407. * Gets the number of facets in the mesh
  93408. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93409. */
  93410. readonly facetNb: number;
  93411. /**
  93412. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  93413. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93414. */
  93415. partitioningSubdivisions: number;
  93416. /**
  93417. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  93418. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  93419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93420. */
  93421. partitioningBBoxRatio: number;
  93422. /**
  93423. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  93424. * Works only for updatable meshes.
  93425. * Doesn't work with multi-materials
  93426. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93427. */
  93428. mustDepthSortFacets: boolean;
  93429. /**
  93430. * The location (Vector3) where the facet depth sort must be computed from.
  93431. * By default, the active camera position.
  93432. * Used only when facet depth sort is enabled
  93433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93434. */
  93435. facetDepthSortFrom: Vector3;
  93436. /**
  93437. * gets a boolean indicating if facetData is enabled
  93438. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93439. */
  93440. readonly isFacetDataEnabled: boolean;
  93441. /** @hidden */
  93442. _updateNonUniformScalingState(value: boolean): boolean;
  93443. /**
  93444. * An event triggered when this mesh collides with another one
  93445. */
  93446. onCollideObservable: Observable<AbstractMesh>;
  93447. /** Set a function to call when this mesh collides with another one */
  93448. onCollide: () => void;
  93449. /**
  93450. * An event triggered when the collision's position changes
  93451. */
  93452. onCollisionPositionChangeObservable: Observable<Vector3>;
  93453. /** Set a function to call when the collision's position changes */
  93454. onCollisionPositionChange: () => void;
  93455. /**
  93456. * An event triggered when material is changed
  93457. */
  93458. onMaterialChangedObservable: Observable<AbstractMesh>;
  93459. /**
  93460. * Gets or sets the orientation for POV movement & rotation
  93461. */
  93462. definedFacingForward: boolean;
  93463. /** @hidden */
  93464. _occlusionQuery: Nullable<WebGLQuery>;
  93465. /** @hidden */
  93466. _renderingGroup: Nullable<RenderingGroup>;
  93467. /**
  93468. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93469. */
  93470. /**
  93471. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93472. */
  93473. visibility: number;
  93474. /** Gets or sets the alpha index used to sort transparent meshes
  93475. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  93476. */
  93477. alphaIndex: number;
  93478. /**
  93479. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  93480. */
  93481. isVisible: boolean;
  93482. /**
  93483. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  93484. */
  93485. isPickable: boolean;
  93486. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  93487. showSubMeshesBoundingBox: boolean;
  93488. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  93489. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  93490. */
  93491. isBlocker: boolean;
  93492. /**
  93493. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  93494. */
  93495. enablePointerMoveEvents: boolean;
  93496. /**
  93497. * Specifies the rendering group id for this mesh (0 by default)
  93498. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  93499. */
  93500. renderingGroupId: number;
  93501. private _material;
  93502. /** Gets or sets current material */
  93503. material: Nullable<Material>;
  93504. /**
  93505. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  93506. * @see http://doc.babylonjs.com/babylon101/shadows
  93507. */
  93508. receiveShadows: boolean;
  93509. /** Defines color to use when rendering outline */
  93510. outlineColor: Color3;
  93511. /** Define width to use when rendering outline */
  93512. outlineWidth: number;
  93513. /** Defines color to use when rendering overlay */
  93514. overlayColor: Color3;
  93515. /** Defines alpha to use when rendering overlay */
  93516. overlayAlpha: number;
  93517. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  93518. hasVertexAlpha: boolean;
  93519. /** 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) */
  93520. useVertexColors: boolean;
  93521. /**
  93522. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  93523. */
  93524. computeBonesUsingShaders: boolean;
  93525. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  93526. numBoneInfluencers: number;
  93527. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  93528. applyFog: boolean;
  93529. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  93530. useOctreeForRenderingSelection: boolean;
  93531. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  93532. useOctreeForPicking: boolean;
  93533. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  93534. useOctreeForCollisions: boolean;
  93535. /**
  93536. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  93537. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  93538. */
  93539. layerMask: number;
  93540. /**
  93541. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  93542. */
  93543. alwaysSelectAsActiveMesh: boolean;
  93544. /**
  93545. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  93546. */
  93547. doNotSyncBoundingInfo: boolean;
  93548. /**
  93549. * Gets or sets the current action manager
  93550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93551. */
  93552. actionManager: Nullable<AbstractActionManager>;
  93553. private _meshCollisionData;
  93554. /**
  93555. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  93556. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93557. */
  93558. ellipsoid: Vector3;
  93559. /**
  93560. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  93561. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93562. */
  93563. ellipsoidOffset: Vector3;
  93564. /**
  93565. * Gets or sets a collision mask used to mask collisions (default is -1).
  93566. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93567. */
  93568. collisionMask: number;
  93569. /**
  93570. * Gets or sets the current collision group mask (-1 by default).
  93571. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93572. */
  93573. collisionGroup: number;
  93574. /**
  93575. * Defines edge width used when edgesRenderer is enabled
  93576. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93577. */
  93578. edgesWidth: number;
  93579. /**
  93580. * Defines edge color used when edgesRenderer is enabled
  93581. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93582. */
  93583. edgesColor: Color4;
  93584. /** @hidden */
  93585. _edgesRenderer: Nullable<IEdgesRenderer>;
  93586. /** @hidden */
  93587. _masterMesh: Nullable<AbstractMesh>;
  93588. /** @hidden */
  93589. _boundingInfo: Nullable<BoundingInfo>;
  93590. /** @hidden */
  93591. _renderId: number;
  93592. /**
  93593. * Gets or sets the list of subMeshes
  93594. * @see http://doc.babylonjs.com/how_to/multi_materials
  93595. */
  93596. subMeshes: SubMesh[];
  93597. /** @hidden */
  93598. _intersectionsInProgress: AbstractMesh[];
  93599. /** @hidden */
  93600. _unIndexed: boolean;
  93601. /** @hidden */
  93602. _lightSources: Light[];
  93603. /** Gets the list of lights affecting that mesh */
  93604. readonly lightSources: Light[];
  93605. /** @hidden */
  93606. readonly _positions: Nullable<Vector3[]>;
  93607. /** @hidden */
  93608. _waitingData: {
  93609. lods: Nullable<any>;
  93610. actions: Nullable<any>;
  93611. freezeWorldMatrix: Nullable<boolean>;
  93612. };
  93613. /** @hidden */
  93614. _bonesTransformMatrices: Nullable<Float32Array>;
  93615. /** @hidden */
  93616. _transformMatrixTexture: Nullable<RawTexture>;
  93617. /**
  93618. * Gets or sets a skeleton to apply skining transformations
  93619. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93620. */
  93621. skeleton: Nullable<Skeleton>;
  93622. /**
  93623. * An event triggered when the mesh is rebuilt.
  93624. */
  93625. onRebuildObservable: Observable<AbstractMesh>;
  93626. /**
  93627. * Creates a new AbstractMesh
  93628. * @param name defines the name of the mesh
  93629. * @param scene defines the hosting scene
  93630. */
  93631. constructor(name: string, scene?: Nullable<Scene>);
  93632. /**
  93633. * Returns the string "AbstractMesh"
  93634. * @returns "AbstractMesh"
  93635. */
  93636. getClassName(): string;
  93637. /**
  93638. * Gets a string representation of the current mesh
  93639. * @param fullDetails defines a boolean indicating if full details must be included
  93640. * @returns a string representation of the current mesh
  93641. */
  93642. toString(fullDetails?: boolean): string;
  93643. /**
  93644. * @hidden
  93645. */
  93646. protected _getEffectiveParent(): Nullable<Node>;
  93647. /** @hidden */
  93648. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93649. /** @hidden */
  93650. _rebuild(): void;
  93651. /** @hidden */
  93652. _resyncLightSources(): void;
  93653. /** @hidden */
  93654. _resyncLighSource(light: Light): void;
  93655. /** @hidden */
  93656. _unBindEffect(): void;
  93657. /** @hidden */
  93658. _removeLightSource(light: Light, dispose: boolean): void;
  93659. private _markSubMeshesAsDirty;
  93660. /** @hidden */
  93661. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  93662. /** @hidden */
  93663. _markSubMeshesAsAttributesDirty(): void;
  93664. /** @hidden */
  93665. _markSubMeshesAsMiscDirty(): void;
  93666. /**
  93667. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  93668. */
  93669. scaling: Vector3;
  93670. /**
  93671. * Returns true if the mesh is blocked. Implemented by child classes
  93672. */
  93673. readonly isBlocked: boolean;
  93674. /**
  93675. * Returns the mesh itself by default. Implemented by child classes
  93676. * @param camera defines the camera to use to pick the right LOD level
  93677. * @returns the currentAbstractMesh
  93678. */
  93679. getLOD(camera: Camera): Nullable<AbstractMesh>;
  93680. /**
  93681. * Returns 0 by default. Implemented by child classes
  93682. * @returns an integer
  93683. */
  93684. getTotalVertices(): number;
  93685. /**
  93686. * Returns a positive integer : the total number of indices in this mesh geometry.
  93687. * @returns the numner of indices or zero if the mesh has no geometry.
  93688. */
  93689. getTotalIndices(): number;
  93690. /**
  93691. * Returns null by default. Implemented by child classes
  93692. * @returns null
  93693. */
  93694. getIndices(): Nullable<IndicesArray>;
  93695. /**
  93696. * Returns the array of the requested vertex data kind. Implemented by child classes
  93697. * @param kind defines the vertex data kind to use
  93698. * @returns null
  93699. */
  93700. getVerticesData(kind: string): Nullable<FloatArray>;
  93701. /**
  93702. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93703. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93704. * Note that a new underlying VertexBuffer object is created each call.
  93705. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93706. * @param kind defines vertex data kind:
  93707. * * VertexBuffer.PositionKind
  93708. * * VertexBuffer.UVKind
  93709. * * VertexBuffer.UV2Kind
  93710. * * VertexBuffer.UV3Kind
  93711. * * VertexBuffer.UV4Kind
  93712. * * VertexBuffer.UV5Kind
  93713. * * VertexBuffer.UV6Kind
  93714. * * VertexBuffer.ColorKind
  93715. * * VertexBuffer.MatricesIndicesKind
  93716. * * VertexBuffer.MatricesIndicesExtraKind
  93717. * * VertexBuffer.MatricesWeightsKind
  93718. * * VertexBuffer.MatricesWeightsExtraKind
  93719. * @param data defines the data source
  93720. * @param updatable defines if the data must be flagged as updatable (or static)
  93721. * @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
  93722. * @returns the current mesh
  93723. */
  93724. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93725. /**
  93726. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93727. * If the mesh has no geometry, it is simply returned as it is.
  93728. * @param kind defines vertex data kind:
  93729. * * VertexBuffer.PositionKind
  93730. * * VertexBuffer.UVKind
  93731. * * VertexBuffer.UV2Kind
  93732. * * VertexBuffer.UV3Kind
  93733. * * VertexBuffer.UV4Kind
  93734. * * VertexBuffer.UV5Kind
  93735. * * VertexBuffer.UV6Kind
  93736. * * VertexBuffer.ColorKind
  93737. * * VertexBuffer.MatricesIndicesKind
  93738. * * VertexBuffer.MatricesIndicesExtraKind
  93739. * * VertexBuffer.MatricesWeightsKind
  93740. * * VertexBuffer.MatricesWeightsExtraKind
  93741. * @param data defines the data source
  93742. * @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
  93743. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  93744. * @returns the current mesh
  93745. */
  93746. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93747. /**
  93748. * Sets the mesh indices,
  93749. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93750. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93751. * @param totalVertices Defines the total number of vertices
  93752. * @returns the current mesh
  93753. */
  93754. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93755. /**
  93756. * Gets a boolean indicating if specific vertex data is present
  93757. * @param kind defines the vertex data kind to use
  93758. * @returns true is data kind is present
  93759. */
  93760. isVerticesDataPresent(kind: string): boolean;
  93761. /**
  93762. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93763. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93764. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93765. * @returns a BoundingInfo
  93766. */
  93767. getBoundingInfo(): BoundingInfo;
  93768. /**
  93769. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93770. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93771. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93772. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93773. * @returns the current mesh
  93774. */
  93775. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93776. /**
  93777. * Overwrite the current bounding info
  93778. * @param boundingInfo defines the new bounding info
  93779. * @returns the current mesh
  93780. */
  93781. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93782. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93783. readonly useBones: boolean;
  93784. /** @hidden */
  93785. _preActivate(): void;
  93786. /** @hidden */
  93787. _preActivateForIntermediateRendering(renderId: number): void;
  93788. /** @hidden */
  93789. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93790. /** @hidden */
  93791. _postActivate(): void;
  93792. /** @hidden */
  93793. _freeze(): void;
  93794. /** @hidden */
  93795. _unFreeze(): void;
  93796. /**
  93797. * Gets the current world matrix
  93798. * @returns a Matrix
  93799. */
  93800. getWorldMatrix(): Matrix;
  93801. /** @hidden */
  93802. _getWorldMatrixDeterminant(): number;
  93803. /**
  93804. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93805. */
  93806. readonly isAnInstance: boolean;
  93807. /**
  93808. * Gets a boolean indicating if this mesh has instances
  93809. */
  93810. readonly hasInstances: boolean;
  93811. /**
  93812. * Perform relative position change from the point of view of behind the front of the mesh.
  93813. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93814. * Supports definition of mesh facing forward or backward
  93815. * @param amountRight defines the distance on the right axis
  93816. * @param amountUp defines the distance on the up axis
  93817. * @param amountForward defines the distance on the forward axis
  93818. * @returns the current mesh
  93819. */
  93820. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93821. /**
  93822. * Calculate relative position change from the point of view of behind the front of the mesh.
  93823. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93824. * Supports definition of mesh facing forward or backward
  93825. * @param amountRight defines the distance on the right axis
  93826. * @param amountUp defines the distance on the up axis
  93827. * @param amountForward defines the distance on the forward axis
  93828. * @returns the new displacement vector
  93829. */
  93830. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93831. /**
  93832. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93833. * Supports definition of mesh facing forward or backward
  93834. * @param flipBack defines the flip
  93835. * @param twirlClockwise defines the twirl
  93836. * @param tiltRight defines the tilt
  93837. * @returns the current mesh
  93838. */
  93839. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93840. /**
  93841. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93842. * Supports definition of mesh facing forward or backward.
  93843. * @param flipBack defines the flip
  93844. * @param twirlClockwise defines the twirl
  93845. * @param tiltRight defines the tilt
  93846. * @returns the new rotation vector
  93847. */
  93848. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93849. /**
  93850. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93851. * This means the mesh underlying bounding box and sphere are recomputed.
  93852. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93853. * @returns the current mesh
  93854. */
  93855. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93856. /** @hidden */
  93857. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93858. /** @hidden */
  93859. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93860. /** @hidden */
  93861. _updateBoundingInfo(): AbstractMesh;
  93862. /** @hidden */
  93863. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93864. /** @hidden */
  93865. protected _afterComputeWorldMatrix(): void;
  93866. /** @hidden */
  93867. readonly _effectiveMesh: AbstractMesh;
  93868. /**
  93869. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93870. * A mesh is in the frustum if its bounding box intersects the frustum
  93871. * @param frustumPlanes defines the frustum to test
  93872. * @returns true if the mesh is in the frustum planes
  93873. */
  93874. isInFrustum(frustumPlanes: Plane[]): boolean;
  93875. /**
  93876. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93877. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93878. * @param frustumPlanes defines the frustum to test
  93879. * @returns true if the mesh is completely in the frustum planes
  93880. */
  93881. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93882. /**
  93883. * True if the mesh intersects another mesh or a SolidParticle object
  93884. * @param mesh defines a target mesh or SolidParticle to test
  93885. * @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)
  93886. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93887. * @returns true if there is an intersection
  93888. */
  93889. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93890. /**
  93891. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93892. * @param point defines the point to test
  93893. * @returns true if there is an intersection
  93894. */
  93895. intersectsPoint(point: Vector3): boolean;
  93896. /**
  93897. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93898. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93899. */
  93900. checkCollisions: boolean;
  93901. /**
  93902. * Gets Collider object used to compute collisions (not physics)
  93903. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93904. */
  93905. readonly collider: Nullable<Collider>;
  93906. /**
  93907. * Move the mesh using collision engine
  93908. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93909. * @param displacement defines the requested displacement vector
  93910. * @returns the current mesh
  93911. */
  93912. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93913. private _onCollisionPositionChange;
  93914. /** @hidden */
  93915. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93916. /** @hidden */
  93917. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93918. /** @hidden */
  93919. _checkCollision(collider: Collider): AbstractMesh;
  93920. /** @hidden */
  93921. _generatePointsArray(): boolean;
  93922. /**
  93923. * Checks if the passed Ray intersects with the mesh
  93924. * @param ray defines the ray to use
  93925. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93926. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93927. * @returns the picking info
  93928. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93929. */
  93930. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93931. /**
  93932. * Clones the current mesh
  93933. * @param name defines the mesh name
  93934. * @param newParent defines the new mesh parent
  93935. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93936. * @returns the new mesh
  93937. */
  93938. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93939. /**
  93940. * Disposes all the submeshes of the current meshnp
  93941. * @returns the current mesh
  93942. */
  93943. releaseSubMeshes(): AbstractMesh;
  93944. /**
  93945. * Releases resources associated with this abstract mesh.
  93946. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93947. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93948. */
  93949. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93950. /**
  93951. * Adds the passed mesh as a child to the current mesh
  93952. * @param mesh defines the child mesh
  93953. * @returns the current mesh
  93954. */
  93955. addChild(mesh: AbstractMesh): AbstractMesh;
  93956. /**
  93957. * Removes the passed mesh from the current mesh children list
  93958. * @param mesh defines the child mesh
  93959. * @returns the current mesh
  93960. */
  93961. removeChild(mesh: AbstractMesh): AbstractMesh;
  93962. /** @hidden */
  93963. private _initFacetData;
  93964. /**
  93965. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93966. * This method can be called within the render loop.
  93967. * 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
  93968. * @returns the current mesh
  93969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93970. */
  93971. updateFacetData(): AbstractMesh;
  93972. /**
  93973. * Returns the facetLocalNormals array.
  93974. * The normals are expressed in the mesh local spac
  93975. * @returns an array of Vector3
  93976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93977. */
  93978. getFacetLocalNormals(): Vector3[];
  93979. /**
  93980. * Returns the facetLocalPositions array.
  93981. * The facet positions are expressed in the mesh local space
  93982. * @returns an array of Vector3
  93983. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93984. */
  93985. getFacetLocalPositions(): Vector3[];
  93986. /**
  93987. * Returns the facetLocalPartioning array
  93988. * @returns an array of array of numbers
  93989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93990. */
  93991. getFacetLocalPartitioning(): number[][];
  93992. /**
  93993. * Returns the i-th facet position in the world system.
  93994. * This method allocates a new Vector3 per call
  93995. * @param i defines the facet index
  93996. * @returns a new Vector3
  93997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93998. */
  93999. getFacetPosition(i: number): Vector3;
  94000. /**
  94001. * Sets the reference Vector3 with the i-th facet position in the world system
  94002. * @param i defines the facet index
  94003. * @param ref defines the target vector
  94004. * @returns the current mesh
  94005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94006. */
  94007. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  94008. /**
  94009. * Returns the i-th facet normal in the world system.
  94010. * This method allocates a new Vector3 per call
  94011. * @param i defines the facet index
  94012. * @returns a new Vector3
  94013. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94014. */
  94015. getFacetNormal(i: number): Vector3;
  94016. /**
  94017. * Sets the reference Vector3 with the i-th facet normal in the world system
  94018. * @param i defines the facet index
  94019. * @param ref defines the target vector
  94020. * @returns the current mesh
  94021. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94022. */
  94023. getFacetNormalToRef(i: number, ref: Vector3): this;
  94024. /**
  94025. * 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)
  94026. * @param x defines x coordinate
  94027. * @param y defines y coordinate
  94028. * @param z defines z coordinate
  94029. * @returns the array of facet indexes
  94030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94031. */
  94032. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  94033. /**
  94034. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  94035. * @param projected sets as the (x,y,z) world projection on the facet
  94036. * @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
  94037. * @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
  94038. * @param x defines x coordinate
  94039. * @param y defines y coordinate
  94040. * @param z defines z coordinate
  94041. * @returns the face index if found (or null instead)
  94042. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94043. */
  94044. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94045. /**
  94046. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  94047. * @param projected sets as the (x,y,z) local projection on the facet
  94048. * @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
  94049. * @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
  94050. * @param x defines x coordinate
  94051. * @param y defines y coordinate
  94052. * @param z defines z coordinate
  94053. * @returns the face index if found (or null instead)
  94054. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94055. */
  94056. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94057. /**
  94058. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  94059. * @returns the parameters
  94060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94061. */
  94062. getFacetDataParameters(): any;
  94063. /**
  94064. * Disables the feature FacetData and frees the related memory
  94065. * @returns the current mesh
  94066. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94067. */
  94068. disableFacetData(): AbstractMesh;
  94069. /**
  94070. * Updates the AbstractMesh indices array
  94071. * @param indices defines the data source
  94072. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94073. * @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)
  94074. * @returns the current mesh
  94075. */
  94076. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  94077. /**
  94078. * Creates new normals data for the mesh
  94079. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  94080. * @returns the current mesh
  94081. */
  94082. createNormals(updatable: boolean): AbstractMesh;
  94083. /**
  94084. * Align the mesh with a normal
  94085. * @param normal defines the normal to use
  94086. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  94087. * @returns the current mesh
  94088. */
  94089. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  94090. /** @hidden */
  94091. _checkOcclusionQuery(): boolean;
  94092. /**
  94093. * Disables the mesh edge rendering mode
  94094. * @returns the currentAbstractMesh
  94095. */
  94096. disableEdgesRendering(): AbstractMesh;
  94097. /**
  94098. * Enables the edge rendering mode on the mesh.
  94099. * This mode makes the mesh edges visible
  94100. * @param epsilon defines the maximal distance between two angles to detect a face
  94101. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94102. * @returns the currentAbstractMesh
  94103. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94104. */
  94105. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94106. }
  94107. }
  94108. declare module BABYLON {
  94109. /**
  94110. * Interface used to define ActionEvent
  94111. */
  94112. export interface IActionEvent {
  94113. /** The mesh or sprite that triggered the action */
  94114. source: any;
  94115. /** The X mouse cursor position at the time of the event */
  94116. pointerX: number;
  94117. /** The Y mouse cursor position at the time of the event */
  94118. pointerY: number;
  94119. /** The mesh that is currently pointed at (can be null) */
  94120. meshUnderPointer: Nullable<AbstractMesh>;
  94121. /** the original (browser) event that triggered the ActionEvent */
  94122. sourceEvent?: any;
  94123. /** additional data for the event */
  94124. additionalData?: any;
  94125. }
  94126. /**
  94127. * ActionEvent is the event being sent when an action is triggered.
  94128. */
  94129. export class ActionEvent implements IActionEvent {
  94130. /** The mesh or sprite that triggered the action */
  94131. source: any;
  94132. /** The X mouse cursor position at the time of the event */
  94133. pointerX: number;
  94134. /** The Y mouse cursor position at the time of the event */
  94135. pointerY: number;
  94136. /** The mesh that is currently pointed at (can be null) */
  94137. meshUnderPointer: Nullable<AbstractMesh>;
  94138. /** the original (browser) event that triggered the ActionEvent */
  94139. sourceEvent?: any;
  94140. /** additional data for the event */
  94141. additionalData?: any;
  94142. /**
  94143. * Creates a new ActionEvent
  94144. * @param source The mesh or sprite that triggered the action
  94145. * @param pointerX The X mouse cursor position at the time of the event
  94146. * @param pointerY The Y mouse cursor position at the time of the event
  94147. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  94148. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  94149. * @param additionalData additional data for the event
  94150. */
  94151. constructor(
  94152. /** The mesh or sprite that triggered the action */
  94153. source: any,
  94154. /** The X mouse cursor position at the time of the event */
  94155. pointerX: number,
  94156. /** The Y mouse cursor position at the time of the event */
  94157. pointerY: number,
  94158. /** The mesh that is currently pointed at (can be null) */
  94159. meshUnderPointer: Nullable<AbstractMesh>,
  94160. /** the original (browser) event that triggered the ActionEvent */
  94161. sourceEvent?: any,
  94162. /** additional data for the event */
  94163. additionalData?: any);
  94164. /**
  94165. * Helper function to auto-create an ActionEvent from a source mesh.
  94166. * @param source The source mesh that triggered the event
  94167. * @param evt The original (browser) event
  94168. * @param additionalData additional data for the event
  94169. * @returns the new ActionEvent
  94170. */
  94171. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  94172. /**
  94173. * Helper function to auto-create an ActionEvent from a source sprite
  94174. * @param source The source sprite that triggered the event
  94175. * @param scene Scene associated with the sprite
  94176. * @param evt The original (browser) event
  94177. * @param additionalData additional data for the event
  94178. * @returns the new ActionEvent
  94179. */
  94180. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  94181. /**
  94182. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  94183. * @param scene the scene where the event occurred
  94184. * @param evt The original (browser) event
  94185. * @returns the new ActionEvent
  94186. */
  94187. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  94188. /**
  94189. * Helper function to auto-create an ActionEvent from a primitive
  94190. * @param prim defines the target primitive
  94191. * @param pointerPos defines the pointer position
  94192. * @param evt The original (browser) event
  94193. * @param additionalData additional data for the event
  94194. * @returns the new ActionEvent
  94195. */
  94196. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  94197. }
  94198. }
  94199. declare module BABYLON {
  94200. /**
  94201. * Abstract class used to decouple action Manager from scene and meshes.
  94202. * Do not instantiate.
  94203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94204. */
  94205. export abstract class AbstractActionManager implements IDisposable {
  94206. /** Gets the list of active triggers */
  94207. static Triggers: {
  94208. [key: string]: number;
  94209. };
  94210. /** Gets the cursor to use when hovering items */
  94211. hoverCursor: string;
  94212. /** Gets the list of actions */
  94213. actions: IAction[];
  94214. /**
  94215. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  94216. */
  94217. isRecursive: boolean;
  94218. /**
  94219. * Releases all associated resources
  94220. */
  94221. abstract dispose(): void;
  94222. /**
  94223. * Does this action manager has pointer triggers
  94224. */
  94225. abstract readonly hasPointerTriggers: boolean;
  94226. /**
  94227. * Does this action manager has pick triggers
  94228. */
  94229. abstract readonly hasPickTriggers: boolean;
  94230. /**
  94231. * Process a specific trigger
  94232. * @param trigger defines the trigger to process
  94233. * @param evt defines the event details to be processed
  94234. */
  94235. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  94236. /**
  94237. * Does this action manager handles actions of any of the given triggers
  94238. * @param triggers defines the triggers to be tested
  94239. * @return a boolean indicating whether one (or more) of the triggers is handled
  94240. */
  94241. abstract hasSpecificTriggers(triggers: number[]): boolean;
  94242. /**
  94243. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  94244. * speed.
  94245. * @param triggerA defines the trigger to be tested
  94246. * @param triggerB defines the trigger to be tested
  94247. * @return a boolean indicating whether one (or more) of the triggers is handled
  94248. */
  94249. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  94250. /**
  94251. * Does this action manager handles actions of a given trigger
  94252. * @param trigger defines the trigger to be tested
  94253. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  94254. * @return whether the trigger is handled
  94255. */
  94256. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  94257. /**
  94258. * Serialize this manager to a JSON object
  94259. * @param name defines the property name to store this manager
  94260. * @returns a JSON representation of this manager
  94261. */
  94262. abstract serialize(name: string): any;
  94263. /**
  94264. * Registers an action to this action manager
  94265. * @param action defines the action to be registered
  94266. * @return the action amended (prepared) after registration
  94267. */
  94268. abstract registerAction(action: IAction): Nullable<IAction>;
  94269. /**
  94270. * Unregisters an action to this action manager
  94271. * @param action defines the action to be unregistered
  94272. * @return a boolean indicating whether the action has been unregistered
  94273. */
  94274. abstract unregisterAction(action: IAction): Boolean;
  94275. /**
  94276. * Does exist one action manager with at least one trigger
  94277. **/
  94278. static readonly HasTriggers: boolean;
  94279. /**
  94280. * Does exist one action manager with at least one pick trigger
  94281. **/
  94282. static readonly HasPickTriggers: boolean;
  94283. /**
  94284. * Does exist one action manager that handles actions of a given trigger
  94285. * @param trigger defines the trigger to be tested
  94286. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  94287. **/
  94288. static HasSpecificTrigger(trigger: number): boolean;
  94289. }
  94290. }
  94291. declare module BABYLON {
  94292. /**
  94293. * Defines how a node can be built from a string name.
  94294. */
  94295. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  94296. /**
  94297. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  94298. */
  94299. export class Node implements IBehaviorAware<Node> {
  94300. /** @hidden */
  94301. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  94302. private static _NodeConstructors;
  94303. /**
  94304. * Add a new node constructor
  94305. * @param type defines the type name of the node to construct
  94306. * @param constructorFunc defines the constructor function
  94307. */
  94308. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  94309. /**
  94310. * Returns a node constructor based on type name
  94311. * @param type defines the type name
  94312. * @param name defines the new node name
  94313. * @param scene defines the hosting scene
  94314. * @param options defines optional options to transmit to constructors
  94315. * @returns the new constructor or null
  94316. */
  94317. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  94318. /**
  94319. * Gets or sets the name of the node
  94320. */
  94321. name: string;
  94322. /**
  94323. * Gets or sets the id of the node
  94324. */
  94325. id: string;
  94326. /**
  94327. * Gets or sets the unique id of the node
  94328. */
  94329. uniqueId: number;
  94330. /**
  94331. * Gets or sets a string used to store user defined state for the node
  94332. */
  94333. state: string;
  94334. /**
  94335. * Gets or sets an object used to store user defined information for the node
  94336. */
  94337. metadata: any;
  94338. /**
  94339. * For internal use only. Please do not use.
  94340. */
  94341. reservedDataStore: any;
  94342. /**
  94343. * List of inspectable custom properties (used by the Inspector)
  94344. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94345. */
  94346. inspectableCustomProperties: IInspectable[];
  94347. private _doNotSerialize;
  94348. /**
  94349. * Gets or sets a boolean used to define if the node must be serialized
  94350. */
  94351. doNotSerialize: boolean;
  94352. /** @hidden */
  94353. _isDisposed: boolean;
  94354. /**
  94355. * Gets a list of Animations associated with the node
  94356. */
  94357. animations: Animation[];
  94358. protected _ranges: {
  94359. [name: string]: Nullable<AnimationRange>;
  94360. };
  94361. /**
  94362. * Callback raised when the node is ready to be used
  94363. */
  94364. onReady: Nullable<(node: Node) => void>;
  94365. private _isEnabled;
  94366. private _isParentEnabled;
  94367. private _isReady;
  94368. /** @hidden */
  94369. _currentRenderId: number;
  94370. private _parentUpdateId;
  94371. /** @hidden */
  94372. _childUpdateId: number;
  94373. /** @hidden */
  94374. _waitingParentId: Nullable<string>;
  94375. /** @hidden */
  94376. _scene: Scene;
  94377. /** @hidden */
  94378. _cache: any;
  94379. private _parentNode;
  94380. private _children;
  94381. /** @hidden */
  94382. _worldMatrix: Matrix;
  94383. /** @hidden */
  94384. _worldMatrixDeterminant: number;
  94385. /** @hidden */
  94386. _worldMatrixDeterminantIsDirty: boolean;
  94387. /** @hidden */
  94388. private _sceneRootNodesIndex;
  94389. /**
  94390. * Gets a boolean indicating if the node has been disposed
  94391. * @returns true if the node was disposed
  94392. */
  94393. isDisposed(): boolean;
  94394. /**
  94395. * Gets or sets the parent of the node (without keeping the current position in the scene)
  94396. * @see https://doc.babylonjs.com/how_to/parenting
  94397. */
  94398. parent: Nullable<Node>;
  94399. private addToSceneRootNodes;
  94400. private removeFromSceneRootNodes;
  94401. private _animationPropertiesOverride;
  94402. /**
  94403. * Gets or sets the animation properties override
  94404. */
  94405. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94406. /**
  94407. * Gets a string idenfifying the name of the class
  94408. * @returns "Node" string
  94409. */
  94410. getClassName(): string;
  94411. /** @hidden */
  94412. readonly _isNode: boolean;
  94413. /**
  94414. * An event triggered when the mesh is disposed
  94415. */
  94416. onDisposeObservable: Observable<Node>;
  94417. private _onDisposeObserver;
  94418. /**
  94419. * Sets a callback that will be raised when the node will be disposed
  94420. */
  94421. onDispose: () => void;
  94422. /**
  94423. * Creates a new Node
  94424. * @param name the name and id to be given to this node
  94425. * @param scene the scene this node will be added to
  94426. * @param addToRootNodes the node will be added to scene.rootNodes
  94427. */
  94428. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  94429. /**
  94430. * Gets the scene of the node
  94431. * @returns a scene
  94432. */
  94433. getScene(): Scene;
  94434. /**
  94435. * Gets the engine of the node
  94436. * @returns a Engine
  94437. */
  94438. getEngine(): Engine;
  94439. private _behaviors;
  94440. /**
  94441. * Attach a behavior to the node
  94442. * @see http://doc.babylonjs.com/features/behaviour
  94443. * @param behavior defines the behavior to attach
  94444. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  94445. * @returns the current Node
  94446. */
  94447. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  94448. /**
  94449. * Remove an attached behavior
  94450. * @see http://doc.babylonjs.com/features/behaviour
  94451. * @param behavior defines the behavior to attach
  94452. * @returns the current Node
  94453. */
  94454. removeBehavior(behavior: Behavior<Node>): Node;
  94455. /**
  94456. * Gets the list of attached behaviors
  94457. * @see http://doc.babylonjs.com/features/behaviour
  94458. */
  94459. readonly behaviors: Behavior<Node>[];
  94460. /**
  94461. * Gets an attached behavior by name
  94462. * @param name defines the name of the behavior to look for
  94463. * @see http://doc.babylonjs.com/features/behaviour
  94464. * @returns null if behavior was not found else the requested behavior
  94465. */
  94466. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  94467. /**
  94468. * Returns the latest update of the World matrix
  94469. * @returns a Matrix
  94470. */
  94471. getWorldMatrix(): Matrix;
  94472. /** @hidden */
  94473. _getWorldMatrixDeterminant(): number;
  94474. /**
  94475. * Returns directly the latest state of the mesh World matrix.
  94476. * A Matrix is returned.
  94477. */
  94478. readonly worldMatrixFromCache: Matrix;
  94479. /** @hidden */
  94480. _initCache(): void;
  94481. /** @hidden */
  94482. updateCache(force?: boolean): void;
  94483. /** @hidden */
  94484. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94485. /** @hidden */
  94486. _updateCache(ignoreParentClass?: boolean): void;
  94487. /** @hidden */
  94488. _isSynchronized(): boolean;
  94489. /** @hidden */
  94490. _markSyncedWithParent(): void;
  94491. /** @hidden */
  94492. isSynchronizedWithParent(): boolean;
  94493. /** @hidden */
  94494. isSynchronized(): boolean;
  94495. /**
  94496. * Is this node ready to be used/rendered
  94497. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94498. * @return true if the node is ready
  94499. */
  94500. isReady(completeCheck?: boolean): boolean;
  94501. /**
  94502. * Is this node enabled?
  94503. * 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
  94504. * @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
  94505. * @return whether this node (and its parent) is enabled
  94506. */
  94507. isEnabled(checkAncestors?: boolean): boolean;
  94508. /** @hidden */
  94509. protected _syncParentEnabledState(): void;
  94510. /**
  94511. * Set the enabled state of this node
  94512. * @param value defines the new enabled state
  94513. */
  94514. setEnabled(value: boolean): void;
  94515. /**
  94516. * Is this node a descendant of the given node?
  94517. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  94518. * @param ancestor defines the parent node to inspect
  94519. * @returns a boolean indicating if this node is a descendant of the given node
  94520. */
  94521. isDescendantOf(ancestor: Node): boolean;
  94522. /** @hidden */
  94523. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  94524. /**
  94525. * Will return all nodes that have this node as ascendant
  94526. * @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
  94527. * @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
  94528. * @return all children nodes of all types
  94529. */
  94530. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  94531. /**
  94532. * Get all child-meshes of this node
  94533. * @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)
  94534. * @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
  94535. * @returns an array of AbstractMesh
  94536. */
  94537. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  94538. /**
  94539. * Get all direct children of this node
  94540. * @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
  94541. * @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)
  94542. * @returns an array of Node
  94543. */
  94544. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  94545. /** @hidden */
  94546. _setReady(state: boolean): void;
  94547. /**
  94548. * Get an animation by name
  94549. * @param name defines the name of the animation to look for
  94550. * @returns null if not found else the requested animation
  94551. */
  94552. getAnimationByName(name: string): Nullable<Animation>;
  94553. /**
  94554. * Creates an animation range for this node
  94555. * @param name defines the name of the range
  94556. * @param from defines the starting key
  94557. * @param to defines the end key
  94558. */
  94559. createAnimationRange(name: string, from: number, to: number): void;
  94560. /**
  94561. * Delete a specific animation range
  94562. * @param name defines the name of the range to delete
  94563. * @param deleteFrames defines if animation frames from the range must be deleted as well
  94564. */
  94565. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94566. /**
  94567. * Get an animation range by name
  94568. * @param name defines the name of the animation range to look for
  94569. * @returns null if not found else the requested animation range
  94570. */
  94571. getAnimationRange(name: string): Nullable<AnimationRange>;
  94572. /**
  94573. * Gets the list of all animation ranges defined on this node
  94574. * @returns an array
  94575. */
  94576. getAnimationRanges(): Nullable<AnimationRange>[];
  94577. /**
  94578. * Will start the animation sequence
  94579. * @param name defines the range frames for animation sequence
  94580. * @param loop defines if the animation should loop (false by default)
  94581. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  94582. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  94583. * @returns the object created for this animation. If range does not exist, it will return null
  94584. */
  94585. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94586. /**
  94587. * Serialize animation ranges into a JSON compatible object
  94588. * @returns serialization object
  94589. */
  94590. serializeAnimationRanges(): any;
  94591. /**
  94592. * Computes the world matrix of the node
  94593. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94594. * @returns the world matrix
  94595. */
  94596. computeWorldMatrix(force?: boolean): Matrix;
  94597. /**
  94598. * Releases resources associated with this node.
  94599. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94600. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94601. */
  94602. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94603. /**
  94604. * Parse animation range data from a serialization object and store them into a given node
  94605. * @param node defines where to store the animation ranges
  94606. * @param parsedNode defines the serialization object to read data from
  94607. * @param scene defines the hosting scene
  94608. */
  94609. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  94610. /**
  94611. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  94612. * @param includeDescendants Include bounding info from descendants as well (true by default)
  94613. * @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
  94614. * @returns the new bounding vectors
  94615. */
  94616. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  94617. min: Vector3;
  94618. max: Vector3;
  94619. };
  94620. }
  94621. }
  94622. declare module BABYLON {
  94623. /**
  94624. * @hidden
  94625. */
  94626. export class _IAnimationState {
  94627. key: number;
  94628. repeatCount: number;
  94629. workValue?: any;
  94630. loopMode?: number;
  94631. offsetValue?: any;
  94632. highLimitValue?: any;
  94633. }
  94634. /**
  94635. * Class used to store any kind of animation
  94636. */
  94637. export class Animation {
  94638. /**Name of the animation */
  94639. name: string;
  94640. /**Property to animate */
  94641. targetProperty: string;
  94642. /**The frames per second of the animation */
  94643. framePerSecond: number;
  94644. /**The data type of the animation */
  94645. dataType: number;
  94646. /**The loop mode of the animation */
  94647. loopMode?: number | undefined;
  94648. /**Specifies if blending should be enabled */
  94649. enableBlending?: boolean | undefined;
  94650. /**
  94651. * Use matrix interpolation instead of using direct key value when animating matrices
  94652. */
  94653. static AllowMatricesInterpolation: boolean;
  94654. /**
  94655. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  94656. */
  94657. static AllowMatrixDecomposeForInterpolation: boolean;
  94658. /**
  94659. * Stores the key frames of the animation
  94660. */
  94661. private _keys;
  94662. /**
  94663. * Stores the easing function of the animation
  94664. */
  94665. private _easingFunction;
  94666. /**
  94667. * @hidden Internal use only
  94668. */
  94669. _runtimeAnimations: RuntimeAnimation[];
  94670. /**
  94671. * The set of event that will be linked to this animation
  94672. */
  94673. private _events;
  94674. /**
  94675. * Stores an array of target property paths
  94676. */
  94677. targetPropertyPath: string[];
  94678. /**
  94679. * Stores the blending speed of the animation
  94680. */
  94681. blendingSpeed: number;
  94682. /**
  94683. * Stores the animation ranges for the animation
  94684. */
  94685. private _ranges;
  94686. /**
  94687. * @hidden Internal use
  94688. */
  94689. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  94690. /**
  94691. * Sets up an animation
  94692. * @param property The property to animate
  94693. * @param animationType The animation type to apply
  94694. * @param framePerSecond The frames per second of the animation
  94695. * @param easingFunction The easing function used in the animation
  94696. * @returns The created animation
  94697. */
  94698. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  94699. /**
  94700. * Create and start an animation on a node
  94701. * @param name defines the name of the global animation that will be run on all nodes
  94702. * @param node defines the root node where the animation will take place
  94703. * @param targetProperty defines property to animate
  94704. * @param framePerSecond defines the number of frame per second yo use
  94705. * @param totalFrame defines the number of frames in total
  94706. * @param from defines the initial value
  94707. * @param to defines the final value
  94708. * @param loopMode defines which loop mode you want to use (off by default)
  94709. * @param easingFunction defines the easing function to use (linear by default)
  94710. * @param onAnimationEnd defines the callback to call when animation end
  94711. * @returns the animatable created for this animation
  94712. */
  94713. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94714. /**
  94715. * Create and start an animation on a node and its descendants
  94716. * @param name defines the name of the global animation that will be run on all nodes
  94717. * @param node defines the root node where the animation will take place
  94718. * @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
  94719. * @param targetProperty defines property to animate
  94720. * @param framePerSecond defines the number of frame per second to use
  94721. * @param totalFrame defines the number of frames in total
  94722. * @param from defines the initial value
  94723. * @param to defines the final value
  94724. * @param loopMode defines which loop mode you want to use (off by default)
  94725. * @param easingFunction defines the easing function to use (linear by default)
  94726. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94727. * @returns the list of animatables created for all nodes
  94728. * @example https://www.babylonjs-playground.com/#MH0VLI
  94729. */
  94730. 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[]>;
  94731. /**
  94732. * Creates a new animation, merges it with the existing animations and starts it
  94733. * @param name Name of the animation
  94734. * @param node Node which contains the scene that begins the animations
  94735. * @param targetProperty Specifies which property to animate
  94736. * @param framePerSecond The frames per second of the animation
  94737. * @param totalFrame The total number of frames
  94738. * @param from The frame at the beginning of the animation
  94739. * @param to The frame at the end of the animation
  94740. * @param loopMode Specifies the loop mode of the animation
  94741. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  94742. * @param onAnimationEnd Callback to run once the animation is complete
  94743. * @returns Nullable animation
  94744. */
  94745. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94746. /**
  94747. * Transition property of an host to the target Value
  94748. * @param property The property to transition
  94749. * @param targetValue The target Value of the property
  94750. * @param host The object where the property to animate belongs
  94751. * @param scene Scene used to run the animation
  94752. * @param frameRate Framerate (in frame/s) to use
  94753. * @param transition The transition type we want to use
  94754. * @param duration The duration of the animation, in milliseconds
  94755. * @param onAnimationEnd Callback trigger at the end of the animation
  94756. * @returns Nullable animation
  94757. */
  94758. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94759. /**
  94760. * Return the array of runtime animations currently using this animation
  94761. */
  94762. readonly runtimeAnimations: RuntimeAnimation[];
  94763. /**
  94764. * Specifies if any of the runtime animations are currently running
  94765. */
  94766. readonly hasRunningRuntimeAnimations: boolean;
  94767. /**
  94768. * Initializes the animation
  94769. * @param name Name of the animation
  94770. * @param targetProperty Property to animate
  94771. * @param framePerSecond The frames per second of the animation
  94772. * @param dataType The data type of the animation
  94773. * @param loopMode The loop mode of the animation
  94774. * @param enableBlending Specifies if blending should be enabled
  94775. */
  94776. constructor(
  94777. /**Name of the animation */
  94778. name: string,
  94779. /**Property to animate */
  94780. targetProperty: string,
  94781. /**The frames per second of the animation */
  94782. framePerSecond: number,
  94783. /**The data type of the animation */
  94784. dataType: number,
  94785. /**The loop mode of the animation */
  94786. loopMode?: number | undefined,
  94787. /**Specifies if blending should be enabled */
  94788. enableBlending?: boolean | undefined);
  94789. /**
  94790. * Converts the animation to a string
  94791. * @param fullDetails support for multiple levels of logging within scene loading
  94792. * @returns String form of the animation
  94793. */
  94794. toString(fullDetails?: boolean): string;
  94795. /**
  94796. * Add an event to this animation
  94797. * @param event Event to add
  94798. */
  94799. addEvent(event: AnimationEvent): void;
  94800. /**
  94801. * Remove all events found at the given frame
  94802. * @param frame The frame to remove events from
  94803. */
  94804. removeEvents(frame: number): void;
  94805. /**
  94806. * Retrieves all the events from the animation
  94807. * @returns Events from the animation
  94808. */
  94809. getEvents(): AnimationEvent[];
  94810. /**
  94811. * Creates an animation range
  94812. * @param name Name of the animation range
  94813. * @param from Starting frame of the animation range
  94814. * @param to Ending frame of the animation
  94815. */
  94816. createRange(name: string, from: number, to: number): void;
  94817. /**
  94818. * Deletes an animation range by name
  94819. * @param name Name of the animation range to delete
  94820. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94821. */
  94822. deleteRange(name: string, deleteFrames?: boolean): void;
  94823. /**
  94824. * Gets the animation range by name, or null if not defined
  94825. * @param name Name of the animation range
  94826. * @returns Nullable animation range
  94827. */
  94828. getRange(name: string): Nullable<AnimationRange>;
  94829. /**
  94830. * Gets the key frames from the animation
  94831. * @returns The key frames of the animation
  94832. */
  94833. getKeys(): Array<IAnimationKey>;
  94834. /**
  94835. * Gets the highest frame rate of the animation
  94836. * @returns Highest frame rate of the animation
  94837. */
  94838. getHighestFrame(): number;
  94839. /**
  94840. * Gets the easing function of the animation
  94841. * @returns Easing function of the animation
  94842. */
  94843. getEasingFunction(): IEasingFunction;
  94844. /**
  94845. * Sets the easing function of the animation
  94846. * @param easingFunction A custom mathematical formula for animation
  94847. */
  94848. setEasingFunction(easingFunction: EasingFunction): void;
  94849. /**
  94850. * Interpolates a scalar linearly
  94851. * @param startValue Start value of the animation curve
  94852. * @param endValue End value of the animation curve
  94853. * @param gradient Scalar amount to interpolate
  94854. * @returns Interpolated scalar value
  94855. */
  94856. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94857. /**
  94858. * Interpolates a scalar cubically
  94859. * @param startValue Start value of the animation curve
  94860. * @param outTangent End tangent of the animation
  94861. * @param endValue End value of the animation curve
  94862. * @param inTangent Start tangent of the animation curve
  94863. * @param gradient Scalar amount to interpolate
  94864. * @returns Interpolated scalar value
  94865. */
  94866. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94867. /**
  94868. * Interpolates a quaternion using a spherical linear interpolation
  94869. * @param startValue Start value of the animation curve
  94870. * @param endValue End value of the animation curve
  94871. * @param gradient Scalar amount to interpolate
  94872. * @returns Interpolated quaternion value
  94873. */
  94874. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94875. /**
  94876. * Interpolates a quaternion cubically
  94877. * @param startValue Start value of the animation curve
  94878. * @param outTangent End tangent of the animation curve
  94879. * @param endValue End value of the animation curve
  94880. * @param inTangent Start tangent of the animation curve
  94881. * @param gradient Scalar amount to interpolate
  94882. * @returns Interpolated quaternion value
  94883. */
  94884. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94885. /**
  94886. * Interpolates a Vector3 linearl
  94887. * @param startValue Start value of the animation curve
  94888. * @param endValue End value of the animation curve
  94889. * @param gradient Scalar amount to interpolate
  94890. * @returns Interpolated scalar value
  94891. */
  94892. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94893. /**
  94894. * Interpolates a Vector3 cubically
  94895. * @param startValue Start value of the animation curve
  94896. * @param outTangent End tangent of the animation
  94897. * @param endValue End value of the animation curve
  94898. * @param inTangent Start tangent of the animation curve
  94899. * @param gradient Scalar amount to interpolate
  94900. * @returns InterpolatedVector3 value
  94901. */
  94902. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94903. /**
  94904. * Interpolates a Vector2 linearly
  94905. * @param startValue Start value of the animation curve
  94906. * @param endValue End value of the animation curve
  94907. * @param gradient Scalar amount to interpolate
  94908. * @returns Interpolated Vector2 value
  94909. */
  94910. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94911. /**
  94912. * Interpolates a Vector2 cubically
  94913. * @param startValue Start value of the animation curve
  94914. * @param outTangent End tangent of the animation
  94915. * @param endValue End value of the animation curve
  94916. * @param inTangent Start tangent of the animation curve
  94917. * @param gradient Scalar amount to interpolate
  94918. * @returns Interpolated Vector2 value
  94919. */
  94920. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94921. /**
  94922. * Interpolates a size linearly
  94923. * @param startValue Start value of the animation curve
  94924. * @param endValue End value of the animation curve
  94925. * @param gradient Scalar amount to interpolate
  94926. * @returns Interpolated Size value
  94927. */
  94928. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94929. /**
  94930. * Interpolates a Color3 linearly
  94931. * @param startValue Start value of the animation curve
  94932. * @param endValue End value of the animation curve
  94933. * @param gradient Scalar amount to interpolate
  94934. * @returns Interpolated Color3 value
  94935. */
  94936. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94937. /**
  94938. * Interpolates a Color4 linearly
  94939. * @param startValue Start value of the animation curve
  94940. * @param endValue End value of the animation curve
  94941. * @param gradient Scalar amount to interpolate
  94942. * @returns Interpolated Color3 value
  94943. */
  94944. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  94945. /**
  94946. * @hidden Internal use only
  94947. */
  94948. _getKeyValue(value: any): any;
  94949. /**
  94950. * @hidden Internal use only
  94951. */
  94952. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94953. /**
  94954. * Defines the function to use to interpolate matrices
  94955. * @param startValue defines the start matrix
  94956. * @param endValue defines the end matrix
  94957. * @param gradient defines the gradient between both matrices
  94958. * @param result defines an optional target matrix where to store the interpolation
  94959. * @returns the interpolated matrix
  94960. */
  94961. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94962. /**
  94963. * Makes a copy of the animation
  94964. * @returns Cloned animation
  94965. */
  94966. clone(): Animation;
  94967. /**
  94968. * Sets the key frames of the animation
  94969. * @param values The animation key frames to set
  94970. */
  94971. setKeys(values: Array<IAnimationKey>): void;
  94972. /**
  94973. * Serializes the animation to an object
  94974. * @returns Serialized object
  94975. */
  94976. serialize(): any;
  94977. /**
  94978. * Float animation type
  94979. */
  94980. static readonly ANIMATIONTYPE_FLOAT: number;
  94981. /**
  94982. * Vector3 animation type
  94983. */
  94984. static readonly ANIMATIONTYPE_VECTOR3: number;
  94985. /**
  94986. * Quaternion animation type
  94987. */
  94988. static readonly ANIMATIONTYPE_QUATERNION: number;
  94989. /**
  94990. * Matrix animation type
  94991. */
  94992. static readonly ANIMATIONTYPE_MATRIX: number;
  94993. /**
  94994. * Color3 animation type
  94995. */
  94996. static readonly ANIMATIONTYPE_COLOR3: number;
  94997. /**
  94998. * Color3 animation type
  94999. */
  95000. static readonly ANIMATIONTYPE_COLOR4: number;
  95001. /**
  95002. * Vector2 animation type
  95003. */
  95004. static readonly ANIMATIONTYPE_VECTOR2: number;
  95005. /**
  95006. * Size animation type
  95007. */
  95008. static readonly ANIMATIONTYPE_SIZE: number;
  95009. /**
  95010. * Relative Loop Mode
  95011. */
  95012. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  95013. /**
  95014. * Cycle Loop Mode
  95015. */
  95016. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  95017. /**
  95018. * Constant Loop Mode
  95019. */
  95020. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  95021. /** @hidden */
  95022. static _UniversalLerp(left: any, right: any, amount: number): any;
  95023. /**
  95024. * Parses an animation object and creates an animation
  95025. * @param parsedAnimation Parsed animation object
  95026. * @returns Animation object
  95027. */
  95028. static Parse(parsedAnimation: any): Animation;
  95029. /**
  95030. * Appends the serialized animations from the source animations
  95031. * @param source Source containing the animations
  95032. * @param destination Target to store the animations
  95033. */
  95034. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95035. }
  95036. }
  95037. declare module BABYLON {
  95038. /**
  95039. * Interface containing an array of animations
  95040. */
  95041. export interface IAnimatable {
  95042. /**
  95043. * Array of animations
  95044. */
  95045. animations: Nullable<Array<Animation>>;
  95046. }
  95047. }
  95048. declare module BABYLON {
  95049. /**
  95050. * This represents all the required information to add a fresnel effect on a material:
  95051. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95052. */
  95053. export class FresnelParameters {
  95054. private _isEnabled;
  95055. /**
  95056. * Define if the fresnel effect is enable or not.
  95057. */
  95058. isEnabled: boolean;
  95059. /**
  95060. * Define the color used on edges (grazing angle)
  95061. */
  95062. leftColor: Color3;
  95063. /**
  95064. * Define the color used on center
  95065. */
  95066. rightColor: Color3;
  95067. /**
  95068. * Define bias applied to computed fresnel term
  95069. */
  95070. bias: number;
  95071. /**
  95072. * Defined the power exponent applied to fresnel term
  95073. */
  95074. power: number;
  95075. /**
  95076. * Clones the current fresnel and its valuues
  95077. * @returns a clone fresnel configuration
  95078. */
  95079. clone(): FresnelParameters;
  95080. /**
  95081. * Serializes the current fresnel parameters to a JSON representation.
  95082. * @return the JSON serialization
  95083. */
  95084. serialize(): any;
  95085. /**
  95086. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  95087. * @param parsedFresnelParameters Define the JSON representation
  95088. * @returns the parsed parameters
  95089. */
  95090. static Parse(parsedFresnelParameters: any): FresnelParameters;
  95091. }
  95092. }
  95093. declare module BABYLON {
  95094. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  95095. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95096. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95097. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95098. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95099. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95100. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95101. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95102. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95103. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95104. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95105. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95106. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95107. /**
  95108. * Decorator used to define property that can be serialized as reference to a camera
  95109. * @param sourceName defines the name of the property to decorate
  95110. */
  95111. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95112. /**
  95113. * Class used to help serialization objects
  95114. */
  95115. export class SerializationHelper {
  95116. /** @hidden */
  95117. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  95118. /** @hidden */
  95119. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  95120. /** @hidden */
  95121. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  95122. /** @hidden */
  95123. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  95124. /**
  95125. * Appends the serialized animations from the source animations
  95126. * @param source Source containing the animations
  95127. * @param destination Target to store the animations
  95128. */
  95129. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95130. /**
  95131. * Static function used to serialized a specific entity
  95132. * @param entity defines the entity to serialize
  95133. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95134. * @returns a JSON compatible object representing the serialization of the entity
  95135. */
  95136. static Serialize<T>(entity: T, serializationObject?: any): any;
  95137. /**
  95138. * Creates a new entity from a serialization data object
  95139. * @param creationFunction defines a function used to instanciated the new entity
  95140. * @param source defines the source serialization data
  95141. * @param scene defines the hosting scene
  95142. * @param rootUrl defines the root url for resources
  95143. * @returns a new entity
  95144. */
  95145. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  95146. /**
  95147. * Clones an object
  95148. * @param creationFunction defines the function used to instanciate the new object
  95149. * @param source defines the source object
  95150. * @returns the cloned object
  95151. */
  95152. static Clone<T>(creationFunction: () => T, source: T): T;
  95153. /**
  95154. * Instanciates a new object based on a source one (some data will be shared between both object)
  95155. * @param creationFunction defines the function used to instanciate the new object
  95156. * @param source defines the source object
  95157. * @returns the new object
  95158. */
  95159. static Instanciate<T>(creationFunction: () => T, source: T): T;
  95160. }
  95161. }
  95162. declare module BABYLON {
  95163. /**
  95164. * Class used to manipulate GUIDs
  95165. */
  95166. export class GUID {
  95167. /**
  95168. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95169. * Be aware Math.random() could cause collisions, but:
  95170. * "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"
  95171. * @returns a pseudo random id
  95172. */
  95173. static RandomId(): string;
  95174. }
  95175. }
  95176. declare module BABYLON {
  95177. /**
  95178. * Base class of all the textures in babylon.
  95179. * It groups all the common properties the materials, post process, lights... might need
  95180. * in order to make a correct use of the texture.
  95181. */
  95182. export class BaseTexture implements IAnimatable {
  95183. /**
  95184. * Default anisotropic filtering level for the application.
  95185. * It is set to 4 as a good tradeoff between perf and quality.
  95186. */
  95187. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  95188. /**
  95189. * Gets or sets the unique id of the texture
  95190. */
  95191. uniqueId: number;
  95192. /**
  95193. * Define the name of the texture.
  95194. */
  95195. name: string;
  95196. /**
  95197. * Gets or sets an object used to store user defined information.
  95198. */
  95199. metadata: any;
  95200. /**
  95201. * For internal use only. Please do not use.
  95202. */
  95203. reservedDataStore: any;
  95204. private _hasAlpha;
  95205. /**
  95206. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  95207. */
  95208. hasAlpha: boolean;
  95209. /**
  95210. * Defines if the alpha value should be determined via the rgb values.
  95211. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  95212. */
  95213. getAlphaFromRGB: boolean;
  95214. /**
  95215. * Intensity or strength of the texture.
  95216. * It is commonly used by materials to fine tune the intensity of the texture
  95217. */
  95218. level: number;
  95219. /**
  95220. * Define the UV chanel to use starting from 0 and defaulting to 0.
  95221. * This is part of the texture as textures usually maps to one uv set.
  95222. */
  95223. coordinatesIndex: number;
  95224. private _coordinatesMode;
  95225. /**
  95226. * How a texture is mapped.
  95227. *
  95228. * | Value | Type | Description |
  95229. * | ----- | ----------------------------------- | ----------- |
  95230. * | 0 | EXPLICIT_MODE | |
  95231. * | 1 | SPHERICAL_MODE | |
  95232. * | 2 | PLANAR_MODE | |
  95233. * | 3 | CUBIC_MODE | |
  95234. * | 4 | PROJECTION_MODE | |
  95235. * | 5 | SKYBOX_MODE | |
  95236. * | 6 | INVCUBIC_MODE | |
  95237. * | 7 | EQUIRECTANGULAR_MODE | |
  95238. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  95239. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  95240. */
  95241. coordinatesMode: number;
  95242. /**
  95243. * | Value | Type | Description |
  95244. * | ----- | ------------------ | ----------- |
  95245. * | 0 | CLAMP_ADDRESSMODE | |
  95246. * | 1 | WRAP_ADDRESSMODE | |
  95247. * | 2 | MIRROR_ADDRESSMODE | |
  95248. */
  95249. wrapU: number;
  95250. /**
  95251. * | Value | Type | Description |
  95252. * | ----- | ------------------ | ----------- |
  95253. * | 0 | CLAMP_ADDRESSMODE | |
  95254. * | 1 | WRAP_ADDRESSMODE | |
  95255. * | 2 | MIRROR_ADDRESSMODE | |
  95256. */
  95257. wrapV: number;
  95258. /**
  95259. * | Value | Type | Description |
  95260. * | ----- | ------------------ | ----------- |
  95261. * | 0 | CLAMP_ADDRESSMODE | |
  95262. * | 1 | WRAP_ADDRESSMODE | |
  95263. * | 2 | MIRROR_ADDRESSMODE | |
  95264. */
  95265. wrapR: number;
  95266. /**
  95267. * With compliant hardware and browser (supporting anisotropic filtering)
  95268. * this defines the level of anisotropic filtering in the texture.
  95269. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  95270. */
  95271. anisotropicFilteringLevel: number;
  95272. /**
  95273. * Define if the texture is a cube texture or if false a 2d texture.
  95274. */
  95275. isCube: boolean;
  95276. /**
  95277. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  95278. */
  95279. is3D: boolean;
  95280. /**
  95281. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  95282. * HDR texture are usually stored in linear space.
  95283. * This only impacts the PBR and Background materials
  95284. */
  95285. gammaSpace: boolean;
  95286. /**
  95287. * Gets or sets whether or not the texture contains RGBD data.
  95288. */
  95289. isRGBD: boolean;
  95290. /**
  95291. * Is Z inverted in the texture (useful in a cube texture).
  95292. */
  95293. invertZ: boolean;
  95294. /**
  95295. * Are mip maps generated for this texture or not.
  95296. */
  95297. readonly noMipmap: boolean;
  95298. /**
  95299. * @hidden
  95300. */
  95301. lodLevelInAlpha: boolean;
  95302. /**
  95303. * With prefiltered texture, defined the offset used during the prefiltering steps.
  95304. */
  95305. lodGenerationOffset: number;
  95306. /**
  95307. * With prefiltered texture, defined the scale used during the prefiltering steps.
  95308. */
  95309. lodGenerationScale: number;
  95310. /**
  95311. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  95312. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  95313. * average roughness values.
  95314. */
  95315. linearSpecularLOD: boolean;
  95316. /**
  95317. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  95318. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  95319. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  95320. */
  95321. irradianceTexture: Nullable<BaseTexture>;
  95322. /**
  95323. * Define if the texture is a render target.
  95324. */
  95325. isRenderTarget: boolean;
  95326. /**
  95327. * Define the unique id of the texture in the scene.
  95328. */
  95329. readonly uid: string;
  95330. /**
  95331. * Return a string representation of the texture.
  95332. * @returns the texture as a string
  95333. */
  95334. toString(): string;
  95335. /**
  95336. * Get the class name of the texture.
  95337. * @returns "BaseTexture"
  95338. */
  95339. getClassName(): string;
  95340. /**
  95341. * Define the list of animation attached to the texture.
  95342. */
  95343. animations: Animation[];
  95344. /**
  95345. * An event triggered when the texture is disposed.
  95346. */
  95347. onDisposeObservable: Observable<BaseTexture>;
  95348. private _onDisposeObserver;
  95349. /**
  95350. * Callback triggered when the texture has been disposed.
  95351. * Kept for back compatibility, you can use the onDisposeObservable instead.
  95352. */
  95353. onDispose: () => void;
  95354. /**
  95355. * Define the current state of the loading sequence when in delayed load mode.
  95356. */
  95357. delayLoadState: number;
  95358. private _scene;
  95359. /** @hidden */
  95360. _texture: Nullable<InternalTexture>;
  95361. private _uid;
  95362. /**
  95363. * Define if the texture is preventinga material to render or not.
  95364. * If not and the texture is not ready, the engine will use a default black texture instead.
  95365. */
  95366. readonly isBlocking: boolean;
  95367. /**
  95368. * Instantiates a new BaseTexture.
  95369. * Base class of all the textures in babylon.
  95370. * It groups all the common properties the materials, post process, lights... might need
  95371. * in order to make a correct use of the texture.
  95372. * @param scene Define the scene the texture blongs to
  95373. */
  95374. constructor(scene: Nullable<Scene>);
  95375. /**
  95376. * Get the scene the texture belongs to.
  95377. * @returns the scene or null if undefined
  95378. */
  95379. getScene(): Nullable<Scene>;
  95380. /**
  95381. * Get the texture transform matrix used to offset tile the texture for istance.
  95382. * @returns the transformation matrix
  95383. */
  95384. getTextureMatrix(): Matrix;
  95385. /**
  95386. * Get the texture reflection matrix used to rotate/transform the reflection.
  95387. * @returns the reflection matrix
  95388. */
  95389. getReflectionTextureMatrix(): Matrix;
  95390. /**
  95391. * Get the underlying lower level texture from Babylon.
  95392. * @returns the insternal texture
  95393. */
  95394. getInternalTexture(): Nullable<InternalTexture>;
  95395. /**
  95396. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  95397. * @returns true if ready or not blocking
  95398. */
  95399. isReadyOrNotBlocking(): boolean;
  95400. /**
  95401. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  95402. * @returns true if fully ready
  95403. */
  95404. isReady(): boolean;
  95405. private _cachedSize;
  95406. /**
  95407. * Get the size of the texture.
  95408. * @returns the texture size.
  95409. */
  95410. getSize(): ISize;
  95411. /**
  95412. * Get the base size of the texture.
  95413. * It can be different from the size if the texture has been resized for POT for instance
  95414. * @returns the base size
  95415. */
  95416. getBaseSize(): ISize;
  95417. /**
  95418. * Update the sampling mode of the texture.
  95419. * Default is Trilinear mode.
  95420. *
  95421. * | Value | Type | Description |
  95422. * | ----- | ------------------ | ----------- |
  95423. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  95424. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  95425. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  95426. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  95427. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  95428. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  95429. * | 7 | NEAREST_LINEAR | |
  95430. * | 8 | NEAREST_NEAREST | |
  95431. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  95432. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  95433. * | 11 | LINEAR_LINEAR | |
  95434. * | 12 | LINEAR_NEAREST | |
  95435. *
  95436. * > _mag_: magnification filter (close to the viewer)
  95437. * > _min_: minification filter (far from the viewer)
  95438. * > _mip_: filter used between mip map levels
  95439. *@param samplingMode Define the new sampling mode of the texture
  95440. */
  95441. updateSamplingMode(samplingMode: number): void;
  95442. /**
  95443. * Scales the texture if is `canRescale()`
  95444. * @param ratio the resize factor we want to use to rescale
  95445. */
  95446. scale(ratio: number): void;
  95447. /**
  95448. * Get if the texture can rescale.
  95449. */
  95450. readonly canRescale: boolean;
  95451. /** @hidden */
  95452. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  95453. /** @hidden */
  95454. _rebuild(): void;
  95455. /**
  95456. * Triggers the load sequence in delayed load mode.
  95457. */
  95458. delayLoad(): void;
  95459. /**
  95460. * Clones the texture.
  95461. * @returns the cloned texture
  95462. */
  95463. clone(): Nullable<BaseTexture>;
  95464. /**
  95465. * Get the texture underlying type (INT, FLOAT...)
  95466. */
  95467. readonly textureType: number;
  95468. /**
  95469. * Get the texture underlying format (RGB, RGBA...)
  95470. */
  95471. readonly textureFormat: number;
  95472. /**
  95473. * Indicates that textures need to be re-calculated for all materials
  95474. */
  95475. protected _markAllSubMeshesAsTexturesDirty(): void;
  95476. /**
  95477. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  95478. * This will returns an RGBA array buffer containing either in values (0-255) or
  95479. * float values (0-1) depending of the underlying buffer type.
  95480. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  95481. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  95482. * @param buffer defines a user defined buffer to fill with data (can be null)
  95483. * @returns The Array buffer containing the pixels data.
  95484. */
  95485. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  95486. /**
  95487. * Release and destroy the underlying lower level texture aka internalTexture.
  95488. */
  95489. releaseInternalTexture(): void;
  95490. /** @hidden */
  95491. readonly _lodTextureHigh: Nullable<BaseTexture>;
  95492. /** @hidden */
  95493. readonly _lodTextureMid: Nullable<BaseTexture>;
  95494. /** @hidden */
  95495. readonly _lodTextureLow: Nullable<BaseTexture>;
  95496. /**
  95497. * Dispose the texture and release its associated resources.
  95498. */
  95499. dispose(): void;
  95500. /**
  95501. * Serialize the texture into a JSON representation that can be parsed later on.
  95502. * @returns the JSON representation of the texture
  95503. */
  95504. serialize(): any;
  95505. /**
  95506. * Helper function to be called back once a list of texture contains only ready textures.
  95507. * @param textures Define the list of textures to wait for
  95508. * @param callback Define the callback triggered once the entire list will be ready
  95509. */
  95510. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  95511. }
  95512. }
  95513. declare module BABYLON {
  95514. /**
  95515. * Options to be used when creating an effect.
  95516. */
  95517. export interface IEffectCreationOptions {
  95518. /**
  95519. * Atrributes that will be used in the shader.
  95520. */
  95521. attributes: string[];
  95522. /**
  95523. * Uniform varible names that will be set in the shader.
  95524. */
  95525. uniformsNames: string[];
  95526. /**
  95527. * Uniform buffer varible names that will be set in the shader.
  95528. */
  95529. uniformBuffersNames: string[];
  95530. /**
  95531. * Sampler texture variable names that will be set in the shader.
  95532. */
  95533. samplers: string[];
  95534. /**
  95535. * Define statements that will be set in the shader.
  95536. */
  95537. defines: any;
  95538. /**
  95539. * Possible fallbacks for this effect to improve performance when needed.
  95540. */
  95541. fallbacks: Nullable<IEffectFallbacks>;
  95542. /**
  95543. * Callback that will be called when the shader is compiled.
  95544. */
  95545. onCompiled: Nullable<(effect: Effect) => void>;
  95546. /**
  95547. * Callback that will be called if an error occurs during shader compilation.
  95548. */
  95549. onError: Nullable<(effect: Effect, errors: string) => void>;
  95550. /**
  95551. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95552. */
  95553. indexParameters?: any;
  95554. /**
  95555. * Max number of lights that can be used in the shader.
  95556. */
  95557. maxSimultaneousLights?: number;
  95558. /**
  95559. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  95560. */
  95561. transformFeedbackVaryings?: Nullable<string[]>;
  95562. }
  95563. /**
  95564. * Effect containing vertex and fragment shader that can be executed on an object.
  95565. */
  95566. export class Effect implements IDisposable {
  95567. /**
  95568. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95569. */
  95570. static ShadersRepository: string;
  95571. /**
  95572. * Name of the effect.
  95573. */
  95574. name: any;
  95575. /**
  95576. * String container all the define statements that should be set on the shader.
  95577. */
  95578. defines: string;
  95579. /**
  95580. * Callback that will be called when the shader is compiled.
  95581. */
  95582. onCompiled: Nullable<(effect: Effect) => void>;
  95583. /**
  95584. * Callback that will be called if an error occurs during shader compilation.
  95585. */
  95586. onError: Nullable<(effect: Effect, errors: string) => void>;
  95587. /**
  95588. * Callback that will be called when effect is bound.
  95589. */
  95590. onBind: Nullable<(effect: Effect) => void>;
  95591. /**
  95592. * Unique ID of the effect.
  95593. */
  95594. uniqueId: number;
  95595. /**
  95596. * Observable that will be called when the shader is compiled.
  95597. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  95598. */
  95599. onCompileObservable: Observable<Effect>;
  95600. /**
  95601. * Observable that will be called if an error occurs during shader compilation.
  95602. */
  95603. onErrorObservable: Observable<Effect>;
  95604. /** @hidden */
  95605. _onBindObservable: Nullable<Observable<Effect>>;
  95606. /**
  95607. * Observable that will be called when effect is bound.
  95608. */
  95609. readonly onBindObservable: Observable<Effect>;
  95610. /** @hidden */
  95611. _bonesComputationForcedToCPU: boolean;
  95612. private static _uniqueIdSeed;
  95613. private _engine;
  95614. private _uniformBuffersNames;
  95615. private _uniformsNames;
  95616. private _samplerList;
  95617. private _samplers;
  95618. private _isReady;
  95619. private _compilationError;
  95620. private _allFallbacksProcessed;
  95621. private _attributesNames;
  95622. private _attributes;
  95623. private _uniforms;
  95624. /**
  95625. * Key for the effect.
  95626. * @hidden
  95627. */
  95628. _key: string;
  95629. private _indexParameters;
  95630. private _fallbacks;
  95631. private _vertexSourceCode;
  95632. private _fragmentSourceCode;
  95633. private _vertexSourceCodeOverride;
  95634. private _fragmentSourceCodeOverride;
  95635. private _transformFeedbackVaryings;
  95636. /**
  95637. * Compiled shader to webGL program.
  95638. * @hidden
  95639. */
  95640. _pipelineContext: Nullable<IPipelineContext>;
  95641. private _valueCache;
  95642. private static _baseCache;
  95643. /**
  95644. * Instantiates an effect.
  95645. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95646. * @param baseName Name of the effect.
  95647. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95648. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95649. * @param samplers List of sampler variables that will be passed to the shader.
  95650. * @param engine Engine to be used to render the effect
  95651. * @param defines Define statements to be added to the shader.
  95652. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95653. * @param onCompiled Callback that will be called when the shader is compiled.
  95654. * @param onError Callback that will be called if an error occurs during shader compilation.
  95655. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95656. */
  95657. 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);
  95658. private _useFinalCode;
  95659. /**
  95660. * Unique key for this effect
  95661. */
  95662. readonly key: string;
  95663. /**
  95664. * If the effect has been compiled and prepared.
  95665. * @returns if the effect is compiled and prepared.
  95666. */
  95667. isReady(): boolean;
  95668. private _isReadyInternal;
  95669. /**
  95670. * The engine the effect was initialized with.
  95671. * @returns the engine.
  95672. */
  95673. getEngine(): Engine;
  95674. /**
  95675. * The pipeline context for this effect
  95676. * @returns the associated pipeline context
  95677. */
  95678. getPipelineContext(): Nullable<IPipelineContext>;
  95679. /**
  95680. * The set of names of attribute variables for the shader.
  95681. * @returns An array of attribute names.
  95682. */
  95683. getAttributesNames(): string[];
  95684. /**
  95685. * Returns the attribute at the given index.
  95686. * @param index The index of the attribute.
  95687. * @returns The location of the attribute.
  95688. */
  95689. getAttributeLocation(index: number): number;
  95690. /**
  95691. * Returns the attribute based on the name of the variable.
  95692. * @param name of the attribute to look up.
  95693. * @returns the attribute location.
  95694. */
  95695. getAttributeLocationByName(name: string): number;
  95696. /**
  95697. * The number of attributes.
  95698. * @returns the numnber of attributes.
  95699. */
  95700. getAttributesCount(): number;
  95701. /**
  95702. * Gets the index of a uniform variable.
  95703. * @param uniformName of the uniform to look up.
  95704. * @returns the index.
  95705. */
  95706. getUniformIndex(uniformName: string): number;
  95707. /**
  95708. * Returns the attribute based on the name of the variable.
  95709. * @param uniformName of the uniform to look up.
  95710. * @returns the location of the uniform.
  95711. */
  95712. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95713. /**
  95714. * Returns an array of sampler variable names
  95715. * @returns The array of sampler variable neames.
  95716. */
  95717. getSamplers(): string[];
  95718. /**
  95719. * The error from the last compilation.
  95720. * @returns the error string.
  95721. */
  95722. getCompilationError(): string;
  95723. /**
  95724. * Gets a boolean indicating that all fallbacks were used during compilation
  95725. * @returns true if all fallbacks were used
  95726. */
  95727. allFallbacksProcessed(): boolean;
  95728. /**
  95729. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95730. * @param func The callback to be used.
  95731. */
  95732. executeWhenCompiled(func: (effect: Effect) => void): void;
  95733. private _checkIsReady;
  95734. private _loadShader;
  95735. /**
  95736. * Recompiles the webGL program
  95737. * @param vertexSourceCode The source code for the vertex shader.
  95738. * @param fragmentSourceCode The source code for the fragment shader.
  95739. * @param onCompiled Callback called when completed.
  95740. * @param onError Callback called on error.
  95741. * @hidden
  95742. */
  95743. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95744. /**
  95745. * Prepares the effect
  95746. * @hidden
  95747. */
  95748. _prepareEffect(): void;
  95749. private _processCompilationErrors;
  95750. /**
  95751. * Checks if the effect is supported. (Must be called after compilation)
  95752. */
  95753. readonly isSupported: boolean;
  95754. /**
  95755. * Binds a texture to the engine to be used as output of the shader.
  95756. * @param channel Name of the output variable.
  95757. * @param texture Texture to bind.
  95758. * @hidden
  95759. */
  95760. _bindTexture(channel: string, texture: InternalTexture): void;
  95761. /**
  95762. * Sets a texture on the engine to be used in the shader.
  95763. * @param channel Name of the sampler variable.
  95764. * @param texture Texture to set.
  95765. */
  95766. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95767. /**
  95768. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95769. * @param channel Name of the sampler variable.
  95770. * @param texture Texture to set.
  95771. */
  95772. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95773. /**
  95774. * Sets an array of textures on the engine to be used in the shader.
  95775. * @param channel Name of the variable.
  95776. * @param textures Textures to set.
  95777. */
  95778. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95779. /**
  95780. * 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)
  95781. * @param channel Name of the sampler variable.
  95782. * @param postProcess Post process to get the input texture from.
  95783. */
  95784. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95785. /**
  95786. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95787. * 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)
  95788. * @param channel Name of the sampler variable.
  95789. * @param postProcess Post process to get the output texture from.
  95790. */
  95791. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95792. /** @hidden */
  95793. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95794. /** @hidden */
  95795. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95796. /** @hidden */
  95797. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95798. /** @hidden */
  95799. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95800. /**
  95801. * Binds a buffer to a uniform.
  95802. * @param buffer Buffer to bind.
  95803. * @param name Name of the uniform variable to bind to.
  95804. */
  95805. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95806. /**
  95807. * Binds block to a uniform.
  95808. * @param blockName Name of the block to bind.
  95809. * @param index Index to bind.
  95810. */
  95811. bindUniformBlock(blockName: string, index: number): void;
  95812. /**
  95813. * Sets an interger value on a uniform variable.
  95814. * @param uniformName Name of the variable.
  95815. * @param value Value to be set.
  95816. * @returns this effect.
  95817. */
  95818. setInt(uniformName: string, value: number): Effect;
  95819. /**
  95820. * Sets an int array on a uniform variable.
  95821. * @param uniformName Name of the variable.
  95822. * @param array array to be set.
  95823. * @returns this effect.
  95824. */
  95825. setIntArray(uniformName: string, array: Int32Array): Effect;
  95826. /**
  95827. * 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)
  95828. * @param uniformName Name of the variable.
  95829. * @param array array to be set.
  95830. * @returns this effect.
  95831. */
  95832. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95833. /**
  95834. * 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)
  95835. * @param uniformName Name of the variable.
  95836. * @param array array to be set.
  95837. * @returns this effect.
  95838. */
  95839. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95840. /**
  95841. * 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)
  95842. * @param uniformName Name of the variable.
  95843. * @param array array to be set.
  95844. * @returns this effect.
  95845. */
  95846. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95847. /**
  95848. * Sets an float array on a uniform variable.
  95849. * @param uniformName Name of the variable.
  95850. * @param array array to be set.
  95851. * @returns this effect.
  95852. */
  95853. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95854. /**
  95855. * 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)
  95856. * @param uniformName Name of the variable.
  95857. * @param array array to be set.
  95858. * @returns this effect.
  95859. */
  95860. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95861. /**
  95862. * 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)
  95863. * @param uniformName Name of the variable.
  95864. * @param array array to be set.
  95865. * @returns this effect.
  95866. */
  95867. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95868. /**
  95869. * 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)
  95870. * @param uniformName Name of the variable.
  95871. * @param array array to be set.
  95872. * @returns this effect.
  95873. */
  95874. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95875. /**
  95876. * Sets an array on a uniform variable.
  95877. * @param uniformName Name of the variable.
  95878. * @param array array to be set.
  95879. * @returns this effect.
  95880. */
  95881. setArray(uniformName: string, array: number[]): Effect;
  95882. /**
  95883. * 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)
  95884. * @param uniformName Name of the variable.
  95885. * @param array array to be set.
  95886. * @returns this effect.
  95887. */
  95888. setArray2(uniformName: string, array: number[]): Effect;
  95889. /**
  95890. * 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)
  95891. * @param uniformName Name of the variable.
  95892. * @param array array to be set.
  95893. * @returns this effect.
  95894. */
  95895. setArray3(uniformName: string, array: number[]): Effect;
  95896. /**
  95897. * 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)
  95898. * @param uniformName Name of the variable.
  95899. * @param array array to be set.
  95900. * @returns this effect.
  95901. */
  95902. setArray4(uniformName: string, array: number[]): Effect;
  95903. /**
  95904. * Sets matrices on a uniform variable.
  95905. * @param uniformName Name of the variable.
  95906. * @param matrices matrices to be set.
  95907. * @returns this effect.
  95908. */
  95909. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95910. /**
  95911. * Sets matrix on a uniform variable.
  95912. * @param uniformName Name of the variable.
  95913. * @param matrix matrix to be set.
  95914. * @returns this effect.
  95915. */
  95916. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95917. /**
  95918. * 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)
  95919. * @param uniformName Name of the variable.
  95920. * @param matrix matrix to be set.
  95921. * @returns this effect.
  95922. */
  95923. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95924. /**
  95925. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95926. * @param uniformName Name of the variable.
  95927. * @param matrix matrix to be set.
  95928. * @returns this effect.
  95929. */
  95930. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95931. /**
  95932. * Sets a float on a uniform variable.
  95933. * @param uniformName Name of the variable.
  95934. * @param value value to be set.
  95935. * @returns this effect.
  95936. */
  95937. setFloat(uniformName: string, value: number): Effect;
  95938. /**
  95939. * Sets a boolean on a uniform variable.
  95940. * @param uniformName Name of the variable.
  95941. * @param bool value to be set.
  95942. * @returns this effect.
  95943. */
  95944. setBool(uniformName: string, bool: boolean): Effect;
  95945. /**
  95946. * Sets a Vector2 on a uniform variable.
  95947. * @param uniformName Name of the variable.
  95948. * @param vector2 vector2 to be set.
  95949. * @returns this effect.
  95950. */
  95951. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95952. /**
  95953. * Sets a float2 on a uniform variable.
  95954. * @param uniformName Name of the variable.
  95955. * @param x First float in float2.
  95956. * @param y Second float in float2.
  95957. * @returns this effect.
  95958. */
  95959. setFloat2(uniformName: string, x: number, y: number): Effect;
  95960. /**
  95961. * Sets a Vector3 on a uniform variable.
  95962. * @param uniformName Name of the variable.
  95963. * @param vector3 Value to be set.
  95964. * @returns this effect.
  95965. */
  95966. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95967. /**
  95968. * Sets a float3 on a uniform variable.
  95969. * @param uniformName Name of the variable.
  95970. * @param x First float in float3.
  95971. * @param y Second float in float3.
  95972. * @param z Third float in float3.
  95973. * @returns this effect.
  95974. */
  95975. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95976. /**
  95977. * Sets a Vector4 on a uniform variable.
  95978. * @param uniformName Name of the variable.
  95979. * @param vector4 Value to be set.
  95980. * @returns this effect.
  95981. */
  95982. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95983. /**
  95984. * Sets a float4 on a uniform variable.
  95985. * @param uniformName Name of the variable.
  95986. * @param x First float in float4.
  95987. * @param y Second float in float4.
  95988. * @param z Third float in float4.
  95989. * @param w Fourth float in float4.
  95990. * @returns this effect.
  95991. */
  95992. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95993. /**
  95994. * Sets a Color3 on a uniform variable.
  95995. * @param uniformName Name of the variable.
  95996. * @param color3 Value to be set.
  95997. * @returns this effect.
  95998. */
  95999. setColor3(uniformName: string, color3: IColor3Like): Effect;
  96000. /**
  96001. * Sets a Color4 on a uniform variable.
  96002. * @param uniformName Name of the variable.
  96003. * @param color3 Value to be set.
  96004. * @param alpha Alpha value to be set.
  96005. * @returns this effect.
  96006. */
  96007. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  96008. /**
  96009. * Sets a Color4 on a uniform variable
  96010. * @param uniformName defines the name of the variable
  96011. * @param color4 defines the value to be set
  96012. * @returns this effect.
  96013. */
  96014. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  96015. /** Release all associated resources */
  96016. dispose(): void;
  96017. /**
  96018. * This function will add a new shader to the shader store
  96019. * @param name the name of the shader
  96020. * @param pixelShader optional pixel shader content
  96021. * @param vertexShader optional vertex shader content
  96022. */
  96023. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  96024. /**
  96025. * Store of each shader (The can be looked up using effect.key)
  96026. */
  96027. static ShadersStore: {
  96028. [key: string]: string;
  96029. };
  96030. /**
  96031. * Store of each included file for a shader (The can be looked up using effect.key)
  96032. */
  96033. static IncludesShadersStore: {
  96034. [key: string]: string;
  96035. };
  96036. /**
  96037. * Resets the cache of effects.
  96038. */
  96039. static ResetCache(): void;
  96040. }
  96041. }
  96042. declare module BABYLON {
  96043. /**
  96044. * Interface used to describe the capabilities of the engine relatively to the current browser
  96045. */
  96046. export interface EngineCapabilities {
  96047. /** Maximum textures units per fragment shader */
  96048. maxTexturesImageUnits: number;
  96049. /** Maximum texture units per vertex shader */
  96050. maxVertexTextureImageUnits: number;
  96051. /** Maximum textures units in the entire pipeline */
  96052. maxCombinedTexturesImageUnits: number;
  96053. /** Maximum texture size */
  96054. maxTextureSize: number;
  96055. /** Maximum cube texture size */
  96056. maxCubemapTextureSize: number;
  96057. /** Maximum render texture size */
  96058. maxRenderTextureSize: number;
  96059. /** Maximum number of vertex attributes */
  96060. maxVertexAttribs: number;
  96061. /** Maximum number of varyings */
  96062. maxVaryingVectors: number;
  96063. /** Maximum number of uniforms per vertex shader */
  96064. maxVertexUniformVectors: number;
  96065. /** Maximum number of uniforms per fragment shader */
  96066. maxFragmentUniformVectors: number;
  96067. /** Defines if standard derivates (dx/dy) are supported */
  96068. standardDerivatives: boolean;
  96069. /** Defines if s3tc texture compression is supported */
  96070. s3tc?: WEBGL_compressed_texture_s3tc;
  96071. /** Defines if pvrtc texture compression is supported */
  96072. pvrtc: any;
  96073. /** Defines if etc1 texture compression is supported */
  96074. etc1: any;
  96075. /** Defines if etc2 texture compression is supported */
  96076. etc2: any;
  96077. /** Defines if astc texture compression is supported */
  96078. astc: any;
  96079. /** Defines if float textures are supported */
  96080. textureFloat: boolean;
  96081. /** Defines if vertex array objects are supported */
  96082. vertexArrayObject: boolean;
  96083. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  96084. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  96085. /** Gets the maximum level of anisotropy supported */
  96086. maxAnisotropy: number;
  96087. /** Defines if instancing is supported */
  96088. instancedArrays: boolean;
  96089. /** Defines if 32 bits indices are supported */
  96090. uintIndices: boolean;
  96091. /** Defines if high precision shaders are supported */
  96092. highPrecisionShaderSupported: boolean;
  96093. /** Defines if depth reading in the fragment shader is supported */
  96094. fragmentDepthSupported: boolean;
  96095. /** Defines if float texture linear filtering is supported*/
  96096. textureFloatLinearFiltering: boolean;
  96097. /** Defines if rendering to float textures is supported */
  96098. textureFloatRender: boolean;
  96099. /** Defines if half float textures are supported*/
  96100. textureHalfFloat: boolean;
  96101. /** Defines if half float texture linear filtering is supported*/
  96102. textureHalfFloatLinearFiltering: boolean;
  96103. /** Defines if rendering to half float textures is supported */
  96104. textureHalfFloatRender: boolean;
  96105. /** Defines if textureLOD shader command is supported */
  96106. textureLOD: boolean;
  96107. /** Defines if draw buffers extension is supported */
  96108. drawBuffersExtension: boolean;
  96109. /** Defines if depth textures are supported */
  96110. depthTextureExtension: boolean;
  96111. /** Defines if float color buffer are supported */
  96112. colorBufferFloat: boolean;
  96113. /** Gets disjoint timer query extension (null if not supported) */
  96114. timerQuery?: EXT_disjoint_timer_query;
  96115. /** Defines if timestamp can be used with timer query */
  96116. canUseTimestampForTimerQuery: boolean;
  96117. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  96118. multiview?: any;
  96119. /** Function used to let the system compiles shaders in background */
  96120. parallelShaderCompile?: {
  96121. COMPLETION_STATUS_KHR: number;
  96122. };
  96123. /** Max number of texture samples for MSAA */
  96124. maxMSAASamples: number;
  96125. /** Defines if the blend min max extension is supported */
  96126. blendMinMax: boolean;
  96127. }
  96128. }
  96129. declare module BABYLON {
  96130. /**
  96131. * @hidden
  96132. **/
  96133. export class DepthCullingState {
  96134. private _isDepthTestDirty;
  96135. private _isDepthMaskDirty;
  96136. private _isDepthFuncDirty;
  96137. private _isCullFaceDirty;
  96138. private _isCullDirty;
  96139. private _isZOffsetDirty;
  96140. private _isFrontFaceDirty;
  96141. private _depthTest;
  96142. private _depthMask;
  96143. private _depthFunc;
  96144. private _cull;
  96145. private _cullFace;
  96146. private _zOffset;
  96147. private _frontFace;
  96148. /**
  96149. * Initializes the state.
  96150. */
  96151. constructor();
  96152. readonly isDirty: boolean;
  96153. zOffset: number;
  96154. cullFace: Nullable<number>;
  96155. cull: Nullable<boolean>;
  96156. depthFunc: Nullable<number>;
  96157. depthMask: boolean;
  96158. depthTest: boolean;
  96159. frontFace: Nullable<number>;
  96160. reset(): void;
  96161. apply(gl: WebGLRenderingContext): void;
  96162. }
  96163. }
  96164. declare module BABYLON {
  96165. /**
  96166. * @hidden
  96167. **/
  96168. export class StencilState {
  96169. /** 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 */
  96170. static readonly ALWAYS: number;
  96171. /** Passed to stencilOperation to specify that stencil value must be kept */
  96172. static readonly KEEP: number;
  96173. /** Passed to stencilOperation to specify that stencil value must be replaced */
  96174. static readonly REPLACE: number;
  96175. private _isStencilTestDirty;
  96176. private _isStencilMaskDirty;
  96177. private _isStencilFuncDirty;
  96178. private _isStencilOpDirty;
  96179. private _stencilTest;
  96180. private _stencilMask;
  96181. private _stencilFunc;
  96182. private _stencilFuncRef;
  96183. private _stencilFuncMask;
  96184. private _stencilOpStencilFail;
  96185. private _stencilOpDepthFail;
  96186. private _stencilOpStencilDepthPass;
  96187. readonly isDirty: boolean;
  96188. stencilFunc: number;
  96189. stencilFuncRef: number;
  96190. stencilFuncMask: number;
  96191. stencilOpStencilFail: number;
  96192. stencilOpDepthFail: number;
  96193. stencilOpStencilDepthPass: number;
  96194. stencilMask: number;
  96195. stencilTest: boolean;
  96196. constructor();
  96197. reset(): void;
  96198. apply(gl: WebGLRenderingContext): void;
  96199. }
  96200. }
  96201. declare module BABYLON {
  96202. /**
  96203. * @hidden
  96204. **/
  96205. export class AlphaState {
  96206. private _isAlphaBlendDirty;
  96207. private _isBlendFunctionParametersDirty;
  96208. private _isBlendEquationParametersDirty;
  96209. private _isBlendConstantsDirty;
  96210. private _alphaBlend;
  96211. private _blendFunctionParameters;
  96212. private _blendEquationParameters;
  96213. private _blendConstants;
  96214. /**
  96215. * Initializes the state.
  96216. */
  96217. constructor();
  96218. readonly isDirty: boolean;
  96219. alphaBlend: boolean;
  96220. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  96221. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  96222. setAlphaEquationParameters(rgb: number, alpha: number): void;
  96223. reset(): void;
  96224. apply(gl: WebGLRenderingContext): void;
  96225. }
  96226. }
  96227. declare module BABYLON {
  96228. /** @hidden */
  96229. export class WebGL2ShaderProcessor implements IShaderProcessor {
  96230. attributeProcessor(attribute: string): string;
  96231. varyingProcessor(varying: string, isFragment: boolean): string;
  96232. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  96233. }
  96234. }
  96235. declare module BABYLON {
  96236. /**
  96237. * Interface for attribute information associated with buffer instanciation
  96238. */
  96239. export interface InstancingAttributeInfo {
  96240. /**
  96241. * Index/offset of the attribute in the vertex shader
  96242. */
  96243. index: number;
  96244. /**
  96245. * size of the attribute, 1, 2, 3 or 4
  96246. */
  96247. attributeSize: number;
  96248. /**
  96249. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  96250. * default is FLOAT
  96251. */
  96252. attributeType: number;
  96253. /**
  96254. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  96255. */
  96256. normalized: boolean;
  96257. /**
  96258. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  96259. */
  96260. offset: number;
  96261. /**
  96262. * Name of the GLSL attribute, for debugging purpose only
  96263. */
  96264. attributeName: string;
  96265. }
  96266. }
  96267. declare module BABYLON {
  96268. interface ThinEngine {
  96269. /**
  96270. * Update a video texture
  96271. * @param texture defines the texture to update
  96272. * @param video defines the video element to use
  96273. * @param invertY defines if data must be stored with Y axis inverted
  96274. */
  96275. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96276. }
  96277. }
  96278. declare module BABYLON {
  96279. /**
  96280. * Settings for finer control over video usage
  96281. */
  96282. export interface VideoTextureSettings {
  96283. /**
  96284. * Applies `autoplay` to video, if specified
  96285. */
  96286. autoPlay?: boolean;
  96287. /**
  96288. * Applies `loop` to video, if specified
  96289. */
  96290. loop?: boolean;
  96291. /**
  96292. * Automatically updates internal texture from video at every frame in the render loop
  96293. */
  96294. autoUpdateTexture: boolean;
  96295. /**
  96296. * Image src displayed during the video loading or until the user interacts with the video.
  96297. */
  96298. poster?: string;
  96299. }
  96300. /**
  96301. * If you want to display a video in your scene, this is the special texture for that.
  96302. * This special texture works similar to other textures, with the exception of a few parameters.
  96303. * @see https://doc.babylonjs.com/how_to/video_texture
  96304. */
  96305. export class VideoTexture extends Texture {
  96306. /**
  96307. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  96308. */
  96309. readonly autoUpdateTexture: boolean;
  96310. /**
  96311. * The video instance used by the texture internally
  96312. */
  96313. readonly video: HTMLVideoElement;
  96314. private _onUserActionRequestedObservable;
  96315. /**
  96316. * Event triggerd when a dom action is required by the user to play the video.
  96317. * This happens due to recent changes in browser policies preventing video to auto start.
  96318. */
  96319. readonly onUserActionRequestedObservable: Observable<Texture>;
  96320. private _generateMipMaps;
  96321. private _engine;
  96322. private _stillImageCaptured;
  96323. private _displayingPosterTexture;
  96324. private _settings;
  96325. private _createInternalTextureOnEvent;
  96326. private _frameId;
  96327. /**
  96328. * Creates a video texture.
  96329. * If you want to display a video in your scene, this is the special texture for that.
  96330. * This special texture works similar to other textures, with the exception of a few parameters.
  96331. * @see https://doc.babylonjs.com/how_to/video_texture
  96332. * @param name optional name, will detect from video source, if not defined
  96333. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  96334. * @param scene is obviously the current scene.
  96335. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  96336. * @param invertY is false by default but can be used to invert video on Y axis
  96337. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  96338. * @param settings allows finer control over video usage
  96339. */
  96340. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  96341. private _getName;
  96342. private _getVideo;
  96343. private _createInternalTexture;
  96344. private reset;
  96345. /**
  96346. * @hidden Internal method to initiate `update`.
  96347. */
  96348. _rebuild(): void;
  96349. /**
  96350. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  96351. */
  96352. update(): void;
  96353. /**
  96354. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  96355. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  96356. */
  96357. updateTexture(isVisible: boolean): void;
  96358. protected _updateInternalTexture: () => void;
  96359. /**
  96360. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  96361. * @param url New url.
  96362. */
  96363. updateURL(url: string): void;
  96364. /**
  96365. * Dispose the texture and release its associated resources.
  96366. */
  96367. dispose(): void;
  96368. /**
  96369. * Creates a video texture straight from a stream.
  96370. * @param scene Define the scene the texture should be created in
  96371. * @param stream Define the stream the texture should be created from
  96372. * @returns The created video texture as a promise
  96373. */
  96374. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  96375. /**
  96376. * Creates a video texture straight from your WebCam video feed.
  96377. * @param scene Define the scene the texture should be created in
  96378. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96379. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96380. * @returns The created video texture as a promise
  96381. */
  96382. static CreateFromWebCamAsync(scene: Scene, constraints: {
  96383. minWidth: number;
  96384. maxWidth: number;
  96385. minHeight: number;
  96386. maxHeight: number;
  96387. deviceId: string;
  96388. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  96389. /**
  96390. * Creates a video texture straight from your WebCam video feed.
  96391. * @param scene Define the scene the texture should be created in
  96392. * @param onReady Define a callback to triggered once the texture will be ready
  96393. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96394. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96395. */
  96396. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  96397. minWidth: number;
  96398. maxWidth: number;
  96399. minHeight: number;
  96400. maxHeight: number;
  96401. deviceId: string;
  96402. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  96403. }
  96404. }
  96405. declare module BABYLON {
  96406. /**
  96407. * Defines the interface used by objects working like Scene
  96408. * @hidden
  96409. */
  96410. interface ISceneLike {
  96411. _addPendingData(data: any): void;
  96412. _removePendingData(data: any): void;
  96413. offlineProvider: IOfflineProvider;
  96414. }
  96415. /** Interface defining initialization parameters for Engine class */
  96416. export interface EngineOptions extends WebGLContextAttributes {
  96417. /**
  96418. * Defines if the engine should no exceed a specified device ratio
  96419. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  96420. */
  96421. limitDeviceRatio?: number;
  96422. /**
  96423. * Defines if webvr should be enabled automatically
  96424. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96425. */
  96426. autoEnableWebVR?: boolean;
  96427. /**
  96428. * Defines if webgl2 should be turned off even if supported
  96429. * @see http://doc.babylonjs.com/features/webgl2
  96430. */
  96431. disableWebGL2Support?: boolean;
  96432. /**
  96433. * Defines if webaudio should be initialized as well
  96434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96435. */
  96436. audioEngine?: boolean;
  96437. /**
  96438. * Defines if animations should run using a deterministic lock step
  96439. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96440. */
  96441. deterministicLockstep?: boolean;
  96442. /** Defines the maximum steps to use with deterministic lock step mode */
  96443. lockstepMaxSteps?: number;
  96444. /**
  96445. * Defines that engine should ignore context lost events
  96446. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  96447. */
  96448. doNotHandleContextLost?: boolean;
  96449. /**
  96450. * Defines that engine should ignore modifying touch action attribute and style
  96451. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  96452. */
  96453. doNotHandleTouchAction?: boolean;
  96454. /**
  96455. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  96456. */
  96457. useHighPrecisionFloats?: boolean;
  96458. }
  96459. /**
  96460. * The base engine class (root of all engines)
  96461. */
  96462. export class ThinEngine {
  96463. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  96464. static ExceptionList: ({
  96465. key: string;
  96466. capture: string;
  96467. captureConstraint: number;
  96468. targets: string[];
  96469. } | {
  96470. key: string;
  96471. capture: null;
  96472. captureConstraint: null;
  96473. targets: string[];
  96474. })[];
  96475. /** @hidden */
  96476. static _TextureLoaders: IInternalTextureLoader[];
  96477. /**
  96478. * Returns the current npm package of the sdk
  96479. */
  96480. static readonly NpmPackage: string;
  96481. /**
  96482. * Returns the current version of the framework
  96483. */
  96484. static readonly Version: string;
  96485. /**
  96486. * Returns a string describing the current engine
  96487. */
  96488. readonly description: string;
  96489. /**
  96490. * Gets or sets the epsilon value used by collision engine
  96491. */
  96492. static CollisionsEpsilon: number;
  96493. /**
  96494. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96495. */
  96496. static ShadersRepository: string;
  96497. /** @hidden */
  96498. _shaderProcessor: IShaderProcessor;
  96499. /**
  96500. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96501. */
  96502. forcePOTTextures: boolean;
  96503. /**
  96504. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96505. */
  96506. isFullscreen: boolean;
  96507. /**
  96508. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96509. */
  96510. cullBackFaces: boolean;
  96511. /**
  96512. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96513. */
  96514. renderEvenInBackground: boolean;
  96515. /**
  96516. * Gets or sets a boolean indicating that cache can be kept between frames
  96517. */
  96518. preventCacheWipeBetweenFrames: boolean;
  96519. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96520. validateShaderPrograms: boolean;
  96521. /**
  96522. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96523. */
  96524. disableUniformBuffers: boolean;
  96525. /** @hidden */
  96526. _uniformBuffers: UniformBuffer[];
  96527. /**
  96528. * Gets a boolean indicating that the engine supports uniform buffers
  96529. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96530. */
  96531. readonly supportsUniformBuffers: boolean;
  96532. /** @hidden */
  96533. _gl: WebGLRenderingContext;
  96534. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96535. protected _windowIsBackground: boolean;
  96536. protected _webGLVersion: number;
  96537. protected _highPrecisionShadersAllowed: boolean;
  96538. /** @hidden */
  96539. readonly _shouldUseHighPrecisionShader: boolean;
  96540. /**
  96541. * Gets a boolean indicating that only power of 2 textures are supported
  96542. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96543. */
  96544. readonly needPOTTextures: boolean;
  96545. /** @hidden */
  96546. _badOS: boolean;
  96547. /** @hidden */
  96548. _badDesktopOS: boolean;
  96549. private _hardwareScalingLevel;
  96550. /** @hidden */
  96551. _caps: EngineCapabilities;
  96552. private _isStencilEnable;
  96553. protected _colorWrite: boolean;
  96554. private _glVersion;
  96555. private _glRenderer;
  96556. private _glVendor;
  96557. /** @hidden */
  96558. _videoTextureSupported: boolean;
  96559. protected _renderingQueueLaunched: boolean;
  96560. protected _activeRenderLoops: (() => void)[];
  96561. /**
  96562. * Observable signaled when a context lost event is raised
  96563. */
  96564. onContextLostObservable: Observable<ThinEngine>;
  96565. /**
  96566. * Observable signaled when a context restored event is raised
  96567. */
  96568. onContextRestoredObservable: Observable<ThinEngine>;
  96569. private _onContextLost;
  96570. private _onContextRestored;
  96571. protected _contextWasLost: boolean;
  96572. /** @hidden */
  96573. _doNotHandleContextLost: boolean;
  96574. /**
  96575. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96576. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96577. */
  96578. doNotHandleContextLost: boolean;
  96579. /**
  96580. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96581. */
  96582. disableVertexArrayObjects: boolean;
  96583. /** @hidden */
  96584. protected _depthCullingState: DepthCullingState;
  96585. /** @hidden */
  96586. protected _stencilState: StencilState;
  96587. /** @hidden */
  96588. protected _alphaState: AlphaState;
  96589. /** @hidden */
  96590. _internalTexturesCache: InternalTexture[];
  96591. /** @hidden */
  96592. protected _activeChannel: number;
  96593. private _currentTextureChannel;
  96594. /** @hidden */
  96595. protected _boundTexturesCache: {
  96596. [key: string]: Nullable<InternalTexture>;
  96597. };
  96598. /** @hidden */
  96599. protected _currentEffect: Nullable<Effect>;
  96600. /** @hidden */
  96601. protected _currentProgram: Nullable<WebGLProgram>;
  96602. private _compiledEffects;
  96603. private _vertexAttribArraysEnabled;
  96604. /** @hidden */
  96605. protected _cachedViewport: Nullable<IViewportLike>;
  96606. private _cachedVertexArrayObject;
  96607. /** @hidden */
  96608. protected _cachedVertexBuffers: any;
  96609. /** @hidden */
  96610. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96611. /** @hidden */
  96612. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96613. /** @hidden */
  96614. _currentRenderTarget: Nullable<InternalTexture>;
  96615. private _uintIndicesCurrentlySet;
  96616. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  96617. /** @hidden */
  96618. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96619. private _currentBufferPointers;
  96620. private _currentInstanceLocations;
  96621. private _currentInstanceBuffers;
  96622. private _textureUnits;
  96623. /** @hidden */
  96624. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  96625. /** @hidden */
  96626. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  96627. /** @hidden */
  96628. _bindedRenderFunction: any;
  96629. private _vaoRecordInProgress;
  96630. private _mustWipeVertexAttributes;
  96631. private _emptyTexture;
  96632. private _emptyCubeTexture;
  96633. private _emptyTexture3D;
  96634. /** @hidden */
  96635. _frameHandler: number;
  96636. private _nextFreeTextureSlots;
  96637. private _maxSimultaneousTextures;
  96638. private _activeRequests;
  96639. protected _texturesSupported: string[];
  96640. /** @hidden */
  96641. _textureFormatInUse: Nullable<string>;
  96642. protected readonly _supportsHardwareTextureRescaling: boolean;
  96643. /**
  96644. * Gets the list of texture formats supported
  96645. */
  96646. readonly texturesSupported: Array<string>;
  96647. /**
  96648. * Gets the list of texture formats in use
  96649. */
  96650. readonly textureFormatInUse: Nullable<string>;
  96651. /**
  96652. * Gets the current viewport
  96653. */
  96654. readonly currentViewport: Nullable<IViewportLike>;
  96655. /**
  96656. * Gets the default empty texture
  96657. */
  96658. readonly emptyTexture: InternalTexture;
  96659. /**
  96660. * Gets the default empty 3D texture
  96661. */
  96662. readonly emptyTexture3D: InternalTexture;
  96663. /**
  96664. * Gets the default empty cube texture
  96665. */
  96666. readonly emptyCubeTexture: InternalTexture;
  96667. /**
  96668. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96669. */
  96670. readonly premultipliedAlpha: boolean;
  96671. /**
  96672. * Observable event triggered before each texture is initialized
  96673. */
  96674. onBeforeTextureInitObservable: Observable<Texture>;
  96675. /**
  96676. * Creates a new engine
  96677. * @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
  96678. * @param antialias defines enable antialiasing (default: false)
  96679. * @param options defines further options to be sent to the getContext() function
  96680. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96681. */
  96682. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96683. private _rebuildInternalTextures;
  96684. private _rebuildEffects;
  96685. /**
  96686. * Gets a boolean indicating if all created effects are ready
  96687. * @returns true if all effects are ready
  96688. */
  96689. areAllEffectsReady(): boolean;
  96690. protected _rebuildBuffers(): void;
  96691. private _initGLContext;
  96692. /**
  96693. * Gets version of the current webGL context
  96694. */
  96695. readonly webGLVersion: number;
  96696. /**
  96697. * Gets a string idenfifying the name of the class
  96698. * @returns "Engine" string
  96699. */
  96700. getClassName(): string;
  96701. /**
  96702. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96703. */
  96704. readonly isStencilEnable: boolean;
  96705. /** @hidden */
  96706. _prepareWorkingCanvas(): void;
  96707. /**
  96708. * Reset the texture cache to empty state
  96709. */
  96710. resetTextureCache(): void;
  96711. /**
  96712. * Gets an object containing information about the current webGL context
  96713. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96714. */
  96715. getGlInfo(): {
  96716. vendor: string;
  96717. renderer: string;
  96718. version: string;
  96719. };
  96720. /**
  96721. * Defines the hardware scaling level.
  96722. * By default the hardware scaling level is computed from the window device ratio.
  96723. * 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.
  96724. * @param level defines the level to use
  96725. */
  96726. setHardwareScalingLevel(level: number): void;
  96727. /**
  96728. * Gets the current hardware scaling level.
  96729. * By default the hardware scaling level is computed from the window device ratio.
  96730. * 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.
  96731. * @returns a number indicating the current hardware scaling level
  96732. */
  96733. getHardwareScalingLevel(): number;
  96734. /**
  96735. * Gets the list of loaded textures
  96736. * @returns an array containing all loaded textures
  96737. */
  96738. getLoadedTexturesCache(): InternalTexture[];
  96739. /**
  96740. * Gets the object containing all engine capabilities
  96741. * @returns the EngineCapabilities object
  96742. */
  96743. getCaps(): EngineCapabilities;
  96744. /**
  96745. * stop executing a render loop function and remove it from the execution array
  96746. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96747. */
  96748. stopRenderLoop(renderFunction?: () => void): void;
  96749. /** @hidden */
  96750. _renderLoop(): void;
  96751. /**
  96752. * Gets the HTML canvas attached with the current webGL context
  96753. * @returns a HTML canvas
  96754. */
  96755. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96756. /**
  96757. * Gets host window
  96758. * @returns the host window object
  96759. */
  96760. getHostWindow(): Nullable<Window>;
  96761. /**
  96762. * Gets the current render width
  96763. * @param useScreen defines if screen size must be used (or the current render target if any)
  96764. * @returns a number defining the current render width
  96765. */
  96766. getRenderWidth(useScreen?: boolean): number;
  96767. /**
  96768. * Gets the current render height
  96769. * @param useScreen defines if screen size must be used (or the current render target if any)
  96770. * @returns a number defining the current render height
  96771. */
  96772. getRenderHeight(useScreen?: boolean): number;
  96773. /**
  96774. * Can be used to override the current requestAnimationFrame requester.
  96775. * @hidden
  96776. */
  96777. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96778. /**
  96779. * Register and execute a render loop. The engine can have more than one render function
  96780. * @param renderFunction defines the function to continuously execute
  96781. */
  96782. runRenderLoop(renderFunction: () => void): void;
  96783. /**
  96784. * Clear the current render buffer or the current render target (if any is set up)
  96785. * @param color defines the color to use
  96786. * @param backBuffer defines if the back buffer must be cleared
  96787. * @param depth defines if the depth buffer must be cleared
  96788. * @param stencil defines if the stencil buffer must be cleared
  96789. */
  96790. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96791. private _viewportCached;
  96792. /** @hidden */
  96793. _viewport(x: number, y: number, width: number, height: number): void;
  96794. /**
  96795. * Set the WebGL's viewport
  96796. * @param viewport defines the viewport element to be used
  96797. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96798. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96799. */
  96800. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96801. /**
  96802. * Begin a new frame
  96803. */
  96804. beginFrame(): void;
  96805. /**
  96806. * Enf the current frame
  96807. */
  96808. endFrame(): void;
  96809. /**
  96810. * Resize the view according to the canvas' size
  96811. */
  96812. resize(): void;
  96813. /**
  96814. * Force a specific size of the canvas
  96815. * @param width defines the new canvas' width
  96816. * @param height defines the new canvas' height
  96817. */
  96818. setSize(width: number, height: number): void;
  96819. /**
  96820. * Binds the frame buffer to the specified texture.
  96821. * @param texture The texture to render to or null for the default canvas
  96822. * @param faceIndex The face of the texture to render to in case of cube texture
  96823. * @param requiredWidth The width of the target to render to
  96824. * @param requiredHeight The height of the target to render to
  96825. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96826. * @param depthStencilTexture The depth stencil texture to use to render
  96827. * @param lodLevel defines le lod level to bind to the frame buffer
  96828. */
  96829. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96830. /** @hidden */
  96831. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96832. /**
  96833. * Unbind the current render target texture from the webGL context
  96834. * @param texture defines the render target texture to unbind
  96835. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96836. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96837. */
  96838. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96839. /**
  96840. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96841. */
  96842. flushFramebuffer(): void;
  96843. /**
  96844. * Unbind the current render target and bind the default framebuffer
  96845. */
  96846. restoreDefaultFramebuffer(): void;
  96847. /** @hidden */
  96848. protected _resetVertexBufferBinding(): void;
  96849. /**
  96850. * Creates a vertex buffer
  96851. * @param data the data for the vertex buffer
  96852. * @returns the new WebGL static buffer
  96853. */
  96854. createVertexBuffer(data: DataArray): DataBuffer;
  96855. private _createVertexBuffer;
  96856. /**
  96857. * Creates a dynamic vertex buffer
  96858. * @param data the data for the dynamic vertex buffer
  96859. * @returns the new WebGL dynamic buffer
  96860. */
  96861. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96862. protected _resetIndexBufferBinding(): void;
  96863. /**
  96864. * Creates a new index buffer
  96865. * @param indices defines the content of the index buffer
  96866. * @param updatable defines if the index buffer must be updatable
  96867. * @returns a new webGL buffer
  96868. */
  96869. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96870. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96871. /**
  96872. * Bind a webGL buffer to the webGL context
  96873. * @param buffer defines the buffer to bind
  96874. */
  96875. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96876. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96877. private bindBuffer;
  96878. /**
  96879. * update the bound buffer with the given data
  96880. * @param data defines the data to update
  96881. */
  96882. updateArrayBuffer(data: Float32Array): void;
  96883. private _vertexAttribPointer;
  96884. private _bindIndexBufferWithCache;
  96885. private _bindVertexBuffersAttributes;
  96886. /**
  96887. * Records a vertex array object
  96888. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96889. * @param vertexBuffers defines the list of vertex buffers to store
  96890. * @param indexBuffer defines the index buffer to store
  96891. * @param effect defines the effect to store
  96892. * @returns the new vertex array object
  96893. */
  96894. recordVertexArrayObject(vertexBuffers: {
  96895. [key: string]: VertexBuffer;
  96896. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96897. /**
  96898. * Bind a specific vertex array object
  96899. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96900. * @param vertexArrayObject defines the vertex array object to bind
  96901. * @param indexBuffer defines the index buffer to bind
  96902. */
  96903. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96904. /**
  96905. * Bind webGl buffers directly to the webGL context
  96906. * @param vertexBuffer defines the vertex buffer to bind
  96907. * @param indexBuffer defines the index buffer to bind
  96908. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96909. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96910. * @param effect defines the effect associated with the vertex buffer
  96911. */
  96912. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96913. private _unbindVertexArrayObject;
  96914. /**
  96915. * Bind a list of vertex buffers to the webGL context
  96916. * @param vertexBuffers defines the list of vertex buffers to bind
  96917. * @param indexBuffer defines the index buffer to bind
  96918. * @param effect defines the effect associated with the vertex buffers
  96919. */
  96920. bindBuffers(vertexBuffers: {
  96921. [key: string]: Nullable<VertexBuffer>;
  96922. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96923. /**
  96924. * Unbind all instance attributes
  96925. */
  96926. unbindInstanceAttributes(): void;
  96927. /**
  96928. * Release and free the memory of a vertex array object
  96929. * @param vao defines the vertex array object to delete
  96930. */
  96931. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96932. /** @hidden */
  96933. _releaseBuffer(buffer: DataBuffer): boolean;
  96934. protected _deleteBuffer(buffer: DataBuffer): void;
  96935. /**
  96936. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96937. * @param instancesBuffer defines the webGL buffer to update and bind
  96938. * @param data defines the data to store in the buffer
  96939. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96940. */
  96941. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96942. /**
  96943. * Apply all cached states (depth, culling, stencil and alpha)
  96944. */
  96945. applyStates(): void;
  96946. /**
  96947. * Send a draw order
  96948. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96949. * @param indexStart defines the starting index
  96950. * @param indexCount defines the number of index to draw
  96951. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96952. */
  96953. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96954. /**
  96955. * Draw a list of points
  96956. * @param verticesStart defines the index of first vertex to draw
  96957. * @param verticesCount defines the count of vertices to draw
  96958. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96959. */
  96960. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96961. /**
  96962. * Draw a list of unindexed primitives
  96963. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96964. * @param verticesStart defines the index of first vertex to draw
  96965. * @param verticesCount defines the count of vertices to draw
  96966. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96967. */
  96968. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96969. /**
  96970. * Draw a list of indexed primitives
  96971. * @param fillMode defines the primitive to use
  96972. * @param indexStart defines the starting index
  96973. * @param indexCount defines the number of index to draw
  96974. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96975. */
  96976. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96977. /**
  96978. * Draw a list of unindexed primitives
  96979. * @param fillMode defines the primitive to use
  96980. * @param verticesStart defines the index of first vertex to draw
  96981. * @param verticesCount defines the count of vertices to draw
  96982. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96983. */
  96984. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96985. private _drawMode;
  96986. /** @hidden */
  96987. protected _reportDrawCall(): void;
  96988. /** @hidden */
  96989. _releaseEffect(effect: Effect): void;
  96990. /** @hidden */
  96991. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96992. /**
  96993. * Create a new effect (used to store vertex/fragment shaders)
  96994. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96995. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  96996. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96997. * @param samplers defines an array of string used to represent textures
  96998. * @param defines defines the string containing the defines to use to compile the shaders
  96999. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  97000. * @param onCompiled defines a function to call when the effect creation is successful
  97001. * @param onError defines a function to call when the effect creation has failed
  97002. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  97003. * @returns the new Effect
  97004. */
  97005. 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;
  97006. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  97007. private _compileShader;
  97008. private _compileRawShader;
  97009. /**
  97010. * Directly creates a webGL program
  97011. * @param pipelineContext defines the pipeline context to attach to
  97012. * @param vertexCode defines the vertex shader code to use
  97013. * @param fragmentCode defines the fragment shader code to use
  97014. * @param context defines the webGL context to use (if not set, the current one will be used)
  97015. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97016. * @returns the new webGL program
  97017. */
  97018. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97019. /**
  97020. * Creates a webGL program
  97021. * @param pipelineContext defines the pipeline context to attach to
  97022. * @param vertexCode defines the vertex shader code to use
  97023. * @param fragmentCode defines the fragment shader code to use
  97024. * @param defines defines the string containing the defines to use to compile the shaders
  97025. * @param context defines the webGL context to use (if not set, the current one will be used)
  97026. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97027. * @returns the new webGL program
  97028. */
  97029. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97030. /**
  97031. * Creates a new pipeline context
  97032. * @returns the new pipeline
  97033. */
  97034. createPipelineContext(): IPipelineContext;
  97035. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97036. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  97037. /** @hidden */
  97038. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97039. /** @hidden */
  97040. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97041. /** @hidden */
  97042. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97043. /**
  97044. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97045. * @param pipelineContext defines the pipeline context to use
  97046. * @param uniformsNames defines the list of uniform names
  97047. * @returns an array of webGL uniform locations
  97048. */
  97049. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97050. /**
  97051. * Gets the lsit of active attributes for a given webGL program
  97052. * @param pipelineContext defines the pipeline context to use
  97053. * @param attributesNames defines the list of attribute names to get
  97054. * @returns an array of indices indicating the offset of each attribute
  97055. */
  97056. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97057. /**
  97058. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97059. * @param effect defines the effect to activate
  97060. */
  97061. enableEffect(effect: Nullable<Effect>): void;
  97062. /**
  97063. * Set the value of an uniform to a number (int)
  97064. * @param uniform defines the webGL uniform location where to store the value
  97065. * @param value defines the int number to store
  97066. */
  97067. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97068. /**
  97069. * Set the value of an uniform to an array of int32
  97070. * @param uniform defines the webGL uniform location where to store the value
  97071. * @param array defines the array of int32 to store
  97072. */
  97073. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97074. /**
  97075. * Set the value of an uniform to an array of int32 (stored as vec2)
  97076. * @param uniform defines the webGL uniform location where to store the value
  97077. * @param array defines the array of int32 to store
  97078. */
  97079. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97080. /**
  97081. * Set the value of an uniform to an array of int32 (stored as vec3)
  97082. * @param uniform defines the webGL uniform location where to store the value
  97083. * @param array defines the array of int32 to store
  97084. */
  97085. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97086. /**
  97087. * Set the value of an uniform to an array of int32 (stored as vec4)
  97088. * @param uniform defines the webGL uniform location where to store the value
  97089. * @param array defines the array of int32 to store
  97090. */
  97091. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97092. /**
  97093. * Set the value of an uniform to an array of number
  97094. * @param uniform defines the webGL uniform location where to store the value
  97095. * @param array defines the array of number to store
  97096. */
  97097. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97098. /**
  97099. * Set the value of an uniform to an array of number (stored as vec2)
  97100. * @param uniform defines the webGL uniform location where to store the value
  97101. * @param array defines the array of number to store
  97102. */
  97103. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97104. /**
  97105. * Set the value of an uniform to an array of number (stored as vec3)
  97106. * @param uniform defines the webGL uniform location where to store the value
  97107. * @param array defines the array of number to store
  97108. */
  97109. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97110. /**
  97111. * Set the value of an uniform to an array of number (stored as vec4)
  97112. * @param uniform defines the webGL uniform location where to store the value
  97113. * @param array defines the array of number to store
  97114. */
  97115. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97116. /**
  97117. * Set the value of an uniform to an array of float32 (stored as matrices)
  97118. * @param uniform defines the webGL uniform location where to store the value
  97119. * @param matrices defines the array of float32 to store
  97120. */
  97121. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97122. /**
  97123. * Set the value of an uniform to a matrix (3x3)
  97124. * @param uniform defines the webGL uniform location where to store the value
  97125. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97126. */
  97127. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97128. /**
  97129. * Set the value of an uniform to a matrix (2x2)
  97130. * @param uniform defines the webGL uniform location where to store the value
  97131. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97132. */
  97133. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97134. /**
  97135. * Set the value of an uniform to a number (float)
  97136. * @param uniform defines the webGL uniform location where to store the value
  97137. * @param value defines the float number to store
  97138. */
  97139. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97140. /**
  97141. * Set the value of an uniform to a vec2
  97142. * @param uniform defines the webGL uniform location where to store the value
  97143. * @param x defines the 1st component of the value
  97144. * @param y defines the 2nd component of the value
  97145. */
  97146. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97147. /**
  97148. * Set the value of an uniform to a vec3
  97149. * @param uniform defines the webGL uniform location where to store the value
  97150. * @param x defines the 1st component of the value
  97151. * @param y defines the 2nd component of the value
  97152. * @param z defines the 3rd component of the value
  97153. */
  97154. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97155. /**
  97156. * Set the value of an uniform to a vec4
  97157. * @param uniform defines the webGL uniform location where to store the value
  97158. * @param x defines the 1st component of the value
  97159. * @param y defines the 2nd component of the value
  97160. * @param z defines the 3rd component of the value
  97161. * @param w defines the 4th component of the value
  97162. */
  97163. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97164. /**
  97165. * Gets the depth culling state manager
  97166. */
  97167. readonly depthCullingState: DepthCullingState;
  97168. /**
  97169. * Gets the alpha state manager
  97170. */
  97171. readonly alphaState: AlphaState;
  97172. /**
  97173. * Gets the stencil state manager
  97174. */
  97175. readonly stencilState: StencilState;
  97176. /**
  97177. * Clears the list of texture accessible through engine.
  97178. * This can help preventing texture load conflict due to name collision.
  97179. */
  97180. clearInternalTexturesCache(): void;
  97181. /**
  97182. * Force the entire cache to be cleared
  97183. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97184. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97185. */
  97186. wipeCaches(bruteForce?: boolean): void;
  97187. /** @hidden */
  97188. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97189. min: number;
  97190. mag: number;
  97191. };
  97192. /** @hidden */
  97193. _createTexture(): WebGLTexture;
  97194. /**
  97195. * Usually called from Texture.ts.
  97196. * Passed information to create a WebGLTexture
  97197. * @param urlArg defines a value which contains one of the following:
  97198. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97199. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97200. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97201. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97202. * @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)
  97203. * @param scene needed for loading to the correct scene
  97204. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97205. * @param onLoad optional callback to be called upon successful completion
  97206. * @param onError optional callback to be called upon failure
  97207. * @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
  97208. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97209. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97210. * @param forcedExtension defines the extension to use to pick the right loader
  97211. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97212. * @param mimeType defines an optional mime type
  97213. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97214. */
  97215. 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;
  97216. /**
  97217. * @hidden
  97218. */
  97219. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  97220. /**
  97221. * Creates a raw texture
  97222. * @param data defines the data to store in the texture
  97223. * @param width defines the width of the texture
  97224. * @param height defines the height of the texture
  97225. * @param format defines the format of the data
  97226. * @param generateMipMaps defines if the engine should generate the mip levels
  97227. * @param invertY defines if data must be stored with Y axis inverted
  97228. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97229. * @param compression defines the compression used (null by default)
  97230. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  97231. * @returns the raw texture inside an InternalTexture
  97232. */
  97233. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  97234. /**
  97235. * Creates a new raw cube texture
  97236. * @param data defines the array of data to use to create each face
  97237. * @param size defines the size of the textures
  97238. * @param format defines the format of the data
  97239. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  97240. * @param generateMipMaps defines if the engine should generate the mip levels
  97241. * @param invertY defines if data must be stored with Y axis inverted
  97242. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97243. * @param compression defines the compression used (null by default)
  97244. * @returns the cube texture as an InternalTexture
  97245. */
  97246. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  97247. /**
  97248. * Creates a new raw 3D texture
  97249. * @param data defines the data used to create the texture
  97250. * @param width defines the width of the texture
  97251. * @param height defines the height of the texture
  97252. * @param depth defines the depth of the texture
  97253. * @param format defines the format of the texture
  97254. * @param generateMipMaps defines if the engine must generate mip levels
  97255. * @param invertY defines if data must be stored with Y axis inverted
  97256. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97257. * @param compression defines the compressed used (can be null)
  97258. * @param textureType defines the compressed used (can be null)
  97259. * @returns a new raw 3D texture (stored in an InternalTexture)
  97260. */
  97261. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  97262. private _unpackFlipYCached;
  97263. /**
  97264. * In case you are sharing the context with other applications, it might
  97265. * be interested to not cache the unpack flip y state to ensure a consistent
  97266. * value would be set.
  97267. */
  97268. enableUnpackFlipYCached: boolean;
  97269. /** @hidden */
  97270. _unpackFlipY(value: boolean): void;
  97271. /** @hidden */
  97272. _getUnpackAlignement(): number;
  97273. /**
  97274. * Update the sampling mode of a given texture
  97275. * @param samplingMode defines the required sampling mode
  97276. * @param texture defines the texture to update
  97277. */
  97278. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97279. /** @hidden */
  97280. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97281. width: number;
  97282. height: number;
  97283. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97284. /** @hidden */
  97285. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97286. /** @hidden */
  97287. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97288. /** @hidden */
  97289. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97290. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97291. private _prepareWebGLTexture;
  97292. /** @hidden */
  97293. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97294. /** @hidden */
  97295. _releaseFramebufferObjects(texture: InternalTexture): void;
  97296. /** @hidden */
  97297. _releaseTexture(texture: InternalTexture): void;
  97298. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97299. protected _setProgram(program: WebGLProgram): void;
  97300. protected _boundUniforms: {
  97301. [key: number]: WebGLUniformLocation;
  97302. };
  97303. /**
  97304. * Binds an effect to the webGL context
  97305. * @param effect defines the effect to bind
  97306. */
  97307. bindSamplers(effect: Effect): void;
  97308. private _activateCurrentTexture;
  97309. /** @hidden */
  97310. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97311. /** @hidden */
  97312. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97313. /**
  97314. * Unbind all textures from the webGL context
  97315. */
  97316. unbindAllTextures(): void;
  97317. /**
  97318. * Sets a texture to the according uniform.
  97319. * @param channel The texture channel
  97320. * @param uniform The uniform to set
  97321. * @param texture The texture to apply
  97322. */
  97323. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97324. private _bindSamplerUniformToChannel;
  97325. private _getTextureWrapMode;
  97326. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97327. /**
  97328. * Sets an array of texture to the webGL context
  97329. * @param channel defines the channel where the texture array must be set
  97330. * @param uniform defines the associated uniform location
  97331. * @param textures defines the array of textures to bind
  97332. */
  97333. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97334. /** @hidden */
  97335. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97336. private _setTextureParameterFloat;
  97337. private _setTextureParameterInteger;
  97338. /**
  97339. * Unbind all vertex attributes from the webGL context
  97340. */
  97341. unbindAllAttributes(): void;
  97342. /**
  97343. * 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
  97344. */
  97345. releaseEffects(): void;
  97346. /**
  97347. * Dispose and release all associated resources
  97348. */
  97349. dispose(): void;
  97350. /**
  97351. * Attach a new callback raised when context lost event is fired
  97352. * @param callback defines the callback to call
  97353. */
  97354. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97355. /**
  97356. * Attach a new callback raised when context restored event is fired
  97357. * @param callback defines the callback to call
  97358. */
  97359. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97360. /**
  97361. * Get the current error code of the webGL context
  97362. * @returns the error code
  97363. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97364. */
  97365. getError(): number;
  97366. private _canRenderToFloatFramebuffer;
  97367. private _canRenderToHalfFloatFramebuffer;
  97368. private _canRenderToFramebuffer;
  97369. /** @hidden */
  97370. _getWebGLTextureType(type: number): number;
  97371. /** @hidden */
  97372. _getInternalFormat(format: number): number;
  97373. /** @hidden */
  97374. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97375. /** @hidden */
  97376. _getRGBAMultiSampleBufferFormat(type: number): number;
  97377. /** @hidden */
  97378. _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;
  97379. /**
  97380. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97381. * @returns true if the engine can be created
  97382. * @ignorenaming
  97383. */
  97384. static isSupported(): boolean;
  97385. /**
  97386. * Find the next highest power of two.
  97387. * @param x Number to start search from.
  97388. * @return Next highest power of two.
  97389. */
  97390. static CeilingPOT(x: number): number;
  97391. /**
  97392. * Find the next lowest power of two.
  97393. * @param x Number to start search from.
  97394. * @return Next lowest power of two.
  97395. */
  97396. static FloorPOT(x: number): number;
  97397. /**
  97398. * Find the nearest power of two.
  97399. * @param x Number to start search from.
  97400. * @return Next nearest power of two.
  97401. */
  97402. static NearestPOT(x: number): number;
  97403. /**
  97404. * Get the closest exponent of two
  97405. * @param value defines the value to approximate
  97406. * @param max defines the maximum value to return
  97407. * @param mode defines how to define the closest value
  97408. * @returns closest exponent of two of the given value
  97409. */
  97410. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97411. /**
  97412. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97413. * @param func - the function to be called
  97414. * @param requester - the object that will request the next frame. Falls back to window.
  97415. * @returns frame number
  97416. */
  97417. static QueueNewFrame(func: () => void, requester?: any): number;
  97418. }
  97419. }
  97420. declare module BABYLON {
  97421. /**
  97422. * Class representing spherical harmonics coefficients to the 3rd degree
  97423. */
  97424. export class SphericalHarmonics {
  97425. /**
  97426. * Defines whether or not the harmonics have been prescaled for rendering.
  97427. */
  97428. preScaled: boolean;
  97429. /**
  97430. * The l0,0 coefficients of the spherical harmonics
  97431. */
  97432. l00: Vector3;
  97433. /**
  97434. * The l1,-1 coefficients of the spherical harmonics
  97435. */
  97436. l1_1: Vector3;
  97437. /**
  97438. * The l1,0 coefficients of the spherical harmonics
  97439. */
  97440. l10: Vector3;
  97441. /**
  97442. * The l1,1 coefficients of the spherical harmonics
  97443. */
  97444. l11: Vector3;
  97445. /**
  97446. * The l2,-2 coefficients of the spherical harmonics
  97447. */
  97448. l2_2: Vector3;
  97449. /**
  97450. * The l2,-1 coefficients of the spherical harmonics
  97451. */
  97452. l2_1: Vector3;
  97453. /**
  97454. * The l2,0 coefficients of the spherical harmonics
  97455. */
  97456. l20: Vector3;
  97457. /**
  97458. * The l2,1 coefficients of the spherical harmonics
  97459. */
  97460. l21: Vector3;
  97461. /**
  97462. * The l2,2 coefficients of the spherical harmonics
  97463. */
  97464. l22: Vector3;
  97465. /**
  97466. * Adds a light to the spherical harmonics
  97467. * @param direction the direction of the light
  97468. * @param color the color of the light
  97469. * @param deltaSolidAngle the delta solid angle of the light
  97470. */
  97471. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  97472. /**
  97473. * Scales the spherical harmonics by the given amount
  97474. * @param scale the amount to scale
  97475. */
  97476. scaleInPlace(scale: number): void;
  97477. /**
  97478. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  97479. *
  97480. * ```
  97481. * E_lm = A_l * L_lm
  97482. * ```
  97483. *
  97484. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  97485. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  97486. * the scaling factors are given in equation 9.
  97487. */
  97488. convertIncidentRadianceToIrradiance(): void;
  97489. /**
  97490. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  97491. *
  97492. * ```
  97493. * L = (1/pi) * E * rho
  97494. * ```
  97495. *
  97496. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  97497. */
  97498. convertIrradianceToLambertianRadiance(): void;
  97499. /**
  97500. * Integrates the reconstruction coefficients directly in to the SH preventing further
  97501. * required operations at run time.
  97502. *
  97503. * This is simply done by scaling back the SH with Ylm constants parameter.
  97504. * The trigonometric part being applied by the shader at run time.
  97505. */
  97506. preScaleForRendering(): void;
  97507. /**
  97508. * Constructs a spherical harmonics from an array.
  97509. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  97510. * @returns the spherical harmonics
  97511. */
  97512. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  97513. /**
  97514. * Gets the spherical harmonics from polynomial
  97515. * @param polynomial the spherical polynomial
  97516. * @returns the spherical harmonics
  97517. */
  97518. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  97519. }
  97520. /**
  97521. * Class representing spherical polynomial coefficients to the 3rd degree
  97522. */
  97523. export class SphericalPolynomial {
  97524. private _harmonics;
  97525. /**
  97526. * The spherical harmonics used to create the polynomials.
  97527. */
  97528. readonly preScaledHarmonics: SphericalHarmonics;
  97529. /**
  97530. * The x coefficients of the spherical polynomial
  97531. */
  97532. x: Vector3;
  97533. /**
  97534. * The y coefficients of the spherical polynomial
  97535. */
  97536. y: Vector3;
  97537. /**
  97538. * The z coefficients of the spherical polynomial
  97539. */
  97540. z: Vector3;
  97541. /**
  97542. * The xx coefficients of the spherical polynomial
  97543. */
  97544. xx: Vector3;
  97545. /**
  97546. * The yy coefficients of the spherical polynomial
  97547. */
  97548. yy: Vector3;
  97549. /**
  97550. * The zz coefficients of the spherical polynomial
  97551. */
  97552. zz: Vector3;
  97553. /**
  97554. * The xy coefficients of the spherical polynomial
  97555. */
  97556. xy: Vector3;
  97557. /**
  97558. * The yz coefficients of the spherical polynomial
  97559. */
  97560. yz: Vector3;
  97561. /**
  97562. * The zx coefficients of the spherical polynomial
  97563. */
  97564. zx: Vector3;
  97565. /**
  97566. * Adds an ambient color to the spherical polynomial
  97567. * @param color the color to add
  97568. */
  97569. addAmbient(color: Color3): void;
  97570. /**
  97571. * Scales the spherical polynomial by the given amount
  97572. * @param scale the amount to scale
  97573. */
  97574. scaleInPlace(scale: number): void;
  97575. /**
  97576. * Gets the spherical polynomial from harmonics
  97577. * @param harmonics the spherical harmonics
  97578. * @returns the spherical polynomial
  97579. */
  97580. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  97581. /**
  97582. * Constructs a spherical polynomial from an array.
  97583. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  97584. * @returns the spherical polynomial
  97585. */
  97586. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  97587. }
  97588. }
  97589. declare module BABYLON {
  97590. /**
  97591. * Defines the source of the internal texture
  97592. */
  97593. export enum InternalTextureSource {
  97594. /**
  97595. * The source of the texture data is unknown
  97596. */
  97597. Unknown = 0,
  97598. /**
  97599. * Texture data comes from an URL
  97600. */
  97601. Url = 1,
  97602. /**
  97603. * Texture data is only used for temporary storage
  97604. */
  97605. Temp = 2,
  97606. /**
  97607. * Texture data comes from raw data (ArrayBuffer)
  97608. */
  97609. Raw = 3,
  97610. /**
  97611. * Texture content is dynamic (video or dynamic texture)
  97612. */
  97613. Dynamic = 4,
  97614. /**
  97615. * Texture content is generated by rendering to it
  97616. */
  97617. RenderTarget = 5,
  97618. /**
  97619. * Texture content is part of a multi render target process
  97620. */
  97621. MultiRenderTarget = 6,
  97622. /**
  97623. * Texture data comes from a cube data file
  97624. */
  97625. Cube = 7,
  97626. /**
  97627. * Texture data comes from a raw cube data
  97628. */
  97629. CubeRaw = 8,
  97630. /**
  97631. * Texture data come from a prefiltered cube data file
  97632. */
  97633. CubePrefiltered = 9,
  97634. /**
  97635. * Texture content is raw 3D data
  97636. */
  97637. Raw3D = 10,
  97638. /**
  97639. * Texture content is a depth texture
  97640. */
  97641. Depth = 11,
  97642. /**
  97643. * Texture data comes from a raw cube data encoded with RGBD
  97644. */
  97645. CubeRawRGBD = 12
  97646. }
  97647. /**
  97648. * Class used to store data associated with WebGL texture data for the engine
  97649. * This class should not be used directly
  97650. */
  97651. export class InternalTexture {
  97652. /** @hidden */
  97653. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97654. /**
  97655. * Defines if the texture is ready
  97656. */
  97657. isReady: boolean;
  97658. /**
  97659. * Defines if the texture is a cube texture
  97660. */
  97661. isCube: boolean;
  97662. /**
  97663. * Defines if the texture contains 3D data
  97664. */
  97665. is3D: boolean;
  97666. /**
  97667. * Defines if the texture contains multiview data
  97668. */
  97669. isMultiview: boolean;
  97670. /**
  97671. * Gets the URL used to load this texture
  97672. */
  97673. url: string;
  97674. /**
  97675. * Gets the sampling mode of the texture
  97676. */
  97677. samplingMode: number;
  97678. /**
  97679. * Gets a boolean indicating if the texture needs mipmaps generation
  97680. */
  97681. generateMipMaps: boolean;
  97682. /**
  97683. * Gets the number of samples used by the texture (WebGL2+ only)
  97684. */
  97685. samples: number;
  97686. /**
  97687. * Gets the type of the texture (int, float...)
  97688. */
  97689. type: number;
  97690. /**
  97691. * Gets the format of the texture (RGB, RGBA...)
  97692. */
  97693. format: number;
  97694. /**
  97695. * Observable called when the texture is loaded
  97696. */
  97697. onLoadedObservable: Observable<InternalTexture>;
  97698. /**
  97699. * Gets the width of the texture
  97700. */
  97701. width: number;
  97702. /**
  97703. * Gets the height of the texture
  97704. */
  97705. height: number;
  97706. /**
  97707. * Gets the depth of the texture
  97708. */
  97709. depth: number;
  97710. /**
  97711. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97712. */
  97713. baseWidth: number;
  97714. /**
  97715. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97716. */
  97717. baseHeight: number;
  97718. /**
  97719. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97720. */
  97721. baseDepth: number;
  97722. /**
  97723. * Gets a boolean indicating if the texture is inverted on Y axis
  97724. */
  97725. invertY: boolean;
  97726. /** @hidden */
  97727. _invertVScale: boolean;
  97728. /** @hidden */
  97729. _associatedChannel: number;
  97730. /** @hidden */
  97731. _source: InternalTextureSource;
  97732. /** @hidden */
  97733. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  97734. /** @hidden */
  97735. _bufferView: Nullable<ArrayBufferView>;
  97736. /** @hidden */
  97737. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97738. /** @hidden */
  97739. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97740. /** @hidden */
  97741. _size: number;
  97742. /** @hidden */
  97743. _extension: string;
  97744. /** @hidden */
  97745. _files: Nullable<string[]>;
  97746. /** @hidden */
  97747. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97748. /** @hidden */
  97749. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97750. /** @hidden */
  97751. _framebuffer: Nullable<WebGLFramebuffer>;
  97752. /** @hidden */
  97753. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97754. /** @hidden */
  97755. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97756. /** @hidden */
  97757. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97758. /** @hidden */
  97759. _attachments: Nullable<number[]>;
  97760. /** @hidden */
  97761. _cachedCoordinatesMode: Nullable<number>;
  97762. /** @hidden */
  97763. _cachedWrapU: Nullable<number>;
  97764. /** @hidden */
  97765. _cachedWrapV: Nullable<number>;
  97766. /** @hidden */
  97767. _cachedWrapR: Nullable<number>;
  97768. /** @hidden */
  97769. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97770. /** @hidden */
  97771. _isDisabled: boolean;
  97772. /** @hidden */
  97773. _compression: Nullable<string>;
  97774. /** @hidden */
  97775. _generateStencilBuffer: boolean;
  97776. /** @hidden */
  97777. _generateDepthBuffer: boolean;
  97778. /** @hidden */
  97779. _comparisonFunction: number;
  97780. /** @hidden */
  97781. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97782. /** @hidden */
  97783. _lodGenerationScale: number;
  97784. /** @hidden */
  97785. _lodGenerationOffset: number;
  97786. /** @hidden */
  97787. _colorTextureArray: Nullable<WebGLTexture>;
  97788. /** @hidden */
  97789. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97790. /** @hidden */
  97791. _lodTextureHigh: Nullable<BaseTexture>;
  97792. /** @hidden */
  97793. _lodTextureMid: Nullable<BaseTexture>;
  97794. /** @hidden */
  97795. _lodTextureLow: Nullable<BaseTexture>;
  97796. /** @hidden */
  97797. _isRGBD: boolean;
  97798. /** @hidden */
  97799. _linearSpecularLOD: boolean;
  97800. /** @hidden */
  97801. _irradianceTexture: Nullable<BaseTexture>;
  97802. /** @hidden */
  97803. _webGLTexture: Nullable<WebGLTexture>;
  97804. /** @hidden */
  97805. _references: number;
  97806. private _engine;
  97807. /**
  97808. * Gets the Engine the texture belongs to.
  97809. * @returns The babylon engine
  97810. */
  97811. getEngine(): ThinEngine;
  97812. /**
  97813. * Gets the data source type of the texture
  97814. */
  97815. readonly source: InternalTextureSource;
  97816. /**
  97817. * Creates a new InternalTexture
  97818. * @param engine defines the engine to use
  97819. * @param source defines the type of data that will be used
  97820. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97821. */
  97822. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97823. /**
  97824. * Increments the number of references (ie. the number of Texture that point to it)
  97825. */
  97826. incrementReferences(): void;
  97827. /**
  97828. * Change the size of the texture (not the size of the content)
  97829. * @param width defines the new width
  97830. * @param height defines the new height
  97831. * @param depth defines the new depth (1 by default)
  97832. */
  97833. updateSize(width: int, height: int, depth?: int): void;
  97834. /** @hidden */
  97835. _rebuild(): void;
  97836. /** @hidden */
  97837. _swapAndDie(target: InternalTexture): void;
  97838. /**
  97839. * Dispose the current allocated resources
  97840. */
  97841. dispose(): void;
  97842. }
  97843. }
  97844. declare module BABYLON {
  97845. /**
  97846. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97848. */
  97849. export class Analyser {
  97850. /**
  97851. * Gets or sets the smoothing
  97852. * @ignorenaming
  97853. */
  97854. SMOOTHING: number;
  97855. /**
  97856. * Gets or sets the FFT table size
  97857. * @ignorenaming
  97858. */
  97859. FFT_SIZE: number;
  97860. /**
  97861. * Gets or sets the bar graph amplitude
  97862. * @ignorenaming
  97863. */
  97864. BARGRAPHAMPLITUDE: number;
  97865. /**
  97866. * Gets or sets the position of the debug canvas
  97867. * @ignorenaming
  97868. */
  97869. DEBUGCANVASPOS: {
  97870. x: number;
  97871. y: number;
  97872. };
  97873. /**
  97874. * Gets or sets the debug canvas size
  97875. * @ignorenaming
  97876. */
  97877. DEBUGCANVASSIZE: {
  97878. width: number;
  97879. height: number;
  97880. };
  97881. private _byteFreqs;
  97882. private _byteTime;
  97883. private _floatFreqs;
  97884. private _webAudioAnalyser;
  97885. private _debugCanvas;
  97886. private _debugCanvasContext;
  97887. private _scene;
  97888. private _registerFunc;
  97889. private _audioEngine;
  97890. /**
  97891. * Creates a new analyser
  97892. * @param scene defines hosting scene
  97893. */
  97894. constructor(scene: Scene);
  97895. /**
  97896. * Get the number of data values you will have to play with for the visualization
  97897. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97898. * @returns a number
  97899. */
  97900. getFrequencyBinCount(): number;
  97901. /**
  97902. * Gets the current frequency data as a byte array
  97903. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97904. * @returns a Uint8Array
  97905. */
  97906. getByteFrequencyData(): Uint8Array;
  97907. /**
  97908. * Gets the current waveform as a byte array
  97909. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97910. * @returns a Uint8Array
  97911. */
  97912. getByteTimeDomainData(): Uint8Array;
  97913. /**
  97914. * Gets the current frequency data as a float array
  97915. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97916. * @returns a Float32Array
  97917. */
  97918. getFloatFrequencyData(): Float32Array;
  97919. /**
  97920. * Renders the debug canvas
  97921. */
  97922. drawDebugCanvas(): void;
  97923. /**
  97924. * Stops rendering the debug canvas and removes it
  97925. */
  97926. stopDebugCanvas(): void;
  97927. /**
  97928. * Connects two audio nodes
  97929. * @param inputAudioNode defines first node to connect
  97930. * @param outputAudioNode defines second node to connect
  97931. */
  97932. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97933. /**
  97934. * Releases all associated resources
  97935. */
  97936. dispose(): void;
  97937. }
  97938. }
  97939. declare module BABYLON {
  97940. /**
  97941. * This represents an audio engine and it is responsible
  97942. * to play, synchronize and analyse sounds throughout the application.
  97943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97944. */
  97945. export interface IAudioEngine extends IDisposable {
  97946. /**
  97947. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97948. */
  97949. readonly canUseWebAudio: boolean;
  97950. /**
  97951. * Gets the current AudioContext if available.
  97952. */
  97953. readonly audioContext: Nullable<AudioContext>;
  97954. /**
  97955. * The master gain node defines the global audio volume of your audio engine.
  97956. */
  97957. readonly masterGain: GainNode;
  97958. /**
  97959. * Gets whether or not mp3 are supported by your browser.
  97960. */
  97961. readonly isMP3supported: boolean;
  97962. /**
  97963. * Gets whether or not ogg are supported by your browser.
  97964. */
  97965. readonly isOGGsupported: boolean;
  97966. /**
  97967. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97968. * @ignoreNaming
  97969. */
  97970. WarnedWebAudioUnsupported: boolean;
  97971. /**
  97972. * Defines if the audio engine relies on a custom unlocked button.
  97973. * In this case, the embedded button will not be displayed.
  97974. */
  97975. useCustomUnlockedButton: boolean;
  97976. /**
  97977. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97978. */
  97979. readonly unlocked: boolean;
  97980. /**
  97981. * Event raised when audio has been unlocked on the browser.
  97982. */
  97983. onAudioUnlockedObservable: Observable<AudioEngine>;
  97984. /**
  97985. * Event raised when audio has been locked on the browser.
  97986. */
  97987. onAudioLockedObservable: Observable<AudioEngine>;
  97988. /**
  97989. * Flags the audio engine in Locked state.
  97990. * This happens due to new browser policies preventing audio to autoplay.
  97991. */
  97992. lock(): void;
  97993. /**
  97994. * Unlocks the audio engine once a user action has been done on the dom.
  97995. * This is helpful to resume play once browser policies have been satisfied.
  97996. */
  97997. unlock(): void;
  97998. }
  97999. /**
  98000. * This represents the default audio engine used in babylon.
  98001. * It is responsible to play, synchronize and analyse sounds throughout the application.
  98002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98003. */
  98004. export class AudioEngine implements IAudioEngine {
  98005. private _audioContext;
  98006. private _audioContextInitialized;
  98007. private _muteButton;
  98008. private _hostElement;
  98009. /**
  98010. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98011. */
  98012. canUseWebAudio: boolean;
  98013. /**
  98014. * The master gain node defines the global audio volume of your audio engine.
  98015. */
  98016. masterGain: GainNode;
  98017. /**
  98018. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98019. * @ignoreNaming
  98020. */
  98021. WarnedWebAudioUnsupported: boolean;
  98022. /**
  98023. * Gets whether or not mp3 are supported by your browser.
  98024. */
  98025. isMP3supported: boolean;
  98026. /**
  98027. * Gets whether or not ogg are supported by your browser.
  98028. */
  98029. isOGGsupported: boolean;
  98030. /**
  98031. * Gets whether audio has been unlocked on the device.
  98032. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  98033. * a user interaction has happened.
  98034. */
  98035. unlocked: boolean;
  98036. /**
  98037. * Defines if the audio engine relies on a custom unlocked button.
  98038. * In this case, the embedded button will not be displayed.
  98039. */
  98040. useCustomUnlockedButton: boolean;
  98041. /**
  98042. * Event raised when audio has been unlocked on the browser.
  98043. */
  98044. onAudioUnlockedObservable: Observable<AudioEngine>;
  98045. /**
  98046. * Event raised when audio has been locked on the browser.
  98047. */
  98048. onAudioLockedObservable: Observable<AudioEngine>;
  98049. /**
  98050. * Gets the current AudioContext if available.
  98051. */
  98052. readonly audioContext: Nullable<AudioContext>;
  98053. private _connectedAnalyser;
  98054. /**
  98055. * Instantiates a new audio engine.
  98056. *
  98057. * There should be only one per page as some browsers restrict the number
  98058. * of audio contexts you can create.
  98059. * @param hostElement defines the host element where to display the mute icon if necessary
  98060. */
  98061. constructor(hostElement?: Nullable<HTMLElement>);
  98062. /**
  98063. * Flags the audio engine in Locked state.
  98064. * This happens due to new browser policies preventing audio to autoplay.
  98065. */
  98066. lock(): void;
  98067. /**
  98068. * Unlocks the audio engine once a user action has been done on the dom.
  98069. * This is helpful to resume play once browser policies have been satisfied.
  98070. */
  98071. unlock(): void;
  98072. private _resumeAudioContext;
  98073. private _initializeAudioContext;
  98074. private _tryToRun;
  98075. private _triggerRunningState;
  98076. private _triggerSuspendedState;
  98077. private _displayMuteButton;
  98078. private _moveButtonToTopLeft;
  98079. private _onResize;
  98080. private _hideMuteButton;
  98081. /**
  98082. * Destroy and release the resources associated with the audio ccontext.
  98083. */
  98084. dispose(): void;
  98085. /**
  98086. * Gets the global volume sets on the master gain.
  98087. * @returns the global volume if set or -1 otherwise
  98088. */
  98089. getGlobalVolume(): number;
  98090. /**
  98091. * Sets the global volume of your experience (sets on the master gain).
  98092. * @param newVolume Defines the new global volume of the application
  98093. */
  98094. setGlobalVolume(newVolume: number): void;
  98095. /**
  98096. * Connect the audio engine to an audio analyser allowing some amazing
  98097. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98099. * @param analyser The analyser to connect to the engine
  98100. */
  98101. connectToAnalyser(analyser: Analyser): void;
  98102. }
  98103. }
  98104. declare module BABYLON {
  98105. /**
  98106. * Interface used to present a loading screen while loading a scene
  98107. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98108. */
  98109. export interface ILoadingScreen {
  98110. /**
  98111. * Function called to display the loading screen
  98112. */
  98113. displayLoadingUI: () => void;
  98114. /**
  98115. * Function called to hide the loading screen
  98116. */
  98117. hideLoadingUI: () => void;
  98118. /**
  98119. * Gets or sets the color to use for the background
  98120. */
  98121. loadingUIBackgroundColor: string;
  98122. /**
  98123. * Gets or sets the text to display while loading
  98124. */
  98125. loadingUIText: string;
  98126. }
  98127. /**
  98128. * Class used for the default loading screen
  98129. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98130. */
  98131. export class DefaultLoadingScreen implements ILoadingScreen {
  98132. private _renderingCanvas;
  98133. private _loadingText;
  98134. private _loadingDivBackgroundColor;
  98135. private _loadingDiv;
  98136. private _loadingTextDiv;
  98137. /** Gets or sets the logo url to use for the default loading screen */
  98138. static DefaultLogoUrl: string;
  98139. /** Gets or sets the spinner url to use for the default loading screen */
  98140. static DefaultSpinnerUrl: string;
  98141. /**
  98142. * Creates a new default loading screen
  98143. * @param _renderingCanvas defines the canvas used to render the scene
  98144. * @param _loadingText defines the default text to display
  98145. * @param _loadingDivBackgroundColor defines the default background color
  98146. */
  98147. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  98148. /**
  98149. * Function called to display the loading screen
  98150. */
  98151. displayLoadingUI(): void;
  98152. /**
  98153. * Function called to hide the loading screen
  98154. */
  98155. hideLoadingUI(): void;
  98156. /**
  98157. * Gets or sets the text to display while loading
  98158. */
  98159. loadingUIText: string;
  98160. /**
  98161. * Gets or sets the color to use for the background
  98162. */
  98163. loadingUIBackgroundColor: string;
  98164. private _resizeLoadingUI;
  98165. }
  98166. }
  98167. declare module BABYLON {
  98168. /**
  98169. * Interface for any object that can request an animation frame
  98170. */
  98171. export interface ICustomAnimationFrameRequester {
  98172. /**
  98173. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  98174. */
  98175. renderFunction?: Function;
  98176. /**
  98177. * Called to request the next frame to render to
  98178. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  98179. */
  98180. requestAnimationFrame: Function;
  98181. /**
  98182. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  98183. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  98184. */
  98185. requestID?: number;
  98186. }
  98187. }
  98188. declare module BABYLON {
  98189. /**
  98190. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  98191. */
  98192. export class PerformanceMonitor {
  98193. private _enabled;
  98194. private _rollingFrameTime;
  98195. private _lastFrameTimeMs;
  98196. /**
  98197. * constructor
  98198. * @param frameSampleSize The number of samples required to saturate the sliding window
  98199. */
  98200. constructor(frameSampleSize?: number);
  98201. /**
  98202. * Samples current frame
  98203. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  98204. */
  98205. sampleFrame(timeMs?: number): void;
  98206. /**
  98207. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98208. */
  98209. readonly averageFrameTime: number;
  98210. /**
  98211. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98212. */
  98213. readonly averageFrameTimeVariance: number;
  98214. /**
  98215. * Returns the frame time of the most recent frame
  98216. */
  98217. readonly instantaneousFrameTime: number;
  98218. /**
  98219. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  98220. */
  98221. readonly averageFPS: number;
  98222. /**
  98223. * Returns the average framerate in frames per second using the most recent frame time
  98224. */
  98225. readonly instantaneousFPS: number;
  98226. /**
  98227. * Returns true if enough samples have been taken to completely fill the sliding window
  98228. */
  98229. readonly isSaturated: boolean;
  98230. /**
  98231. * Enables contributions to the sliding window sample set
  98232. */
  98233. enable(): void;
  98234. /**
  98235. * Disables contributions to the sliding window sample set
  98236. * Samples will not be interpolated over the disabled period
  98237. */
  98238. disable(): void;
  98239. /**
  98240. * Returns true if sampling is enabled
  98241. */
  98242. readonly isEnabled: boolean;
  98243. /**
  98244. * Resets performance monitor
  98245. */
  98246. reset(): void;
  98247. }
  98248. /**
  98249. * RollingAverage
  98250. *
  98251. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  98252. */
  98253. export class RollingAverage {
  98254. /**
  98255. * Current average
  98256. */
  98257. average: number;
  98258. /**
  98259. * Current variance
  98260. */
  98261. variance: number;
  98262. protected _samples: Array<number>;
  98263. protected _sampleCount: number;
  98264. protected _pos: number;
  98265. protected _m2: number;
  98266. /**
  98267. * constructor
  98268. * @param length The number of samples required to saturate the sliding window
  98269. */
  98270. constructor(length: number);
  98271. /**
  98272. * Adds a sample to the sample set
  98273. * @param v The sample value
  98274. */
  98275. add(v: number): void;
  98276. /**
  98277. * Returns previously added values or null if outside of history or outside the sliding window domain
  98278. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  98279. * @return Value previously recorded with add() or null if outside of range
  98280. */
  98281. history(i: number): number;
  98282. /**
  98283. * Returns true if enough samples have been taken to completely fill the sliding window
  98284. * @return true if sample-set saturated
  98285. */
  98286. isSaturated(): boolean;
  98287. /**
  98288. * Resets the rolling average (equivalent to 0 samples taken so far)
  98289. */
  98290. reset(): void;
  98291. /**
  98292. * Wraps a value around the sample range boundaries
  98293. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  98294. * @return Wrapped position in sample range
  98295. */
  98296. protected _wrapPosition(i: number): number;
  98297. }
  98298. }
  98299. declare module BABYLON {
  98300. /**
  98301. * This class is used to track a performance counter which is number based.
  98302. * The user has access to many properties which give statistics of different nature.
  98303. *
  98304. * The implementer can track two kinds of Performance Counter: time and count.
  98305. * 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.
  98306. * 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.
  98307. */
  98308. export class PerfCounter {
  98309. /**
  98310. * Gets or sets a global boolean to turn on and off all the counters
  98311. */
  98312. static Enabled: boolean;
  98313. /**
  98314. * Returns the smallest value ever
  98315. */
  98316. readonly min: number;
  98317. /**
  98318. * Returns the biggest value ever
  98319. */
  98320. readonly max: number;
  98321. /**
  98322. * Returns the average value since the performance counter is running
  98323. */
  98324. readonly average: number;
  98325. /**
  98326. * Returns the average value of the last second the counter was monitored
  98327. */
  98328. readonly lastSecAverage: number;
  98329. /**
  98330. * Returns the current value
  98331. */
  98332. readonly current: number;
  98333. /**
  98334. * Gets the accumulated total
  98335. */
  98336. readonly total: number;
  98337. /**
  98338. * Gets the total value count
  98339. */
  98340. readonly count: number;
  98341. /**
  98342. * Creates a new counter
  98343. */
  98344. constructor();
  98345. /**
  98346. * Call this method to start monitoring a new frame.
  98347. * 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.
  98348. */
  98349. fetchNewFrame(): void;
  98350. /**
  98351. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98352. * @param newCount the count value to add to the monitored count
  98353. * @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.
  98354. */
  98355. addCount(newCount: number, fetchResult: boolean): void;
  98356. /**
  98357. * Start monitoring this performance counter
  98358. */
  98359. beginMonitoring(): void;
  98360. /**
  98361. * Compute the time lapsed since the previous beginMonitoring() call.
  98362. * @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
  98363. */
  98364. endMonitoring(newFrame?: boolean): void;
  98365. private _fetchResult;
  98366. private _startMonitoringTime;
  98367. private _min;
  98368. private _max;
  98369. private _average;
  98370. private _current;
  98371. private _totalValueCount;
  98372. private _totalAccumulated;
  98373. private _lastSecAverage;
  98374. private _lastSecAccumulated;
  98375. private _lastSecTime;
  98376. private _lastSecValueCount;
  98377. }
  98378. }
  98379. declare module BABYLON {
  98380. /**
  98381. * Defines the interface used by display changed events
  98382. */
  98383. export interface IDisplayChangedEventArgs {
  98384. /** Gets the vrDisplay object (if any) */
  98385. vrDisplay: Nullable<any>;
  98386. /** Gets a boolean indicating if webVR is supported */
  98387. vrSupported: boolean;
  98388. }
  98389. /**
  98390. * Defines the interface used by objects containing a viewport (like a camera)
  98391. */
  98392. interface IViewportOwnerLike {
  98393. /**
  98394. * Gets or sets the viewport
  98395. */
  98396. viewport: IViewportLike;
  98397. }
  98398. /**
  98399. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  98400. */
  98401. export class Engine extends ThinEngine {
  98402. /** Defines that alpha blending is disabled */
  98403. static readonly ALPHA_DISABLE: number;
  98404. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  98405. static readonly ALPHA_ADD: number;
  98406. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  98407. static readonly ALPHA_COMBINE: number;
  98408. /** Defines that alpha blending to DEST - SRC * DEST */
  98409. static readonly ALPHA_SUBTRACT: number;
  98410. /** Defines that alpha blending to SRC * DEST */
  98411. static readonly ALPHA_MULTIPLY: number;
  98412. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  98413. static readonly ALPHA_MAXIMIZED: number;
  98414. /** Defines that alpha blending to SRC + DEST */
  98415. static readonly ALPHA_ONEONE: number;
  98416. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  98417. static readonly ALPHA_PREMULTIPLIED: number;
  98418. /**
  98419. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  98420. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  98421. */
  98422. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  98423. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  98424. static readonly ALPHA_INTERPOLATE: number;
  98425. /**
  98426. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  98427. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  98428. */
  98429. static readonly ALPHA_SCREENMODE: number;
  98430. /** Defines that the ressource is not delayed*/
  98431. static readonly DELAYLOADSTATE_NONE: number;
  98432. /** Defines that the ressource was successfully delay loaded */
  98433. static readonly DELAYLOADSTATE_LOADED: number;
  98434. /** Defines that the ressource is currently delay loading */
  98435. static readonly DELAYLOADSTATE_LOADING: number;
  98436. /** Defines that the ressource is delayed and has not started loading */
  98437. static readonly DELAYLOADSTATE_NOTLOADED: number;
  98438. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  98439. static readonly NEVER: number;
  98440. /** 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 */
  98441. static readonly ALWAYS: number;
  98442. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  98443. static readonly LESS: number;
  98444. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  98445. static readonly EQUAL: number;
  98446. /** 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 */
  98447. static readonly LEQUAL: number;
  98448. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  98449. static readonly GREATER: number;
  98450. /** 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 */
  98451. static readonly GEQUAL: number;
  98452. /** 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 */
  98453. static readonly NOTEQUAL: number;
  98454. /** Passed to stencilOperation to specify that stencil value must be kept */
  98455. static readonly KEEP: number;
  98456. /** Passed to stencilOperation to specify that stencil value must be replaced */
  98457. static readonly REPLACE: number;
  98458. /** Passed to stencilOperation to specify that stencil value must be incremented */
  98459. static readonly INCR: number;
  98460. /** Passed to stencilOperation to specify that stencil value must be decremented */
  98461. static readonly DECR: number;
  98462. /** Passed to stencilOperation to specify that stencil value must be inverted */
  98463. static readonly INVERT: number;
  98464. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  98465. static readonly INCR_WRAP: number;
  98466. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  98467. static readonly DECR_WRAP: number;
  98468. /** Texture is not repeating outside of 0..1 UVs */
  98469. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  98470. /** Texture is repeating outside of 0..1 UVs */
  98471. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  98472. /** Texture is repeating and mirrored */
  98473. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  98474. /** ALPHA */
  98475. static readonly TEXTUREFORMAT_ALPHA: number;
  98476. /** LUMINANCE */
  98477. static readonly TEXTUREFORMAT_LUMINANCE: number;
  98478. /** LUMINANCE_ALPHA */
  98479. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  98480. /** RGB */
  98481. static readonly TEXTUREFORMAT_RGB: number;
  98482. /** RGBA */
  98483. static readonly TEXTUREFORMAT_RGBA: number;
  98484. /** RED */
  98485. static readonly TEXTUREFORMAT_RED: number;
  98486. /** RED (2nd reference) */
  98487. static readonly TEXTUREFORMAT_R: number;
  98488. /** RG */
  98489. static readonly TEXTUREFORMAT_RG: number;
  98490. /** RED_INTEGER */
  98491. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  98492. /** RED_INTEGER (2nd reference) */
  98493. static readonly TEXTUREFORMAT_R_INTEGER: number;
  98494. /** RG_INTEGER */
  98495. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  98496. /** RGB_INTEGER */
  98497. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  98498. /** RGBA_INTEGER */
  98499. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  98500. /** UNSIGNED_BYTE */
  98501. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  98502. /** UNSIGNED_BYTE (2nd reference) */
  98503. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  98504. /** FLOAT */
  98505. static readonly TEXTURETYPE_FLOAT: number;
  98506. /** HALF_FLOAT */
  98507. static readonly TEXTURETYPE_HALF_FLOAT: number;
  98508. /** BYTE */
  98509. static readonly TEXTURETYPE_BYTE: number;
  98510. /** SHORT */
  98511. static readonly TEXTURETYPE_SHORT: number;
  98512. /** UNSIGNED_SHORT */
  98513. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  98514. /** INT */
  98515. static readonly TEXTURETYPE_INT: number;
  98516. /** UNSIGNED_INT */
  98517. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  98518. /** UNSIGNED_SHORT_4_4_4_4 */
  98519. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  98520. /** UNSIGNED_SHORT_5_5_5_1 */
  98521. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  98522. /** UNSIGNED_SHORT_5_6_5 */
  98523. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  98524. /** UNSIGNED_INT_2_10_10_10_REV */
  98525. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  98526. /** UNSIGNED_INT_24_8 */
  98527. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  98528. /** UNSIGNED_INT_10F_11F_11F_REV */
  98529. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  98530. /** UNSIGNED_INT_5_9_9_9_REV */
  98531. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  98532. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  98533. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  98534. /** nearest is mag = nearest and min = nearest and mip = linear */
  98535. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  98536. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98537. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  98538. /** Trilinear is mag = linear and min = linear and mip = linear */
  98539. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  98540. /** nearest is mag = nearest and min = nearest and mip = linear */
  98541. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  98542. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98543. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  98544. /** Trilinear is mag = linear and min = linear and mip = linear */
  98545. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  98546. /** mag = nearest and min = nearest and mip = nearest */
  98547. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  98548. /** mag = nearest and min = linear and mip = nearest */
  98549. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  98550. /** mag = nearest and min = linear and mip = linear */
  98551. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  98552. /** mag = nearest and min = linear and mip = none */
  98553. static readonly TEXTURE_NEAREST_LINEAR: number;
  98554. /** mag = nearest and min = nearest and mip = none */
  98555. static readonly TEXTURE_NEAREST_NEAREST: number;
  98556. /** mag = linear and min = nearest and mip = nearest */
  98557. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  98558. /** mag = linear and min = nearest and mip = linear */
  98559. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  98560. /** mag = linear and min = linear and mip = none */
  98561. static readonly TEXTURE_LINEAR_LINEAR: number;
  98562. /** mag = linear and min = nearest and mip = none */
  98563. static readonly TEXTURE_LINEAR_NEAREST: number;
  98564. /** Explicit coordinates mode */
  98565. static readonly TEXTURE_EXPLICIT_MODE: number;
  98566. /** Spherical coordinates mode */
  98567. static readonly TEXTURE_SPHERICAL_MODE: number;
  98568. /** Planar coordinates mode */
  98569. static readonly TEXTURE_PLANAR_MODE: number;
  98570. /** Cubic coordinates mode */
  98571. static readonly TEXTURE_CUBIC_MODE: number;
  98572. /** Projection coordinates mode */
  98573. static readonly TEXTURE_PROJECTION_MODE: number;
  98574. /** Skybox coordinates mode */
  98575. static readonly TEXTURE_SKYBOX_MODE: number;
  98576. /** Inverse Cubic coordinates mode */
  98577. static readonly TEXTURE_INVCUBIC_MODE: number;
  98578. /** Equirectangular coordinates mode */
  98579. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  98580. /** Equirectangular Fixed coordinates mode */
  98581. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  98582. /** Equirectangular Fixed Mirrored coordinates mode */
  98583. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  98584. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  98585. static readonly SCALEMODE_FLOOR: number;
  98586. /** Defines that texture rescaling will look for the nearest power of 2 size */
  98587. static readonly SCALEMODE_NEAREST: number;
  98588. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  98589. static readonly SCALEMODE_CEILING: number;
  98590. /**
  98591. * Returns the current npm package of the sdk
  98592. */
  98593. static readonly NpmPackage: string;
  98594. /**
  98595. * Returns the current version of the framework
  98596. */
  98597. static readonly Version: string;
  98598. /** Gets the list of created engines */
  98599. static readonly Instances: Engine[];
  98600. /**
  98601. * Gets the latest created engine
  98602. */
  98603. static readonly LastCreatedEngine: Nullable<Engine>;
  98604. /**
  98605. * Gets the latest created scene
  98606. */
  98607. static readonly LastCreatedScene: Nullable<Scene>;
  98608. /**
  98609. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  98610. * @param flag defines which part of the materials must be marked as dirty
  98611. * @param predicate defines a predicate used to filter which materials should be affected
  98612. */
  98613. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98614. /**
  98615. * Method called to create the default loading screen.
  98616. * This can be overriden in your own app.
  98617. * @param canvas The rendering canvas element
  98618. * @returns The loading screen
  98619. */
  98620. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  98621. /**
  98622. * Method called to create the default rescale post process on each engine.
  98623. */
  98624. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  98625. /**
  98626. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  98627. **/
  98628. enableOfflineSupport: boolean;
  98629. /**
  98630. * 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)
  98631. **/
  98632. disableManifestCheck: boolean;
  98633. /**
  98634. * Gets the list of created scenes
  98635. */
  98636. scenes: Scene[];
  98637. /**
  98638. * Event raised when a new scene is created
  98639. */
  98640. onNewSceneAddedObservable: Observable<Scene>;
  98641. /**
  98642. * Gets the list of created postprocesses
  98643. */
  98644. postProcesses: PostProcess[];
  98645. /**
  98646. * Gets a boolean indicating if the pointer is currently locked
  98647. */
  98648. isPointerLock: boolean;
  98649. /**
  98650. * Observable event triggered each time the rendering canvas is resized
  98651. */
  98652. onResizeObservable: Observable<Engine>;
  98653. /**
  98654. * Observable event triggered each time the canvas loses focus
  98655. */
  98656. onCanvasBlurObservable: Observable<Engine>;
  98657. /**
  98658. * Observable event triggered each time the canvas gains focus
  98659. */
  98660. onCanvasFocusObservable: Observable<Engine>;
  98661. /**
  98662. * Observable event triggered each time the canvas receives pointerout event
  98663. */
  98664. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98665. /**
  98666. * Observable raised when the engine begins a new frame
  98667. */
  98668. onBeginFrameObservable: Observable<Engine>;
  98669. /**
  98670. * If set, will be used to request the next animation frame for the render loop
  98671. */
  98672. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98673. /**
  98674. * Observable raised when the engine ends the current frame
  98675. */
  98676. onEndFrameObservable: Observable<Engine>;
  98677. /**
  98678. * Observable raised when the engine is about to compile a shader
  98679. */
  98680. onBeforeShaderCompilationObservable: Observable<Engine>;
  98681. /**
  98682. * Observable raised when the engine has jsut compiled a shader
  98683. */
  98684. onAfterShaderCompilationObservable: Observable<Engine>;
  98685. /**
  98686. * Gets the audio engine
  98687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98688. * @ignorenaming
  98689. */
  98690. static audioEngine: IAudioEngine;
  98691. /**
  98692. * Default AudioEngine factory responsible of creating the Audio Engine.
  98693. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98694. */
  98695. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98696. /**
  98697. * Default offline support factory responsible of creating a tool used to store data locally.
  98698. * By default, this will create a Database object if the workload has been embedded.
  98699. */
  98700. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98701. private _loadingScreen;
  98702. private _pointerLockRequested;
  98703. private _dummyFramebuffer;
  98704. private _rescalePostProcess;
  98705. /** @hidden */
  98706. protected _alphaMode: number;
  98707. /** @hidden */
  98708. protected _alphaEquation: number;
  98709. private _deterministicLockstep;
  98710. private _lockstepMaxSteps;
  98711. protected readonly _supportsHardwareTextureRescaling: boolean;
  98712. private _fps;
  98713. private _deltaTime;
  98714. /** @hidden */
  98715. _drawCalls: PerfCounter;
  98716. /**
  98717. * Turn this value on if you want to pause FPS computation when in background
  98718. */
  98719. disablePerformanceMonitorInBackground: boolean;
  98720. private _performanceMonitor;
  98721. /**
  98722. * Gets the performance monitor attached to this engine
  98723. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98724. */
  98725. readonly performanceMonitor: PerformanceMonitor;
  98726. private _onFocus;
  98727. private _onBlur;
  98728. private _onCanvasPointerOut;
  98729. private _onCanvasBlur;
  98730. private _onCanvasFocus;
  98731. private _onFullscreenChange;
  98732. private _onPointerLockChange;
  98733. /**
  98734. * Creates a new engine
  98735. * @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
  98736. * @param antialias defines enable antialiasing (default: false)
  98737. * @param options defines further options to be sent to the getContext() function
  98738. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98739. */
  98740. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98741. /**
  98742. * Gets current aspect ratio
  98743. * @param viewportOwner defines the camera to use to get the aspect ratio
  98744. * @param useScreen defines if screen size must be used (or the current render target if any)
  98745. * @returns a number defining the aspect ratio
  98746. */
  98747. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98748. /**
  98749. * Gets current screen aspect ratio
  98750. * @returns a number defining the aspect ratio
  98751. */
  98752. getScreenAspectRatio(): number;
  98753. /**
  98754. * Gets host document
  98755. * @returns the host document object
  98756. */
  98757. getHostDocument(): Document;
  98758. /**
  98759. * Gets the client rect of the HTML canvas attached with the current webGL context
  98760. * @returns a client rectanglee
  98761. */
  98762. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98763. /**
  98764. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98765. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98766. * @returns true if engine is in deterministic lock step mode
  98767. */
  98768. isDeterministicLockStep(): boolean;
  98769. /**
  98770. * Gets the max steps when engine is running in deterministic lock step
  98771. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98772. * @returns the max steps
  98773. */
  98774. getLockstepMaxSteps(): number;
  98775. /**
  98776. * Force the mipmap generation for the given render target texture
  98777. * @param texture defines the render target texture to use
  98778. */
  98779. generateMipMapsForCubemap(texture: InternalTexture): void;
  98780. /** States */
  98781. /**
  98782. * Set various states to the webGL context
  98783. * @param culling defines backface culling state
  98784. * @param zOffset defines the value to apply to zOffset (0 by default)
  98785. * @param force defines if states must be applied even if cache is up to date
  98786. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98787. */
  98788. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98789. /**
  98790. * Set the z offset to apply to current rendering
  98791. * @param value defines the offset to apply
  98792. */
  98793. setZOffset(value: number): void;
  98794. /**
  98795. * Gets the current value of the zOffset
  98796. * @returns the current zOffset state
  98797. */
  98798. getZOffset(): number;
  98799. /**
  98800. * Enable or disable depth buffering
  98801. * @param enable defines the state to set
  98802. */
  98803. setDepthBuffer(enable: boolean): void;
  98804. /**
  98805. * Gets a boolean indicating if depth writing is enabled
  98806. * @returns the current depth writing state
  98807. */
  98808. getDepthWrite(): boolean;
  98809. /**
  98810. * Enable or disable depth writing
  98811. * @param enable defines the state to set
  98812. */
  98813. setDepthWrite(enable: boolean): void;
  98814. /**
  98815. * Enable or disable color writing
  98816. * @param enable defines the state to set
  98817. */
  98818. setColorWrite(enable: boolean): void;
  98819. /**
  98820. * Gets a boolean indicating if color writing is enabled
  98821. * @returns the current color writing state
  98822. */
  98823. getColorWrite(): boolean;
  98824. /**
  98825. * Sets alpha constants used by some alpha blending modes
  98826. * @param r defines the red component
  98827. * @param g defines the green component
  98828. * @param b defines the blue component
  98829. * @param a defines the alpha component
  98830. */
  98831. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98832. /**
  98833. * Sets the current alpha mode
  98834. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98835. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98836. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98837. */
  98838. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98839. /**
  98840. * Gets the current alpha mode
  98841. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98842. * @returns the current alpha mode
  98843. */
  98844. getAlphaMode(): number;
  98845. /**
  98846. * Sets the current alpha equation
  98847. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98848. */
  98849. setAlphaEquation(equation: number): void;
  98850. /**
  98851. * Gets the current alpha equation.
  98852. * @returns the current alpha equation
  98853. */
  98854. getAlphaEquation(): number;
  98855. /**
  98856. * Gets a boolean indicating if stencil buffer is enabled
  98857. * @returns the current stencil buffer state
  98858. */
  98859. getStencilBuffer(): boolean;
  98860. /**
  98861. * Enable or disable the stencil buffer
  98862. * @param enable defines if the stencil buffer must be enabled or disabled
  98863. */
  98864. setStencilBuffer(enable: boolean): void;
  98865. /**
  98866. * Gets the current stencil mask
  98867. * @returns a number defining the new stencil mask to use
  98868. */
  98869. getStencilMask(): number;
  98870. /**
  98871. * Sets the current stencil mask
  98872. * @param mask defines the new stencil mask to use
  98873. */
  98874. setStencilMask(mask: number): void;
  98875. /**
  98876. * Gets the current stencil function
  98877. * @returns a number defining the stencil function to use
  98878. */
  98879. getStencilFunction(): number;
  98880. /**
  98881. * Gets the current stencil reference value
  98882. * @returns a number defining the stencil reference value to use
  98883. */
  98884. getStencilFunctionReference(): number;
  98885. /**
  98886. * Gets the current stencil mask
  98887. * @returns a number defining the stencil mask to use
  98888. */
  98889. getStencilFunctionMask(): number;
  98890. /**
  98891. * Sets the current stencil function
  98892. * @param stencilFunc defines the new stencil function to use
  98893. */
  98894. setStencilFunction(stencilFunc: number): void;
  98895. /**
  98896. * Sets the current stencil reference
  98897. * @param reference defines the new stencil reference to use
  98898. */
  98899. setStencilFunctionReference(reference: number): void;
  98900. /**
  98901. * Sets the current stencil mask
  98902. * @param mask defines the new stencil mask to use
  98903. */
  98904. setStencilFunctionMask(mask: number): void;
  98905. /**
  98906. * Gets the current stencil operation when stencil fails
  98907. * @returns a number defining stencil operation to use when stencil fails
  98908. */
  98909. getStencilOperationFail(): number;
  98910. /**
  98911. * Gets the current stencil operation when depth fails
  98912. * @returns a number defining stencil operation to use when depth fails
  98913. */
  98914. getStencilOperationDepthFail(): number;
  98915. /**
  98916. * Gets the current stencil operation when stencil passes
  98917. * @returns a number defining stencil operation to use when stencil passes
  98918. */
  98919. getStencilOperationPass(): number;
  98920. /**
  98921. * Sets the stencil operation to use when stencil fails
  98922. * @param operation defines the stencil operation to use when stencil fails
  98923. */
  98924. setStencilOperationFail(operation: number): void;
  98925. /**
  98926. * Sets the stencil operation to use when depth fails
  98927. * @param operation defines the stencil operation to use when depth fails
  98928. */
  98929. setStencilOperationDepthFail(operation: number): void;
  98930. /**
  98931. * Sets the stencil operation to use when stencil passes
  98932. * @param operation defines the stencil operation to use when stencil passes
  98933. */
  98934. setStencilOperationPass(operation: number): void;
  98935. /**
  98936. * Sets a boolean indicating if the dithering state is enabled or disabled
  98937. * @param value defines the dithering state
  98938. */
  98939. setDitheringState(value: boolean): void;
  98940. /**
  98941. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98942. * @param value defines the rasterizer state
  98943. */
  98944. setRasterizerState(value: boolean): void;
  98945. /**
  98946. * Gets the current depth function
  98947. * @returns a number defining the depth function
  98948. */
  98949. getDepthFunction(): Nullable<number>;
  98950. /**
  98951. * Sets the current depth function
  98952. * @param depthFunc defines the function to use
  98953. */
  98954. setDepthFunction(depthFunc: number): void;
  98955. /**
  98956. * Sets the current depth function to GREATER
  98957. */
  98958. setDepthFunctionToGreater(): void;
  98959. /**
  98960. * Sets the current depth function to GEQUAL
  98961. */
  98962. setDepthFunctionToGreaterOrEqual(): void;
  98963. /**
  98964. * Sets the current depth function to LESS
  98965. */
  98966. setDepthFunctionToLess(): void;
  98967. /**
  98968. * Sets the current depth function to LEQUAL
  98969. */
  98970. setDepthFunctionToLessOrEqual(): void;
  98971. private _cachedStencilBuffer;
  98972. private _cachedStencilFunction;
  98973. private _cachedStencilMask;
  98974. private _cachedStencilOperationPass;
  98975. private _cachedStencilOperationFail;
  98976. private _cachedStencilOperationDepthFail;
  98977. private _cachedStencilReference;
  98978. /**
  98979. * Caches the the state of the stencil buffer
  98980. */
  98981. cacheStencilState(): void;
  98982. /**
  98983. * Restores the state of the stencil buffer
  98984. */
  98985. restoreStencilState(): void;
  98986. /**
  98987. * Directly set the WebGL Viewport
  98988. * @param x defines the x coordinate of the viewport (in screen space)
  98989. * @param y defines the y coordinate of the viewport (in screen space)
  98990. * @param width defines the width of the viewport (in screen space)
  98991. * @param height defines the height of the viewport (in screen space)
  98992. * @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
  98993. */
  98994. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98995. /**
  98996. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98997. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98998. * @param y defines the y-coordinate of the corner of the clear rectangle
  98999. * @param width defines the width of the clear rectangle
  99000. * @param height defines the height of the clear rectangle
  99001. * @param clearColor defines the clear color
  99002. */
  99003. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  99004. /**
  99005. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  99006. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99007. * @param y defines the y-coordinate of the corner of the clear rectangle
  99008. * @param width defines the width of the clear rectangle
  99009. * @param height defines the height of the clear rectangle
  99010. */
  99011. enableScissor(x: number, y: number, width: number, height: number): void;
  99012. /**
  99013. * Disable previously set scissor test rectangle
  99014. */
  99015. disableScissor(): void;
  99016. protected _reportDrawCall(): void;
  99017. /**
  99018. * Initializes a webVR display and starts listening to display change events
  99019. * The onVRDisplayChangedObservable will be notified upon these changes
  99020. * @returns The onVRDisplayChangedObservable
  99021. */
  99022. initWebVR(): Observable<IDisplayChangedEventArgs>;
  99023. /** @hidden */
  99024. _prepareVRComponent(): void;
  99025. /** @hidden */
  99026. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  99027. /** @hidden */
  99028. _submitVRFrame(): void;
  99029. /**
  99030. * Call this function to leave webVR mode
  99031. * Will do nothing if webVR is not supported or if there is no webVR device
  99032. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99033. */
  99034. disableVR(): void;
  99035. /**
  99036. * Gets a boolean indicating that the system is in VR mode and is presenting
  99037. * @returns true if VR mode is engaged
  99038. */
  99039. isVRPresenting(): boolean;
  99040. /** @hidden */
  99041. _requestVRFrame(): void;
  99042. /** @hidden */
  99043. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99044. /**
  99045. * Gets the source code of the vertex shader associated with a specific webGL program
  99046. * @param program defines the program to use
  99047. * @returns a string containing the source code of the vertex shader associated with the program
  99048. */
  99049. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  99050. /**
  99051. * Gets the source code of the fragment shader associated with a specific webGL program
  99052. * @param program defines the program to use
  99053. * @returns a string containing the source code of the fragment shader associated with the program
  99054. */
  99055. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  99056. /**
  99057. * Reads pixels from the current frame buffer. Please note that this function can be slow
  99058. * @param x defines the x coordinate of the rectangle where pixels must be read
  99059. * @param y defines the y coordinate of the rectangle where pixels must be read
  99060. * @param width defines the width of the rectangle where pixels must be read
  99061. * @param height defines the height of the rectangle where pixels must be read
  99062. * @returns a Uint8Array containing RGBA colors
  99063. */
  99064. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  99065. /**
  99066. * Sets a depth stencil texture from a render target to the according uniform.
  99067. * @param channel The texture channel
  99068. * @param uniform The uniform to set
  99069. * @param texture The render target texture containing the depth stencil texture to apply
  99070. */
  99071. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  99072. /**
  99073. * Sets a texture to the webGL context from a postprocess
  99074. * @param channel defines the channel to use
  99075. * @param postProcess defines the source postprocess
  99076. */
  99077. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  99078. /**
  99079. * Binds the output of the passed in post process to the texture channel specified
  99080. * @param channel The channel the texture should be bound to
  99081. * @param postProcess The post process which's output should be bound
  99082. */
  99083. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  99084. /** @hidden */
  99085. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  99086. protected _rebuildBuffers(): void;
  99087. _renderLoop(): void;
  99088. /**
  99089. * Toggle full screen mode
  99090. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99091. */
  99092. switchFullscreen(requestPointerLock: boolean): void;
  99093. /**
  99094. * Enters full screen mode
  99095. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99096. */
  99097. enterFullscreen(requestPointerLock: boolean): void;
  99098. /**
  99099. * Exits full screen mode
  99100. */
  99101. exitFullscreen(): void;
  99102. /**
  99103. * Enters Pointerlock mode
  99104. */
  99105. enterPointerlock(): void;
  99106. /**
  99107. * Exits Pointerlock mode
  99108. */
  99109. exitPointerlock(): void;
  99110. /**
  99111. * Begin a new frame
  99112. */
  99113. beginFrame(): void;
  99114. /**
  99115. * Enf the current frame
  99116. */
  99117. endFrame(): void;
  99118. resize(): void;
  99119. /**
  99120. * Set the compressed texture format to use, based on the formats you have, and the formats
  99121. * supported by the hardware / browser.
  99122. *
  99123. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  99124. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  99125. * to API arguments needed to compressed textures. This puts the burden on the container
  99126. * generator to house the arcane code for determining these for current & future formats.
  99127. *
  99128. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99129. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99130. *
  99131. * Note: The result of this call is not taken into account when a texture is base64.
  99132. *
  99133. * @param formatsAvailable defines the list of those format families you have created
  99134. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  99135. *
  99136. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  99137. * @returns The extension selected.
  99138. */
  99139. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  99140. /**
  99141. * Force a specific size of the canvas
  99142. * @param width defines the new canvas' width
  99143. * @param height defines the new canvas' height
  99144. */
  99145. setSize(width: number, height: number): void;
  99146. /**
  99147. * Updates a dynamic vertex buffer.
  99148. * @param vertexBuffer the vertex buffer to update
  99149. * @param data the data used to update the vertex buffer
  99150. * @param byteOffset the byte offset of the data
  99151. * @param byteLength the byte length of the data
  99152. */
  99153. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  99154. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99155. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99156. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99157. _releaseTexture(texture: InternalTexture): void;
  99158. /**
  99159. * @hidden
  99160. * Rescales a texture
  99161. * @param source input texutre
  99162. * @param destination destination texture
  99163. * @param scene scene to use to render the resize
  99164. * @param internalFormat format to use when resizing
  99165. * @param onComplete callback to be called when resize has completed
  99166. */
  99167. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  99168. /**
  99169. * Gets the current framerate
  99170. * @returns a number representing the framerate
  99171. */
  99172. getFps(): number;
  99173. /**
  99174. * Gets the time spent between current and previous frame
  99175. * @returns a number representing the delta time in ms
  99176. */
  99177. getDeltaTime(): number;
  99178. private _measureFps;
  99179. /** @hidden */
  99180. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  99181. /**
  99182. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  99183. * @param renderTarget The render target to set the frame buffer for
  99184. */
  99185. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  99186. /**
  99187. * Update a dynamic index buffer
  99188. * @param indexBuffer defines the target index buffer
  99189. * @param indices defines the data to update
  99190. * @param offset defines the offset in the target index buffer where update should start
  99191. */
  99192. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99193. /**
  99194. * Updates the sample count of a render target texture
  99195. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99196. * @param texture defines the texture to update
  99197. * @param samples defines the sample count to set
  99198. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99199. */
  99200. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  99201. /**
  99202. * Updates a depth texture Comparison Mode and Function.
  99203. * If the comparison Function is equal to 0, the mode will be set to none.
  99204. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  99205. * @param texture The texture to set the comparison function for
  99206. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  99207. */
  99208. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  99209. /**
  99210. * Creates a webGL buffer to use with instanciation
  99211. * @param capacity defines the size of the buffer
  99212. * @returns the webGL buffer
  99213. */
  99214. createInstancesBuffer(capacity: number): DataBuffer;
  99215. /**
  99216. * Delete a webGL buffer used with instanciation
  99217. * @param buffer defines the webGL buffer to delete
  99218. */
  99219. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  99220. /** @hidden */
  99221. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  99222. dispose(): void;
  99223. private _disableTouchAction;
  99224. /**
  99225. * Display the loading screen
  99226. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99227. */
  99228. displayLoadingUI(): void;
  99229. /**
  99230. * Hide the loading screen
  99231. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99232. */
  99233. hideLoadingUI(): void;
  99234. /**
  99235. * Gets the current loading screen object
  99236. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99237. */
  99238. /**
  99239. * Sets the current loading screen object
  99240. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99241. */
  99242. loadingScreen: ILoadingScreen;
  99243. /**
  99244. * Sets the current loading screen text
  99245. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99246. */
  99247. loadingUIText: string;
  99248. /**
  99249. * Sets the current loading screen background color
  99250. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99251. */
  99252. loadingUIBackgroundColor: string;
  99253. /** Pointerlock and fullscreen */
  99254. /**
  99255. * Ask the browser to promote the current element to pointerlock mode
  99256. * @param element defines the DOM element to promote
  99257. */
  99258. static _RequestPointerlock(element: HTMLElement): void;
  99259. /**
  99260. * Asks the browser to exit pointerlock mode
  99261. */
  99262. static _ExitPointerlock(): void;
  99263. /**
  99264. * Ask the browser to promote the current element to fullscreen rendering mode
  99265. * @param element defines the DOM element to promote
  99266. */
  99267. static _RequestFullscreen(element: HTMLElement): void;
  99268. /**
  99269. * Asks the browser to exit fullscreen mode
  99270. */
  99271. static _ExitFullscreen(): void;
  99272. }
  99273. }
  99274. declare module BABYLON {
  99275. /**
  99276. * The engine store class is responsible to hold all the instances of Engine and Scene created
  99277. * during the life time of the application.
  99278. */
  99279. export class EngineStore {
  99280. /** Gets the list of created engines */
  99281. static Instances: Engine[];
  99282. /** @hidden */
  99283. static _LastCreatedScene: Nullable<Scene>;
  99284. /**
  99285. * Gets the latest created engine
  99286. */
  99287. static readonly LastCreatedEngine: Nullable<Engine>;
  99288. /**
  99289. * Gets the latest created scene
  99290. */
  99291. static readonly LastCreatedScene: Nullable<Scene>;
  99292. /**
  99293. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99294. * @ignorenaming
  99295. */
  99296. static UseFallbackTexture: boolean;
  99297. /**
  99298. * Texture content used if a texture cannot loaded
  99299. * @ignorenaming
  99300. */
  99301. static FallbackTexture: string;
  99302. }
  99303. }
  99304. declare module BABYLON {
  99305. /**
  99306. * Helper class that provides a small promise polyfill
  99307. */
  99308. export class PromisePolyfill {
  99309. /**
  99310. * Static function used to check if the polyfill is required
  99311. * If this is the case then the function will inject the polyfill to window.Promise
  99312. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  99313. */
  99314. static Apply(force?: boolean): void;
  99315. }
  99316. }
  99317. declare module BABYLON {
  99318. /**
  99319. * Interface for screenshot methods with describe argument called `size` as object with options
  99320. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  99321. */
  99322. export interface IScreenshotSize {
  99323. /**
  99324. * number in pixels for canvas height
  99325. */
  99326. height?: number;
  99327. /**
  99328. * multiplier allowing render at a higher or lower resolution
  99329. * If value is defined then height and width will be ignored and taken from camera
  99330. */
  99331. precision?: number;
  99332. /**
  99333. * number in pixels for canvas width
  99334. */
  99335. width?: number;
  99336. }
  99337. }
  99338. declare module BABYLON {
  99339. interface IColor4Like {
  99340. r: float;
  99341. g: float;
  99342. b: float;
  99343. a: float;
  99344. }
  99345. /**
  99346. * Class containing a set of static utilities functions
  99347. */
  99348. export class Tools {
  99349. /**
  99350. * Gets or sets the base URL to use to load assets
  99351. */
  99352. static BaseUrl: string;
  99353. /**
  99354. * Enable/Disable Custom HTTP Request Headers globally.
  99355. * default = false
  99356. * @see CustomRequestHeaders
  99357. */
  99358. static UseCustomRequestHeaders: boolean;
  99359. /**
  99360. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99361. * i.e. when loading files, where the server/service expects an Authorization header
  99362. */
  99363. static CustomRequestHeaders: {
  99364. [key: string]: string;
  99365. };
  99366. /**
  99367. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99368. */
  99369. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  99370. /**
  99371. * Default behaviour for cors in the application.
  99372. * It can be a string if the expected behavior is identical in the entire app.
  99373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99374. */
  99375. static CorsBehavior: string | ((url: string | string[]) => string);
  99376. /**
  99377. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99378. * @ignorenaming
  99379. */
  99380. static UseFallbackTexture: boolean;
  99381. /**
  99382. * Use this object to register external classes like custom textures or material
  99383. * to allow the laoders to instantiate them
  99384. */
  99385. static RegisteredExternalClasses: {
  99386. [key: string]: Object;
  99387. };
  99388. /**
  99389. * Texture content used if a texture cannot loaded
  99390. * @ignorenaming
  99391. */
  99392. static fallbackTexture: string;
  99393. /**
  99394. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  99395. * @param u defines the coordinate on X axis
  99396. * @param v defines the coordinate on Y axis
  99397. * @param width defines the width of the source data
  99398. * @param height defines the height of the source data
  99399. * @param pixels defines the source byte array
  99400. * @param color defines the output color
  99401. */
  99402. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  99403. /**
  99404. * Interpolates between a and b via alpha
  99405. * @param a The lower value (returned when alpha = 0)
  99406. * @param b The upper value (returned when alpha = 1)
  99407. * @param alpha The interpolation-factor
  99408. * @return The mixed value
  99409. */
  99410. static Mix(a: number, b: number, alpha: number): number;
  99411. /**
  99412. * Tries to instantiate a new object from a given class name
  99413. * @param className defines the class name to instantiate
  99414. * @returns the new object or null if the system was not able to do the instantiation
  99415. */
  99416. static Instantiate(className: string): any;
  99417. /**
  99418. * Provides a slice function that will work even on IE
  99419. * @param data defines the array to slice
  99420. * @param start defines the start of the data (optional)
  99421. * @param end defines the end of the data (optional)
  99422. * @returns the new sliced array
  99423. */
  99424. static Slice<T>(data: T, start?: number, end?: number): T;
  99425. /**
  99426. * Polyfill for setImmediate
  99427. * @param action defines the action to execute after the current execution block
  99428. */
  99429. static SetImmediate(action: () => void): void;
  99430. /**
  99431. * Function indicating if a number is an exponent of 2
  99432. * @param value defines the value to test
  99433. * @returns true if the value is an exponent of 2
  99434. */
  99435. static IsExponentOfTwo(value: number): boolean;
  99436. private static _tmpFloatArray;
  99437. /**
  99438. * Returns the nearest 32-bit single precision float representation of a Number
  99439. * @param value A Number. If the parameter is of a different type, it will get converted
  99440. * to a number or to NaN if it cannot be converted
  99441. * @returns number
  99442. */
  99443. static FloatRound(value: number): number;
  99444. /**
  99445. * Extracts the filename from a path
  99446. * @param path defines the path to use
  99447. * @returns the filename
  99448. */
  99449. static GetFilename(path: string): string;
  99450. /**
  99451. * Extracts the "folder" part of a path (everything before the filename).
  99452. * @param uri The URI to extract the info from
  99453. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  99454. * @returns The "folder" part of the path
  99455. */
  99456. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  99457. /**
  99458. * Extracts text content from a DOM element hierarchy
  99459. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99460. */
  99461. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  99462. /**
  99463. * Convert an angle in radians to degrees
  99464. * @param angle defines the angle to convert
  99465. * @returns the angle in degrees
  99466. */
  99467. static ToDegrees(angle: number): number;
  99468. /**
  99469. * Convert an angle in degrees to radians
  99470. * @param angle defines the angle to convert
  99471. * @returns the angle in radians
  99472. */
  99473. static ToRadians(angle: number): number;
  99474. /**
  99475. * Returns an array if obj is not an array
  99476. * @param obj defines the object to evaluate as an array
  99477. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  99478. * @returns either obj directly if obj is an array or a new array containing obj
  99479. */
  99480. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  99481. /**
  99482. * Gets the pointer prefix to use
  99483. * @returns "pointer" if touch is enabled. Else returns "mouse"
  99484. */
  99485. static GetPointerPrefix(): string;
  99486. /**
  99487. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  99488. * @param url define the url we are trying
  99489. * @param element define the dom element where to configure the cors policy
  99490. */
  99491. static SetCorsBehavior(url: string | string[], element: {
  99492. crossOrigin: string | null;
  99493. }): void;
  99494. /**
  99495. * Removes unwanted characters from an url
  99496. * @param url defines the url to clean
  99497. * @returns the cleaned url
  99498. */
  99499. static CleanUrl(url: string): string;
  99500. /**
  99501. * Gets or sets a function used to pre-process url before using them to load assets
  99502. */
  99503. static PreprocessUrl: (url: string) => string;
  99504. /**
  99505. * Loads an image as an HTMLImageElement.
  99506. * @param input url string, ArrayBuffer, or Blob to load
  99507. * @param onLoad callback called when the image successfully loads
  99508. * @param onError callback called when the image fails to load
  99509. * @param offlineProvider offline provider for caching
  99510. * @param mimeType optional mime type
  99511. * @returns the HTMLImageElement of the loaded image
  99512. */
  99513. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  99514. /**
  99515. * Loads a file from a url
  99516. * @param url url string, ArrayBuffer, or Blob to load
  99517. * @param onSuccess callback called when the file successfully loads
  99518. * @param onProgress callback called while file is loading (if the server supports this mode)
  99519. * @param offlineProvider defines the offline provider for caching
  99520. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  99521. * @param onError callback called when the file fails to load
  99522. * @returns a file request object
  99523. */
  99524. 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;
  99525. /**
  99526. * Loads a file from a url
  99527. * @param url the file url to load
  99528. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  99529. */
  99530. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  99531. /**
  99532. * Load a script (identified by an url). When the url returns, the
  99533. * content of this file is added into a new script element, attached to the DOM (body element)
  99534. * @param scriptUrl defines the url of the script to laod
  99535. * @param onSuccess defines the callback called when the script is loaded
  99536. * @param onError defines the callback to call if an error occurs
  99537. * @param scriptId defines the id of the script element
  99538. */
  99539. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  99540. /**
  99541. * Load an asynchronous script (identified by an url). When the url returns, the
  99542. * content of this file is added into a new script element, attached to the DOM (body element)
  99543. * @param scriptUrl defines the url of the script to laod
  99544. * @param scriptId defines the id of the script element
  99545. * @returns a promise request object
  99546. */
  99547. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  99548. /**
  99549. * Loads a file from a blob
  99550. * @param fileToLoad defines the blob to use
  99551. * @param callback defines the callback to call when data is loaded
  99552. * @param progressCallback defines the callback to call during loading process
  99553. * @returns a file request object
  99554. */
  99555. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  99556. /**
  99557. * Reads a file from a File object
  99558. * @param file defines the file to load
  99559. * @param onSuccess defines the callback to call when data is loaded
  99560. * @param onProgress defines the callback to call during loading process
  99561. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  99562. * @param onError defines the callback to call when an error occurs
  99563. * @returns a file request object
  99564. */
  99565. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  99566. /**
  99567. * Creates a data url from a given string content
  99568. * @param content defines the content to convert
  99569. * @returns the new data url link
  99570. */
  99571. static FileAsURL(content: string): string;
  99572. /**
  99573. * Format the given number to a specific decimal format
  99574. * @param value defines the number to format
  99575. * @param decimals defines the number of decimals to use
  99576. * @returns the formatted string
  99577. */
  99578. static Format(value: number, decimals?: number): string;
  99579. /**
  99580. * Tries to copy an object by duplicating every property
  99581. * @param source defines the source object
  99582. * @param destination defines the target object
  99583. * @param doNotCopyList defines a list of properties to avoid
  99584. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  99585. */
  99586. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  99587. /**
  99588. * Gets a boolean indicating if the given object has no own property
  99589. * @param obj defines the object to test
  99590. * @returns true if object has no own property
  99591. */
  99592. static IsEmpty(obj: any): boolean;
  99593. /**
  99594. * Function used to register events at window level
  99595. * @param windowElement defines the Window object to use
  99596. * @param events defines the events to register
  99597. */
  99598. static RegisterTopRootEvents(windowElement: Window, events: {
  99599. name: string;
  99600. handler: Nullable<(e: FocusEvent) => any>;
  99601. }[]): void;
  99602. /**
  99603. * Function used to unregister events from window level
  99604. * @param windowElement defines the Window object to use
  99605. * @param events defines the events to unregister
  99606. */
  99607. static UnregisterTopRootEvents(windowElement: Window, events: {
  99608. name: string;
  99609. handler: Nullable<(e: FocusEvent) => any>;
  99610. }[]): void;
  99611. /**
  99612. * @ignore
  99613. */
  99614. static _ScreenshotCanvas: HTMLCanvasElement;
  99615. /**
  99616. * Dumps the current bound framebuffer
  99617. * @param width defines the rendering width
  99618. * @param height defines the rendering height
  99619. * @param engine defines the hosting engine
  99620. * @param successCallback defines the callback triggered once the data are available
  99621. * @param mimeType defines the mime type of the result
  99622. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99623. */
  99624. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99625. /**
  99626. * Converts the canvas data to blob.
  99627. * This acts as a polyfill for browsers not supporting the to blob function.
  99628. * @param canvas Defines the canvas to extract the data from
  99629. * @param successCallback Defines the callback triggered once the data are available
  99630. * @param mimeType Defines the mime type of the result
  99631. */
  99632. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  99633. /**
  99634. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99635. * @param successCallback defines the callback triggered once the data are available
  99636. * @param mimeType defines the mime type of the result
  99637. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99638. */
  99639. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99640. /**
  99641. * Downloads a blob in the browser
  99642. * @param blob defines the blob to download
  99643. * @param fileName defines the name of the downloaded file
  99644. */
  99645. static Download(blob: Blob, fileName: string): void;
  99646. /**
  99647. * Captures a screenshot of the current rendering
  99648. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99649. * @param engine defines the rendering engine
  99650. * @param camera defines the source camera
  99651. * @param size This parameter can be set to a single number or to an object with the
  99652. * following (optional) properties: precision, width, height. If a single number is passed,
  99653. * it will be used for both width and height. If an object is passed, the screenshot size
  99654. * will be derived from the parameters. The precision property is a multiplier allowing
  99655. * rendering at a higher or lower resolution
  99656. * @param successCallback defines the callback receives a single parameter which contains the
  99657. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99658. * src parameter of an <img> to display it
  99659. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99660. * Check your browser for supported MIME types
  99661. */
  99662. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  99663. /**
  99664. * Captures a screenshot of the current rendering
  99665. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99666. * @param engine defines the rendering engine
  99667. * @param camera defines the source camera
  99668. * @param size This parameter can be set to a single number or to an object with the
  99669. * following (optional) properties: precision, width, height. If a single number is passed,
  99670. * it will be used for both width and height. If an object is passed, the screenshot size
  99671. * will be derived from the parameters. The precision property is a multiplier allowing
  99672. * rendering at a higher or lower resolution
  99673. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99674. * Check your browser for supported MIME types
  99675. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99676. * to the src parameter of an <img> to display it
  99677. */
  99678. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99679. /**
  99680. * Generates an image screenshot from the specified camera.
  99681. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99682. * @param engine The engine to use for rendering
  99683. * @param camera The camera to use for rendering
  99684. * @param size This parameter can be set to a single number or to an object with the
  99685. * following (optional) properties: precision, width, height. If a single number is passed,
  99686. * it will be used for both width and height. If an object is passed, the screenshot size
  99687. * will be derived from the parameters. The precision property is a multiplier allowing
  99688. * rendering at a higher or lower resolution
  99689. * @param successCallback The callback receives a single parameter which contains the
  99690. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99691. * src parameter of an <img> to display it
  99692. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99693. * Check your browser for supported MIME types
  99694. * @param samples Texture samples (default: 1)
  99695. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99696. * @param fileName A name for for the downloaded file.
  99697. */
  99698. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99699. /**
  99700. * Generates an image screenshot from the specified camera.
  99701. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99702. * @param engine The engine to use for rendering
  99703. * @param camera The camera to use for rendering
  99704. * @param size This parameter can be set to a single number or to an object with the
  99705. * following (optional) properties: precision, width, height. If a single number is passed,
  99706. * it will be used for both width and height. If an object is passed, the screenshot size
  99707. * will be derived from the parameters. The precision property is a multiplier allowing
  99708. * rendering at a higher or lower resolution
  99709. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99710. * Check your browser for supported MIME types
  99711. * @param samples Texture samples (default: 1)
  99712. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99713. * @param fileName A name for for the downloaded file.
  99714. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99715. * to the src parameter of an <img> to display it
  99716. */
  99717. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99718. /**
  99719. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99720. * Be aware Math.random() could cause collisions, but:
  99721. * "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"
  99722. * @returns a pseudo random id
  99723. */
  99724. static RandomId(): string;
  99725. /**
  99726. * Test if the given uri is a base64 string
  99727. * @param uri The uri to test
  99728. * @return True if the uri is a base64 string or false otherwise
  99729. */
  99730. static IsBase64(uri: string): boolean;
  99731. /**
  99732. * Decode the given base64 uri.
  99733. * @param uri The uri to decode
  99734. * @return The decoded base64 data.
  99735. */
  99736. static DecodeBase64(uri: string): ArrayBuffer;
  99737. /**
  99738. * Gets the absolute url.
  99739. * @param url the input url
  99740. * @return the absolute url
  99741. */
  99742. static GetAbsoluteUrl(url: string): string;
  99743. /**
  99744. * No log
  99745. */
  99746. static readonly NoneLogLevel: number;
  99747. /**
  99748. * Only message logs
  99749. */
  99750. static readonly MessageLogLevel: number;
  99751. /**
  99752. * Only warning logs
  99753. */
  99754. static readonly WarningLogLevel: number;
  99755. /**
  99756. * Only error logs
  99757. */
  99758. static readonly ErrorLogLevel: number;
  99759. /**
  99760. * All logs
  99761. */
  99762. static readonly AllLogLevel: number;
  99763. /**
  99764. * Gets a value indicating the number of loading errors
  99765. * @ignorenaming
  99766. */
  99767. static readonly errorsCount: number;
  99768. /**
  99769. * Callback called when a new log is added
  99770. */
  99771. static OnNewCacheEntry: (entry: string) => void;
  99772. /**
  99773. * Log a message to the console
  99774. * @param message defines the message to log
  99775. */
  99776. static Log(message: string): void;
  99777. /**
  99778. * Write a warning message to the console
  99779. * @param message defines the message to log
  99780. */
  99781. static Warn(message: string): void;
  99782. /**
  99783. * Write an error message to the console
  99784. * @param message defines the message to log
  99785. */
  99786. static Error(message: string): void;
  99787. /**
  99788. * Gets current log cache (list of logs)
  99789. */
  99790. static readonly LogCache: string;
  99791. /**
  99792. * Clears the log cache
  99793. */
  99794. static ClearLogCache(): void;
  99795. /**
  99796. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99797. */
  99798. static LogLevels: number;
  99799. /**
  99800. * Checks if the window object exists
  99801. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99802. */
  99803. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99804. /**
  99805. * No performance log
  99806. */
  99807. static readonly PerformanceNoneLogLevel: number;
  99808. /**
  99809. * Use user marks to log performance
  99810. */
  99811. static readonly PerformanceUserMarkLogLevel: number;
  99812. /**
  99813. * Log performance to the console
  99814. */
  99815. static readonly PerformanceConsoleLogLevel: number;
  99816. private static _performance;
  99817. /**
  99818. * Sets the current performance log level
  99819. */
  99820. static PerformanceLogLevel: number;
  99821. private static _StartPerformanceCounterDisabled;
  99822. private static _EndPerformanceCounterDisabled;
  99823. private static _StartUserMark;
  99824. private static _EndUserMark;
  99825. private static _StartPerformanceConsole;
  99826. private static _EndPerformanceConsole;
  99827. /**
  99828. * Starts a performance counter
  99829. */
  99830. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99831. /**
  99832. * Ends a specific performance coutner
  99833. */
  99834. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99835. /**
  99836. * Gets either window.performance.now() if supported or Date.now() else
  99837. */
  99838. static readonly Now: number;
  99839. /**
  99840. * This method will return the name of the class used to create the instance of the given object.
  99841. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99842. * @param object the object to get the class name from
  99843. * @param isType defines if the object is actually a type
  99844. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99845. */
  99846. static GetClassName(object: any, isType?: boolean): string;
  99847. /**
  99848. * Gets the first element of an array satisfying a given predicate
  99849. * @param array defines the array to browse
  99850. * @param predicate defines the predicate to use
  99851. * @returns null if not found or the element
  99852. */
  99853. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99854. /**
  99855. * This method will return the name of the full name of the class, including its owning module (if any).
  99856. * 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).
  99857. * @param object the object to get the class name from
  99858. * @param isType defines if the object is actually a type
  99859. * @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.
  99860. * @ignorenaming
  99861. */
  99862. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99863. /**
  99864. * Returns a promise that resolves after the given amount of time.
  99865. * @param delay Number of milliseconds to delay
  99866. * @returns Promise that resolves after the given amount of time
  99867. */
  99868. static DelayAsync(delay: number): Promise<void>;
  99869. }
  99870. /**
  99871. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99872. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99873. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99874. * @param name The name of the class, case should be preserved
  99875. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99876. */
  99877. export function className(name: string, module?: string): (target: Object) => void;
  99878. /**
  99879. * An implementation of a loop for asynchronous functions.
  99880. */
  99881. export class AsyncLoop {
  99882. /**
  99883. * Defines the number of iterations for the loop
  99884. */
  99885. iterations: number;
  99886. /**
  99887. * Defines the current index of the loop.
  99888. */
  99889. index: number;
  99890. private _done;
  99891. private _fn;
  99892. private _successCallback;
  99893. /**
  99894. * Constructor.
  99895. * @param iterations the number of iterations.
  99896. * @param func the function to run each iteration
  99897. * @param successCallback the callback that will be called upon succesful execution
  99898. * @param offset starting offset.
  99899. */
  99900. constructor(
  99901. /**
  99902. * Defines the number of iterations for the loop
  99903. */
  99904. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99905. /**
  99906. * Execute the next iteration. Must be called after the last iteration was finished.
  99907. */
  99908. executeNext(): void;
  99909. /**
  99910. * Break the loop and run the success callback.
  99911. */
  99912. breakLoop(): void;
  99913. /**
  99914. * Create and run an async loop.
  99915. * @param iterations the number of iterations.
  99916. * @param fn the function to run each iteration
  99917. * @param successCallback the callback that will be called upon succesful execution
  99918. * @param offset starting offset.
  99919. * @returns the created async loop object
  99920. */
  99921. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99922. /**
  99923. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99924. * @param iterations total number of iterations
  99925. * @param syncedIterations number of synchronous iterations in each async iteration.
  99926. * @param fn the function to call each iteration.
  99927. * @param callback a success call back that will be called when iterating stops.
  99928. * @param breakFunction a break condition (optional)
  99929. * @param timeout timeout settings for the setTimeout function. default - 0.
  99930. * @returns the created async loop object
  99931. */
  99932. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99933. }
  99934. }
  99935. declare module BABYLON {
  99936. /**
  99937. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99938. * The underlying implementation relies on an associative array to ensure the best performances.
  99939. * The value can be anything including 'null' but except 'undefined'
  99940. */
  99941. export class StringDictionary<T> {
  99942. /**
  99943. * This will clear this dictionary and copy the content from the 'source' one.
  99944. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99945. * @param source the dictionary to take the content from and copy to this dictionary
  99946. */
  99947. copyFrom(source: StringDictionary<T>): void;
  99948. /**
  99949. * Get a value based from its key
  99950. * @param key the given key to get the matching value from
  99951. * @return the value if found, otherwise undefined is returned
  99952. */
  99953. get(key: string): T | undefined;
  99954. /**
  99955. * Get a value from its key or add it if it doesn't exist.
  99956. * This method will ensure you that a given key/data will be present in the dictionary.
  99957. * @param key the given key to get the matching value from
  99958. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99959. * The factory will only be invoked if there's no data for the given key.
  99960. * @return the value corresponding to the key.
  99961. */
  99962. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99963. /**
  99964. * Get a value from its key if present in the dictionary otherwise add it
  99965. * @param key the key to get the value from
  99966. * @param val if there's no such key/value pair in the dictionary add it with this value
  99967. * @return the value corresponding to the key
  99968. */
  99969. getOrAdd(key: string, val: T): T;
  99970. /**
  99971. * Check if there's a given key in the dictionary
  99972. * @param key the key to check for
  99973. * @return true if the key is present, false otherwise
  99974. */
  99975. contains(key: string): boolean;
  99976. /**
  99977. * Add a new key and its corresponding value
  99978. * @param key the key to add
  99979. * @param value the value corresponding to the key
  99980. * @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
  99981. */
  99982. add(key: string, value: T): boolean;
  99983. /**
  99984. * Update a specific value associated to a key
  99985. * @param key defines the key to use
  99986. * @param value defines the value to store
  99987. * @returns true if the value was updated (or false if the key was not found)
  99988. */
  99989. set(key: string, value: T): boolean;
  99990. /**
  99991. * Get the element of the given key and remove it from the dictionary
  99992. * @param key defines the key to search
  99993. * @returns the value associated with the key or null if not found
  99994. */
  99995. getAndRemove(key: string): Nullable<T>;
  99996. /**
  99997. * Remove a key/value from the dictionary.
  99998. * @param key the key to remove
  99999. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100000. */
  100001. remove(key: string): boolean;
  100002. /**
  100003. * Clear the whole content of the dictionary
  100004. */
  100005. clear(): void;
  100006. /**
  100007. * Gets the current count
  100008. */
  100009. readonly count: number;
  100010. /**
  100011. * Execute a callback on each key/val of the dictionary.
  100012. * Note that you can remove any element in this dictionary in the callback implementation
  100013. * @param callback the callback to execute on a given key/value pair
  100014. */
  100015. forEach(callback: (key: string, val: T) => void): void;
  100016. /**
  100017. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100018. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100019. * Note that you can remove any element in this dictionary in the callback implementation
  100020. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100021. * @returns the first item
  100022. */
  100023. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  100024. private _count;
  100025. private _data;
  100026. }
  100027. }
  100028. declare module BABYLON {
  100029. /** @hidden */
  100030. export interface ICollisionCoordinator {
  100031. createCollider(): Collider;
  100032. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100033. init(scene: Scene): void;
  100034. }
  100035. /** @hidden */
  100036. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  100037. private _scene;
  100038. private _scaledPosition;
  100039. private _scaledVelocity;
  100040. private _finalPosition;
  100041. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100042. createCollider(): Collider;
  100043. init(scene: Scene): void;
  100044. private _collideWithWorld;
  100045. }
  100046. }
  100047. declare module BABYLON {
  100048. /**
  100049. * Class used to manage all inputs for the scene.
  100050. */
  100051. export class InputManager {
  100052. /** The distance in pixel that you have to move to prevent some events */
  100053. static DragMovementThreshold: number;
  100054. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  100055. static LongPressDelay: number;
  100056. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  100057. static DoubleClickDelay: number;
  100058. /** If you need to check double click without raising a single click at first click, enable this flag */
  100059. static ExclusiveDoubleClickMode: boolean;
  100060. private _wheelEventName;
  100061. private _onPointerMove;
  100062. private _onPointerDown;
  100063. private _onPointerUp;
  100064. private _initClickEvent;
  100065. private _initActionManager;
  100066. private _delayedSimpleClick;
  100067. private _delayedSimpleClickTimeout;
  100068. private _previousDelayedSimpleClickTimeout;
  100069. private _meshPickProceed;
  100070. private _previousButtonPressed;
  100071. private _currentPickResult;
  100072. private _previousPickResult;
  100073. private _totalPointersPressed;
  100074. private _doubleClickOccured;
  100075. private _pointerOverMesh;
  100076. private _pickedDownMesh;
  100077. private _pickedUpMesh;
  100078. private _pointerX;
  100079. private _pointerY;
  100080. private _unTranslatedPointerX;
  100081. private _unTranslatedPointerY;
  100082. private _startingPointerPosition;
  100083. private _previousStartingPointerPosition;
  100084. private _startingPointerTime;
  100085. private _previousStartingPointerTime;
  100086. private _pointerCaptures;
  100087. private _onKeyDown;
  100088. private _onKeyUp;
  100089. private _onCanvasFocusObserver;
  100090. private _onCanvasBlurObserver;
  100091. private _scene;
  100092. /**
  100093. * Creates a new InputManager
  100094. * @param scene defines the hosting scene
  100095. */
  100096. constructor(scene: Scene);
  100097. /**
  100098. * Gets the mesh that is currently under the pointer
  100099. */
  100100. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100101. /**
  100102. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  100103. */
  100104. readonly unTranslatedPointer: Vector2;
  100105. /**
  100106. * Gets or sets the current on-screen X position of the pointer
  100107. */
  100108. pointerX: number;
  100109. /**
  100110. * Gets or sets the current on-screen Y position of the pointer
  100111. */
  100112. pointerY: number;
  100113. private _updatePointerPosition;
  100114. private _processPointerMove;
  100115. private _setRayOnPointerInfo;
  100116. private _checkPrePointerObservable;
  100117. /**
  100118. * Use this method to simulate a pointer move on a mesh
  100119. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100120. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100121. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100122. */
  100123. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100124. /**
  100125. * Use this method to simulate a pointer down on a mesh
  100126. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100127. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100128. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100129. */
  100130. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100131. private _processPointerDown;
  100132. /** @hidden */
  100133. _isPointerSwiping(): boolean;
  100134. /**
  100135. * Use this method to simulate a pointer up on a mesh
  100136. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100137. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100138. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100139. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100140. */
  100141. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  100142. private _processPointerUp;
  100143. /**
  100144. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100145. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100146. * @returns true if the pointer was captured
  100147. */
  100148. isPointerCaptured(pointerId?: number): boolean;
  100149. /**
  100150. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100151. * @param attachUp defines if you want to attach events to pointerup
  100152. * @param attachDown defines if you want to attach events to pointerdown
  100153. * @param attachMove defines if you want to attach events to pointermove
  100154. */
  100155. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100156. /**
  100157. * Detaches all event handlers
  100158. */
  100159. detachControl(): void;
  100160. /**
  100161. * Force the value of meshUnderPointer
  100162. * @param mesh defines the mesh to use
  100163. */
  100164. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100165. /**
  100166. * Gets the mesh under the pointer
  100167. * @returns a Mesh or null if no mesh is under the pointer
  100168. */
  100169. getPointerOverMesh(): Nullable<AbstractMesh>;
  100170. }
  100171. }
  100172. declare module BABYLON {
  100173. /**
  100174. * Helper class used to generate session unique ID
  100175. */
  100176. export class UniqueIdGenerator {
  100177. private static _UniqueIdCounter;
  100178. /**
  100179. * Gets an unique (relatively to the current scene) Id
  100180. */
  100181. static readonly UniqueId: number;
  100182. }
  100183. }
  100184. declare module BABYLON {
  100185. /**
  100186. * This class defines the direct association between an animation and a target
  100187. */
  100188. export class TargetedAnimation {
  100189. /**
  100190. * Animation to perform
  100191. */
  100192. animation: Animation;
  100193. /**
  100194. * Target to animate
  100195. */
  100196. target: any;
  100197. /**
  100198. * Serialize the object
  100199. * @returns the JSON object representing the current entity
  100200. */
  100201. serialize(): any;
  100202. }
  100203. /**
  100204. * Use this class to create coordinated animations on multiple targets
  100205. */
  100206. export class AnimationGroup implements IDisposable {
  100207. /** The name of the animation group */
  100208. name: string;
  100209. private _scene;
  100210. private _targetedAnimations;
  100211. private _animatables;
  100212. private _from;
  100213. private _to;
  100214. private _isStarted;
  100215. private _isPaused;
  100216. private _speedRatio;
  100217. private _loopAnimation;
  100218. /**
  100219. * Gets or sets the unique id of the node
  100220. */
  100221. uniqueId: number;
  100222. /**
  100223. * This observable will notify when one animation have ended
  100224. */
  100225. onAnimationEndObservable: Observable<TargetedAnimation>;
  100226. /**
  100227. * Observer raised when one animation loops
  100228. */
  100229. onAnimationLoopObservable: Observable<TargetedAnimation>;
  100230. /**
  100231. * This observable will notify when all animations have ended.
  100232. */
  100233. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  100234. /**
  100235. * This observable will notify when all animations have paused.
  100236. */
  100237. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  100238. /**
  100239. * This observable will notify when all animations are playing.
  100240. */
  100241. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  100242. /**
  100243. * Gets the first frame
  100244. */
  100245. readonly from: number;
  100246. /**
  100247. * Gets the last frame
  100248. */
  100249. readonly to: number;
  100250. /**
  100251. * Define if the animations are started
  100252. */
  100253. readonly isStarted: boolean;
  100254. /**
  100255. * Gets a value indicating that the current group is playing
  100256. */
  100257. readonly isPlaying: boolean;
  100258. /**
  100259. * Gets or sets the speed ratio to use for all animations
  100260. */
  100261. /**
  100262. * Gets or sets the speed ratio to use for all animations
  100263. */
  100264. speedRatio: number;
  100265. /**
  100266. * Gets or sets if all animations should loop or not
  100267. */
  100268. loopAnimation: boolean;
  100269. /**
  100270. * Gets the targeted animations for this animation group
  100271. */
  100272. readonly targetedAnimations: Array<TargetedAnimation>;
  100273. /**
  100274. * returning the list of animatables controlled by this animation group.
  100275. */
  100276. readonly animatables: Array<Animatable>;
  100277. /**
  100278. * Instantiates a new Animation Group.
  100279. * This helps managing several animations at once.
  100280. * @see http://doc.babylonjs.com/how_to/group
  100281. * @param name Defines the name of the group
  100282. * @param scene Defines the scene the group belongs to
  100283. */
  100284. constructor(
  100285. /** The name of the animation group */
  100286. name: string, scene?: Nullable<Scene>);
  100287. /**
  100288. * Add an animation (with its target) in the group
  100289. * @param animation defines the animation we want to add
  100290. * @param target defines the target of the animation
  100291. * @returns the TargetedAnimation object
  100292. */
  100293. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  100294. /**
  100295. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  100296. * It can add constant keys at begin or end
  100297. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  100298. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  100299. * @returns the animation group
  100300. */
  100301. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  100302. /**
  100303. * Start all animations on given targets
  100304. * @param loop defines if animations must loop
  100305. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  100306. * @param from defines the from key (optional)
  100307. * @param to defines the to key (optional)
  100308. * @returns the current animation group
  100309. */
  100310. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  100311. /**
  100312. * Pause all animations
  100313. * @returns the animation group
  100314. */
  100315. pause(): AnimationGroup;
  100316. /**
  100317. * Play all animations to initial state
  100318. * This function will start() the animations if they were not started or will restart() them if they were paused
  100319. * @param loop defines if animations must loop
  100320. * @returns the animation group
  100321. */
  100322. play(loop?: boolean): AnimationGroup;
  100323. /**
  100324. * Reset all animations to initial state
  100325. * @returns the animation group
  100326. */
  100327. reset(): AnimationGroup;
  100328. /**
  100329. * Restart animations from key 0
  100330. * @returns the animation group
  100331. */
  100332. restart(): AnimationGroup;
  100333. /**
  100334. * Stop all animations
  100335. * @returns the animation group
  100336. */
  100337. stop(): AnimationGroup;
  100338. /**
  100339. * Set animation weight for all animatables
  100340. * @param weight defines the weight to use
  100341. * @return the animationGroup
  100342. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100343. */
  100344. setWeightForAllAnimatables(weight: number): AnimationGroup;
  100345. /**
  100346. * Synchronize and normalize all animatables with a source animatable
  100347. * @param root defines the root animatable to synchronize with
  100348. * @return the animationGroup
  100349. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100350. */
  100351. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  100352. /**
  100353. * Goes to a specific frame in this animation group
  100354. * @param frame the frame number to go to
  100355. * @return the animationGroup
  100356. */
  100357. goToFrame(frame: number): AnimationGroup;
  100358. /**
  100359. * Dispose all associated resources
  100360. */
  100361. dispose(): void;
  100362. private _checkAnimationGroupEnded;
  100363. /**
  100364. * Clone the current animation group and returns a copy
  100365. * @param newName defines the name of the new group
  100366. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  100367. * @returns the new aniamtion group
  100368. */
  100369. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  100370. /**
  100371. * Serializes the animationGroup to an object
  100372. * @returns Serialized object
  100373. */
  100374. serialize(): any;
  100375. /**
  100376. * Returns a new AnimationGroup object parsed from the source provided.
  100377. * @param parsedAnimationGroup defines the source
  100378. * @param scene defines the scene that will receive the animationGroup
  100379. * @returns a new AnimationGroup
  100380. */
  100381. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  100382. /**
  100383. * Returns the string "AnimationGroup"
  100384. * @returns "AnimationGroup"
  100385. */
  100386. getClassName(): string;
  100387. /**
  100388. * Creates a detailled string about the object
  100389. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  100390. * @returns a string representing the object
  100391. */
  100392. toString(fullDetails?: boolean): string;
  100393. }
  100394. }
  100395. declare module BABYLON {
  100396. /**
  100397. * Define an interface for all classes that will hold resources
  100398. */
  100399. export interface IDisposable {
  100400. /**
  100401. * Releases all held resources
  100402. */
  100403. dispose(): void;
  100404. }
  100405. /** Interface defining initialization parameters for Scene class */
  100406. export interface SceneOptions {
  100407. /**
  100408. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  100409. * It will improve performance when the number of geometries becomes important.
  100410. */
  100411. useGeometryUniqueIdsMap?: boolean;
  100412. /**
  100413. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  100414. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100415. */
  100416. useMaterialMeshMap?: boolean;
  100417. /**
  100418. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  100419. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100420. */
  100421. useClonedMeshhMap?: boolean;
  100422. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  100423. virtual?: boolean;
  100424. }
  100425. /**
  100426. * Represents a scene to be rendered by the engine.
  100427. * @see http://doc.babylonjs.com/features/scene
  100428. */
  100429. export class Scene extends AbstractScene implements IAnimatable {
  100430. /** The fog is deactivated */
  100431. static readonly FOGMODE_NONE: number;
  100432. /** The fog density is following an exponential function */
  100433. static readonly FOGMODE_EXP: number;
  100434. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  100435. static readonly FOGMODE_EXP2: number;
  100436. /** The fog density is following a linear function. */
  100437. static readonly FOGMODE_LINEAR: number;
  100438. /**
  100439. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  100440. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100441. */
  100442. static MinDeltaTime: number;
  100443. /**
  100444. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  100445. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100446. */
  100447. static MaxDeltaTime: number;
  100448. /**
  100449. * Factory used to create the default material.
  100450. * @param name The name of the material to create
  100451. * @param scene The scene to create the material for
  100452. * @returns The default material
  100453. */
  100454. static DefaultMaterialFactory(scene: Scene): Material;
  100455. /**
  100456. * Factory used to create the a collision coordinator.
  100457. * @returns The collision coordinator
  100458. */
  100459. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  100460. /** @hidden */
  100461. _inputManager: InputManager;
  100462. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  100463. cameraToUseForPointers: Nullable<Camera>;
  100464. /** @hidden */
  100465. readonly _isScene: boolean;
  100466. /**
  100467. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  100468. */
  100469. autoClear: boolean;
  100470. /**
  100471. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  100472. */
  100473. autoClearDepthAndStencil: boolean;
  100474. /**
  100475. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  100476. */
  100477. clearColor: Color4;
  100478. /**
  100479. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  100480. */
  100481. ambientColor: Color3;
  100482. /**
  100483. * This is use to store the default BRDF lookup for PBR materials in your scene.
  100484. * It should only be one of the following (if not the default embedded one):
  100485. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  100486. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  100487. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  100488. * The material properties need to be setup according to the type of texture in use.
  100489. */
  100490. environmentBRDFTexture: BaseTexture;
  100491. /** @hidden */
  100492. protected _environmentTexture: Nullable<BaseTexture>;
  100493. /**
  100494. * Texture used in all pbr material as the reflection texture.
  100495. * As in the majority of the scene they are the same (exception for multi room and so on),
  100496. * this is easier to reference from here than from all the materials.
  100497. */
  100498. /**
  100499. * Texture used in all pbr material as the reflection texture.
  100500. * As in the majority of the scene they are the same (exception for multi room and so on),
  100501. * this is easier to set here than in all the materials.
  100502. */
  100503. environmentTexture: Nullable<BaseTexture>;
  100504. /** @hidden */
  100505. protected _environmentIntensity: number;
  100506. /**
  100507. * Intensity of the environment in all pbr material.
  100508. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100509. * As in the majority of the scene they are the same (exception for multi room and so on),
  100510. * this is easier to reference from here than from all the materials.
  100511. */
  100512. /**
  100513. * Intensity of the environment in all pbr material.
  100514. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100515. * As in the majority of the scene they are the same (exception for multi room and so on),
  100516. * this is easier to set here than in all the materials.
  100517. */
  100518. environmentIntensity: number;
  100519. /** @hidden */
  100520. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100521. /**
  100522. * Default image processing configuration used either in the rendering
  100523. * Forward main pass or through the imageProcessingPostProcess if present.
  100524. * As in the majority of the scene they are the same (exception for multi camera),
  100525. * this is easier to reference from here than from all the materials and post process.
  100526. *
  100527. * No setter as we it is a shared configuration, you can set the values instead.
  100528. */
  100529. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  100530. private _forceWireframe;
  100531. /**
  100532. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  100533. */
  100534. forceWireframe: boolean;
  100535. private _forcePointsCloud;
  100536. /**
  100537. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  100538. */
  100539. forcePointsCloud: boolean;
  100540. /**
  100541. * Gets or sets the active clipplane 1
  100542. */
  100543. clipPlane: Nullable<Plane>;
  100544. /**
  100545. * Gets or sets the active clipplane 2
  100546. */
  100547. clipPlane2: Nullable<Plane>;
  100548. /**
  100549. * Gets or sets the active clipplane 3
  100550. */
  100551. clipPlane3: Nullable<Plane>;
  100552. /**
  100553. * Gets or sets the active clipplane 4
  100554. */
  100555. clipPlane4: Nullable<Plane>;
  100556. /**
  100557. * Gets or sets a boolean indicating if animations are enabled
  100558. */
  100559. animationsEnabled: boolean;
  100560. private _animationPropertiesOverride;
  100561. /**
  100562. * Gets or sets the animation properties override
  100563. */
  100564. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  100565. /**
  100566. * Gets or sets a boolean indicating if a constant deltatime has to be used
  100567. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  100568. */
  100569. useConstantAnimationDeltaTime: boolean;
  100570. /**
  100571. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  100572. * Please note that it requires to run a ray cast through the scene on every frame
  100573. */
  100574. constantlyUpdateMeshUnderPointer: boolean;
  100575. /**
  100576. * Defines the HTML cursor to use when hovering over interactive elements
  100577. */
  100578. hoverCursor: string;
  100579. /**
  100580. * Defines the HTML default cursor to use (empty by default)
  100581. */
  100582. defaultCursor: string;
  100583. /**
  100584. * Defines wether cursors are handled by the scene.
  100585. */
  100586. doNotHandleCursors: boolean;
  100587. /**
  100588. * This is used to call preventDefault() on pointer down
  100589. * in order to block unwanted artifacts like system double clicks
  100590. */
  100591. preventDefaultOnPointerDown: boolean;
  100592. /**
  100593. * This is used to call preventDefault() on pointer up
  100594. * in order to block unwanted artifacts like system double clicks
  100595. */
  100596. preventDefaultOnPointerUp: boolean;
  100597. /**
  100598. * Gets or sets user defined metadata
  100599. */
  100600. metadata: any;
  100601. /**
  100602. * For internal use only. Please do not use.
  100603. */
  100604. reservedDataStore: any;
  100605. /**
  100606. * Gets the name of the plugin used to load this scene (null by default)
  100607. */
  100608. loadingPluginName: string;
  100609. /**
  100610. * Use this array to add regular expressions used to disable offline support for specific urls
  100611. */
  100612. disableOfflineSupportExceptionRules: RegExp[];
  100613. /**
  100614. * An event triggered when the scene is disposed.
  100615. */
  100616. onDisposeObservable: Observable<Scene>;
  100617. private _onDisposeObserver;
  100618. /** Sets a function to be executed when this scene is disposed. */
  100619. onDispose: () => void;
  100620. /**
  100621. * An event triggered before rendering the scene (right after animations and physics)
  100622. */
  100623. onBeforeRenderObservable: Observable<Scene>;
  100624. private _onBeforeRenderObserver;
  100625. /** Sets a function to be executed before rendering this scene */
  100626. beforeRender: Nullable<() => void>;
  100627. /**
  100628. * An event triggered after rendering the scene
  100629. */
  100630. onAfterRenderObservable: Observable<Scene>;
  100631. /**
  100632. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  100633. */
  100634. onAfterRenderCameraObservable: Observable<Camera>;
  100635. private _onAfterRenderObserver;
  100636. /** Sets a function to be executed after rendering this scene */
  100637. afterRender: Nullable<() => void>;
  100638. /**
  100639. * An event triggered before animating the scene
  100640. */
  100641. onBeforeAnimationsObservable: Observable<Scene>;
  100642. /**
  100643. * An event triggered after animations processing
  100644. */
  100645. onAfterAnimationsObservable: Observable<Scene>;
  100646. /**
  100647. * An event triggered before draw calls are ready to be sent
  100648. */
  100649. onBeforeDrawPhaseObservable: Observable<Scene>;
  100650. /**
  100651. * An event triggered after draw calls have been sent
  100652. */
  100653. onAfterDrawPhaseObservable: Observable<Scene>;
  100654. /**
  100655. * An event triggered when the scene is ready
  100656. */
  100657. onReadyObservable: Observable<Scene>;
  100658. /**
  100659. * An event triggered before rendering a camera
  100660. */
  100661. onBeforeCameraRenderObservable: Observable<Camera>;
  100662. private _onBeforeCameraRenderObserver;
  100663. /** Sets a function to be executed before rendering a camera*/
  100664. beforeCameraRender: () => void;
  100665. /**
  100666. * An event triggered after rendering a camera
  100667. */
  100668. onAfterCameraRenderObservable: Observable<Camera>;
  100669. private _onAfterCameraRenderObserver;
  100670. /** Sets a function to be executed after rendering a camera*/
  100671. afterCameraRender: () => void;
  100672. /**
  100673. * An event triggered when active meshes evaluation is about to start
  100674. */
  100675. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100676. /**
  100677. * An event triggered when active meshes evaluation is done
  100678. */
  100679. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100680. /**
  100681. * An event triggered when particles rendering is about to start
  100682. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100683. */
  100684. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100685. /**
  100686. * An event triggered when particles rendering is done
  100687. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100688. */
  100689. onAfterParticlesRenderingObservable: Observable<Scene>;
  100690. /**
  100691. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100692. */
  100693. onDataLoadedObservable: Observable<Scene>;
  100694. /**
  100695. * An event triggered when a camera is created
  100696. */
  100697. onNewCameraAddedObservable: Observable<Camera>;
  100698. /**
  100699. * An event triggered when a camera is removed
  100700. */
  100701. onCameraRemovedObservable: Observable<Camera>;
  100702. /**
  100703. * An event triggered when a light is created
  100704. */
  100705. onNewLightAddedObservable: Observable<Light>;
  100706. /**
  100707. * An event triggered when a light is removed
  100708. */
  100709. onLightRemovedObservable: Observable<Light>;
  100710. /**
  100711. * An event triggered when a geometry is created
  100712. */
  100713. onNewGeometryAddedObservable: Observable<Geometry>;
  100714. /**
  100715. * An event triggered when a geometry is removed
  100716. */
  100717. onGeometryRemovedObservable: Observable<Geometry>;
  100718. /**
  100719. * An event triggered when a transform node is created
  100720. */
  100721. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100722. /**
  100723. * An event triggered when a transform node is removed
  100724. */
  100725. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100726. /**
  100727. * An event triggered when a mesh is created
  100728. */
  100729. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100730. /**
  100731. * An event triggered when a mesh is removed
  100732. */
  100733. onMeshRemovedObservable: Observable<AbstractMesh>;
  100734. /**
  100735. * An event triggered when a skeleton is created
  100736. */
  100737. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100738. /**
  100739. * An event triggered when a skeleton is removed
  100740. */
  100741. onSkeletonRemovedObservable: Observable<Skeleton>;
  100742. /**
  100743. * An event triggered when a material is created
  100744. */
  100745. onNewMaterialAddedObservable: Observable<Material>;
  100746. /**
  100747. * An event triggered when a material is removed
  100748. */
  100749. onMaterialRemovedObservable: Observable<Material>;
  100750. /**
  100751. * An event triggered when a texture is created
  100752. */
  100753. onNewTextureAddedObservable: Observable<BaseTexture>;
  100754. /**
  100755. * An event triggered when a texture is removed
  100756. */
  100757. onTextureRemovedObservable: Observable<BaseTexture>;
  100758. /**
  100759. * An event triggered when render targets are about to be rendered
  100760. * Can happen multiple times per frame.
  100761. */
  100762. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100763. /**
  100764. * An event triggered when render targets were rendered.
  100765. * Can happen multiple times per frame.
  100766. */
  100767. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100768. /**
  100769. * An event triggered before calculating deterministic simulation step
  100770. */
  100771. onBeforeStepObservable: Observable<Scene>;
  100772. /**
  100773. * An event triggered after calculating deterministic simulation step
  100774. */
  100775. onAfterStepObservable: Observable<Scene>;
  100776. /**
  100777. * An event triggered when the activeCamera property is updated
  100778. */
  100779. onActiveCameraChanged: Observable<Scene>;
  100780. /**
  100781. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100782. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100783. * 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)
  100784. */
  100785. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100786. /**
  100787. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100788. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100789. * 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)
  100790. */
  100791. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100792. /**
  100793. * This Observable will when a mesh has been imported into the scene.
  100794. */
  100795. onMeshImportedObservable: Observable<AbstractMesh>;
  100796. /**
  100797. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100798. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100799. */
  100800. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100801. /** @hidden */
  100802. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100803. /**
  100804. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100805. */
  100806. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100807. /**
  100808. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100809. */
  100810. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100811. /**
  100812. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100813. */
  100814. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100815. /** Callback called when a pointer move is detected */
  100816. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100817. /** Callback called when a pointer down is detected */
  100818. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100819. /** Callback called when a pointer up is detected */
  100820. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100821. /** Callback called when a pointer pick is detected */
  100822. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100823. /**
  100824. * 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).
  100825. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100826. */
  100827. onPrePointerObservable: Observable<PointerInfoPre>;
  100828. /**
  100829. * Observable event triggered each time an input event is received from the rendering canvas
  100830. */
  100831. onPointerObservable: Observable<PointerInfo>;
  100832. /**
  100833. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100834. */
  100835. readonly unTranslatedPointer: Vector2;
  100836. /**
  100837. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100838. */
  100839. static DragMovementThreshold: number;
  100840. /**
  100841. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100842. */
  100843. static LongPressDelay: number;
  100844. /**
  100845. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100846. */
  100847. static DoubleClickDelay: number;
  100848. /** If you need to check double click without raising a single click at first click, enable this flag */
  100849. static ExclusiveDoubleClickMode: boolean;
  100850. /** @hidden */
  100851. _mirroredCameraPosition: Nullable<Vector3>;
  100852. /**
  100853. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100854. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100855. */
  100856. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100857. /**
  100858. * Observable event triggered each time an keyboard event is received from the hosting window
  100859. */
  100860. onKeyboardObservable: Observable<KeyboardInfo>;
  100861. private _useRightHandedSystem;
  100862. /**
  100863. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100864. */
  100865. useRightHandedSystem: boolean;
  100866. private _timeAccumulator;
  100867. private _currentStepId;
  100868. private _currentInternalStep;
  100869. /**
  100870. * Sets the step Id used by deterministic lock step
  100871. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100872. * @param newStepId defines the step Id
  100873. */
  100874. setStepId(newStepId: number): void;
  100875. /**
  100876. * Gets the step Id used by deterministic lock step
  100877. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100878. * @returns the step Id
  100879. */
  100880. getStepId(): number;
  100881. /**
  100882. * Gets the internal step used by deterministic lock step
  100883. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100884. * @returns the internal step
  100885. */
  100886. getInternalStep(): number;
  100887. private _fogEnabled;
  100888. /**
  100889. * Gets or sets a boolean indicating if fog is enabled on this scene
  100890. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100891. * (Default is true)
  100892. */
  100893. fogEnabled: boolean;
  100894. private _fogMode;
  100895. /**
  100896. * Gets or sets the fog mode to use
  100897. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100898. * | mode | value |
  100899. * | --- | --- |
  100900. * | FOGMODE_NONE | 0 |
  100901. * | FOGMODE_EXP | 1 |
  100902. * | FOGMODE_EXP2 | 2 |
  100903. * | FOGMODE_LINEAR | 3 |
  100904. */
  100905. fogMode: number;
  100906. /**
  100907. * Gets or sets the fog color to use
  100908. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100909. * (Default is Color3(0.2, 0.2, 0.3))
  100910. */
  100911. fogColor: Color3;
  100912. /**
  100913. * Gets or sets the fog density to use
  100914. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100915. * (Default is 0.1)
  100916. */
  100917. fogDensity: number;
  100918. /**
  100919. * Gets or sets the fog start distance to use
  100920. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100921. * (Default is 0)
  100922. */
  100923. fogStart: number;
  100924. /**
  100925. * Gets or sets the fog end distance to use
  100926. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100927. * (Default is 1000)
  100928. */
  100929. fogEnd: number;
  100930. private _shadowsEnabled;
  100931. /**
  100932. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100933. */
  100934. shadowsEnabled: boolean;
  100935. private _lightsEnabled;
  100936. /**
  100937. * Gets or sets a boolean indicating if lights are enabled on this scene
  100938. */
  100939. lightsEnabled: boolean;
  100940. /** All of the active cameras added to this scene. */
  100941. activeCameras: Camera[];
  100942. /** @hidden */
  100943. _activeCamera: Nullable<Camera>;
  100944. /** Gets or sets the current active camera */
  100945. activeCamera: Nullable<Camera>;
  100946. private _defaultMaterial;
  100947. /** The default material used on meshes when no material is affected */
  100948. /** The default material used on meshes when no material is affected */
  100949. defaultMaterial: Material;
  100950. private _texturesEnabled;
  100951. /**
  100952. * Gets or sets a boolean indicating if textures are enabled on this scene
  100953. */
  100954. texturesEnabled: boolean;
  100955. /**
  100956. * Gets or sets a boolean indicating if particles are enabled on this scene
  100957. */
  100958. particlesEnabled: boolean;
  100959. /**
  100960. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100961. */
  100962. spritesEnabled: boolean;
  100963. private _skeletonsEnabled;
  100964. /**
  100965. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100966. */
  100967. skeletonsEnabled: boolean;
  100968. /**
  100969. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100970. */
  100971. lensFlaresEnabled: boolean;
  100972. /**
  100973. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100974. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100975. */
  100976. collisionsEnabled: boolean;
  100977. private _collisionCoordinator;
  100978. /** @hidden */
  100979. readonly collisionCoordinator: ICollisionCoordinator;
  100980. /**
  100981. * Defines the gravity applied to this scene (used only for collisions)
  100982. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100983. */
  100984. gravity: Vector3;
  100985. /**
  100986. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100987. */
  100988. postProcessesEnabled: boolean;
  100989. /**
  100990. * The list of postprocesses added to the scene
  100991. */
  100992. postProcesses: PostProcess[];
  100993. /**
  100994. * Gets the current postprocess manager
  100995. */
  100996. postProcessManager: PostProcessManager;
  100997. /**
  100998. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100999. */
  101000. renderTargetsEnabled: boolean;
  101001. /**
  101002. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  101003. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  101004. */
  101005. dumpNextRenderTargets: boolean;
  101006. /**
  101007. * The list of user defined render targets added to the scene
  101008. */
  101009. customRenderTargets: RenderTargetTexture[];
  101010. /**
  101011. * Defines if texture loading must be delayed
  101012. * If true, textures will only be loaded when they need to be rendered
  101013. */
  101014. useDelayedTextureLoading: boolean;
  101015. /**
  101016. * Gets the list of meshes imported to the scene through SceneLoader
  101017. */
  101018. importedMeshesFiles: String[];
  101019. /**
  101020. * Gets or sets a boolean indicating if probes are enabled on this scene
  101021. */
  101022. probesEnabled: boolean;
  101023. /**
  101024. * Gets or sets the current offline provider to use to store scene data
  101025. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101026. */
  101027. offlineProvider: IOfflineProvider;
  101028. /**
  101029. * Gets or sets the action manager associated with the scene
  101030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101031. */
  101032. actionManager: AbstractActionManager;
  101033. private _meshesForIntersections;
  101034. /**
  101035. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  101036. */
  101037. proceduralTexturesEnabled: boolean;
  101038. private _engine;
  101039. private _totalVertices;
  101040. /** @hidden */
  101041. _activeIndices: PerfCounter;
  101042. /** @hidden */
  101043. _activeParticles: PerfCounter;
  101044. /** @hidden */
  101045. _activeBones: PerfCounter;
  101046. private _animationRatio;
  101047. /** @hidden */
  101048. _animationTimeLast: number;
  101049. /** @hidden */
  101050. _animationTime: number;
  101051. /**
  101052. * Gets or sets a general scale for animation speed
  101053. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  101054. */
  101055. animationTimeScale: number;
  101056. /** @hidden */
  101057. _cachedMaterial: Nullable<Material>;
  101058. /** @hidden */
  101059. _cachedEffect: Nullable<Effect>;
  101060. /** @hidden */
  101061. _cachedVisibility: Nullable<number>;
  101062. private _renderId;
  101063. private _frameId;
  101064. private _executeWhenReadyTimeoutId;
  101065. private _intermediateRendering;
  101066. private _viewUpdateFlag;
  101067. private _projectionUpdateFlag;
  101068. /** @hidden */
  101069. _toBeDisposed: Nullable<IDisposable>[];
  101070. private _activeRequests;
  101071. /** @hidden */
  101072. _pendingData: any[];
  101073. private _isDisposed;
  101074. /**
  101075. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  101076. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  101077. */
  101078. dispatchAllSubMeshesOfActiveMeshes: boolean;
  101079. private _activeMeshes;
  101080. private _processedMaterials;
  101081. private _renderTargets;
  101082. /** @hidden */
  101083. _activeParticleSystems: SmartArray<IParticleSystem>;
  101084. private _activeSkeletons;
  101085. private _softwareSkinnedMeshes;
  101086. private _renderingManager;
  101087. /** @hidden */
  101088. _activeAnimatables: Animatable[];
  101089. private _transformMatrix;
  101090. private _sceneUbo;
  101091. /** @hidden */
  101092. _viewMatrix: Matrix;
  101093. private _projectionMatrix;
  101094. /** @hidden */
  101095. _forcedViewPosition: Nullable<Vector3>;
  101096. /** @hidden */
  101097. _frustumPlanes: Plane[];
  101098. /**
  101099. * Gets the list of frustum planes (built from the active camera)
  101100. */
  101101. readonly frustumPlanes: Plane[];
  101102. /**
  101103. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  101104. * This is useful if there are more lights that the maximum simulteanous authorized
  101105. */
  101106. requireLightSorting: boolean;
  101107. /** @hidden */
  101108. readonly useMaterialMeshMap: boolean;
  101109. /** @hidden */
  101110. readonly useClonedMeshhMap: boolean;
  101111. private _externalData;
  101112. private _uid;
  101113. /**
  101114. * @hidden
  101115. * Backing store of defined scene components.
  101116. */
  101117. _components: ISceneComponent[];
  101118. /**
  101119. * @hidden
  101120. * Backing store of defined scene components.
  101121. */
  101122. _serializableComponents: ISceneSerializableComponent[];
  101123. /**
  101124. * List of components to register on the next registration step.
  101125. */
  101126. private _transientComponents;
  101127. /**
  101128. * Registers the transient components if needed.
  101129. */
  101130. private _registerTransientComponents;
  101131. /**
  101132. * @hidden
  101133. * Add a component to the scene.
  101134. * Note that the ccomponent could be registered on th next frame if this is called after
  101135. * the register component stage.
  101136. * @param component Defines the component to add to the scene
  101137. */
  101138. _addComponent(component: ISceneComponent): void;
  101139. /**
  101140. * @hidden
  101141. * Gets a component from the scene.
  101142. * @param name defines the name of the component to retrieve
  101143. * @returns the component or null if not present
  101144. */
  101145. _getComponent(name: string): Nullable<ISceneComponent>;
  101146. /**
  101147. * @hidden
  101148. * Defines the actions happening before camera updates.
  101149. */
  101150. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  101151. /**
  101152. * @hidden
  101153. * Defines the actions happening before clear the canvas.
  101154. */
  101155. _beforeClearStage: Stage<SimpleStageAction>;
  101156. /**
  101157. * @hidden
  101158. * Defines the actions when collecting render targets for the frame.
  101159. */
  101160. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101161. /**
  101162. * @hidden
  101163. * Defines the actions happening for one camera in the frame.
  101164. */
  101165. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101166. /**
  101167. * @hidden
  101168. * Defines the actions happening during the per mesh ready checks.
  101169. */
  101170. _isReadyForMeshStage: Stage<MeshStageAction>;
  101171. /**
  101172. * @hidden
  101173. * Defines the actions happening before evaluate active mesh checks.
  101174. */
  101175. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  101176. /**
  101177. * @hidden
  101178. * Defines the actions happening during the evaluate sub mesh checks.
  101179. */
  101180. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  101181. /**
  101182. * @hidden
  101183. * Defines the actions happening during the active mesh stage.
  101184. */
  101185. _activeMeshStage: Stage<ActiveMeshStageAction>;
  101186. /**
  101187. * @hidden
  101188. * Defines the actions happening during the per camera render target step.
  101189. */
  101190. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  101191. /**
  101192. * @hidden
  101193. * Defines the actions happening just before the active camera is drawing.
  101194. */
  101195. _beforeCameraDrawStage: Stage<CameraStageAction>;
  101196. /**
  101197. * @hidden
  101198. * Defines the actions happening just before a render target is drawing.
  101199. */
  101200. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101201. /**
  101202. * @hidden
  101203. * Defines the actions happening just before a rendering group is drawing.
  101204. */
  101205. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101206. /**
  101207. * @hidden
  101208. * Defines the actions happening just before a mesh is drawing.
  101209. */
  101210. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101211. /**
  101212. * @hidden
  101213. * Defines the actions happening just after a mesh has been drawn.
  101214. */
  101215. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101216. /**
  101217. * @hidden
  101218. * Defines the actions happening just after a rendering group has been drawn.
  101219. */
  101220. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101221. /**
  101222. * @hidden
  101223. * Defines the actions happening just after the active camera has been drawn.
  101224. */
  101225. _afterCameraDrawStage: Stage<CameraStageAction>;
  101226. /**
  101227. * @hidden
  101228. * Defines the actions happening just after a render target has been drawn.
  101229. */
  101230. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101231. /**
  101232. * @hidden
  101233. * Defines the actions happening just after rendering all cameras and computing intersections.
  101234. */
  101235. _afterRenderStage: Stage<SimpleStageAction>;
  101236. /**
  101237. * @hidden
  101238. * Defines the actions happening when a pointer move event happens.
  101239. */
  101240. _pointerMoveStage: Stage<PointerMoveStageAction>;
  101241. /**
  101242. * @hidden
  101243. * Defines the actions happening when a pointer down event happens.
  101244. */
  101245. _pointerDownStage: Stage<PointerUpDownStageAction>;
  101246. /**
  101247. * @hidden
  101248. * Defines the actions happening when a pointer up event happens.
  101249. */
  101250. _pointerUpStage: Stage<PointerUpDownStageAction>;
  101251. /**
  101252. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  101253. */
  101254. private geometriesByUniqueId;
  101255. /**
  101256. * Creates a new Scene
  101257. * @param engine defines the engine to use to render this scene
  101258. * @param options defines the scene options
  101259. */
  101260. constructor(engine: Engine, options?: SceneOptions);
  101261. /**
  101262. * Gets a string idenfifying the name of the class
  101263. * @returns "Scene" string
  101264. */
  101265. getClassName(): string;
  101266. private _defaultMeshCandidates;
  101267. /**
  101268. * @hidden
  101269. */
  101270. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  101271. private _defaultSubMeshCandidates;
  101272. /**
  101273. * @hidden
  101274. */
  101275. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  101276. /**
  101277. * Sets the default candidate providers for the scene.
  101278. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  101279. * and getCollidingSubMeshCandidates to their default function
  101280. */
  101281. setDefaultCandidateProviders(): void;
  101282. /**
  101283. * Gets the mesh that is currently under the pointer
  101284. */
  101285. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101286. /**
  101287. * Gets or sets the current on-screen X position of the pointer
  101288. */
  101289. pointerX: number;
  101290. /**
  101291. * Gets or sets the current on-screen Y position of the pointer
  101292. */
  101293. pointerY: number;
  101294. /**
  101295. * Gets the cached material (ie. the latest rendered one)
  101296. * @returns the cached material
  101297. */
  101298. getCachedMaterial(): Nullable<Material>;
  101299. /**
  101300. * Gets the cached effect (ie. the latest rendered one)
  101301. * @returns the cached effect
  101302. */
  101303. getCachedEffect(): Nullable<Effect>;
  101304. /**
  101305. * Gets the cached visibility state (ie. the latest rendered one)
  101306. * @returns the cached visibility state
  101307. */
  101308. getCachedVisibility(): Nullable<number>;
  101309. /**
  101310. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  101311. * @param material defines the current material
  101312. * @param effect defines the current effect
  101313. * @param visibility defines the current visibility state
  101314. * @returns true if one parameter is not cached
  101315. */
  101316. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  101317. /**
  101318. * Gets the engine associated with the scene
  101319. * @returns an Engine
  101320. */
  101321. getEngine(): Engine;
  101322. /**
  101323. * Gets the total number of vertices rendered per frame
  101324. * @returns the total number of vertices rendered per frame
  101325. */
  101326. getTotalVertices(): number;
  101327. /**
  101328. * Gets the performance counter for total vertices
  101329. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101330. */
  101331. readonly totalVerticesPerfCounter: PerfCounter;
  101332. /**
  101333. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  101334. * @returns the total number of active indices rendered per frame
  101335. */
  101336. getActiveIndices(): number;
  101337. /**
  101338. * Gets the performance counter for active indices
  101339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101340. */
  101341. readonly totalActiveIndicesPerfCounter: PerfCounter;
  101342. /**
  101343. * Gets the total number of active particles rendered per frame
  101344. * @returns the total number of active particles rendered per frame
  101345. */
  101346. getActiveParticles(): number;
  101347. /**
  101348. * Gets the performance counter for active particles
  101349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101350. */
  101351. readonly activeParticlesPerfCounter: PerfCounter;
  101352. /**
  101353. * Gets the total number of active bones rendered per frame
  101354. * @returns the total number of active bones rendered per frame
  101355. */
  101356. getActiveBones(): number;
  101357. /**
  101358. * Gets the performance counter for active bones
  101359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101360. */
  101361. readonly activeBonesPerfCounter: PerfCounter;
  101362. /**
  101363. * Gets the array of active meshes
  101364. * @returns an array of AbstractMesh
  101365. */
  101366. getActiveMeshes(): SmartArray<AbstractMesh>;
  101367. /**
  101368. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  101369. * @returns a number
  101370. */
  101371. getAnimationRatio(): number;
  101372. /**
  101373. * Gets an unique Id for the current render phase
  101374. * @returns a number
  101375. */
  101376. getRenderId(): number;
  101377. /**
  101378. * Gets an unique Id for the current frame
  101379. * @returns a number
  101380. */
  101381. getFrameId(): number;
  101382. /** Call this function if you want to manually increment the render Id*/
  101383. incrementRenderId(): void;
  101384. private _createUbo;
  101385. /**
  101386. * Use this method to simulate a pointer move on a mesh
  101387. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101388. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101389. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101390. * @returns the current scene
  101391. */
  101392. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101393. /**
  101394. * Use this method to simulate a pointer down on a mesh
  101395. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101396. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101397. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101398. * @returns the current scene
  101399. */
  101400. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101401. /**
  101402. * Use this method to simulate a pointer up on a mesh
  101403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101406. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101407. * @returns the current scene
  101408. */
  101409. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  101410. /**
  101411. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101412. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101413. * @returns true if the pointer was captured
  101414. */
  101415. isPointerCaptured(pointerId?: number): boolean;
  101416. /**
  101417. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101418. * @param attachUp defines if you want to attach events to pointerup
  101419. * @param attachDown defines if you want to attach events to pointerdown
  101420. * @param attachMove defines if you want to attach events to pointermove
  101421. */
  101422. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101423. /** Detaches all event handlers*/
  101424. detachControl(): void;
  101425. /**
  101426. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  101427. * Delay loaded resources are not taking in account
  101428. * @return true if all required resources are ready
  101429. */
  101430. isReady(): boolean;
  101431. /** Resets all cached information relative to material (including effect and visibility) */
  101432. resetCachedMaterial(): void;
  101433. /**
  101434. * Registers a function to be called before every frame render
  101435. * @param func defines the function to register
  101436. */
  101437. registerBeforeRender(func: () => void): void;
  101438. /**
  101439. * Unregisters a function called before every frame render
  101440. * @param func defines the function to unregister
  101441. */
  101442. unregisterBeforeRender(func: () => void): void;
  101443. /**
  101444. * Registers a function to be called after every frame render
  101445. * @param func defines the function to register
  101446. */
  101447. registerAfterRender(func: () => void): void;
  101448. /**
  101449. * Unregisters a function called after every frame render
  101450. * @param func defines the function to unregister
  101451. */
  101452. unregisterAfterRender(func: () => void): void;
  101453. private _executeOnceBeforeRender;
  101454. /**
  101455. * The provided function will run before render once and will be disposed afterwards.
  101456. * A timeout delay can be provided so that the function will be executed in N ms.
  101457. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  101458. * @param func The function to be executed.
  101459. * @param timeout optional delay in ms
  101460. */
  101461. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  101462. /** @hidden */
  101463. _addPendingData(data: any): void;
  101464. /** @hidden */
  101465. _removePendingData(data: any): void;
  101466. /**
  101467. * Returns the number of items waiting to be loaded
  101468. * @returns the number of items waiting to be loaded
  101469. */
  101470. getWaitingItemsCount(): number;
  101471. /**
  101472. * Returns a boolean indicating if the scene is still loading data
  101473. */
  101474. readonly isLoading: boolean;
  101475. /**
  101476. * Registers a function to be executed when the scene is ready
  101477. * @param {Function} func - the function to be executed
  101478. */
  101479. executeWhenReady(func: () => void): void;
  101480. /**
  101481. * Returns a promise that resolves when the scene is ready
  101482. * @returns A promise that resolves when the scene is ready
  101483. */
  101484. whenReadyAsync(): Promise<void>;
  101485. /** @hidden */
  101486. _checkIsReady(): void;
  101487. /**
  101488. * Gets all animatable attached to the scene
  101489. */
  101490. readonly animatables: Animatable[];
  101491. /**
  101492. * Resets the last animation time frame.
  101493. * Useful to override when animations start running when loading a scene for the first time.
  101494. */
  101495. resetLastAnimationTimeFrame(): void;
  101496. /**
  101497. * Gets the current view matrix
  101498. * @returns a Matrix
  101499. */
  101500. getViewMatrix(): Matrix;
  101501. /**
  101502. * Gets the current projection matrix
  101503. * @returns a Matrix
  101504. */
  101505. getProjectionMatrix(): Matrix;
  101506. /**
  101507. * Gets the current transform matrix
  101508. * @returns a Matrix made of View * Projection
  101509. */
  101510. getTransformMatrix(): Matrix;
  101511. /**
  101512. * Sets the current transform matrix
  101513. * @param viewL defines the View matrix to use
  101514. * @param projectionL defines the Projection matrix to use
  101515. * @param viewR defines the right View matrix to use (if provided)
  101516. * @param projectionR defines the right Projection matrix to use (if provided)
  101517. */
  101518. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  101519. /**
  101520. * Gets the uniform buffer used to store scene data
  101521. * @returns a UniformBuffer
  101522. */
  101523. getSceneUniformBuffer(): UniformBuffer;
  101524. /**
  101525. * Gets an unique (relatively to the current scene) Id
  101526. * @returns an unique number for the scene
  101527. */
  101528. getUniqueId(): number;
  101529. /**
  101530. * Add a mesh to the list of scene's meshes
  101531. * @param newMesh defines the mesh to add
  101532. * @param recursive if all child meshes should also be added to the scene
  101533. */
  101534. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  101535. /**
  101536. * Remove a mesh for the list of scene's meshes
  101537. * @param toRemove defines the mesh to remove
  101538. * @param recursive if all child meshes should also be removed from the scene
  101539. * @returns the index where the mesh was in the mesh list
  101540. */
  101541. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  101542. /**
  101543. * Add a transform node to the list of scene's transform nodes
  101544. * @param newTransformNode defines the transform node to add
  101545. */
  101546. addTransformNode(newTransformNode: TransformNode): void;
  101547. /**
  101548. * Remove a transform node for the list of scene's transform nodes
  101549. * @param toRemove defines the transform node to remove
  101550. * @returns the index where the transform node was in the transform node list
  101551. */
  101552. removeTransformNode(toRemove: TransformNode): number;
  101553. /**
  101554. * Remove a skeleton for the list of scene's skeletons
  101555. * @param toRemove defines the skeleton to remove
  101556. * @returns the index where the skeleton was in the skeleton list
  101557. */
  101558. removeSkeleton(toRemove: Skeleton): number;
  101559. /**
  101560. * Remove a morph target for the list of scene's morph targets
  101561. * @param toRemove defines the morph target to remove
  101562. * @returns the index where the morph target was in the morph target list
  101563. */
  101564. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  101565. /**
  101566. * Remove a light for the list of scene's lights
  101567. * @param toRemove defines the light to remove
  101568. * @returns the index where the light was in the light list
  101569. */
  101570. removeLight(toRemove: Light): number;
  101571. /**
  101572. * Remove a camera for the list of scene's cameras
  101573. * @param toRemove defines the camera to remove
  101574. * @returns the index where the camera was in the camera list
  101575. */
  101576. removeCamera(toRemove: Camera): number;
  101577. /**
  101578. * Remove a particle system for the list of scene's particle systems
  101579. * @param toRemove defines the particle system to remove
  101580. * @returns the index where the particle system was in the particle system list
  101581. */
  101582. removeParticleSystem(toRemove: IParticleSystem): number;
  101583. /**
  101584. * Remove a animation for the list of scene's animations
  101585. * @param toRemove defines the animation to remove
  101586. * @returns the index where the animation was in the animation list
  101587. */
  101588. removeAnimation(toRemove: Animation): number;
  101589. /**
  101590. * Will stop the animation of the given target
  101591. * @param target - the target
  101592. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  101593. * @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)
  101594. */
  101595. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  101596. /**
  101597. * Removes the given animation group from this scene.
  101598. * @param toRemove The animation group to remove
  101599. * @returns The index of the removed animation group
  101600. */
  101601. removeAnimationGroup(toRemove: AnimationGroup): number;
  101602. /**
  101603. * Removes the given multi-material from this scene.
  101604. * @param toRemove The multi-material to remove
  101605. * @returns The index of the removed multi-material
  101606. */
  101607. removeMultiMaterial(toRemove: MultiMaterial): number;
  101608. /**
  101609. * Removes the given material from this scene.
  101610. * @param toRemove The material to remove
  101611. * @returns The index of the removed material
  101612. */
  101613. removeMaterial(toRemove: Material): number;
  101614. /**
  101615. * Removes the given action manager from this scene.
  101616. * @param toRemove The action manager to remove
  101617. * @returns The index of the removed action manager
  101618. */
  101619. removeActionManager(toRemove: AbstractActionManager): number;
  101620. /**
  101621. * Removes the given texture from this scene.
  101622. * @param toRemove The texture to remove
  101623. * @returns The index of the removed texture
  101624. */
  101625. removeTexture(toRemove: BaseTexture): number;
  101626. /**
  101627. * Adds the given light to this scene
  101628. * @param newLight The light to add
  101629. */
  101630. addLight(newLight: Light): void;
  101631. /**
  101632. * Sorts the list list based on light priorities
  101633. */
  101634. sortLightsByPriority(): void;
  101635. /**
  101636. * Adds the given camera to this scene
  101637. * @param newCamera The camera to add
  101638. */
  101639. addCamera(newCamera: Camera): void;
  101640. /**
  101641. * Adds the given skeleton to this scene
  101642. * @param newSkeleton The skeleton to add
  101643. */
  101644. addSkeleton(newSkeleton: Skeleton): void;
  101645. /**
  101646. * Adds the given particle system to this scene
  101647. * @param newParticleSystem The particle system to add
  101648. */
  101649. addParticleSystem(newParticleSystem: IParticleSystem): void;
  101650. /**
  101651. * Adds the given animation to this scene
  101652. * @param newAnimation The animation to add
  101653. */
  101654. addAnimation(newAnimation: Animation): void;
  101655. /**
  101656. * Adds the given animation group to this scene.
  101657. * @param newAnimationGroup The animation group to add
  101658. */
  101659. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  101660. /**
  101661. * Adds the given multi-material to this scene
  101662. * @param newMultiMaterial The multi-material to add
  101663. */
  101664. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  101665. /**
  101666. * Adds the given material to this scene
  101667. * @param newMaterial The material to add
  101668. */
  101669. addMaterial(newMaterial: Material): void;
  101670. /**
  101671. * Adds the given morph target to this scene
  101672. * @param newMorphTargetManager The morph target to add
  101673. */
  101674. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101675. /**
  101676. * Adds the given geometry to this scene
  101677. * @param newGeometry The geometry to add
  101678. */
  101679. addGeometry(newGeometry: Geometry): void;
  101680. /**
  101681. * Adds the given action manager to this scene
  101682. * @param newActionManager The action manager to add
  101683. */
  101684. addActionManager(newActionManager: AbstractActionManager): void;
  101685. /**
  101686. * Adds the given texture to this scene.
  101687. * @param newTexture The texture to add
  101688. */
  101689. addTexture(newTexture: BaseTexture): void;
  101690. /**
  101691. * Switch active camera
  101692. * @param newCamera defines the new active camera
  101693. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101694. */
  101695. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101696. /**
  101697. * sets the active camera of the scene using its ID
  101698. * @param id defines the camera's ID
  101699. * @return the new active camera or null if none found.
  101700. */
  101701. setActiveCameraByID(id: string): Nullable<Camera>;
  101702. /**
  101703. * sets the active camera of the scene using its name
  101704. * @param name defines the camera's name
  101705. * @returns the new active camera or null if none found.
  101706. */
  101707. setActiveCameraByName(name: string): Nullable<Camera>;
  101708. /**
  101709. * get an animation group using its name
  101710. * @param name defines the material's name
  101711. * @return the animation group or null if none found.
  101712. */
  101713. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101714. /**
  101715. * Get a material using its unique id
  101716. * @param uniqueId defines the material's unique id
  101717. * @return the material or null if none found.
  101718. */
  101719. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101720. /**
  101721. * get a material using its id
  101722. * @param id defines the material's ID
  101723. * @return the material or null if none found.
  101724. */
  101725. getMaterialByID(id: string): Nullable<Material>;
  101726. /**
  101727. * Gets a the last added material using a given id
  101728. * @param id defines the material's ID
  101729. * @return the last material with the given id or null if none found.
  101730. */
  101731. getLastMaterialByID(id: string): Nullable<Material>;
  101732. /**
  101733. * Gets a material using its name
  101734. * @param name defines the material's name
  101735. * @return the material or null if none found.
  101736. */
  101737. getMaterialByName(name: string): Nullable<Material>;
  101738. /**
  101739. * Get a texture using its unique id
  101740. * @param uniqueId defines the texture's unique id
  101741. * @return the texture or null if none found.
  101742. */
  101743. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101744. /**
  101745. * Gets a camera using its id
  101746. * @param id defines the id to look for
  101747. * @returns the camera or null if not found
  101748. */
  101749. getCameraByID(id: string): Nullable<Camera>;
  101750. /**
  101751. * Gets a camera using its unique id
  101752. * @param uniqueId defines the unique id to look for
  101753. * @returns the camera or null if not found
  101754. */
  101755. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101756. /**
  101757. * Gets a camera using its name
  101758. * @param name defines the camera's name
  101759. * @return the camera or null if none found.
  101760. */
  101761. getCameraByName(name: string): Nullable<Camera>;
  101762. /**
  101763. * Gets a bone using its id
  101764. * @param id defines the bone's id
  101765. * @return the bone or null if not found
  101766. */
  101767. getBoneByID(id: string): Nullable<Bone>;
  101768. /**
  101769. * Gets a bone using its id
  101770. * @param name defines the bone's name
  101771. * @return the bone or null if not found
  101772. */
  101773. getBoneByName(name: string): Nullable<Bone>;
  101774. /**
  101775. * Gets a light node using its name
  101776. * @param name defines the the light's name
  101777. * @return the light or null if none found.
  101778. */
  101779. getLightByName(name: string): Nullable<Light>;
  101780. /**
  101781. * Gets a light node using its id
  101782. * @param id defines the light's id
  101783. * @return the light or null if none found.
  101784. */
  101785. getLightByID(id: string): Nullable<Light>;
  101786. /**
  101787. * Gets a light node using its scene-generated unique ID
  101788. * @param uniqueId defines the light's unique id
  101789. * @return the light or null if none found.
  101790. */
  101791. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101792. /**
  101793. * Gets a particle system by id
  101794. * @param id defines the particle system id
  101795. * @return the corresponding system or null if none found
  101796. */
  101797. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101798. /**
  101799. * Gets a geometry using its ID
  101800. * @param id defines the geometry's id
  101801. * @return the geometry or null if none found.
  101802. */
  101803. getGeometryByID(id: string): Nullable<Geometry>;
  101804. private _getGeometryByUniqueID;
  101805. /**
  101806. * Add a new geometry to this scene
  101807. * @param geometry defines the geometry to be added to the scene.
  101808. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101809. * @return a boolean defining if the geometry was added or not
  101810. */
  101811. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101812. /**
  101813. * Removes an existing geometry
  101814. * @param geometry defines the geometry to be removed from the scene
  101815. * @return a boolean defining if the geometry was removed or not
  101816. */
  101817. removeGeometry(geometry: Geometry): boolean;
  101818. /**
  101819. * Gets the list of geometries attached to the scene
  101820. * @returns an array of Geometry
  101821. */
  101822. getGeometries(): Geometry[];
  101823. /**
  101824. * Gets the first added mesh found of a given ID
  101825. * @param id defines the id to search for
  101826. * @return the mesh found or null if not found at all
  101827. */
  101828. getMeshByID(id: string): Nullable<AbstractMesh>;
  101829. /**
  101830. * Gets a list of meshes using their id
  101831. * @param id defines the id to search for
  101832. * @returns a list of meshes
  101833. */
  101834. getMeshesByID(id: string): Array<AbstractMesh>;
  101835. /**
  101836. * Gets the first added transform node found of a given ID
  101837. * @param id defines the id to search for
  101838. * @return the found transform node or null if not found at all.
  101839. */
  101840. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101841. /**
  101842. * Gets a transform node with its auto-generated unique id
  101843. * @param uniqueId efines the unique id to search for
  101844. * @return the found transform node or null if not found at all.
  101845. */
  101846. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101847. /**
  101848. * Gets a list of transform nodes using their id
  101849. * @param id defines the id to search for
  101850. * @returns a list of transform nodes
  101851. */
  101852. getTransformNodesByID(id: string): Array<TransformNode>;
  101853. /**
  101854. * Gets a mesh with its auto-generated unique id
  101855. * @param uniqueId defines the unique id to search for
  101856. * @return the found mesh or null if not found at all.
  101857. */
  101858. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101859. /**
  101860. * Gets a the last added mesh using a given id
  101861. * @param id defines the id to search for
  101862. * @return the found mesh or null if not found at all.
  101863. */
  101864. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101865. /**
  101866. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101867. * @param id defines the id to search for
  101868. * @return the found node or null if not found at all
  101869. */
  101870. getLastEntryByID(id: string): Nullable<Node>;
  101871. /**
  101872. * Gets a node (Mesh, Camera, Light) using a given id
  101873. * @param id defines the id to search for
  101874. * @return the found node or null if not found at all
  101875. */
  101876. getNodeByID(id: string): Nullable<Node>;
  101877. /**
  101878. * Gets a node (Mesh, Camera, Light) using a given name
  101879. * @param name defines the name to search for
  101880. * @return the found node or null if not found at all.
  101881. */
  101882. getNodeByName(name: string): Nullable<Node>;
  101883. /**
  101884. * Gets a mesh using a given name
  101885. * @param name defines the name to search for
  101886. * @return the found mesh or null if not found at all.
  101887. */
  101888. getMeshByName(name: string): Nullable<AbstractMesh>;
  101889. /**
  101890. * Gets a transform node using a given name
  101891. * @param name defines the name to search for
  101892. * @return the found transform node or null if not found at all.
  101893. */
  101894. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101895. /**
  101896. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101897. * @param id defines the id to search for
  101898. * @return the found skeleton or null if not found at all.
  101899. */
  101900. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101901. /**
  101902. * Gets a skeleton using a given auto generated unique id
  101903. * @param uniqueId defines the unique id to search for
  101904. * @return the found skeleton or null if not found at all.
  101905. */
  101906. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101907. /**
  101908. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101909. * @param id defines the id to search for
  101910. * @return the found skeleton or null if not found at all.
  101911. */
  101912. getSkeletonById(id: string): Nullable<Skeleton>;
  101913. /**
  101914. * Gets a skeleton using a given name
  101915. * @param name defines the name to search for
  101916. * @return the found skeleton or null if not found at all.
  101917. */
  101918. getSkeletonByName(name: string): Nullable<Skeleton>;
  101919. /**
  101920. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101921. * @param id defines the id to search for
  101922. * @return the found morph target manager or null if not found at all.
  101923. */
  101924. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101925. /**
  101926. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101927. * @param id defines the id to search for
  101928. * @return the found morph target or null if not found at all.
  101929. */
  101930. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101931. /**
  101932. * Gets a boolean indicating if the given mesh is active
  101933. * @param mesh defines the mesh to look for
  101934. * @returns true if the mesh is in the active list
  101935. */
  101936. isActiveMesh(mesh: AbstractMesh): boolean;
  101937. /**
  101938. * Return a unique id as a string which can serve as an identifier for the scene
  101939. */
  101940. readonly uid: string;
  101941. /**
  101942. * Add an externaly attached data from its key.
  101943. * This method call will fail and return false, if such key already exists.
  101944. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101945. * @param key the unique key that identifies the data
  101946. * @param data the data object to associate to the key for this Engine instance
  101947. * @return true if no such key were already present and the data was added successfully, false otherwise
  101948. */
  101949. addExternalData<T>(key: string, data: T): boolean;
  101950. /**
  101951. * Get an externaly attached data from its key
  101952. * @param key the unique key that identifies the data
  101953. * @return the associated data, if present (can be null), or undefined if not present
  101954. */
  101955. getExternalData<T>(key: string): Nullable<T>;
  101956. /**
  101957. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101958. * @param key the unique key that identifies the data
  101959. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101960. * @return the associated data, can be null if the factory returned null.
  101961. */
  101962. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101963. /**
  101964. * Remove an externaly attached data from the Engine instance
  101965. * @param key the unique key that identifies the data
  101966. * @return true if the data was successfully removed, false if it doesn't exist
  101967. */
  101968. removeExternalData(key: string): boolean;
  101969. private _evaluateSubMesh;
  101970. /**
  101971. * Clear the processed materials smart array preventing retention point in material dispose.
  101972. */
  101973. freeProcessedMaterials(): void;
  101974. private _preventFreeActiveMeshesAndRenderingGroups;
  101975. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101976. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101977. * when disposing several meshes in a row or a hierarchy of meshes.
  101978. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101979. */
  101980. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101981. /**
  101982. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101983. */
  101984. freeActiveMeshes(): void;
  101985. /**
  101986. * Clear the info related to rendering groups preventing retention points during dispose.
  101987. */
  101988. freeRenderingGroups(): void;
  101989. /** @hidden */
  101990. _isInIntermediateRendering(): boolean;
  101991. /**
  101992. * Lambda returning the list of potentially active meshes.
  101993. */
  101994. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101995. /**
  101996. * Lambda returning the list of potentially active sub meshes.
  101997. */
  101998. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101999. /**
  102000. * Lambda returning the list of potentially intersecting sub meshes.
  102001. */
  102002. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  102003. /**
  102004. * Lambda returning the list of potentially colliding sub meshes.
  102005. */
  102006. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  102007. private _activeMeshesFrozen;
  102008. /**
  102009. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  102010. * @returns the current scene
  102011. */
  102012. freezeActiveMeshes(): Scene;
  102013. /**
  102014. * Use this function to restart evaluating active meshes on every frame
  102015. * @returns the current scene
  102016. */
  102017. unfreezeActiveMeshes(): Scene;
  102018. private _evaluateActiveMeshes;
  102019. private _activeMesh;
  102020. /**
  102021. * Update the transform matrix to update from the current active camera
  102022. * @param force defines a boolean used to force the update even if cache is up to date
  102023. */
  102024. updateTransformMatrix(force?: boolean): void;
  102025. private _bindFrameBuffer;
  102026. /** @hidden */
  102027. _allowPostProcessClearColor: boolean;
  102028. /** @hidden */
  102029. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  102030. private _processSubCameras;
  102031. private _checkIntersections;
  102032. /** @hidden */
  102033. _advancePhysicsEngineStep(step: number): void;
  102034. /**
  102035. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  102036. */
  102037. getDeterministicFrameTime: () => number;
  102038. /** @hidden */
  102039. _animate(): void;
  102040. /** Execute all animations (for a frame) */
  102041. animate(): void;
  102042. /**
  102043. * Render the scene
  102044. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  102045. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  102046. */
  102047. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  102048. /**
  102049. * Freeze all materials
  102050. * A frozen material will not be updatable but should be faster to render
  102051. */
  102052. freezeMaterials(): void;
  102053. /**
  102054. * Unfreeze all materials
  102055. * A frozen material will not be updatable but should be faster to render
  102056. */
  102057. unfreezeMaterials(): void;
  102058. /**
  102059. * Releases all held ressources
  102060. */
  102061. dispose(): void;
  102062. /**
  102063. * Gets if the scene is already disposed
  102064. */
  102065. readonly isDisposed: boolean;
  102066. /**
  102067. * Call this function to reduce memory footprint of the scene.
  102068. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  102069. */
  102070. clearCachedVertexData(): void;
  102071. /**
  102072. * This function will remove the local cached buffer data from texture.
  102073. * It will save memory but will prevent the texture from being rebuilt
  102074. */
  102075. cleanCachedTextureBuffer(): void;
  102076. /**
  102077. * Get the world extend vectors with an optional filter
  102078. *
  102079. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  102080. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  102081. */
  102082. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  102083. min: Vector3;
  102084. max: Vector3;
  102085. };
  102086. /**
  102087. * Creates a ray that can be used to pick in the scene
  102088. * @param x defines the x coordinate of the origin (on-screen)
  102089. * @param y defines the y coordinate of the origin (on-screen)
  102090. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102091. * @param camera defines the camera to use for the picking
  102092. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102093. * @returns a Ray
  102094. */
  102095. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  102096. /**
  102097. * Creates a ray that can be used to pick in the scene
  102098. * @param x defines the x coordinate of the origin (on-screen)
  102099. * @param y defines the y coordinate of the origin (on-screen)
  102100. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102101. * @param result defines the ray where to store the picking ray
  102102. * @param camera defines the camera to use for the picking
  102103. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102104. * @returns the current scene
  102105. */
  102106. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  102107. /**
  102108. * Creates a ray that can be used to pick in the scene
  102109. * @param x defines the x coordinate of the origin (on-screen)
  102110. * @param y defines the y coordinate of the origin (on-screen)
  102111. * @param camera defines the camera to use for the picking
  102112. * @returns a Ray
  102113. */
  102114. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  102115. /**
  102116. * Creates a ray that can be used to pick in the scene
  102117. * @param x defines the x coordinate of the origin (on-screen)
  102118. * @param y defines the y coordinate of the origin (on-screen)
  102119. * @param result defines the ray where to store the picking ray
  102120. * @param camera defines the camera to use for the picking
  102121. * @returns the current scene
  102122. */
  102123. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  102124. /** Launch a ray to try to pick a mesh in the scene
  102125. * @param x position on screen
  102126. * @param y position on screen
  102127. * @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
  102128. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  102129. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102130. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102131. * @returns a PickingInfo
  102132. */
  102133. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102134. /** Use the given ray to pick a mesh in the scene
  102135. * @param ray The ray to use to pick meshes
  102136. * @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
  102137. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  102138. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102139. * @returns a PickingInfo
  102140. */
  102141. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102142. /**
  102143. * Launch a ray to try to pick a mesh in the scene
  102144. * @param x X position on screen
  102145. * @param y Y position on screen
  102146. * @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
  102147. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102148. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102149. * @returns an array of PickingInfo
  102150. */
  102151. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102152. /**
  102153. * Launch a ray to try to pick a mesh in the scene
  102154. * @param ray Ray to use
  102155. * @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
  102156. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102157. * @returns an array of PickingInfo
  102158. */
  102159. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102160. /**
  102161. * Force the value of meshUnderPointer
  102162. * @param mesh defines the mesh to use
  102163. */
  102164. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  102165. /**
  102166. * Gets the mesh under the pointer
  102167. * @returns a Mesh or null if no mesh is under the pointer
  102168. */
  102169. getPointerOverMesh(): Nullable<AbstractMesh>;
  102170. /** @hidden */
  102171. _rebuildGeometries(): void;
  102172. /** @hidden */
  102173. _rebuildTextures(): void;
  102174. private _getByTags;
  102175. /**
  102176. * Get a list of meshes by tags
  102177. * @param tagsQuery defines the tags query to use
  102178. * @param forEach defines a predicate used to filter results
  102179. * @returns an array of Mesh
  102180. */
  102181. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  102182. /**
  102183. * Get a list of cameras by tags
  102184. * @param tagsQuery defines the tags query to use
  102185. * @param forEach defines a predicate used to filter results
  102186. * @returns an array of Camera
  102187. */
  102188. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  102189. /**
  102190. * Get a list of lights by tags
  102191. * @param tagsQuery defines the tags query to use
  102192. * @param forEach defines a predicate used to filter results
  102193. * @returns an array of Light
  102194. */
  102195. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  102196. /**
  102197. * Get a list of materials by tags
  102198. * @param tagsQuery defines the tags query to use
  102199. * @param forEach defines a predicate used to filter results
  102200. * @returns an array of Material
  102201. */
  102202. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  102203. /**
  102204. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102205. * This allowed control for front to back rendering or reversly depending of the special needs.
  102206. *
  102207. * @param renderingGroupId The rendering group id corresponding to its index
  102208. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102209. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102210. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102211. */
  102212. 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;
  102213. /**
  102214. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102215. *
  102216. * @param renderingGroupId The rendering group id corresponding to its index
  102217. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102218. * @param depth Automatically clears depth between groups if true and autoClear is true.
  102219. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  102220. */
  102221. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  102222. /**
  102223. * Gets the current auto clear configuration for one rendering group of the rendering
  102224. * manager.
  102225. * @param index the rendering group index to get the information for
  102226. * @returns The auto clear setup for the requested rendering group
  102227. */
  102228. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  102229. private _blockMaterialDirtyMechanism;
  102230. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  102231. blockMaterialDirtyMechanism: boolean;
  102232. /**
  102233. * Will flag all materials as dirty to trigger new shader compilation
  102234. * @param flag defines the flag used to specify which material part must be marked as dirty
  102235. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  102236. */
  102237. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  102238. /** @hidden */
  102239. _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;
  102240. /** @hidden */
  102241. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102242. /** @hidden */
  102243. _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;
  102244. /** @hidden */
  102245. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  102246. /** @hidden */
  102247. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102248. /** @hidden */
  102249. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102250. }
  102251. }
  102252. declare module BABYLON {
  102253. /**
  102254. * Set of assets to keep when moving a scene into an asset container.
  102255. */
  102256. export class KeepAssets extends AbstractScene {
  102257. }
  102258. /**
  102259. * Container with a set of assets that can be added or removed from a scene.
  102260. */
  102261. export class AssetContainer extends AbstractScene {
  102262. /**
  102263. * The scene the AssetContainer belongs to.
  102264. */
  102265. scene: Scene;
  102266. /**
  102267. * Instantiates an AssetContainer.
  102268. * @param scene The scene the AssetContainer belongs to.
  102269. */
  102270. constructor(scene: Scene);
  102271. /**
  102272. * Adds all the assets from the container to the scene.
  102273. */
  102274. addAllToScene(): void;
  102275. /**
  102276. * Removes all the assets in the container from the scene
  102277. */
  102278. removeAllFromScene(): void;
  102279. /**
  102280. * Disposes all the assets in the container
  102281. */
  102282. dispose(): void;
  102283. private _moveAssets;
  102284. /**
  102285. * Removes all the assets contained in the scene and adds them to the container.
  102286. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  102287. */
  102288. moveAllFromScene(keepAssets?: KeepAssets): void;
  102289. /**
  102290. * 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.
  102291. * @returns the root mesh
  102292. */
  102293. createRootMesh(): Mesh;
  102294. }
  102295. }
  102296. declare module BABYLON {
  102297. /**
  102298. * Defines how the parser contract is defined.
  102299. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  102300. */
  102301. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  102302. /**
  102303. * Defines how the individual parser contract is defined.
  102304. * These parser can parse an individual asset
  102305. */
  102306. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  102307. /**
  102308. * Base class of the scene acting as a container for the different elements composing a scene.
  102309. * This class is dynamically extended by the different components of the scene increasing
  102310. * flexibility and reducing coupling
  102311. */
  102312. export abstract class AbstractScene {
  102313. /**
  102314. * Stores the list of available parsers in the application.
  102315. */
  102316. private static _BabylonFileParsers;
  102317. /**
  102318. * Stores the list of available individual parsers in the application.
  102319. */
  102320. private static _IndividualBabylonFileParsers;
  102321. /**
  102322. * Adds a parser in the list of available ones
  102323. * @param name Defines the name of the parser
  102324. * @param parser Defines the parser to add
  102325. */
  102326. static AddParser(name: string, parser: BabylonFileParser): void;
  102327. /**
  102328. * Gets a general parser from the list of avaialble ones
  102329. * @param name Defines the name of the parser
  102330. * @returns the requested parser or null
  102331. */
  102332. static GetParser(name: string): Nullable<BabylonFileParser>;
  102333. /**
  102334. * Adds n individual parser in the list of available ones
  102335. * @param name Defines the name of the parser
  102336. * @param parser Defines the parser to add
  102337. */
  102338. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  102339. /**
  102340. * Gets an individual parser from the list of avaialble ones
  102341. * @param name Defines the name of the parser
  102342. * @returns the requested parser or null
  102343. */
  102344. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  102345. /**
  102346. * Parser json data and populate both a scene and its associated container object
  102347. * @param jsonData Defines the data to parse
  102348. * @param scene Defines the scene to parse the data for
  102349. * @param container Defines the container attached to the parsing sequence
  102350. * @param rootUrl Defines the root url of the data
  102351. */
  102352. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  102353. /**
  102354. * Gets the list of root nodes (ie. nodes with no parent)
  102355. */
  102356. rootNodes: Node[];
  102357. /** All of the cameras added to this scene
  102358. * @see http://doc.babylonjs.com/babylon101/cameras
  102359. */
  102360. cameras: Camera[];
  102361. /**
  102362. * All of the lights added to this scene
  102363. * @see http://doc.babylonjs.com/babylon101/lights
  102364. */
  102365. lights: Light[];
  102366. /**
  102367. * All of the (abstract) meshes added to this scene
  102368. */
  102369. meshes: AbstractMesh[];
  102370. /**
  102371. * The list of skeletons added to the scene
  102372. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102373. */
  102374. skeletons: Skeleton[];
  102375. /**
  102376. * All of the particle systems added to this scene
  102377. * @see http://doc.babylonjs.com/babylon101/particles
  102378. */
  102379. particleSystems: IParticleSystem[];
  102380. /**
  102381. * Gets a list of Animations associated with the scene
  102382. */
  102383. animations: Animation[];
  102384. /**
  102385. * All of the animation groups added to this scene
  102386. * @see http://doc.babylonjs.com/how_to/group
  102387. */
  102388. animationGroups: AnimationGroup[];
  102389. /**
  102390. * All of the multi-materials added to this scene
  102391. * @see http://doc.babylonjs.com/how_to/multi_materials
  102392. */
  102393. multiMaterials: MultiMaterial[];
  102394. /**
  102395. * All of the materials added to this scene
  102396. * In the context of a Scene, it is not supposed to be modified manually.
  102397. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  102398. * Note also that the order of the Material wihin the array is not significant and might change.
  102399. * @see http://doc.babylonjs.com/babylon101/materials
  102400. */
  102401. materials: Material[];
  102402. /**
  102403. * The list of morph target managers added to the scene
  102404. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  102405. */
  102406. morphTargetManagers: MorphTargetManager[];
  102407. /**
  102408. * The list of geometries used in the scene.
  102409. */
  102410. geometries: Geometry[];
  102411. /**
  102412. * All of the tranform nodes added to this scene
  102413. * In the context of a Scene, it is not supposed to be modified manually.
  102414. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  102415. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  102416. * @see http://doc.babylonjs.com/how_to/transformnode
  102417. */
  102418. transformNodes: TransformNode[];
  102419. /**
  102420. * ActionManagers available on the scene.
  102421. */
  102422. actionManagers: AbstractActionManager[];
  102423. /**
  102424. * Textures to keep.
  102425. */
  102426. textures: BaseTexture[];
  102427. /**
  102428. * Environment texture for the scene
  102429. */
  102430. environmentTexture: Nullable<BaseTexture>;
  102431. }
  102432. }
  102433. declare module BABYLON {
  102434. /**
  102435. * Interface used to define options for Sound class
  102436. */
  102437. export interface ISoundOptions {
  102438. /**
  102439. * Does the sound autoplay once loaded.
  102440. */
  102441. autoplay?: boolean;
  102442. /**
  102443. * Does the sound loop after it finishes playing once.
  102444. */
  102445. loop?: boolean;
  102446. /**
  102447. * Sound's volume
  102448. */
  102449. volume?: number;
  102450. /**
  102451. * Is it a spatial sound?
  102452. */
  102453. spatialSound?: boolean;
  102454. /**
  102455. * Maximum distance to hear that sound
  102456. */
  102457. maxDistance?: number;
  102458. /**
  102459. * Uses user defined attenuation function
  102460. */
  102461. useCustomAttenuation?: boolean;
  102462. /**
  102463. * Define the roll off factor of spatial sounds.
  102464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102465. */
  102466. rolloffFactor?: number;
  102467. /**
  102468. * Define the reference distance the sound should be heard perfectly.
  102469. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102470. */
  102471. refDistance?: number;
  102472. /**
  102473. * Define the distance attenuation model the sound will follow.
  102474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102475. */
  102476. distanceModel?: string;
  102477. /**
  102478. * Defines the playback speed (1 by default)
  102479. */
  102480. playbackRate?: number;
  102481. /**
  102482. * Defines if the sound is from a streaming source
  102483. */
  102484. streaming?: boolean;
  102485. /**
  102486. * Defines an optional length (in seconds) inside the sound file
  102487. */
  102488. length?: number;
  102489. /**
  102490. * Defines an optional offset (in seconds) inside the sound file
  102491. */
  102492. offset?: number;
  102493. /**
  102494. * If true, URLs will not be required to state the audio file codec to use.
  102495. */
  102496. skipCodecCheck?: boolean;
  102497. }
  102498. /**
  102499. * Defines a sound that can be played in the application.
  102500. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  102501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102502. */
  102503. export class Sound {
  102504. /**
  102505. * The name of the sound in the scene.
  102506. */
  102507. name: string;
  102508. /**
  102509. * Does the sound autoplay once loaded.
  102510. */
  102511. autoplay: boolean;
  102512. /**
  102513. * Does the sound loop after it finishes playing once.
  102514. */
  102515. loop: boolean;
  102516. /**
  102517. * Does the sound use a custom attenuation curve to simulate the falloff
  102518. * happening when the source gets further away from the camera.
  102519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102520. */
  102521. useCustomAttenuation: boolean;
  102522. /**
  102523. * The sound track id this sound belongs to.
  102524. */
  102525. soundTrackId: number;
  102526. /**
  102527. * Is this sound currently played.
  102528. */
  102529. isPlaying: boolean;
  102530. /**
  102531. * Is this sound currently paused.
  102532. */
  102533. isPaused: boolean;
  102534. /**
  102535. * Does this sound enables spatial sound.
  102536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102537. */
  102538. spatialSound: boolean;
  102539. /**
  102540. * Define the reference distance the sound should be heard perfectly.
  102541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102542. */
  102543. refDistance: number;
  102544. /**
  102545. * Define the roll off factor of spatial sounds.
  102546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102547. */
  102548. rolloffFactor: number;
  102549. /**
  102550. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  102551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102552. */
  102553. maxDistance: number;
  102554. /**
  102555. * Define the distance attenuation model the sound will follow.
  102556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102557. */
  102558. distanceModel: string;
  102559. /**
  102560. * @hidden
  102561. * Back Compat
  102562. **/
  102563. onended: () => any;
  102564. /**
  102565. * Observable event when the current playing sound finishes.
  102566. */
  102567. onEndedObservable: Observable<Sound>;
  102568. private _panningModel;
  102569. private _playbackRate;
  102570. private _streaming;
  102571. private _startTime;
  102572. private _startOffset;
  102573. private _position;
  102574. /** @hidden */
  102575. _positionInEmitterSpace: boolean;
  102576. private _localDirection;
  102577. private _volume;
  102578. private _isReadyToPlay;
  102579. private _isDirectional;
  102580. private _readyToPlayCallback;
  102581. private _audioBuffer;
  102582. private _soundSource;
  102583. private _streamingSource;
  102584. private _soundPanner;
  102585. private _soundGain;
  102586. private _inputAudioNode;
  102587. private _outputAudioNode;
  102588. private _coneInnerAngle;
  102589. private _coneOuterAngle;
  102590. private _coneOuterGain;
  102591. private _scene;
  102592. private _connectedTransformNode;
  102593. private _customAttenuationFunction;
  102594. private _registerFunc;
  102595. private _isOutputConnected;
  102596. private _htmlAudioElement;
  102597. private _urlType;
  102598. private _length?;
  102599. private _offset?;
  102600. /** @hidden */
  102601. static _SceneComponentInitialization: (scene: Scene) => void;
  102602. /**
  102603. * Create a sound and attach it to a scene
  102604. * @param name Name of your sound
  102605. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  102606. * @param scene defines the scene the sound belongs to
  102607. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  102608. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  102609. */
  102610. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  102611. /**
  102612. * Release the sound and its associated resources
  102613. */
  102614. dispose(): void;
  102615. /**
  102616. * Gets if the sounds is ready to be played or not.
  102617. * @returns true if ready, otherwise false
  102618. */
  102619. isReady(): boolean;
  102620. private _soundLoaded;
  102621. /**
  102622. * Sets the data of the sound from an audiobuffer
  102623. * @param audioBuffer The audioBuffer containing the data
  102624. */
  102625. setAudioBuffer(audioBuffer: AudioBuffer): void;
  102626. /**
  102627. * Updates the current sounds options such as maxdistance, loop...
  102628. * @param options A JSON object containing values named as the object properties
  102629. */
  102630. updateOptions(options: ISoundOptions): void;
  102631. private _createSpatialParameters;
  102632. private _updateSpatialParameters;
  102633. /**
  102634. * Switch the panning model to HRTF:
  102635. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102637. */
  102638. switchPanningModelToHRTF(): void;
  102639. /**
  102640. * Switch the panning model to Equal Power:
  102641. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102643. */
  102644. switchPanningModelToEqualPower(): void;
  102645. private _switchPanningModel;
  102646. /**
  102647. * Connect this sound to a sound track audio node like gain...
  102648. * @param soundTrackAudioNode the sound track audio node to connect to
  102649. */
  102650. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  102651. /**
  102652. * Transform this sound into a directional source
  102653. * @param coneInnerAngle Size of the inner cone in degree
  102654. * @param coneOuterAngle Size of the outer cone in degree
  102655. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  102656. */
  102657. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  102658. /**
  102659. * Gets or sets the inner angle for the directional cone.
  102660. */
  102661. /**
  102662. * Gets or sets the inner angle for the directional cone.
  102663. */
  102664. directionalConeInnerAngle: number;
  102665. /**
  102666. * Gets or sets the outer angle for the directional cone.
  102667. */
  102668. /**
  102669. * Gets or sets the outer angle for the directional cone.
  102670. */
  102671. directionalConeOuterAngle: number;
  102672. /**
  102673. * Sets the position of the emitter if spatial sound is enabled
  102674. * @param newPosition Defines the new posisiton
  102675. */
  102676. setPosition(newPosition: Vector3): void;
  102677. /**
  102678. * Sets the local direction of the emitter if spatial sound is enabled
  102679. * @param newLocalDirection Defines the new local direction
  102680. */
  102681. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102682. private _updateDirection;
  102683. /** @hidden */
  102684. updateDistanceFromListener(): void;
  102685. /**
  102686. * Sets a new custom attenuation function for the sound.
  102687. * @param callback Defines the function used for the attenuation
  102688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102689. */
  102690. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102691. /**
  102692. * Play the sound
  102693. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102694. * @param offset (optional) Start the sound at a specific time in seconds
  102695. * @param length (optional) Sound duration (in seconds)
  102696. */
  102697. play(time?: number, offset?: number, length?: number): void;
  102698. private _onended;
  102699. /**
  102700. * Stop the sound
  102701. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102702. */
  102703. stop(time?: number): void;
  102704. /**
  102705. * Put the sound in pause
  102706. */
  102707. pause(): void;
  102708. /**
  102709. * Sets a dedicated volume for this sounds
  102710. * @param newVolume Define the new volume of the sound
  102711. * @param time Define time for gradual change to new volume
  102712. */
  102713. setVolume(newVolume: number, time?: number): void;
  102714. /**
  102715. * Set the sound play back rate
  102716. * @param newPlaybackRate Define the playback rate the sound should be played at
  102717. */
  102718. setPlaybackRate(newPlaybackRate: number): void;
  102719. /**
  102720. * Gets the volume of the sound.
  102721. * @returns the volume of the sound
  102722. */
  102723. getVolume(): number;
  102724. /**
  102725. * Attach the sound to a dedicated mesh
  102726. * @param transformNode The transform node to connect the sound with
  102727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102728. */
  102729. attachToMesh(transformNode: TransformNode): void;
  102730. /**
  102731. * Detach the sound from the previously attached mesh
  102732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102733. */
  102734. detachFromMesh(): void;
  102735. private _onRegisterAfterWorldMatrixUpdate;
  102736. /**
  102737. * Clone the current sound in the scene.
  102738. * @returns the new sound clone
  102739. */
  102740. clone(): Nullable<Sound>;
  102741. /**
  102742. * Gets the current underlying audio buffer containing the data
  102743. * @returns the audio buffer
  102744. */
  102745. getAudioBuffer(): Nullable<AudioBuffer>;
  102746. /**
  102747. * Serializes the Sound in a JSON representation
  102748. * @returns the JSON representation of the sound
  102749. */
  102750. serialize(): any;
  102751. /**
  102752. * Parse a JSON representation of a sound to innstantiate in a given scene
  102753. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102754. * @param scene Define the scene the new parsed sound should be created in
  102755. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102756. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102757. * @returns the newly parsed sound
  102758. */
  102759. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102760. }
  102761. }
  102762. declare module BABYLON {
  102763. /**
  102764. * This defines an action helpful to play a defined sound on a triggered action.
  102765. */
  102766. export class PlaySoundAction extends Action {
  102767. private _sound;
  102768. /**
  102769. * Instantiate the action
  102770. * @param triggerOptions defines the trigger options
  102771. * @param sound defines the sound to play
  102772. * @param condition defines the trigger related conditions
  102773. */
  102774. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102775. /** @hidden */
  102776. _prepare(): void;
  102777. /**
  102778. * Execute the action and play the sound.
  102779. */
  102780. execute(): void;
  102781. /**
  102782. * Serializes the actions and its related information.
  102783. * @param parent defines the object to serialize in
  102784. * @returns the serialized object
  102785. */
  102786. serialize(parent: any): any;
  102787. }
  102788. /**
  102789. * This defines an action helpful to stop a defined sound on a triggered action.
  102790. */
  102791. export class StopSoundAction extends Action {
  102792. private _sound;
  102793. /**
  102794. * Instantiate the action
  102795. * @param triggerOptions defines the trigger options
  102796. * @param sound defines the sound to stop
  102797. * @param condition defines the trigger related conditions
  102798. */
  102799. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102800. /** @hidden */
  102801. _prepare(): void;
  102802. /**
  102803. * Execute the action and stop the sound.
  102804. */
  102805. execute(): void;
  102806. /**
  102807. * Serializes the actions and its related information.
  102808. * @param parent defines the object to serialize in
  102809. * @returns the serialized object
  102810. */
  102811. serialize(parent: any): any;
  102812. }
  102813. }
  102814. declare module BABYLON {
  102815. /**
  102816. * This defines an action responsible to change the value of a property
  102817. * by interpolating between its current value and the newly set one once triggered.
  102818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102819. */
  102820. export class InterpolateValueAction extends Action {
  102821. /**
  102822. * Defines the path of the property where the value should be interpolated
  102823. */
  102824. propertyPath: string;
  102825. /**
  102826. * Defines the target value at the end of the interpolation.
  102827. */
  102828. value: any;
  102829. /**
  102830. * Defines the time it will take for the property to interpolate to the value.
  102831. */
  102832. duration: number;
  102833. /**
  102834. * Defines if the other scene animations should be stopped when the action has been triggered
  102835. */
  102836. stopOtherAnimations?: boolean;
  102837. /**
  102838. * Defines a callback raised once the interpolation animation has been done.
  102839. */
  102840. onInterpolationDone?: () => void;
  102841. /**
  102842. * Observable triggered once the interpolation animation has been done.
  102843. */
  102844. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102845. private _target;
  102846. private _effectiveTarget;
  102847. private _property;
  102848. /**
  102849. * Instantiate the action
  102850. * @param triggerOptions defines the trigger options
  102851. * @param target defines the object containing the value to interpolate
  102852. * @param propertyPath defines the path to the property in the target object
  102853. * @param value defines the target value at the end of the interpolation
  102854. * @param duration deines the time it will take for the property to interpolate to the value.
  102855. * @param condition defines the trigger related conditions
  102856. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102857. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102858. */
  102859. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102860. /** @hidden */
  102861. _prepare(): void;
  102862. /**
  102863. * Execute the action starts the value interpolation.
  102864. */
  102865. execute(): void;
  102866. /**
  102867. * Serializes the actions and its related information.
  102868. * @param parent defines the object to serialize in
  102869. * @returns the serialized object
  102870. */
  102871. serialize(parent: any): any;
  102872. }
  102873. }
  102874. declare module BABYLON {
  102875. /**
  102876. * Options allowed during the creation of a sound track.
  102877. */
  102878. export interface ISoundTrackOptions {
  102879. /**
  102880. * The volume the sound track should take during creation
  102881. */
  102882. volume?: number;
  102883. /**
  102884. * Define if the sound track is the main sound track of the scene
  102885. */
  102886. mainTrack?: boolean;
  102887. }
  102888. /**
  102889. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102890. * It will be also used in a future release to apply effects on a specific track.
  102891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102892. */
  102893. export class SoundTrack {
  102894. /**
  102895. * The unique identifier of the sound track in the scene.
  102896. */
  102897. id: number;
  102898. /**
  102899. * The list of sounds included in the sound track.
  102900. */
  102901. soundCollection: Array<Sound>;
  102902. private _outputAudioNode;
  102903. private _scene;
  102904. private _isMainTrack;
  102905. private _connectedAnalyser;
  102906. private _options;
  102907. private _isInitialized;
  102908. /**
  102909. * Creates a new sound track.
  102910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102911. * @param scene Define the scene the sound track belongs to
  102912. * @param options
  102913. */
  102914. constructor(scene: Scene, options?: ISoundTrackOptions);
  102915. private _initializeSoundTrackAudioGraph;
  102916. /**
  102917. * Release the sound track and its associated resources
  102918. */
  102919. dispose(): void;
  102920. /**
  102921. * Adds a sound to this sound track
  102922. * @param sound define the cound to add
  102923. * @ignoreNaming
  102924. */
  102925. AddSound(sound: Sound): void;
  102926. /**
  102927. * Removes a sound to this sound track
  102928. * @param sound define the cound to remove
  102929. * @ignoreNaming
  102930. */
  102931. RemoveSound(sound: Sound): void;
  102932. /**
  102933. * Set a global volume for the full sound track.
  102934. * @param newVolume Define the new volume of the sound track
  102935. */
  102936. setVolume(newVolume: number): void;
  102937. /**
  102938. * Switch the panning model to HRTF:
  102939. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102941. */
  102942. switchPanningModelToHRTF(): void;
  102943. /**
  102944. * Switch the panning model to Equal Power:
  102945. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102947. */
  102948. switchPanningModelToEqualPower(): void;
  102949. /**
  102950. * Connect the sound track to an audio analyser allowing some amazing
  102951. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102953. * @param analyser The analyser to connect to the engine
  102954. */
  102955. connectToAnalyser(analyser: Analyser): void;
  102956. }
  102957. }
  102958. declare module BABYLON {
  102959. interface AbstractScene {
  102960. /**
  102961. * The list of sounds used in the scene.
  102962. */
  102963. sounds: Nullable<Array<Sound>>;
  102964. }
  102965. interface Scene {
  102966. /**
  102967. * @hidden
  102968. * Backing field
  102969. */
  102970. _mainSoundTrack: SoundTrack;
  102971. /**
  102972. * The main sound track played by the scene.
  102973. * It cotains your primary collection of sounds.
  102974. */
  102975. mainSoundTrack: SoundTrack;
  102976. /**
  102977. * The list of sound tracks added to the scene
  102978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102979. */
  102980. soundTracks: Nullable<Array<SoundTrack>>;
  102981. /**
  102982. * Gets a sound using a given name
  102983. * @param name defines the name to search for
  102984. * @return the found sound or null if not found at all.
  102985. */
  102986. getSoundByName(name: string): Nullable<Sound>;
  102987. /**
  102988. * Gets or sets if audio support is enabled
  102989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102990. */
  102991. audioEnabled: boolean;
  102992. /**
  102993. * Gets or sets if audio will be output to headphones
  102994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102995. */
  102996. headphone: boolean;
  102997. /**
  102998. * Gets or sets custom audio listener position provider
  102999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103000. */
  103001. audioListenerPositionProvider: Nullable<() => Vector3>;
  103002. }
  103003. /**
  103004. * Defines the sound scene component responsible to manage any sounds
  103005. * in a given scene.
  103006. */
  103007. export class AudioSceneComponent implements ISceneSerializableComponent {
  103008. /**
  103009. * The component name helpfull to identify the component in the list of scene components.
  103010. */
  103011. readonly name: string;
  103012. /**
  103013. * The scene the component belongs to.
  103014. */
  103015. scene: Scene;
  103016. private _audioEnabled;
  103017. /**
  103018. * Gets whether audio is enabled or not.
  103019. * Please use related enable/disable method to switch state.
  103020. */
  103021. readonly audioEnabled: boolean;
  103022. private _headphone;
  103023. /**
  103024. * Gets whether audio is outputing to headphone or not.
  103025. * Please use the according Switch methods to change output.
  103026. */
  103027. readonly headphone: boolean;
  103028. private _audioListenerPositionProvider;
  103029. /**
  103030. * Gets the current audio listener position provider
  103031. */
  103032. /**
  103033. * Sets a custom listener position for all sounds in the scene
  103034. * By default, this is the position of the first active camera
  103035. */
  103036. audioListenerPositionProvider: Nullable<() => Vector3>;
  103037. /**
  103038. * Creates a new instance of the component for the given scene
  103039. * @param scene Defines the scene to register the component in
  103040. */
  103041. constructor(scene: Scene);
  103042. /**
  103043. * Registers the component in a given scene
  103044. */
  103045. register(): void;
  103046. /**
  103047. * Rebuilds the elements related to this component in case of
  103048. * context lost for instance.
  103049. */
  103050. rebuild(): void;
  103051. /**
  103052. * Serializes the component data to the specified json object
  103053. * @param serializationObject The object to serialize to
  103054. */
  103055. serialize(serializationObject: any): void;
  103056. /**
  103057. * Adds all the elements from the container to the scene
  103058. * @param container the container holding the elements
  103059. */
  103060. addFromContainer(container: AbstractScene): void;
  103061. /**
  103062. * Removes all the elements in the container from the scene
  103063. * @param container contains the elements to remove
  103064. * @param dispose if the removed element should be disposed (default: false)
  103065. */
  103066. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  103067. /**
  103068. * Disposes the component and the associated ressources.
  103069. */
  103070. dispose(): void;
  103071. /**
  103072. * Disables audio in the associated scene.
  103073. */
  103074. disableAudio(): void;
  103075. /**
  103076. * Enables audio in the associated scene.
  103077. */
  103078. enableAudio(): void;
  103079. /**
  103080. * Switch audio to headphone output.
  103081. */
  103082. switchAudioModeForHeadphones(): void;
  103083. /**
  103084. * Switch audio to normal speakers.
  103085. */
  103086. switchAudioModeForNormalSpeakers(): void;
  103087. private _afterRender;
  103088. }
  103089. }
  103090. declare module BABYLON {
  103091. /**
  103092. * Wraps one or more Sound objects and selects one with random weight for playback.
  103093. */
  103094. export class WeightedSound {
  103095. /** When true a Sound will be selected and played when the current playing Sound completes. */
  103096. loop: boolean;
  103097. private _coneInnerAngle;
  103098. private _coneOuterAngle;
  103099. private _volume;
  103100. /** A Sound is currently playing. */
  103101. isPlaying: boolean;
  103102. /** A Sound is currently paused. */
  103103. isPaused: boolean;
  103104. private _sounds;
  103105. private _weights;
  103106. private _currentIndex?;
  103107. /**
  103108. * Creates a new WeightedSound from the list of sounds given.
  103109. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  103110. * @param sounds Array of Sounds that will be selected from.
  103111. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  103112. */
  103113. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  103114. /**
  103115. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  103116. */
  103117. /**
  103118. * The size of cone in degress for a directional sound in which there will be no attenuation.
  103119. */
  103120. directionalConeInnerAngle: number;
  103121. /**
  103122. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103123. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103124. */
  103125. /**
  103126. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103127. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103128. */
  103129. directionalConeOuterAngle: number;
  103130. /**
  103131. * Playback volume.
  103132. */
  103133. /**
  103134. * Playback volume.
  103135. */
  103136. volume: number;
  103137. private _onended;
  103138. /**
  103139. * Suspend playback
  103140. */
  103141. pause(): void;
  103142. /**
  103143. * Stop playback
  103144. */
  103145. stop(): void;
  103146. /**
  103147. * Start playback.
  103148. * @param startOffset Position the clip head at a specific time in seconds.
  103149. */
  103150. play(startOffset?: number): void;
  103151. }
  103152. }
  103153. declare module BABYLON {
  103154. /**
  103155. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  103156. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103157. */
  103158. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  103159. /**
  103160. * Gets the name of the behavior.
  103161. */
  103162. readonly name: string;
  103163. /**
  103164. * The easing function used by animations
  103165. */
  103166. static EasingFunction: BackEase;
  103167. /**
  103168. * The easing mode used by animations
  103169. */
  103170. static EasingMode: number;
  103171. /**
  103172. * The duration of the animation, in milliseconds
  103173. */
  103174. transitionDuration: number;
  103175. /**
  103176. * Length of the distance animated by the transition when lower radius is reached
  103177. */
  103178. lowerRadiusTransitionRange: number;
  103179. /**
  103180. * Length of the distance animated by the transition when upper radius is reached
  103181. */
  103182. upperRadiusTransitionRange: number;
  103183. private _autoTransitionRange;
  103184. /**
  103185. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103186. */
  103187. /**
  103188. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103189. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  103190. */
  103191. autoTransitionRange: boolean;
  103192. private _attachedCamera;
  103193. private _onAfterCheckInputsObserver;
  103194. private _onMeshTargetChangedObserver;
  103195. /**
  103196. * Initializes the behavior.
  103197. */
  103198. init(): void;
  103199. /**
  103200. * Attaches the behavior to its arc rotate camera.
  103201. * @param camera Defines the camera to attach the behavior to
  103202. */
  103203. attach(camera: ArcRotateCamera): void;
  103204. /**
  103205. * Detaches the behavior from its current arc rotate camera.
  103206. */
  103207. detach(): void;
  103208. private _radiusIsAnimating;
  103209. private _radiusBounceTransition;
  103210. private _animatables;
  103211. private _cachedWheelPrecision;
  103212. /**
  103213. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  103214. * @param radiusLimit The limit to check against.
  103215. * @return Bool to indicate if at limit.
  103216. */
  103217. private _isRadiusAtLimit;
  103218. /**
  103219. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  103220. * @param radiusDelta The delta by which to animate to. Can be negative.
  103221. */
  103222. private _applyBoundRadiusAnimation;
  103223. /**
  103224. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  103225. */
  103226. protected _clearAnimationLocks(): void;
  103227. /**
  103228. * Stops and removes all animations that have been applied to the camera
  103229. */
  103230. stopAllAnimations(): void;
  103231. }
  103232. }
  103233. declare module BABYLON {
  103234. /**
  103235. * 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.
  103236. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103237. */
  103238. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  103239. /**
  103240. * Gets the name of the behavior.
  103241. */
  103242. readonly name: string;
  103243. private _mode;
  103244. private _radiusScale;
  103245. private _positionScale;
  103246. private _defaultElevation;
  103247. private _elevationReturnTime;
  103248. private _elevationReturnWaitTime;
  103249. private _zoomStopsAnimation;
  103250. private _framingTime;
  103251. /**
  103252. * The easing function used by animations
  103253. */
  103254. static EasingFunction: ExponentialEase;
  103255. /**
  103256. * The easing mode used by animations
  103257. */
  103258. static EasingMode: number;
  103259. /**
  103260. * Sets the current mode used by the behavior
  103261. */
  103262. /**
  103263. * Gets current mode used by the behavior.
  103264. */
  103265. mode: number;
  103266. /**
  103267. * Sets the scale applied to the radius (1 by default)
  103268. */
  103269. /**
  103270. * Gets the scale applied to the radius
  103271. */
  103272. radiusScale: number;
  103273. /**
  103274. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103275. */
  103276. /**
  103277. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103278. */
  103279. positionScale: number;
  103280. /**
  103281. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103282. * behaviour is triggered, in radians.
  103283. */
  103284. /**
  103285. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103286. * behaviour is triggered, in radians.
  103287. */
  103288. defaultElevation: number;
  103289. /**
  103290. * Sets the time (in milliseconds) taken to return to the default beta position.
  103291. * Negative value indicates camera should not return to default.
  103292. */
  103293. /**
  103294. * Gets the time (in milliseconds) taken to return to the default beta position.
  103295. * Negative value indicates camera should not return to default.
  103296. */
  103297. elevationReturnTime: number;
  103298. /**
  103299. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103300. */
  103301. /**
  103302. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103303. */
  103304. elevationReturnWaitTime: number;
  103305. /**
  103306. * Sets the flag that indicates if user zooming should stop animation.
  103307. */
  103308. /**
  103309. * Gets the flag that indicates if user zooming should stop animation.
  103310. */
  103311. zoomStopsAnimation: boolean;
  103312. /**
  103313. * Sets the transition time when framing the mesh, in milliseconds
  103314. */
  103315. /**
  103316. * Gets the transition time when framing the mesh, in milliseconds
  103317. */
  103318. framingTime: number;
  103319. /**
  103320. * Define if the behavior should automatically change the configured
  103321. * camera limits and sensibilities.
  103322. */
  103323. autoCorrectCameraLimitsAndSensibility: boolean;
  103324. private _onPrePointerObservableObserver;
  103325. private _onAfterCheckInputsObserver;
  103326. private _onMeshTargetChangedObserver;
  103327. private _attachedCamera;
  103328. private _isPointerDown;
  103329. private _lastInteractionTime;
  103330. /**
  103331. * Initializes the behavior.
  103332. */
  103333. init(): void;
  103334. /**
  103335. * Attaches the behavior to its arc rotate camera.
  103336. * @param camera Defines the camera to attach the behavior to
  103337. */
  103338. attach(camera: ArcRotateCamera): void;
  103339. /**
  103340. * Detaches the behavior from its current arc rotate camera.
  103341. */
  103342. detach(): void;
  103343. private _animatables;
  103344. private _betaIsAnimating;
  103345. private _betaTransition;
  103346. private _radiusTransition;
  103347. private _vectorTransition;
  103348. /**
  103349. * Targets the given mesh and updates zoom level accordingly.
  103350. * @param mesh The mesh to target.
  103351. * @param radius Optional. If a cached radius position already exists, overrides default.
  103352. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103353. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103354. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103355. */
  103356. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103357. /**
  103358. * Targets the given mesh with its children and updates zoom level accordingly.
  103359. * @param mesh The mesh to target.
  103360. * @param radius Optional. If a cached radius position already exists, overrides default.
  103361. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103362. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103363. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103364. */
  103365. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103366. /**
  103367. * Targets the given meshes with their children and updates zoom level accordingly.
  103368. * @param meshes The mesh to target.
  103369. * @param radius Optional. If a cached radius position already exists, overrides default.
  103370. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103371. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103372. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103373. */
  103374. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103375. /**
  103376. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  103377. * @param minimumWorld Determines the smaller position of the bounding box extend
  103378. * @param maximumWorld Determines the bigger position of the bounding box extend
  103379. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103380. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103381. */
  103382. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103383. /**
  103384. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  103385. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  103386. * frustum width.
  103387. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  103388. * to fully enclose the mesh in the viewing frustum.
  103389. */
  103390. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  103391. /**
  103392. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  103393. * is automatically returned to its default position (expected to be above ground plane).
  103394. */
  103395. private _maintainCameraAboveGround;
  103396. /**
  103397. * Returns the frustum slope based on the canvas ratio and camera FOV
  103398. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  103399. */
  103400. private _getFrustumSlope;
  103401. /**
  103402. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  103403. */
  103404. private _clearAnimationLocks;
  103405. /**
  103406. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103407. */
  103408. private _applyUserInteraction;
  103409. /**
  103410. * Stops and removes all animations that have been applied to the camera
  103411. */
  103412. stopAllAnimations(): void;
  103413. /**
  103414. * Gets a value indicating if the user is moving the camera
  103415. */
  103416. readonly isUserIsMoving: boolean;
  103417. /**
  103418. * The camera can move all the way towards the mesh.
  103419. */
  103420. static IgnoreBoundsSizeMode: number;
  103421. /**
  103422. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  103423. */
  103424. static FitFrustumSidesMode: number;
  103425. }
  103426. }
  103427. declare module BABYLON {
  103428. /**
  103429. * Base class for Camera Pointer Inputs.
  103430. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  103431. * for example usage.
  103432. */
  103433. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  103434. /**
  103435. * Defines the camera the input is attached to.
  103436. */
  103437. abstract camera: Camera;
  103438. /**
  103439. * Whether keyboard modifier keys are pressed at time of last mouse event.
  103440. */
  103441. protected _altKey: boolean;
  103442. protected _ctrlKey: boolean;
  103443. protected _metaKey: boolean;
  103444. protected _shiftKey: boolean;
  103445. /**
  103446. * Which mouse buttons were pressed at time of last mouse event.
  103447. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  103448. */
  103449. protected _buttonsPressed: number;
  103450. /**
  103451. * Defines the buttons associated with the input to handle camera move.
  103452. */
  103453. buttons: number[];
  103454. /**
  103455. * Attach the input controls to a specific dom element to get the input from.
  103456. * @param element Defines the element the controls should be listened from
  103457. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103458. */
  103459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103460. /**
  103461. * Detach the current controls from the specified dom element.
  103462. * @param element Defines the element to stop listening the inputs from
  103463. */
  103464. detachControl(element: Nullable<HTMLElement>): void;
  103465. /**
  103466. * Gets the class name of the current input.
  103467. * @returns the class name
  103468. */
  103469. getClassName(): string;
  103470. /**
  103471. * Get the friendly name associated with the input class.
  103472. * @returns the input friendly name
  103473. */
  103474. getSimpleName(): string;
  103475. /**
  103476. * Called on pointer POINTERDOUBLETAP event.
  103477. * Override this method to provide functionality on POINTERDOUBLETAP event.
  103478. */
  103479. protected onDoubleTap(type: string): void;
  103480. /**
  103481. * Called on pointer POINTERMOVE event if only a single touch is active.
  103482. * Override this method to provide functionality.
  103483. */
  103484. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103485. /**
  103486. * Called on pointer POINTERMOVE event if multiple touches are active.
  103487. * Override this method to provide functionality.
  103488. */
  103489. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103490. /**
  103491. * Called on JS contextmenu event.
  103492. * Override this method to provide functionality.
  103493. */
  103494. protected onContextMenu(evt: PointerEvent): void;
  103495. /**
  103496. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103497. * press.
  103498. * Override this method to provide functionality.
  103499. */
  103500. protected onButtonDown(evt: PointerEvent): void;
  103501. /**
  103502. * Called each time a new POINTERUP event occurs. Ie, for each button
  103503. * release.
  103504. * Override this method to provide functionality.
  103505. */
  103506. protected onButtonUp(evt: PointerEvent): void;
  103507. /**
  103508. * Called when window becomes inactive.
  103509. * Override this method to provide functionality.
  103510. */
  103511. protected onLostFocus(): void;
  103512. private _pointerInput;
  103513. private _observer;
  103514. private _onLostFocus;
  103515. private pointA;
  103516. private pointB;
  103517. }
  103518. }
  103519. declare module BABYLON {
  103520. /**
  103521. * Manage the pointers inputs to control an arc rotate camera.
  103522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103523. */
  103524. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  103525. /**
  103526. * Defines the camera the input is attached to.
  103527. */
  103528. camera: ArcRotateCamera;
  103529. /**
  103530. * Gets the class name of the current input.
  103531. * @returns the class name
  103532. */
  103533. getClassName(): string;
  103534. /**
  103535. * Defines the buttons associated with the input to handle camera move.
  103536. */
  103537. buttons: number[];
  103538. /**
  103539. * Defines the pointer angular sensibility along the X axis or how fast is
  103540. * the camera rotating.
  103541. */
  103542. angularSensibilityX: number;
  103543. /**
  103544. * Defines the pointer angular sensibility along the Y axis or how fast is
  103545. * the camera rotating.
  103546. */
  103547. angularSensibilityY: number;
  103548. /**
  103549. * Defines the pointer pinch precision or how fast is the camera zooming.
  103550. */
  103551. pinchPrecision: number;
  103552. /**
  103553. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103554. * from 0.
  103555. * It defines the percentage of current camera.radius to use as delta when
  103556. * pinch zoom is used.
  103557. */
  103558. pinchDeltaPercentage: number;
  103559. /**
  103560. * Defines the pointer panning sensibility or how fast is the camera moving.
  103561. */
  103562. panningSensibility: number;
  103563. /**
  103564. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  103565. */
  103566. multiTouchPanning: boolean;
  103567. /**
  103568. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  103569. * zoom (pinch) through multitouch.
  103570. */
  103571. multiTouchPanAndZoom: boolean;
  103572. /**
  103573. * Revers pinch action direction.
  103574. */
  103575. pinchInwards: boolean;
  103576. private _isPanClick;
  103577. private _twoFingerActivityCount;
  103578. private _isPinching;
  103579. /**
  103580. * Called on pointer POINTERMOVE event if only a single touch is active.
  103581. */
  103582. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103583. /**
  103584. * Called on pointer POINTERDOUBLETAP event.
  103585. */
  103586. protected onDoubleTap(type: string): void;
  103587. /**
  103588. * Called on pointer POINTERMOVE event if multiple touches are active.
  103589. */
  103590. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103591. /**
  103592. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103593. * press.
  103594. */
  103595. protected onButtonDown(evt: PointerEvent): void;
  103596. /**
  103597. * Called each time a new POINTERUP event occurs. Ie, for each button
  103598. * release.
  103599. */
  103600. protected onButtonUp(evt: PointerEvent): void;
  103601. /**
  103602. * Called when window becomes inactive.
  103603. */
  103604. protected onLostFocus(): void;
  103605. }
  103606. }
  103607. declare module BABYLON {
  103608. /**
  103609. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  103610. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103611. */
  103612. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  103613. /**
  103614. * Defines the camera the input is attached to.
  103615. */
  103616. camera: ArcRotateCamera;
  103617. /**
  103618. * Defines the list of key codes associated with the up action (increase alpha)
  103619. */
  103620. keysUp: number[];
  103621. /**
  103622. * Defines the list of key codes associated with the down action (decrease alpha)
  103623. */
  103624. keysDown: number[];
  103625. /**
  103626. * Defines the list of key codes associated with the left action (increase beta)
  103627. */
  103628. keysLeft: number[];
  103629. /**
  103630. * Defines the list of key codes associated with the right action (decrease beta)
  103631. */
  103632. keysRight: number[];
  103633. /**
  103634. * Defines the list of key codes associated with the reset action.
  103635. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  103636. */
  103637. keysReset: number[];
  103638. /**
  103639. * Defines the panning sensibility of the inputs.
  103640. * (How fast is the camera paning)
  103641. */
  103642. panningSensibility: number;
  103643. /**
  103644. * Defines the zooming sensibility of the inputs.
  103645. * (How fast is the camera zooming)
  103646. */
  103647. zoomingSensibility: number;
  103648. /**
  103649. * Defines wether maintaining the alt key down switch the movement mode from
  103650. * orientation to zoom.
  103651. */
  103652. useAltToZoom: boolean;
  103653. /**
  103654. * Rotation speed of the camera
  103655. */
  103656. angularSpeed: number;
  103657. private _keys;
  103658. private _ctrlPressed;
  103659. private _altPressed;
  103660. private _onCanvasBlurObserver;
  103661. private _onKeyboardObserver;
  103662. private _engine;
  103663. private _scene;
  103664. /**
  103665. * Attach the input controls to a specific dom element to get the input from.
  103666. * @param element Defines the element the controls should be listened from
  103667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103668. */
  103669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103670. /**
  103671. * Detach the current controls from the specified dom element.
  103672. * @param element Defines the element to stop listening the inputs from
  103673. */
  103674. detachControl(element: Nullable<HTMLElement>): void;
  103675. /**
  103676. * Update the current camera state depending on the inputs that have been used this frame.
  103677. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103678. */
  103679. checkInputs(): void;
  103680. /**
  103681. * Gets the class name of the current intput.
  103682. * @returns the class name
  103683. */
  103684. getClassName(): string;
  103685. /**
  103686. * Get the friendly name associated with the input class.
  103687. * @returns the input friendly name
  103688. */
  103689. getSimpleName(): string;
  103690. }
  103691. }
  103692. declare module BABYLON {
  103693. /**
  103694. * Manage the mouse wheel inputs to control an arc rotate camera.
  103695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103696. */
  103697. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103698. /**
  103699. * Defines the camera the input is attached to.
  103700. */
  103701. camera: ArcRotateCamera;
  103702. /**
  103703. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103704. */
  103705. wheelPrecision: number;
  103706. /**
  103707. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103708. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103709. */
  103710. wheelDeltaPercentage: number;
  103711. private _wheel;
  103712. private _observer;
  103713. private computeDeltaFromMouseWheelLegacyEvent;
  103714. /**
  103715. * Attach the input controls to a specific dom element to get the input from.
  103716. * @param element Defines the element the controls should be listened from
  103717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103718. */
  103719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103720. /**
  103721. * Detach the current controls from the specified dom element.
  103722. * @param element Defines the element to stop listening the inputs from
  103723. */
  103724. detachControl(element: Nullable<HTMLElement>): void;
  103725. /**
  103726. * Gets the class name of the current intput.
  103727. * @returns the class name
  103728. */
  103729. getClassName(): string;
  103730. /**
  103731. * Get the friendly name associated with the input class.
  103732. * @returns the input friendly name
  103733. */
  103734. getSimpleName(): string;
  103735. }
  103736. }
  103737. declare module BABYLON {
  103738. /**
  103739. * Default Inputs manager for the ArcRotateCamera.
  103740. * It groups all the default supported inputs for ease of use.
  103741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103742. */
  103743. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103744. /**
  103745. * Instantiates a new ArcRotateCameraInputsManager.
  103746. * @param camera Defines the camera the inputs belong to
  103747. */
  103748. constructor(camera: ArcRotateCamera);
  103749. /**
  103750. * Add mouse wheel input support to the input manager.
  103751. * @returns the current input manager
  103752. */
  103753. addMouseWheel(): ArcRotateCameraInputsManager;
  103754. /**
  103755. * Add pointers input support to the input manager.
  103756. * @returns the current input manager
  103757. */
  103758. addPointers(): ArcRotateCameraInputsManager;
  103759. /**
  103760. * Add keyboard input support to the input manager.
  103761. * @returns the current input manager
  103762. */
  103763. addKeyboard(): ArcRotateCameraInputsManager;
  103764. }
  103765. }
  103766. declare module BABYLON {
  103767. /**
  103768. * This represents an orbital type of camera.
  103769. *
  103770. * 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.
  103771. * 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.
  103772. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103773. */
  103774. export class ArcRotateCamera extends TargetCamera {
  103775. /**
  103776. * Defines the rotation angle of the camera along the longitudinal axis.
  103777. */
  103778. alpha: number;
  103779. /**
  103780. * Defines the rotation angle of the camera along the latitudinal axis.
  103781. */
  103782. beta: number;
  103783. /**
  103784. * Defines the radius of the camera from it s target point.
  103785. */
  103786. radius: number;
  103787. protected _target: Vector3;
  103788. protected _targetHost: Nullable<AbstractMesh>;
  103789. /**
  103790. * Defines the target point of the camera.
  103791. * The camera looks towards it form the radius distance.
  103792. */
  103793. target: Vector3;
  103794. /**
  103795. * Define the current local position of the camera in the scene
  103796. */
  103797. position: Vector3;
  103798. protected _upVector: Vector3;
  103799. protected _upToYMatrix: Matrix;
  103800. protected _YToUpMatrix: Matrix;
  103801. /**
  103802. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103803. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103804. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103805. */
  103806. upVector: Vector3;
  103807. /**
  103808. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103809. */
  103810. setMatUp(): void;
  103811. /**
  103812. * Current inertia value on the longitudinal axis.
  103813. * The bigger this number the longer it will take for the camera to stop.
  103814. */
  103815. inertialAlphaOffset: number;
  103816. /**
  103817. * Current inertia value on the latitudinal axis.
  103818. * The bigger this number the longer it will take for the camera to stop.
  103819. */
  103820. inertialBetaOffset: number;
  103821. /**
  103822. * Current inertia value on the radius axis.
  103823. * The bigger this number the longer it will take for the camera to stop.
  103824. */
  103825. inertialRadiusOffset: number;
  103826. /**
  103827. * Minimum allowed angle on the longitudinal axis.
  103828. * This can help limiting how the Camera is able to move in the scene.
  103829. */
  103830. lowerAlphaLimit: Nullable<number>;
  103831. /**
  103832. * Maximum allowed angle on the longitudinal axis.
  103833. * This can help limiting how the Camera is able to move in the scene.
  103834. */
  103835. upperAlphaLimit: Nullable<number>;
  103836. /**
  103837. * Minimum allowed angle on the latitudinal axis.
  103838. * This can help limiting how the Camera is able to move in the scene.
  103839. */
  103840. lowerBetaLimit: number;
  103841. /**
  103842. * Maximum allowed angle on the latitudinal axis.
  103843. * This can help limiting how the Camera is able to move in the scene.
  103844. */
  103845. upperBetaLimit: number;
  103846. /**
  103847. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103848. * This can help limiting how the Camera is able to move in the scene.
  103849. */
  103850. lowerRadiusLimit: Nullable<number>;
  103851. /**
  103852. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103853. * This can help limiting how the Camera is able to move in the scene.
  103854. */
  103855. upperRadiusLimit: Nullable<number>;
  103856. /**
  103857. * Defines the current inertia value used during panning of the camera along the X axis.
  103858. */
  103859. inertialPanningX: number;
  103860. /**
  103861. * Defines the current inertia value used during panning of the camera along the Y axis.
  103862. */
  103863. inertialPanningY: number;
  103864. /**
  103865. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103866. * Basically if your fingers moves away from more than this distance you will be considered
  103867. * in pinch mode.
  103868. */
  103869. pinchToPanMaxDistance: number;
  103870. /**
  103871. * Defines the maximum distance the camera can pan.
  103872. * This could help keeping the cammera always in your scene.
  103873. */
  103874. panningDistanceLimit: Nullable<number>;
  103875. /**
  103876. * Defines the target of the camera before paning.
  103877. */
  103878. panningOriginTarget: Vector3;
  103879. /**
  103880. * Defines the value of the inertia used during panning.
  103881. * 0 would mean stop inertia and one would mean no decelleration at all.
  103882. */
  103883. panningInertia: number;
  103884. /**
  103885. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103886. */
  103887. angularSensibilityX: number;
  103888. /**
  103889. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103890. */
  103891. angularSensibilityY: number;
  103892. /**
  103893. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103894. */
  103895. pinchPrecision: number;
  103896. /**
  103897. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103898. * It will be used instead of pinchDeltaPrecision if different from 0.
  103899. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103900. */
  103901. pinchDeltaPercentage: number;
  103902. /**
  103903. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103904. */
  103905. panningSensibility: number;
  103906. /**
  103907. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103908. */
  103909. keysUp: number[];
  103910. /**
  103911. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103912. */
  103913. keysDown: number[];
  103914. /**
  103915. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103916. */
  103917. keysLeft: number[];
  103918. /**
  103919. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103920. */
  103921. keysRight: number[];
  103922. /**
  103923. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103924. */
  103925. wheelPrecision: number;
  103926. /**
  103927. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103928. * It will be used instead of pinchDeltaPrecision if different from 0.
  103929. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103930. */
  103931. wheelDeltaPercentage: number;
  103932. /**
  103933. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103934. */
  103935. zoomOnFactor: number;
  103936. /**
  103937. * Defines a screen offset for the camera position.
  103938. */
  103939. targetScreenOffset: Vector2;
  103940. /**
  103941. * Allows the camera to be completely reversed.
  103942. * If false the camera can not arrive upside down.
  103943. */
  103944. allowUpsideDown: boolean;
  103945. /**
  103946. * Define if double tap/click is used to restore the previously saved state of the camera.
  103947. */
  103948. useInputToRestoreState: boolean;
  103949. /** @hidden */
  103950. _viewMatrix: Matrix;
  103951. /** @hidden */
  103952. _useCtrlForPanning: boolean;
  103953. /** @hidden */
  103954. _panningMouseButton: number;
  103955. /**
  103956. * Defines the input associated to the camera.
  103957. */
  103958. inputs: ArcRotateCameraInputsManager;
  103959. /** @hidden */
  103960. _reset: () => void;
  103961. /**
  103962. * Defines the allowed panning axis.
  103963. */
  103964. panningAxis: Vector3;
  103965. protected _localDirection: Vector3;
  103966. protected _transformedDirection: Vector3;
  103967. private _bouncingBehavior;
  103968. /**
  103969. * Gets the bouncing behavior of the camera if it has been enabled.
  103970. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103971. */
  103972. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103973. /**
  103974. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103975. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103976. */
  103977. useBouncingBehavior: boolean;
  103978. private _framingBehavior;
  103979. /**
  103980. * Gets the framing behavior of the camera if it has been enabled.
  103981. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103982. */
  103983. readonly framingBehavior: Nullable<FramingBehavior>;
  103984. /**
  103985. * Defines if the framing behavior of the camera is enabled on the camera.
  103986. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103987. */
  103988. useFramingBehavior: boolean;
  103989. private _autoRotationBehavior;
  103990. /**
  103991. * Gets the auto rotation behavior of the camera if it has been enabled.
  103992. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103993. */
  103994. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103995. /**
  103996. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103997. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103998. */
  103999. useAutoRotationBehavior: boolean;
  104000. /**
  104001. * Observable triggered when the mesh target has been changed on the camera.
  104002. */
  104003. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  104004. /**
  104005. * Event raised when the camera is colliding with a mesh.
  104006. */
  104007. onCollide: (collidedMesh: AbstractMesh) => void;
  104008. /**
  104009. * Defines whether the camera should check collision with the objects oh the scene.
  104010. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  104011. */
  104012. checkCollisions: boolean;
  104013. /**
  104014. * Defines the collision radius of the camera.
  104015. * This simulates a sphere around the camera.
  104016. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104017. */
  104018. collisionRadius: Vector3;
  104019. protected _collider: Collider;
  104020. protected _previousPosition: Vector3;
  104021. protected _collisionVelocity: Vector3;
  104022. protected _newPosition: Vector3;
  104023. protected _previousAlpha: number;
  104024. protected _previousBeta: number;
  104025. protected _previousRadius: number;
  104026. protected _collisionTriggered: boolean;
  104027. protected _targetBoundingCenter: Nullable<Vector3>;
  104028. private _computationVector;
  104029. /**
  104030. * Instantiates a new ArcRotateCamera in a given scene
  104031. * @param name Defines the name of the camera
  104032. * @param alpha Defines the camera rotation along the logitudinal axis
  104033. * @param beta Defines the camera rotation along the latitudinal axis
  104034. * @param radius Defines the camera distance from its target
  104035. * @param target Defines the camera target
  104036. * @param scene Defines the scene the camera belongs to
  104037. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  104038. */
  104039. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104040. /** @hidden */
  104041. _initCache(): void;
  104042. /** @hidden */
  104043. _updateCache(ignoreParentClass?: boolean): void;
  104044. protected _getTargetPosition(): Vector3;
  104045. private _storedAlpha;
  104046. private _storedBeta;
  104047. private _storedRadius;
  104048. private _storedTarget;
  104049. private _storedTargetScreenOffset;
  104050. /**
  104051. * Stores the current state of the camera (alpha, beta, radius and target)
  104052. * @returns the camera itself
  104053. */
  104054. storeState(): Camera;
  104055. /**
  104056. * @hidden
  104057. * Restored camera state. You must call storeState() first
  104058. */
  104059. _restoreStateValues(): boolean;
  104060. /** @hidden */
  104061. _isSynchronizedViewMatrix(): boolean;
  104062. /**
  104063. * Attached controls to the current camera.
  104064. * @param element Defines the element the controls should be listened from
  104065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104066. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  104067. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  104068. */
  104069. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  104070. /**
  104071. * Detach the current controls from the camera.
  104072. * The camera will stop reacting to inputs.
  104073. * @param element Defines the element to stop listening the inputs from
  104074. */
  104075. detachControl(element: HTMLElement): void;
  104076. /** @hidden */
  104077. _checkInputs(): void;
  104078. protected _checkLimits(): void;
  104079. /**
  104080. * Rebuilds angles (alpha, beta) and radius from the give position and target
  104081. */
  104082. rebuildAnglesAndRadius(): void;
  104083. /**
  104084. * Use a position to define the current camera related information like alpha, beta and radius
  104085. * @param position Defines the position to set the camera at
  104086. */
  104087. setPosition(position: Vector3): void;
  104088. /**
  104089. * Defines the target the camera should look at.
  104090. * This will automatically adapt alpha beta and radius to fit within the new target.
  104091. * @param target Defines the new target as a Vector or a mesh
  104092. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  104093. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  104094. */
  104095. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  104096. /** @hidden */
  104097. _getViewMatrix(): Matrix;
  104098. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  104099. /**
  104100. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  104101. * @param meshes Defines the mesh to zoom on
  104102. * @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)
  104103. */
  104104. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  104105. /**
  104106. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  104107. * The target will be changed but the radius
  104108. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  104109. * @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)
  104110. */
  104111. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  104112. min: Vector3;
  104113. max: Vector3;
  104114. distance: number;
  104115. }, doNotUpdateMaxZ?: boolean): void;
  104116. /**
  104117. * @override
  104118. * Override Camera.createRigCamera
  104119. */
  104120. createRigCamera(name: string, cameraIndex: number): Camera;
  104121. /**
  104122. * @hidden
  104123. * @override
  104124. * Override Camera._updateRigCameras
  104125. */
  104126. _updateRigCameras(): void;
  104127. /**
  104128. * Destroy the camera and release the current resources hold by it.
  104129. */
  104130. dispose(): void;
  104131. /**
  104132. * Gets the current object class name.
  104133. * @return the class name
  104134. */
  104135. getClassName(): string;
  104136. }
  104137. }
  104138. declare module BABYLON {
  104139. /**
  104140. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  104141. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104142. */
  104143. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  104144. /**
  104145. * Gets the name of the behavior.
  104146. */
  104147. readonly name: string;
  104148. private _zoomStopsAnimation;
  104149. private _idleRotationSpeed;
  104150. private _idleRotationWaitTime;
  104151. private _idleRotationSpinupTime;
  104152. /**
  104153. * Sets the flag that indicates if user zooming should stop animation.
  104154. */
  104155. /**
  104156. * Gets the flag that indicates if user zooming should stop animation.
  104157. */
  104158. zoomStopsAnimation: boolean;
  104159. /**
  104160. * Sets the default speed at which the camera rotates around the model.
  104161. */
  104162. /**
  104163. * Gets the default speed at which the camera rotates around the model.
  104164. */
  104165. idleRotationSpeed: number;
  104166. /**
  104167. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  104168. */
  104169. /**
  104170. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  104171. */
  104172. idleRotationWaitTime: number;
  104173. /**
  104174. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104175. */
  104176. /**
  104177. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104178. */
  104179. idleRotationSpinupTime: number;
  104180. /**
  104181. * Gets a value indicating if the camera is currently rotating because of this behavior
  104182. */
  104183. readonly rotationInProgress: boolean;
  104184. private _onPrePointerObservableObserver;
  104185. private _onAfterCheckInputsObserver;
  104186. private _attachedCamera;
  104187. private _isPointerDown;
  104188. private _lastFrameTime;
  104189. private _lastInteractionTime;
  104190. private _cameraRotationSpeed;
  104191. /**
  104192. * Initializes the behavior.
  104193. */
  104194. init(): void;
  104195. /**
  104196. * Attaches the behavior to its arc rotate camera.
  104197. * @param camera Defines the camera to attach the behavior to
  104198. */
  104199. attach(camera: ArcRotateCamera): void;
  104200. /**
  104201. * Detaches the behavior from its current arc rotate camera.
  104202. */
  104203. detach(): void;
  104204. /**
  104205. * Returns true if user is scrolling.
  104206. * @return true if user is scrolling.
  104207. */
  104208. private _userIsZooming;
  104209. private _lastFrameRadius;
  104210. private _shouldAnimationStopForInteraction;
  104211. /**
  104212. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104213. */
  104214. private _applyUserInteraction;
  104215. private _userIsMoving;
  104216. }
  104217. }
  104218. declare module BABYLON {
  104219. /**
  104220. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  104221. */
  104222. export class AttachToBoxBehavior implements Behavior<Mesh> {
  104223. private ui;
  104224. /**
  104225. * The name of the behavior
  104226. */
  104227. name: string;
  104228. /**
  104229. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  104230. */
  104231. distanceAwayFromFace: number;
  104232. /**
  104233. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  104234. */
  104235. distanceAwayFromBottomOfFace: number;
  104236. private _faceVectors;
  104237. private _target;
  104238. private _scene;
  104239. private _onRenderObserver;
  104240. private _tmpMatrix;
  104241. private _tmpVector;
  104242. /**
  104243. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  104244. * @param ui The transform node that should be attched to the mesh
  104245. */
  104246. constructor(ui: TransformNode);
  104247. /**
  104248. * Initializes the behavior
  104249. */
  104250. init(): void;
  104251. private _closestFace;
  104252. private _zeroVector;
  104253. private _lookAtTmpMatrix;
  104254. private _lookAtToRef;
  104255. /**
  104256. * Attaches the AttachToBoxBehavior to the passed in mesh
  104257. * @param target The mesh that the specified node will be attached to
  104258. */
  104259. attach(target: Mesh): void;
  104260. /**
  104261. * Detaches the behavior from the mesh
  104262. */
  104263. detach(): void;
  104264. }
  104265. }
  104266. declare module BABYLON {
  104267. /**
  104268. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  104269. */
  104270. export class FadeInOutBehavior implements Behavior<Mesh> {
  104271. /**
  104272. * Time in milliseconds to delay before fading in (Default: 0)
  104273. */
  104274. delay: number;
  104275. /**
  104276. * Time in milliseconds for the mesh to fade in (Default: 300)
  104277. */
  104278. fadeInTime: number;
  104279. private _millisecondsPerFrame;
  104280. private _hovered;
  104281. private _hoverValue;
  104282. private _ownerNode;
  104283. /**
  104284. * Instatiates the FadeInOutBehavior
  104285. */
  104286. constructor();
  104287. /**
  104288. * The name of the behavior
  104289. */
  104290. readonly name: string;
  104291. /**
  104292. * Initializes the behavior
  104293. */
  104294. init(): void;
  104295. /**
  104296. * Attaches the fade behavior on the passed in mesh
  104297. * @param ownerNode The mesh that will be faded in/out once attached
  104298. */
  104299. attach(ownerNode: Mesh): void;
  104300. /**
  104301. * Detaches the behavior from the mesh
  104302. */
  104303. detach(): void;
  104304. /**
  104305. * Triggers the mesh to begin fading in or out
  104306. * @param value if the object should fade in or out (true to fade in)
  104307. */
  104308. fadeIn(value: boolean): void;
  104309. private _update;
  104310. private _setAllVisibility;
  104311. }
  104312. }
  104313. declare module BABYLON {
  104314. /**
  104315. * Class containing a set of static utilities functions for managing Pivots
  104316. * @hidden
  104317. */
  104318. export class PivotTools {
  104319. private static _PivotCached;
  104320. private static _OldPivotPoint;
  104321. private static _PivotTranslation;
  104322. private static _PivotTmpVector;
  104323. /** @hidden */
  104324. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  104325. /** @hidden */
  104326. static _RestorePivotPoint(mesh: AbstractMesh): void;
  104327. }
  104328. }
  104329. declare module BABYLON {
  104330. /**
  104331. * Class containing static functions to help procedurally build meshes
  104332. */
  104333. export class PlaneBuilder {
  104334. /**
  104335. * Creates a plane mesh
  104336. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104337. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104338. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104342. * @param name defines the name of the mesh
  104343. * @param options defines the options used to create the mesh
  104344. * @param scene defines the hosting scene
  104345. * @returns the plane mesh
  104346. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104347. */
  104348. static CreatePlane(name: string, options: {
  104349. size?: number;
  104350. width?: number;
  104351. height?: number;
  104352. sideOrientation?: number;
  104353. frontUVs?: Vector4;
  104354. backUVs?: Vector4;
  104355. updatable?: boolean;
  104356. sourcePlane?: Plane;
  104357. }, scene?: Nullable<Scene>): Mesh;
  104358. }
  104359. }
  104360. declare module BABYLON {
  104361. /**
  104362. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  104363. */
  104364. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  104365. private static _AnyMouseID;
  104366. /**
  104367. * Abstract mesh the behavior is set on
  104368. */
  104369. attachedNode: AbstractMesh;
  104370. private _dragPlane;
  104371. private _scene;
  104372. private _pointerObserver;
  104373. private _beforeRenderObserver;
  104374. private static _planeScene;
  104375. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  104376. /**
  104377. * 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)
  104378. */
  104379. maxDragAngle: number;
  104380. /**
  104381. * @hidden
  104382. */
  104383. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  104384. /**
  104385. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104386. */
  104387. currentDraggingPointerID: number;
  104388. /**
  104389. * The last position where the pointer hit the drag plane in world space
  104390. */
  104391. lastDragPosition: Vector3;
  104392. /**
  104393. * If the behavior is currently in a dragging state
  104394. */
  104395. dragging: boolean;
  104396. /**
  104397. * 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)
  104398. */
  104399. dragDeltaRatio: number;
  104400. /**
  104401. * If the drag plane orientation should be updated during the dragging (Default: true)
  104402. */
  104403. updateDragPlane: boolean;
  104404. private _debugMode;
  104405. private _moving;
  104406. /**
  104407. * Fires each time the attached mesh is dragged with the pointer
  104408. * * delta between last drag position and current drag position in world space
  104409. * * dragDistance along the drag axis
  104410. * * dragPlaneNormal normal of the current drag plane used during the drag
  104411. * * dragPlanePoint in world space where the drag intersects the drag plane
  104412. */
  104413. onDragObservable: Observable<{
  104414. delta: Vector3;
  104415. dragPlanePoint: Vector3;
  104416. dragPlaneNormal: Vector3;
  104417. dragDistance: number;
  104418. pointerId: number;
  104419. }>;
  104420. /**
  104421. * Fires each time a drag begins (eg. mouse down on mesh)
  104422. */
  104423. onDragStartObservable: Observable<{
  104424. dragPlanePoint: Vector3;
  104425. pointerId: number;
  104426. }>;
  104427. /**
  104428. * Fires each time a drag ends (eg. mouse release after drag)
  104429. */
  104430. onDragEndObservable: Observable<{
  104431. dragPlanePoint: Vector3;
  104432. pointerId: number;
  104433. }>;
  104434. /**
  104435. * If the attached mesh should be moved when dragged
  104436. */
  104437. moveAttached: boolean;
  104438. /**
  104439. * If the drag behavior will react to drag events (Default: true)
  104440. */
  104441. enabled: boolean;
  104442. /**
  104443. * If pointer events should start and release the drag (Default: true)
  104444. */
  104445. startAndReleaseDragOnPointerEvents: boolean;
  104446. /**
  104447. * If camera controls should be detached during the drag
  104448. */
  104449. detachCameraControls: boolean;
  104450. /**
  104451. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  104452. */
  104453. useObjectOrienationForDragging: boolean;
  104454. private _options;
  104455. /**
  104456. * Creates a pointer drag behavior that can be attached to a mesh
  104457. * @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)
  104458. */
  104459. constructor(options?: {
  104460. dragAxis?: Vector3;
  104461. dragPlaneNormal?: Vector3;
  104462. });
  104463. /**
  104464. * Predicate to determine if it is valid to move the object to a new position when it is moved
  104465. */
  104466. validateDrag: (targetPosition: Vector3) => boolean;
  104467. /**
  104468. * The name of the behavior
  104469. */
  104470. readonly name: string;
  104471. /**
  104472. * Initializes the behavior
  104473. */
  104474. init(): void;
  104475. private _tmpVector;
  104476. private _alternatePickedPoint;
  104477. private _worldDragAxis;
  104478. private _targetPosition;
  104479. private _attachedElement;
  104480. /**
  104481. * Attaches the drag behavior the passed in mesh
  104482. * @param ownerNode The mesh that will be dragged around once attached
  104483. * @param predicate Predicate to use for pick filtering
  104484. */
  104485. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  104486. /**
  104487. * Force relase the drag action by code.
  104488. */
  104489. releaseDrag(): void;
  104490. private _startDragRay;
  104491. private _lastPointerRay;
  104492. /**
  104493. * Simulates the start of a pointer drag event on the behavior
  104494. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  104495. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  104496. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  104497. */
  104498. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  104499. private _startDrag;
  104500. private _dragDelta;
  104501. private _moveDrag;
  104502. private _pickWithRayOnDragPlane;
  104503. private _pointA;
  104504. private _pointB;
  104505. private _pointC;
  104506. private _lineA;
  104507. private _lineB;
  104508. private _localAxis;
  104509. private _lookAt;
  104510. private _updateDragPlanePosition;
  104511. /**
  104512. * Detaches the behavior from the mesh
  104513. */
  104514. detach(): void;
  104515. }
  104516. }
  104517. declare module BABYLON {
  104518. /**
  104519. * A behavior that when attached to a mesh will allow the mesh to be scaled
  104520. */
  104521. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  104522. private _dragBehaviorA;
  104523. private _dragBehaviorB;
  104524. private _startDistance;
  104525. private _initialScale;
  104526. private _targetScale;
  104527. private _ownerNode;
  104528. private _sceneRenderObserver;
  104529. /**
  104530. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  104531. */
  104532. constructor();
  104533. /**
  104534. * The name of the behavior
  104535. */
  104536. readonly name: string;
  104537. /**
  104538. * Initializes the behavior
  104539. */
  104540. init(): void;
  104541. private _getCurrentDistance;
  104542. /**
  104543. * Attaches the scale behavior the passed in mesh
  104544. * @param ownerNode The mesh that will be scaled around once attached
  104545. */
  104546. attach(ownerNode: Mesh): void;
  104547. /**
  104548. * Detaches the behavior from the mesh
  104549. */
  104550. detach(): void;
  104551. }
  104552. }
  104553. declare module BABYLON {
  104554. /**
  104555. * 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
  104556. */
  104557. export class SixDofDragBehavior implements Behavior<Mesh> {
  104558. private static _virtualScene;
  104559. private _ownerNode;
  104560. private _sceneRenderObserver;
  104561. private _scene;
  104562. private _targetPosition;
  104563. private _virtualOriginMesh;
  104564. private _virtualDragMesh;
  104565. private _pointerObserver;
  104566. private _moving;
  104567. private _startingOrientation;
  104568. /**
  104569. * 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)
  104570. */
  104571. private zDragFactor;
  104572. /**
  104573. * If the object should rotate to face the drag origin
  104574. */
  104575. rotateDraggedObject: boolean;
  104576. /**
  104577. * If the behavior is currently in a dragging state
  104578. */
  104579. dragging: boolean;
  104580. /**
  104581. * 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)
  104582. */
  104583. dragDeltaRatio: number;
  104584. /**
  104585. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104586. */
  104587. currentDraggingPointerID: number;
  104588. /**
  104589. * If camera controls should be detached during the drag
  104590. */
  104591. detachCameraControls: boolean;
  104592. /**
  104593. * Fires each time a drag starts
  104594. */
  104595. onDragStartObservable: Observable<{}>;
  104596. /**
  104597. * Fires each time a drag ends (eg. mouse release after drag)
  104598. */
  104599. onDragEndObservable: Observable<{}>;
  104600. /**
  104601. * 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
  104602. */
  104603. constructor();
  104604. /**
  104605. * The name of the behavior
  104606. */
  104607. readonly name: string;
  104608. /**
  104609. * Initializes the behavior
  104610. */
  104611. init(): void;
  104612. /**
  104613. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  104614. */
  104615. private readonly _pointerCamera;
  104616. /**
  104617. * Attaches the scale behavior the passed in mesh
  104618. * @param ownerNode The mesh that will be scaled around once attached
  104619. */
  104620. attach(ownerNode: Mesh): void;
  104621. /**
  104622. * Detaches the behavior from the mesh
  104623. */
  104624. detach(): void;
  104625. }
  104626. }
  104627. declare module BABYLON {
  104628. /**
  104629. * Class used to apply inverse kinematics to bones
  104630. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  104631. */
  104632. export class BoneIKController {
  104633. private static _tmpVecs;
  104634. private static _tmpQuat;
  104635. private static _tmpMats;
  104636. /**
  104637. * Gets or sets the target mesh
  104638. */
  104639. targetMesh: AbstractMesh;
  104640. /** Gets or sets the mesh used as pole */
  104641. poleTargetMesh: AbstractMesh;
  104642. /**
  104643. * Gets or sets the bone used as pole
  104644. */
  104645. poleTargetBone: Nullable<Bone>;
  104646. /**
  104647. * Gets or sets the target position
  104648. */
  104649. targetPosition: Vector3;
  104650. /**
  104651. * Gets or sets the pole target position
  104652. */
  104653. poleTargetPosition: Vector3;
  104654. /**
  104655. * Gets or sets the pole target local offset
  104656. */
  104657. poleTargetLocalOffset: Vector3;
  104658. /**
  104659. * Gets or sets the pole angle
  104660. */
  104661. poleAngle: number;
  104662. /**
  104663. * Gets or sets the mesh associated with the controller
  104664. */
  104665. mesh: AbstractMesh;
  104666. /**
  104667. * 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)
  104668. */
  104669. slerpAmount: number;
  104670. private _bone1Quat;
  104671. private _bone1Mat;
  104672. private _bone2Ang;
  104673. private _bone1;
  104674. private _bone2;
  104675. private _bone1Length;
  104676. private _bone2Length;
  104677. private _maxAngle;
  104678. private _maxReach;
  104679. private _rightHandedSystem;
  104680. private _bendAxis;
  104681. private _slerping;
  104682. private _adjustRoll;
  104683. /**
  104684. * Gets or sets maximum allowed angle
  104685. */
  104686. maxAngle: number;
  104687. /**
  104688. * Creates a new BoneIKController
  104689. * @param mesh defines the mesh to control
  104690. * @param bone defines the bone to control
  104691. * @param options defines options to set up the controller
  104692. */
  104693. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104694. targetMesh?: AbstractMesh;
  104695. poleTargetMesh?: AbstractMesh;
  104696. poleTargetBone?: Bone;
  104697. poleTargetLocalOffset?: Vector3;
  104698. poleAngle?: number;
  104699. bendAxis?: Vector3;
  104700. maxAngle?: number;
  104701. slerpAmount?: number;
  104702. });
  104703. private _setMaxAngle;
  104704. /**
  104705. * Force the controller to update the bones
  104706. */
  104707. update(): void;
  104708. }
  104709. }
  104710. declare module BABYLON {
  104711. /**
  104712. * Class used to make a bone look toward a point in space
  104713. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104714. */
  104715. export class BoneLookController {
  104716. private static _tmpVecs;
  104717. private static _tmpQuat;
  104718. private static _tmpMats;
  104719. /**
  104720. * The target Vector3 that the bone will look at
  104721. */
  104722. target: Vector3;
  104723. /**
  104724. * The mesh that the bone is attached to
  104725. */
  104726. mesh: AbstractMesh;
  104727. /**
  104728. * The bone that will be looking to the target
  104729. */
  104730. bone: Bone;
  104731. /**
  104732. * The up axis of the coordinate system that is used when the bone is rotated
  104733. */
  104734. upAxis: Vector3;
  104735. /**
  104736. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104737. */
  104738. upAxisSpace: Space;
  104739. /**
  104740. * Used to make an adjustment to the yaw of the bone
  104741. */
  104742. adjustYaw: number;
  104743. /**
  104744. * Used to make an adjustment to the pitch of the bone
  104745. */
  104746. adjustPitch: number;
  104747. /**
  104748. * Used to make an adjustment to the roll of the bone
  104749. */
  104750. adjustRoll: number;
  104751. /**
  104752. * 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)
  104753. */
  104754. slerpAmount: number;
  104755. private _minYaw;
  104756. private _maxYaw;
  104757. private _minPitch;
  104758. private _maxPitch;
  104759. private _minYawSin;
  104760. private _minYawCos;
  104761. private _maxYawSin;
  104762. private _maxYawCos;
  104763. private _midYawConstraint;
  104764. private _minPitchTan;
  104765. private _maxPitchTan;
  104766. private _boneQuat;
  104767. private _slerping;
  104768. private _transformYawPitch;
  104769. private _transformYawPitchInv;
  104770. private _firstFrameSkipped;
  104771. private _yawRange;
  104772. private _fowardAxis;
  104773. /**
  104774. * Gets or sets the minimum yaw angle that the bone can look to
  104775. */
  104776. minYaw: number;
  104777. /**
  104778. * Gets or sets the maximum yaw angle that the bone can look to
  104779. */
  104780. maxYaw: number;
  104781. /**
  104782. * Gets or sets the minimum pitch angle that the bone can look to
  104783. */
  104784. minPitch: number;
  104785. /**
  104786. * Gets or sets the maximum pitch angle that the bone can look to
  104787. */
  104788. maxPitch: number;
  104789. /**
  104790. * Create a BoneLookController
  104791. * @param mesh the mesh that the bone belongs to
  104792. * @param bone the bone that will be looking to the target
  104793. * @param target the target Vector3 to look at
  104794. * @param options optional settings:
  104795. * * maxYaw: the maximum angle the bone will yaw to
  104796. * * minYaw: the minimum angle the bone will yaw to
  104797. * * maxPitch: the maximum angle the bone will pitch to
  104798. * * minPitch: the minimum angle the bone will yaw to
  104799. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104800. * * upAxis: the up axis of the coordinate system
  104801. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104802. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104803. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104804. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104805. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104806. * * adjustRoll: used to make an adjustment to the roll of the bone
  104807. **/
  104808. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104809. maxYaw?: number;
  104810. minYaw?: number;
  104811. maxPitch?: number;
  104812. minPitch?: number;
  104813. slerpAmount?: number;
  104814. upAxis?: Vector3;
  104815. upAxisSpace?: Space;
  104816. yawAxis?: Vector3;
  104817. pitchAxis?: Vector3;
  104818. adjustYaw?: number;
  104819. adjustPitch?: number;
  104820. adjustRoll?: number;
  104821. });
  104822. /**
  104823. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104824. */
  104825. update(): void;
  104826. private _getAngleDiff;
  104827. private _getAngleBetween;
  104828. private _isAngleBetween;
  104829. }
  104830. }
  104831. declare module BABYLON {
  104832. /**
  104833. * Manage the gamepad inputs to control an arc rotate camera.
  104834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104835. */
  104836. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104837. /**
  104838. * Defines the camera the input is attached to.
  104839. */
  104840. camera: ArcRotateCamera;
  104841. /**
  104842. * Defines the gamepad the input is gathering event from.
  104843. */
  104844. gamepad: Nullable<Gamepad>;
  104845. /**
  104846. * Defines the gamepad rotation sensiblity.
  104847. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104848. */
  104849. gamepadRotationSensibility: number;
  104850. /**
  104851. * Defines the gamepad move sensiblity.
  104852. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104853. */
  104854. gamepadMoveSensibility: number;
  104855. private _yAxisScale;
  104856. /**
  104857. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104858. */
  104859. invertYAxis: boolean;
  104860. private _onGamepadConnectedObserver;
  104861. private _onGamepadDisconnectedObserver;
  104862. /**
  104863. * Attach the input controls to a specific dom element to get the input from.
  104864. * @param element Defines the element the controls should be listened from
  104865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104866. */
  104867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104868. /**
  104869. * Detach the current controls from the specified dom element.
  104870. * @param element Defines the element to stop listening the inputs from
  104871. */
  104872. detachControl(element: Nullable<HTMLElement>): void;
  104873. /**
  104874. * Update the current camera state depending on the inputs that have been used this frame.
  104875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104876. */
  104877. checkInputs(): void;
  104878. /**
  104879. * Gets the class name of the current intput.
  104880. * @returns the class name
  104881. */
  104882. getClassName(): string;
  104883. /**
  104884. * Get the friendly name associated with the input class.
  104885. * @returns the input friendly name
  104886. */
  104887. getSimpleName(): string;
  104888. }
  104889. }
  104890. declare module BABYLON {
  104891. interface ArcRotateCameraInputsManager {
  104892. /**
  104893. * Add orientation input support to the input manager.
  104894. * @returns the current input manager
  104895. */
  104896. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104897. }
  104898. /**
  104899. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104901. */
  104902. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104903. /**
  104904. * Defines the camera the input is attached to.
  104905. */
  104906. camera: ArcRotateCamera;
  104907. /**
  104908. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104909. */
  104910. alphaCorrection: number;
  104911. /**
  104912. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104913. */
  104914. gammaCorrection: number;
  104915. private _alpha;
  104916. private _gamma;
  104917. private _dirty;
  104918. private _deviceOrientationHandler;
  104919. /**
  104920. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104921. */
  104922. constructor();
  104923. /**
  104924. * Attach the input controls to a specific dom element to get the input from.
  104925. * @param element Defines the element the controls should be listened from
  104926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104927. */
  104928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104929. /** @hidden */
  104930. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104931. /**
  104932. * Update the current camera state depending on the inputs that have been used this frame.
  104933. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104934. */
  104935. checkInputs(): void;
  104936. /**
  104937. * Detach the current controls from the specified dom element.
  104938. * @param element Defines the element to stop listening the inputs from
  104939. */
  104940. detachControl(element: Nullable<HTMLElement>): void;
  104941. /**
  104942. * Gets the class name of the current intput.
  104943. * @returns the class name
  104944. */
  104945. getClassName(): string;
  104946. /**
  104947. * Get the friendly name associated with the input class.
  104948. * @returns the input friendly name
  104949. */
  104950. getSimpleName(): string;
  104951. }
  104952. }
  104953. declare module BABYLON {
  104954. /**
  104955. * Listen to mouse events to control the camera.
  104956. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104957. */
  104958. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104959. /**
  104960. * Defines the camera the input is attached to.
  104961. */
  104962. camera: FlyCamera;
  104963. /**
  104964. * Defines if touch is enabled. (Default is true.)
  104965. */
  104966. touchEnabled: boolean;
  104967. /**
  104968. * Defines the buttons associated with the input to handle camera rotation.
  104969. */
  104970. buttons: number[];
  104971. /**
  104972. * Assign buttons for Yaw control.
  104973. */
  104974. buttonsYaw: number[];
  104975. /**
  104976. * Assign buttons for Pitch control.
  104977. */
  104978. buttonsPitch: number[];
  104979. /**
  104980. * Assign buttons for Roll control.
  104981. */
  104982. buttonsRoll: number[];
  104983. /**
  104984. * Detect if any button is being pressed while mouse is moved.
  104985. * -1 = Mouse locked.
  104986. * 0 = Left button.
  104987. * 1 = Middle Button.
  104988. * 2 = Right Button.
  104989. */
  104990. activeButton: number;
  104991. /**
  104992. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104993. * Higher values reduce its sensitivity.
  104994. */
  104995. angularSensibility: number;
  104996. private _mousemoveCallback;
  104997. private _observer;
  104998. private _rollObserver;
  104999. private previousPosition;
  105000. private noPreventDefault;
  105001. private element;
  105002. /**
  105003. * Listen to mouse events to control the camera.
  105004. * @param touchEnabled Define if touch is enabled. (Default is true.)
  105005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105006. */
  105007. constructor(touchEnabled?: boolean);
  105008. /**
  105009. * Attach the mouse control to the HTML DOM element.
  105010. * @param element Defines the element that listens to the input events.
  105011. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  105012. */
  105013. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105014. /**
  105015. * Detach the current controls from the specified dom element.
  105016. * @param element Defines the element to stop listening the inputs from
  105017. */
  105018. detachControl(element: Nullable<HTMLElement>): void;
  105019. /**
  105020. * Gets the class name of the current input.
  105021. * @returns the class name.
  105022. */
  105023. getClassName(): string;
  105024. /**
  105025. * Get the friendly name associated with the input class.
  105026. * @returns the input's friendly name.
  105027. */
  105028. getSimpleName(): string;
  105029. private _pointerInput;
  105030. private _onMouseMove;
  105031. /**
  105032. * Rotate camera by mouse offset.
  105033. */
  105034. private rotateCamera;
  105035. }
  105036. }
  105037. declare module BABYLON {
  105038. /**
  105039. * Default Inputs manager for the FlyCamera.
  105040. * It groups all the default supported inputs for ease of use.
  105041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105042. */
  105043. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  105044. /**
  105045. * Instantiates a new FlyCameraInputsManager.
  105046. * @param camera Defines the camera the inputs belong to.
  105047. */
  105048. constructor(camera: FlyCamera);
  105049. /**
  105050. * Add keyboard input support to the input manager.
  105051. * @returns the new FlyCameraKeyboardMoveInput().
  105052. */
  105053. addKeyboard(): FlyCameraInputsManager;
  105054. /**
  105055. * Add mouse input support to the input manager.
  105056. * @param touchEnabled Enable touch screen support.
  105057. * @returns the new FlyCameraMouseInput().
  105058. */
  105059. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  105060. }
  105061. }
  105062. declare module BABYLON {
  105063. /**
  105064. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105065. * such as in a 3D Space Shooter or a Flight Simulator.
  105066. */
  105067. export class FlyCamera extends TargetCamera {
  105068. /**
  105069. * Define the collision ellipsoid of the camera.
  105070. * This is helpful for simulating a camera body, like a player's body.
  105071. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105072. */
  105073. ellipsoid: Vector3;
  105074. /**
  105075. * Define an offset for the position of the ellipsoid around the camera.
  105076. * This can be helpful if the camera is attached away from the player's body center,
  105077. * such as at its head.
  105078. */
  105079. ellipsoidOffset: Vector3;
  105080. /**
  105081. * Enable or disable collisions of the camera with the rest of the scene objects.
  105082. */
  105083. checkCollisions: boolean;
  105084. /**
  105085. * Enable or disable gravity on the camera.
  105086. */
  105087. applyGravity: boolean;
  105088. /**
  105089. * Define the current direction the camera is moving to.
  105090. */
  105091. cameraDirection: Vector3;
  105092. /**
  105093. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  105094. * This overrides and empties cameraRotation.
  105095. */
  105096. rotationQuaternion: Quaternion;
  105097. /**
  105098. * Track Roll to maintain the wanted Rolling when looking around.
  105099. */
  105100. _trackRoll: number;
  105101. /**
  105102. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  105103. */
  105104. rollCorrect: number;
  105105. /**
  105106. * Mimic a banked turn, Rolling the camera when Yawing.
  105107. * It's recommended to use rollCorrect = 10 for faster banking correction.
  105108. */
  105109. bankedTurn: boolean;
  105110. /**
  105111. * Limit in radians for how much Roll banking will add. (Default: 90°)
  105112. */
  105113. bankedTurnLimit: number;
  105114. /**
  105115. * Value of 0 disables the banked Roll.
  105116. * Value of 1 is equal to the Yaw angle in radians.
  105117. */
  105118. bankedTurnMultiplier: number;
  105119. /**
  105120. * The inputs manager loads all the input sources, such as keyboard and mouse.
  105121. */
  105122. inputs: FlyCameraInputsManager;
  105123. /**
  105124. * Gets the input sensibility for mouse input.
  105125. * Higher values reduce sensitivity.
  105126. */
  105127. /**
  105128. * Sets the input sensibility for a mouse input.
  105129. * Higher values reduce sensitivity.
  105130. */
  105131. angularSensibility: number;
  105132. /**
  105133. * Get the keys for camera movement forward.
  105134. */
  105135. /**
  105136. * Set the keys for camera movement forward.
  105137. */
  105138. keysForward: number[];
  105139. /**
  105140. * Get the keys for camera movement backward.
  105141. */
  105142. keysBackward: number[];
  105143. /**
  105144. * Get the keys for camera movement up.
  105145. */
  105146. /**
  105147. * Set the keys for camera movement up.
  105148. */
  105149. keysUp: number[];
  105150. /**
  105151. * Get the keys for camera movement down.
  105152. */
  105153. /**
  105154. * Set the keys for camera movement down.
  105155. */
  105156. keysDown: number[];
  105157. /**
  105158. * Get the keys for camera movement left.
  105159. */
  105160. /**
  105161. * Set the keys for camera movement left.
  105162. */
  105163. keysLeft: number[];
  105164. /**
  105165. * Set the keys for camera movement right.
  105166. */
  105167. /**
  105168. * Set the keys for camera movement right.
  105169. */
  105170. keysRight: number[];
  105171. /**
  105172. * Event raised when the camera collides with a mesh in the scene.
  105173. */
  105174. onCollide: (collidedMesh: AbstractMesh) => void;
  105175. private _collider;
  105176. private _needMoveForGravity;
  105177. private _oldPosition;
  105178. private _diffPosition;
  105179. private _newPosition;
  105180. /** @hidden */
  105181. _localDirection: Vector3;
  105182. /** @hidden */
  105183. _transformedDirection: Vector3;
  105184. /**
  105185. * Instantiates a FlyCamera.
  105186. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105187. * such as in a 3D Space Shooter or a Flight Simulator.
  105188. * @param name Define the name of the camera in the scene.
  105189. * @param position Define the starting position of the camera in the scene.
  105190. * @param scene Define the scene the camera belongs to.
  105191. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  105192. */
  105193. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105194. /**
  105195. * Attach a control to the HTML DOM element.
  105196. * @param element Defines the element that listens to the input events.
  105197. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  105198. */
  105199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105200. /**
  105201. * Detach a control from the HTML DOM element.
  105202. * The camera will stop reacting to that input.
  105203. * @param element Defines the element that listens to the input events.
  105204. */
  105205. detachControl(element: HTMLElement): void;
  105206. private _collisionMask;
  105207. /**
  105208. * Get the mask that the camera ignores in collision events.
  105209. */
  105210. /**
  105211. * Set the mask that the camera ignores in collision events.
  105212. */
  105213. collisionMask: number;
  105214. /** @hidden */
  105215. _collideWithWorld(displacement: Vector3): void;
  105216. /** @hidden */
  105217. private _onCollisionPositionChange;
  105218. /** @hidden */
  105219. _checkInputs(): void;
  105220. /** @hidden */
  105221. _decideIfNeedsToMove(): boolean;
  105222. /** @hidden */
  105223. _updatePosition(): void;
  105224. /**
  105225. * Restore the Roll to its target value at the rate specified.
  105226. * @param rate - Higher means slower restoring.
  105227. * @hidden
  105228. */
  105229. restoreRoll(rate: number): void;
  105230. /**
  105231. * Destroy the camera and release the current resources held by it.
  105232. */
  105233. dispose(): void;
  105234. /**
  105235. * Get the current object class name.
  105236. * @returns the class name.
  105237. */
  105238. getClassName(): string;
  105239. }
  105240. }
  105241. declare module BABYLON {
  105242. /**
  105243. * Listen to keyboard events to control the camera.
  105244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105245. */
  105246. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  105247. /**
  105248. * Defines the camera the input is attached to.
  105249. */
  105250. camera: FlyCamera;
  105251. /**
  105252. * The list of keyboard keys used to control the forward move of the camera.
  105253. */
  105254. keysForward: number[];
  105255. /**
  105256. * The list of keyboard keys used to control the backward move of the camera.
  105257. */
  105258. keysBackward: number[];
  105259. /**
  105260. * The list of keyboard keys used to control the forward move of the camera.
  105261. */
  105262. keysUp: number[];
  105263. /**
  105264. * The list of keyboard keys used to control the backward move of the camera.
  105265. */
  105266. keysDown: number[];
  105267. /**
  105268. * The list of keyboard keys used to control the right strafe move of the camera.
  105269. */
  105270. keysRight: number[];
  105271. /**
  105272. * The list of keyboard keys used to control the left strafe move of the camera.
  105273. */
  105274. keysLeft: number[];
  105275. private _keys;
  105276. private _onCanvasBlurObserver;
  105277. private _onKeyboardObserver;
  105278. private _engine;
  105279. private _scene;
  105280. /**
  105281. * Attach the input controls to a specific dom element to get the input from.
  105282. * @param element Defines the element the controls should be listened from
  105283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105284. */
  105285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105286. /**
  105287. * Detach the current controls from the specified dom element.
  105288. * @param element Defines the element to stop listening the inputs from
  105289. */
  105290. detachControl(element: Nullable<HTMLElement>): void;
  105291. /**
  105292. * Gets the class name of the current intput.
  105293. * @returns the class name
  105294. */
  105295. getClassName(): string;
  105296. /** @hidden */
  105297. _onLostFocus(e: FocusEvent): void;
  105298. /**
  105299. * Get the friendly name associated with the input class.
  105300. * @returns the input friendly name
  105301. */
  105302. getSimpleName(): string;
  105303. /**
  105304. * Update the current camera state depending on the inputs that have been used this frame.
  105305. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105306. */
  105307. checkInputs(): void;
  105308. }
  105309. }
  105310. declare module BABYLON {
  105311. /**
  105312. * Manage the mouse wheel inputs to control a follow camera.
  105313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105314. */
  105315. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  105316. /**
  105317. * Defines the camera the input is attached to.
  105318. */
  105319. camera: FollowCamera;
  105320. /**
  105321. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  105322. */
  105323. axisControlRadius: boolean;
  105324. /**
  105325. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  105326. */
  105327. axisControlHeight: boolean;
  105328. /**
  105329. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  105330. */
  105331. axisControlRotation: boolean;
  105332. /**
  105333. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  105334. * relation to mouseWheel events.
  105335. */
  105336. wheelPrecision: number;
  105337. /**
  105338. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105339. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105340. */
  105341. wheelDeltaPercentage: number;
  105342. private _wheel;
  105343. private _observer;
  105344. /**
  105345. * Attach the input controls to a specific dom element to get the input from.
  105346. * @param element Defines the element the controls should be listened from
  105347. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105348. */
  105349. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105350. /**
  105351. * Detach the current controls from the specified dom element.
  105352. * @param element Defines the element to stop listening the inputs from
  105353. */
  105354. detachControl(element: Nullable<HTMLElement>): void;
  105355. /**
  105356. * Gets the class name of the current intput.
  105357. * @returns the class name
  105358. */
  105359. getClassName(): string;
  105360. /**
  105361. * Get the friendly name associated with the input class.
  105362. * @returns the input friendly name
  105363. */
  105364. getSimpleName(): string;
  105365. }
  105366. }
  105367. declare module BABYLON {
  105368. /**
  105369. * Manage the pointers inputs to control an follow camera.
  105370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105371. */
  105372. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  105373. /**
  105374. * Defines the camera the input is attached to.
  105375. */
  105376. camera: FollowCamera;
  105377. /**
  105378. * Gets the class name of the current input.
  105379. * @returns the class name
  105380. */
  105381. getClassName(): string;
  105382. /**
  105383. * Defines the pointer angular sensibility along the X axis or how fast is
  105384. * the camera rotating.
  105385. * A negative number will reverse the axis direction.
  105386. */
  105387. angularSensibilityX: number;
  105388. /**
  105389. * Defines the pointer angular sensibility along the Y axis or how fast is
  105390. * the camera rotating.
  105391. * A negative number will reverse the axis direction.
  105392. */
  105393. angularSensibilityY: number;
  105394. /**
  105395. * Defines the pointer pinch precision or how fast is the camera zooming.
  105396. * A negative number will reverse the axis direction.
  105397. */
  105398. pinchPrecision: number;
  105399. /**
  105400. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  105401. * from 0.
  105402. * It defines the percentage of current camera.radius to use as delta when
  105403. * pinch zoom is used.
  105404. */
  105405. pinchDeltaPercentage: number;
  105406. /**
  105407. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  105408. */
  105409. axisXControlRadius: boolean;
  105410. /**
  105411. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  105412. */
  105413. axisXControlHeight: boolean;
  105414. /**
  105415. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  105416. */
  105417. axisXControlRotation: boolean;
  105418. /**
  105419. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  105420. */
  105421. axisYControlRadius: boolean;
  105422. /**
  105423. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  105424. */
  105425. axisYControlHeight: boolean;
  105426. /**
  105427. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  105428. */
  105429. axisYControlRotation: boolean;
  105430. /**
  105431. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  105432. */
  105433. axisPinchControlRadius: boolean;
  105434. /**
  105435. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  105436. */
  105437. axisPinchControlHeight: boolean;
  105438. /**
  105439. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  105440. */
  105441. axisPinchControlRotation: boolean;
  105442. /**
  105443. * Log error messages if basic misconfiguration has occurred.
  105444. */
  105445. warningEnable: boolean;
  105446. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105447. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105448. private _warningCounter;
  105449. private _warning;
  105450. }
  105451. }
  105452. declare module BABYLON {
  105453. /**
  105454. * Default Inputs manager for the FollowCamera.
  105455. * It groups all the default supported inputs for ease of use.
  105456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105457. */
  105458. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  105459. /**
  105460. * Instantiates a new FollowCameraInputsManager.
  105461. * @param camera Defines the camera the inputs belong to
  105462. */
  105463. constructor(camera: FollowCamera);
  105464. /**
  105465. * Add keyboard input support to the input manager.
  105466. * @returns the current input manager
  105467. */
  105468. addKeyboard(): FollowCameraInputsManager;
  105469. /**
  105470. * Add mouse wheel input support to the input manager.
  105471. * @returns the current input manager
  105472. */
  105473. addMouseWheel(): FollowCameraInputsManager;
  105474. /**
  105475. * Add pointers input support to the input manager.
  105476. * @returns the current input manager
  105477. */
  105478. addPointers(): FollowCameraInputsManager;
  105479. /**
  105480. * Add orientation input support to the input manager.
  105481. * @returns the current input manager
  105482. */
  105483. addVRDeviceOrientation(): FollowCameraInputsManager;
  105484. }
  105485. }
  105486. declare module BABYLON {
  105487. /**
  105488. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  105489. * an arc rotate version arcFollowCamera are available.
  105490. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105491. */
  105492. export class FollowCamera extends TargetCamera {
  105493. /**
  105494. * Distance the follow camera should follow an object at
  105495. */
  105496. radius: number;
  105497. /**
  105498. * Minimum allowed distance of the camera to the axis of rotation
  105499. * (The camera can not get closer).
  105500. * This can help limiting how the Camera is able to move in the scene.
  105501. */
  105502. lowerRadiusLimit: Nullable<number>;
  105503. /**
  105504. * Maximum allowed distance of the camera to the axis of rotation
  105505. * (The camera can not get further).
  105506. * This can help limiting how the Camera is able to move in the scene.
  105507. */
  105508. upperRadiusLimit: Nullable<number>;
  105509. /**
  105510. * Define a rotation offset between the camera and the object it follows
  105511. */
  105512. rotationOffset: number;
  105513. /**
  105514. * Minimum allowed angle to camera position relative to target object.
  105515. * This can help limiting how the Camera is able to move in the scene.
  105516. */
  105517. lowerRotationOffsetLimit: Nullable<number>;
  105518. /**
  105519. * Maximum allowed angle to camera position relative to target object.
  105520. * This can help limiting how the Camera is able to move in the scene.
  105521. */
  105522. upperRotationOffsetLimit: Nullable<number>;
  105523. /**
  105524. * Define a height offset between the camera and the object it follows.
  105525. * It can help following an object from the top (like a car chaing a plane)
  105526. */
  105527. heightOffset: number;
  105528. /**
  105529. * Minimum allowed height of camera position relative to target object.
  105530. * This can help limiting how the Camera is able to move in the scene.
  105531. */
  105532. lowerHeightOffsetLimit: Nullable<number>;
  105533. /**
  105534. * Maximum allowed height of camera position relative to target object.
  105535. * This can help limiting how the Camera is able to move in the scene.
  105536. */
  105537. upperHeightOffsetLimit: Nullable<number>;
  105538. /**
  105539. * Define how fast the camera can accelerate to follow it s target.
  105540. */
  105541. cameraAcceleration: number;
  105542. /**
  105543. * Define the speed limit of the camera following an object.
  105544. */
  105545. maxCameraSpeed: number;
  105546. /**
  105547. * Define the target of the camera.
  105548. */
  105549. lockedTarget: Nullable<AbstractMesh>;
  105550. /**
  105551. * Defines the input associated with the camera.
  105552. */
  105553. inputs: FollowCameraInputsManager;
  105554. /**
  105555. * Instantiates the follow camera.
  105556. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105557. * @param name Define the name of the camera in the scene
  105558. * @param position Define the position of the camera
  105559. * @param scene Define the scene the camera belong to
  105560. * @param lockedTarget Define the target of the camera
  105561. */
  105562. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  105563. private _follow;
  105564. /**
  105565. * Attached controls to the current camera.
  105566. * @param element Defines the element the controls should be listened from
  105567. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105568. */
  105569. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105570. /**
  105571. * Detach the current controls from the camera.
  105572. * The camera will stop reacting to inputs.
  105573. * @param element Defines the element to stop listening the inputs from
  105574. */
  105575. detachControl(element: HTMLElement): void;
  105576. /** @hidden */
  105577. _checkInputs(): void;
  105578. private _checkLimits;
  105579. /**
  105580. * Gets the camera class name.
  105581. * @returns the class name
  105582. */
  105583. getClassName(): string;
  105584. }
  105585. /**
  105586. * Arc Rotate version of the follow camera.
  105587. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  105588. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105589. */
  105590. export class ArcFollowCamera extends TargetCamera {
  105591. /** The longitudinal angle of the camera */
  105592. alpha: number;
  105593. /** The latitudinal angle of the camera */
  105594. beta: number;
  105595. /** The radius of the camera from its target */
  105596. radius: number;
  105597. /** Define the camera target (the messh it should follow) */
  105598. target: Nullable<AbstractMesh>;
  105599. private _cartesianCoordinates;
  105600. /**
  105601. * Instantiates a new ArcFollowCamera
  105602. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105603. * @param name Define the name of the camera
  105604. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  105605. * @param beta Define the rotation angle of the camera around the elevation axis
  105606. * @param radius Define the radius of the camera from its target point
  105607. * @param target Define the target of the camera
  105608. * @param scene Define the scene the camera belongs to
  105609. */
  105610. constructor(name: string,
  105611. /** The longitudinal angle of the camera */
  105612. alpha: number,
  105613. /** The latitudinal angle of the camera */
  105614. beta: number,
  105615. /** The radius of the camera from its target */
  105616. radius: number,
  105617. /** Define the camera target (the messh it should follow) */
  105618. target: Nullable<AbstractMesh>, scene: Scene);
  105619. private _follow;
  105620. /** @hidden */
  105621. _checkInputs(): void;
  105622. /**
  105623. * Returns the class name of the object.
  105624. * It is mostly used internally for serialization purposes.
  105625. */
  105626. getClassName(): string;
  105627. }
  105628. }
  105629. declare module BABYLON {
  105630. /**
  105631. * Manage the keyboard inputs to control the movement of a follow camera.
  105632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105633. */
  105634. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  105635. /**
  105636. * Defines the camera the input is attached to.
  105637. */
  105638. camera: FollowCamera;
  105639. /**
  105640. * Defines the list of key codes associated with the up action (increase heightOffset)
  105641. */
  105642. keysHeightOffsetIncr: number[];
  105643. /**
  105644. * Defines the list of key codes associated with the down action (decrease heightOffset)
  105645. */
  105646. keysHeightOffsetDecr: number[];
  105647. /**
  105648. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  105649. */
  105650. keysHeightOffsetModifierAlt: boolean;
  105651. /**
  105652. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  105653. */
  105654. keysHeightOffsetModifierCtrl: boolean;
  105655. /**
  105656. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  105657. */
  105658. keysHeightOffsetModifierShift: boolean;
  105659. /**
  105660. * Defines the list of key codes associated with the left action (increase rotationOffset)
  105661. */
  105662. keysRotationOffsetIncr: number[];
  105663. /**
  105664. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  105665. */
  105666. keysRotationOffsetDecr: number[];
  105667. /**
  105668. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  105669. */
  105670. keysRotationOffsetModifierAlt: boolean;
  105671. /**
  105672. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  105673. */
  105674. keysRotationOffsetModifierCtrl: boolean;
  105675. /**
  105676. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  105677. */
  105678. keysRotationOffsetModifierShift: boolean;
  105679. /**
  105680. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  105681. */
  105682. keysRadiusIncr: number[];
  105683. /**
  105684. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105685. */
  105686. keysRadiusDecr: number[];
  105687. /**
  105688. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105689. */
  105690. keysRadiusModifierAlt: boolean;
  105691. /**
  105692. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105693. */
  105694. keysRadiusModifierCtrl: boolean;
  105695. /**
  105696. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105697. */
  105698. keysRadiusModifierShift: boolean;
  105699. /**
  105700. * Defines the rate of change of heightOffset.
  105701. */
  105702. heightSensibility: number;
  105703. /**
  105704. * Defines the rate of change of rotationOffset.
  105705. */
  105706. rotationSensibility: number;
  105707. /**
  105708. * Defines the rate of change of radius.
  105709. */
  105710. radiusSensibility: number;
  105711. private _keys;
  105712. private _ctrlPressed;
  105713. private _altPressed;
  105714. private _shiftPressed;
  105715. private _onCanvasBlurObserver;
  105716. private _onKeyboardObserver;
  105717. private _engine;
  105718. private _scene;
  105719. /**
  105720. * Attach the input controls to a specific dom element to get the input from.
  105721. * @param element Defines the element the controls should be listened from
  105722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105723. */
  105724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105725. /**
  105726. * Detach the current controls from the specified dom element.
  105727. * @param element Defines the element to stop listening the inputs from
  105728. */
  105729. detachControl(element: Nullable<HTMLElement>): void;
  105730. /**
  105731. * Update the current camera state depending on the inputs that have been used this frame.
  105732. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105733. */
  105734. checkInputs(): void;
  105735. /**
  105736. * Gets the class name of the current input.
  105737. * @returns the class name
  105738. */
  105739. getClassName(): string;
  105740. /**
  105741. * Get the friendly name associated with the input class.
  105742. * @returns the input friendly name
  105743. */
  105744. getSimpleName(): string;
  105745. /**
  105746. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105747. * allow modification of the heightOffset value.
  105748. */
  105749. private _modifierHeightOffset;
  105750. /**
  105751. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105752. * allow modification of the rotationOffset value.
  105753. */
  105754. private _modifierRotationOffset;
  105755. /**
  105756. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105757. * allow modification of the radius value.
  105758. */
  105759. private _modifierRadius;
  105760. }
  105761. }
  105762. declare module BABYLON {
  105763. interface FreeCameraInputsManager {
  105764. /**
  105765. * @hidden
  105766. */
  105767. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105768. /**
  105769. * Add orientation input support to the input manager.
  105770. * @returns the current input manager
  105771. */
  105772. addDeviceOrientation(): FreeCameraInputsManager;
  105773. }
  105774. /**
  105775. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105776. * Screen rotation is taken into account.
  105777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105778. */
  105779. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105780. private _camera;
  105781. private _screenOrientationAngle;
  105782. private _constantTranform;
  105783. private _screenQuaternion;
  105784. private _alpha;
  105785. private _beta;
  105786. private _gamma;
  105787. /**
  105788. * Can be used to detect if a device orientation sensor is availible on a device
  105789. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105790. * @returns a promise that will resolve on orientation change
  105791. */
  105792. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105793. /**
  105794. * @hidden
  105795. */
  105796. _onDeviceOrientationChangedObservable: Observable<void>;
  105797. /**
  105798. * Instantiates a new input
  105799. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105800. */
  105801. constructor();
  105802. /**
  105803. * Define the camera controlled by the input.
  105804. */
  105805. camera: FreeCamera;
  105806. /**
  105807. * Attach the input controls to a specific dom element to get the input from.
  105808. * @param element Defines the element the controls should be listened from
  105809. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105810. */
  105811. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105812. private _orientationChanged;
  105813. private _deviceOrientation;
  105814. /**
  105815. * Detach the current controls from the specified dom element.
  105816. * @param element Defines the element to stop listening the inputs from
  105817. */
  105818. detachControl(element: Nullable<HTMLElement>): void;
  105819. /**
  105820. * Update the current camera state depending on the inputs that have been used this frame.
  105821. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105822. */
  105823. checkInputs(): void;
  105824. /**
  105825. * Gets the class name of the current intput.
  105826. * @returns the class name
  105827. */
  105828. getClassName(): string;
  105829. /**
  105830. * Get the friendly name associated with the input class.
  105831. * @returns the input friendly name
  105832. */
  105833. getSimpleName(): string;
  105834. }
  105835. }
  105836. declare module BABYLON {
  105837. /**
  105838. * Manage the gamepad inputs to control a free camera.
  105839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105840. */
  105841. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105842. /**
  105843. * Define the camera the input is attached to.
  105844. */
  105845. camera: FreeCamera;
  105846. /**
  105847. * Define the Gamepad controlling the input
  105848. */
  105849. gamepad: Nullable<Gamepad>;
  105850. /**
  105851. * Defines the gamepad rotation sensiblity.
  105852. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105853. */
  105854. gamepadAngularSensibility: number;
  105855. /**
  105856. * Defines the gamepad move sensiblity.
  105857. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105858. */
  105859. gamepadMoveSensibility: number;
  105860. private _yAxisScale;
  105861. /**
  105862. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105863. */
  105864. invertYAxis: boolean;
  105865. private _onGamepadConnectedObserver;
  105866. private _onGamepadDisconnectedObserver;
  105867. private _cameraTransform;
  105868. private _deltaTransform;
  105869. private _vector3;
  105870. private _vector2;
  105871. /**
  105872. * Attach the input controls to a specific dom element to get the input from.
  105873. * @param element Defines the element the controls should be listened from
  105874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105875. */
  105876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105877. /**
  105878. * Detach the current controls from the specified dom element.
  105879. * @param element Defines the element to stop listening the inputs from
  105880. */
  105881. detachControl(element: Nullable<HTMLElement>): void;
  105882. /**
  105883. * Update the current camera state depending on the inputs that have been used this frame.
  105884. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105885. */
  105886. checkInputs(): void;
  105887. /**
  105888. * Gets the class name of the current intput.
  105889. * @returns the class name
  105890. */
  105891. getClassName(): string;
  105892. /**
  105893. * Get the friendly name associated with the input class.
  105894. * @returns the input friendly name
  105895. */
  105896. getSimpleName(): string;
  105897. }
  105898. }
  105899. declare module BABYLON {
  105900. /**
  105901. * Defines the potential axis of a Joystick
  105902. */
  105903. export enum JoystickAxis {
  105904. /** X axis */
  105905. X = 0,
  105906. /** Y axis */
  105907. Y = 1,
  105908. /** Z axis */
  105909. Z = 2
  105910. }
  105911. /**
  105912. * Class used to define virtual joystick (used in touch mode)
  105913. */
  105914. export class VirtualJoystick {
  105915. /**
  105916. * Gets or sets a boolean indicating that left and right values must be inverted
  105917. */
  105918. reverseLeftRight: boolean;
  105919. /**
  105920. * Gets or sets a boolean indicating that up and down values must be inverted
  105921. */
  105922. reverseUpDown: boolean;
  105923. /**
  105924. * Gets the offset value for the position (ie. the change of the position value)
  105925. */
  105926. deltaPosition: Vector3;
  105927. /**
  105928. * Gets a boolean indicating if the virtual joystick was pressed
  105929. */
  105930. pressed: boolean;
  105931. /**
  105932. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105933. */
  105934. static Canvas: Nullable<HTMLCanvasElement>;
  105935. private static _globalJoystickIndex;
  105936. private static vjCanvasContext;
  105937. private static vjCanvasWidth;
  105938. private static vjCanvasHeight;
  105939. private static halfWidth;
  105940. private _action;
  105941. private _axisTargetedByLeftAndRight;
  105942. private _axisTargetedByUpAndDown;
  105943. private _joystickSensibility;
  105944. private _inversedSensibility;
  105945. private _joystickPointerID;
  105946. private _joystickColor;
  105947. private _joystickPointerPos;
  105948. private _joystickPreviousPointerPos;
  105949. private _joystickPointerStartPos;
  105950. private _deltaJoystickVector;
  105951. private _leftJoystick;
  105952. private _touches;
  105953. private _onPointerDownHandlerRef;
  105954. private _onPointerMoveHandlerRef;
  105955. private _onPointerUpHandlerRef;
  105956. private _onResize;
  105957. /**
  105958. * Creates a new virtual joystick
  105959. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105960. */
  105961. constructor(leftJoystick?: boolean);
  105962. /**
  105963. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105964. * @param newJoystickSensibility defines the new sensibility
  105965. */
  105966. setJoystickSensibility(newJoystickSensibility: number): void;
  105967. private _onPointerDown;
  105968. private _onPointerMove;
  105969. private _onPointerUp;
  105970. /**
  105971. * Change the color of the virtual joystick
  105972. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105973. */
  105974. setJoystickColor(newColor: string): void;
  105975. /**
  105976. * Defines a callback to call when the joystick is touched
  105977. * @param action defines the callback
  105978. */
  105979. setActionOnTouch(action: () => any): void;
  105980. /**
  105981. * Defines which axis you'd like to control for left & right
  105982. * @param axis defines the axis to use
  105983. */
  105984. setAxisForLeftRight(axis: JoystickAxis): void;
  105985. /**
  105986. * Defines which axis you'd like to control for up & down
  105987. * @param axis defines the axis to use
  105988. */
  105989. setAxisForUpDown(axis: JoystickAxis): void;
  105990. private _drawVirtualJoystick;
  105991. /**
  105992. * Release internal HTML canvas
  105993. */
  105994. releaseCanvas(): void;
  105995. }
  105996. }
  105997. declare module BABYLON {
  105998. interface FreeCameraInputsManager {
  105999. /**
  106000. * Add virtual joystick input support to the input manager.
  106001. * @returns the current input manager
  106002. */
  106003. addVirtualJoystick(): FreeCameraInputsManager;
  106004. }
  106005. /**
  106006. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  106007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106008. */
  106009. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  106010. /**
  106011. * Defines the camera the input is attached to.
  106012. */
  106013. camera: FreeCamera;
  106014. private _leftjoystick;
  106015. private _rightjoystick;
  106016. /**
  106017. * Gets the left stick of the virtual joystick.
  106018. * @returns The virtual Joystick
  106019. */
  106020. getLeftJoystick(): VirtualJoystick;
  106021. /**
  106022. * Gets the right stick of the virtual joystick.
  106023. * @returns The virtual Joystick
  106024. */
  106025. getRightJoystick(): VirtualJoystick;
  106026. /**
  106027. * Update the current camera state depending on the inputs that have been used this frame.
  106028. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106029. */
  106030. checkInputs(): void;
  106031. /**
  106032. * Attach the input controls to a specific dom element to get the input from.
  106033. * @param element Defines the element the controls should be listened from
  106034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106035. */
  106036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106037. /**
  106038. * Detach the current controls from the specified dom element.
  106039. * @param element Defines the element to stop listening the inputs from
  106040. */
  106041. detachControl(element: Nullable<HTMLElement>): void;
  106042. /**
  106043. * Gets the class name of the current intput.
  106044. * @returns the class name
  106045. */
  106046. getClassName(): string;
  106047. /**
  106048. * Get the friendly name associated with the input class.
  106049. * @returns the input friendly name
  106050. */
  106051. getSimpleName(): string;
  106052. }
  106053. }
  106054. declare module BABYLON {
  106055. /**
  106056. * This represents a FPS type of camera controlled by touch.
  106057. * This is like a universal camera minus the Gamepad controls.
  106058. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106059. */
  106060. export class TouchCamera extends FreeCamera {
  106061. /**
  106062. * Defines the touch sensibility for rotation.
  106063. * The higher the faster.
  106064. */
  106065. touchAngularSensibility: number;
  106066. /**
  106067. * Defines the touch sensibility for move.
  106068. * The higher the faster.
  106069. */
  106070. touchMoveSensibility: number;
  106071. /**
  106072. * Instantiates a new touch camera.
  106073. * This represents a FPS type of camera controlled by touch.
  106074. * This is like a universal camera minus the Gamepad controls.
  106075. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106076. * @param name Define the name of the camera in the scene
  106077. * @param position Define the start position of the camera in the scene
  106078. * @param scene Define the scene the camera belongs to
  106079. */
  106080. constructor(name: string, position: Vector3, scene: Scene);
  106081. /**
  106082. * Gets the current object class name.
  106083. * @return the class name
  106084. */
  106085. getClassName(): string;
  106086. /** @hidden */
  106087. _setupInputs(): void;
  106088. }
  106089. }
  106090. declare module BABYLON {
  106091. /**
  106092. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  106093. * being tilted forward or back and left or right.
  106094. */
  106095. export class DeviceOrientationCamera extends FreeCamera {
  106096. private _initialQuaternion;
  106097. private _quaternionCache;
  106098. private _tmpDragQuaternion;
  106099. private _disablePointerInputWhenUsingDeviceOrientation;
  106100. /**
  106101. * Creates a new device orientation camera
  106102. * @param name The name of the camera
  106103. * @param position The start position camera
  106104. * @param scene The scene the camera belongs to
  106105. */
  106106. constructor(name: string, position: Vector3, scene: Scene);
  106107. /**
  106108. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  106109. */
  106110. disablePointerInputWhenUsingDeviceOrientation: boolean;
  106111. private _dragFactor;
  106112. /**
  106113. * Enabled turning on the y axis when the orientation sensor is active
  106114. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  106115. */
  106116. enableHorizontalDragging(dragFactor?: number): void;
  106117. /**
  106118. * Gets the current instance class name ("DeviceOrientationCamera").
  106119. * This helps avoiding instanceof at run time.
  106120. * @returns the class name
  106121. */
  106122. getClassName(): string;
  106123. /**
  106124. * @hidden
  106125. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  106126. */
  106127. _checkInputs(): void;
  106128. /**
  106129. * Reset the camera to its default orientation on the specified axis only.
  106130. * @param axis The axis to reset
  106131. */
  106132. resetToCurrentRotation(axis?: Axis): void;
  106133. }
  106134. }
  106135. declare module BABYLON {
  106136. /**
  106137. * Defines supported buttons for XBox360 compatible gamepads
  106138. */
  106139. export enum Xbox360Button {
  106140. /** A */
  106141. A = 0,
  106142. /** B */
  106143. B = 1,
  106144. /** X */
  106145. X = 2,
  106146. /** Y */
  106147. Y = 3,
  106148. /** Start */
  106149. Start = 4,
  106150. /** Back */
  106151. Back = 5,
  106152. /** Left button */
  106153. LB = 6,
  106154. /** Right button */
  106155. RB = 7,
  106156. /** Left stick */
  106157. LeftStick = 8,
  106158. /** Right stick */
  106159. RightStick = 9
  106160. }
  106161. /** Defines values for XBox360 DPad */
  106162. export enum Xbox360Dpad {
  106163. /** Up */
  106164. Up = 0,
  106165. /** Down */
  106166. Down = 1,
  106167. /** Left */
  106168. Left = 2,
  106169. /** Right */
  106170. Right = 3
  106171. }
  106172. /**
  106173. * Defines a XBox360 gamepad
  106174. */
  106175. export class Xbox360Pad extends Gamepad {
  106176. private _leftTrigger;
  106177. private _rightTrigger;
  106178. private _onlefttriggerchanged;
  106179. private _onrighttriggerchanged;
  106180. private _onbuttondown;
  106181. private _onbuttonup;
  106182. private _ondpaddown;
  106183. private _ondpadup;
  106184. /** Observable raised when a button is pressed */
  106185. onButtonDownObservable: Observable<Xbox360Button>;
  106186. /** Observable raised when a button is released */
  106187. onButtonUpObservable: Observable<Xbox360Button>;
  106188. /** Observable raised when a pad is pressed */
  106189. onPadDownObservable: Observable<Xbox360Dpad>;
  106190. /** Observable raised when a pad is released */
  106191. onPadUpObservable: Observable<Xbox360Dpad>;
  106192. private _buttonA;
  106193. private _buttonB;
  106194. private _buttonX;
  106195. private _buttonY;
  106196. private _buttonBack;
  106197. private _buttonStart;
  106198. private _buttonLB;
  106199. private _buttonRB;
  106200. private _buttonLeftStick;
  106201. private _buttonRightStick;
  106202. private _dPadUp;
  106203. private _dPadDown;
  106204. private _dPadLeft;
  106205. private _dPadRight;
  106206. private _isXboxOnePad;
  106207. /**
  106208. * Creates a new XBox360 gamepad object
  106209. * @param id defines the id of this gamepad
  106210. * @param index defines its index
  106211. * @param gamepad defines the internal HTML gamepad object
  106212. * @param xboxOne defines if it is a XBox One gamepad
  106213. */
  106214. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  106215. /**
  106216. * Defines the callback to call when left trigger is pressed
  106217. * @param callback defines the callback to use
  106218. */
  106219. onlefttriggerchanged(callback: (value: number) => void): void;
  106220. /**
  106221. * Defines the callback to call when right trigger is pressed
  106222. * @param callback defines the callback to use
  106223. */
  106224. onrighttriggerchanged(callback: (value: number) => void): void;
  106225. /**
  106226. * Gets the left trigger value
  106227. */
  106228. /**
  106229. * Sets the left trigger value
  106230. */
  106231. leftTrigger: number;
  106232. /**
  106233. * Gets the right trigger value
  106234. */
  106235. /**
  106236. * Sets the right trigger value
  106237. */
  106238. rightTrigger: number;
  106239. /**
  106240. * Defines the callback to call when a button is pressed
  106241. * @param callback defines the callback to use
  106242. */
  106243. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  106244. /**
  106245. * Defines the callback to call when a button is released
  106246. * @param callback defines the callback to use
  106247. */
  106248. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  106249. /**
  106250. * Defines the callback to call when a pad is pressed
  106251. * @param callback defines the callback to use
  106252. */
  106253. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  106254. /**
  106255. * Defines the callback to call when a pad is released
  106256. * @param callback defines the callback to use
  106257. */
  106258. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  106259. private _setButtonValue;
  106260. private _setDPadValue;
  106261. /**
  106262. * Gets the value of the `A` button
  106263. */
  106264. /**
  106265. * Sets the value of the `A` button
  106266. */
  106267. buttonA: number;
  106268. /**
  106269. * Gets the value of the `B` button
  106270. */
  106271. /**
  106272. * Sets the value of the `B` button
  106273. */
  106274. buttonB: number;
  106275. /**
  106276. * Gets the value of the `X` button
  106277. */
  106278. /**
  106279. * Sets the value of the `X` button
  106280. */
  106281. buttonX: number;
  106282. /**
  106283. * Gets the value of the `Y` button
  106284. */
  106285. /**
  106286. * Sets the value of the `Y` button
  106287. */
  106288. buttonY: number;
  106289. /**
  106290. * Gets the value of the `Start` button
  106291. */
  106292. /**
  106293. * Sets the value of the `Start` button
  106294. */
  106295. buttonStart: number;
  106296. /**
  106297. * Gets the value of the `Back` button
  106298. */
  106299. /**
  106300. * Sets the value of the `Back` button
  106301. */
  106302. buttonBack: number;
  106303. /**
  106304. * Gets the value of the `Left` button
  106305. */
  106306. /**
  106307. * Sets the value of the `Left` button
  106308. */
  106309. buttonLB: number;
  106310. /**
  106311. * Gets the value of the `Right` button
  106312. */
  106313. /**
  106314. * Sets the value of the `Right` button
  106315. */
  106316. buttonRB: number;
  106317. /**
  106318. * Gets the value of the Left joystick
  106319. */
  106320. /**
  106321. * Sets the value of the Left joystick
  106322. */
  106323. buttonLeftStick: number;
  106324. /**
  106325. * Gets the value of the Right joystick
  106326. */
  106327. /**
  106328. * Sets the value of the Right joystick
  106329. */
  106330. buttonRightStick: number;
  106331. /**
  106332. * Gets the value of D-pad up
  106333. */
  106334. /**
  106335. * Sets the value of D-pad up
  106336. */
  106337. dPadUp: number;
  106338. /**
  106339. * Gets the value of D-pad down
  106340. */
  106341. /**
  106342. * Sets the value of D-pad down
  106343. */
  106344. dPadDown: number;
  106345. /**
  106346. * Gets the value of D-pad left
  106347. */
  106348. /**
  106349. * Sets the value of D-pad left
  106350. */
  106351. dPadLeft: number;
  106352. /**
  106353. * Gets the value of D-pad right
  106354. */
  106355. /**
  106356. * Sets the value of D-pad right
  106357. */
  106358. dPadRight: number;
  106359. /**
  106360. * Force the gamepad to synchronize with device values
  106361. */
  106362. update(): void;
  106363. /**
  106364. * Disposes the gamepad
  106365. */
  106366. dispose(): void;
  106367. }
  106368. }
  106369. declare module BABYLON {
  106370. /**
  106371. * Defines supported buttons for DualShock compatible gamepads
  106372. */
  106373. export enum DualShockButton {
  106374. /** Cross */
  106375. Cross = 0,
  106376. /** Circle */
  106377. Circle = 1,
  106378. /** Square */
  106379. Square = 2,
  106380. /** Triangle */
  106381. Triangle = 3,
  106382. /** Options */
  106383. Options = 4,
  106384. /** Share */
  106385. Share = 5,
  106386. /** L1 */
  106387. L1 = 6,
  106388. /** R1 */
  106389. R1 = 7,
  106390. /** Left stick */
  106391. LeftStick = 8,
  106392. /** Right stick */
  106393. RightStick = 9
  106394. }
  106395. /** Defines values for DualShock DPad */
  106396. export enum DualShockDpad {
  106397. /** Up */
  106398. Up = 0,
  106399. /** Down */
  106400. Down = 1,
  106401. /** Left */
  106402. Left = 2,
  106403. /** Right */
  106404. Right = 3
  106405. }
  106406. /**
  106407. * Defines a DualShock gamepad
  106408. */
  106409. export class DualShockPad extends Gamepad {
  106410. private _leftTrigger;
  106411. private _rightTrigger;
  106412. private _onlefttriggerchanged;
  106413. private _onrighttriggerchanged;
  106414. private _onbuttondown;
  106415. private _onbuttonup;
  106416. private _ondpaddown;
  106417. private _ondpadup;
  106418. /** Observable raised when a button is pressed */
  106419. onButtonDownObservable: Observable<DualShockButton>;
  106420. /** Observable raised when a button is released */
  106421. onButtonUpObservable: Observable<DualShockButton>;
  106422. /** Observable raised when a pad is pressed */
  106423. onPadDownObservable: Observable<DualShockDpad>;
  106424. /** Observable raised when a pad is released */
  106425. onPadUpObservable: Observable<DualShockDpad>;
  106426. private _buttonCross;
  106427. private _buttonCircle;
  106428. private _buttonSquare;
  106429. private _buttonTriangle;
  106430. private _buttonShare;
  106431. private _buttonOptions;
  106432. private _buttonL1;
  106433. private _buttonR1;
  106434. private _buttonLeftStick;
  106435. private _buttonRightStick;
  106436. private _dPadUp;
  106437. private _dPadDown;
  106438. private _dPadLeft;
  106439. private _dPadRight;
  106440. /**
  106441. * Creates a new DualShock gamepad object
  106442. * @param id defines the id of this gamepad
  106443. * @param index defines its index
  106444. * @param gamepad defines the internal HTML gamepad object
  106445. */
  106446. constructor(id: string, index: number, gamepad: any);
  106447. /**
  106448. * Defines the callback to call when left trigger is pressed
  106449. * @param callback defines the callback to use
  106450. */
  106451. onlefttriggerchanged(callback: (value: number) => void): void;
  106452. /**
  106453. * Defines the callback to call when right trigger is pressed
  106454. * @param callback defines the callback to use
  106455. */
  106456. onrighttriggerchanged(callback: (value: number) => void): void;
  106457. /**
  106458. * Gets the left trigger value
  106459. */
  106460. /**
  106461. * Sets the left trigger value
  106462. */
  106463. leftTrigger: number;
  106464. /**
  106465. * Gets the right trigger value
  106466. */
  106467. /**
  106468. * Sets the right trigger value
  106469. */
  106470. rightTrigger: number;
  106471. /**
  106472. * Defines the callback to call when a button is pressed
  106473. * @param callback defines the callback to use
  106474. */
  106475. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  106476. /**
  106477. * Defines the callback to call when a button is released
  106478. * @param callback defines the callback to use
  106479. */
  106480. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  106481. /**
  106482. * Defines the callback to call when a pad is pressed
  106483. * @param callback defines the callback to use
  106484. */
  106485. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  106486. /**
  106487. * Defines the callback to call when a pad is released
  106488. * @param callback defines the callback to use
  106489. */
  106490. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  106491. private _setButtonValue;
  106492. private _setDPadValue;
  106493. /**
  106494. * Gets the value of the `Cross` button
  106495. */
  106496. /**
  106497. * Sets the value of the `Cross` button
  106498. */
  106499. buttonCross: number;
  106500. /**
  106501. * Gets the value of the `Circle` button
  106502. */
  106503. /**
  106504. * Sets the value of the `Circle` button
  106505. */
  106506. buttonCircle: number;
  106507. /**
  106508. * Gets the value of the `Square` button
  106509. */
  106510. /**
  106511. * Sets the value of the `Square` button
  106512. */
  106513. buttonSquare: number;
  106514. /**
  106515. * Gets the value of the `Triangle` button
  106516. */
  106517. /**
  106518. * Sets the value of the `Triangle` button
  106519. */
  106520. buttonTriangle: number;
  106521. /**
  106522. * Gets the value of the `Options` button
  106523. */
  106524. /**
  106525. * Sets the value of the `Options` button
  106526. */
  106527. buttonOptions: number;
  106528. /**
  106529. * Gets the value of the `Share` button
  106530. */
  106531. /**
  106532. * Sets the value of the `Share` button
  106533. */
  106534. buttonShare: number;
  106535. /**
  106536. * Gets the value of the `L1` button
  106537. */
  106538. /**
  106539. * Sets the value of the `L1` button
  106540. */
  106541. buttonL1: number;
  106542. /**
  106543. * Gets the value of the `R1` button
  106544. */
  106545. /**
  106546. * Sets the value of the `R1` button
  106547. */
  106548. buttonR1: number;
  106549. /**
  106550. * Gets the value of the Left joystick
  106551. */
  106552. /**
  106553. * Sets the value of the Left joystick
  106554. */
  106555. buttonLeftStick: number;
  106556. /**
  106557. * Gets the value of the Right joystick
  106558. */
  106559. /**
  106560. * Sets the value of the Right joystick
  106561. */
  106562. buttonRightStick: number;
  106563. /**
  106564. * Gets the value of D-pad up
  106565. */
  106566. /**
  106567. * Sets the value of D-pad up
  106568. */
  106569. dPadUp: number;
  106570. /**
  106571. * Gets the value of D-pad down
  106572. */
  106573. /**
  106574. * Sets the value of D-pad down
  106575. */
  106576. dPadDown: number;
  106577. /**
  106578. * Gets the value of D-pad left
  106579. */
  106580. /**
  106581. * Sets the value of D-pad left
  106582. */
  106583. dPadLeft: number;
  106584. /**
  106585. * Gets the value of D-pad right
  106586. */
  106587. /**
  106588. * Sets the value of D-pad right
  106589. */
  106590. dPadRight: number;
  106591. /**
  106592. * Force the gamepad to synchronize with device values
  106593. */
  106594. update(): void;
  106595. /**
  106596. * Disposes the gamepad
  106597. */
  106598. dispose(): void;
  106599. }
  106600. }
  106601. declare module BABYLON {
  106602. /**
  106603. * Manager for handling gamepads
  106604. */
  106605. export class GamepadManager {
  106606. private _scene?;
  106607. private _babylonGamepads;
  106608. private _oneGamepadConnected;
  106609. /** @hidden */
  106610. _isMonitoring: boolean;
  106611. private _gamepadEventSupported;
  106612. private _gamepadSupport;
  106613. /**
  106614. * observable to be triggered when the gamepad controller has been connected
  106615. */
  106616. onGamepadConnectedObservable: Observable<Gamepad>;
  106617. /**
  106618. * observable to be triggered when the gamepad controller has been disconnected
  106619. */
  106620. onGamepadDisconnectedObservable: Observable<Gamepad>;
  106621. private _onGamepadConnectedEvent;
  106622. private _onGamepadDisconnectedEvent;
  106623. /**
  106624. * Initializes the gamepad manager
  106625. * @param _scene BabylonJS scene
  106626. */
  106627. constructor(_scene?: Scene | undefined);
  106628. /**
  106629. * The gamepads in the game pad manager
  106630. */
  106631. readonly gamepads: Gamepad[];
  106632. /**
  106633. * Get the gamepad controllers based on type
  106634. * @param type The type of gamepad controller
  106635. * @returns Nullable gamepad
  106636. */
  106637. getGamepadByType(type?: number): Nullable<Gamepad>;
  106638. /**
  106639. * Disposes the gamepad manager
  106640. */
  106641. dispose(): void;
  106642. private _addNewGamepad;
  106643. private _startMonitoringGamepads;
  106644. private _stopMonitoringGamepads;
  106645. /** @hidden */
  106646. _checkGamepadsStatus(): void;
  106647. private _updateGamepadObjects;
  106648. }
  106649. }
  106650. declare module BABYLON {
  106651. interface Scene {
  106652. /** @hidden */
  106653. _gamepadManager: Nullable<GamepadManager>;
  106654. /**
  106655. * Gets the gamepad manager associated with the scene
  106656. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  106657. */
  106658. gamepadManager: GamepadManager;
  106659. }
  106660. /**
  106661. * Interface representing a free camera inputs manager
  106662. */
  106663. interface FreeCameraInputsManager {
  106664. /**
  106665. * Adds gamepad input support to the FreeCameraInputsManager.
  106666. * @returns the FreeCameraInputsManager
  106667. */
  106668. addGamepad(): FreeCameraInputsManager;
  106669. }
  106670. /**
  106671. * Interface representing an arc rotate camera inputs manager
  106672. */
  106673. interface ArcRotateCameraInputsManager {
  106674. /**
  106675. * Adds gamepad input support to the ArcRotateCamera InputManager.
  106676. * @returns the camera inputs manager
  106677. */
  106678. addGamepad(): ArcRotateCameraInputsManager;
  106679. }
  106680. /**
  106681. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106682. */
  106683. export class GamepadSystemSceneComponent implements ISceneComponent {
  106684. /**
  106685. * The component name helpfull to identify the component in the list of scene components.
  106686. */
  106687. readonly name: string;
  106688. /**
  106689. * The scene the component belongs to.
  106690. */
  106691. scene: Scene;
  106692. /**
  106693. * Creates a new instance of the component for the given scene
  106694. * @param scene Defines the scene to register the component in
  106695. */
  106696. constructor(scene: Scene);
  106697. /**
  106698. * Registers the component in a given scene
  106699. */
  106700. register(): void;
  106701. /**
  106702. * Rebuilds the elements related to this component in case of
  106703. * context lost for instance.
  106704. */
  106705. rebuild(): void;
  106706. /**
  106707. * Disposes the component and the associated ressources
  106708. */
  106709. dispose(): void;
  106710. private _beforeCameraUpdate;
  106711. }
  106712. }
  106713. declare module BABYLON {
  106714. /**
  106715. * 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,
  106716. * which still works and will still be found in many Playgrounds.
  106717. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106718. */
  106719. export class UniversalCamera extends TouchCamera {
  106720. /**
  106721. * Defines the gamepad rotation sensiblity.
  106722. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106723. */
  106724. gamepadAngularSensibility: number;
  106725. /**
  106726. * Defines the gamepad move sensiblity.
  106727. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106728. */
  106729. gamepadMoveSensibility: number;
  106730. /**
  106731. * 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,
  106732. * which still works and will still be found in many Playgrounds.
  106733. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106734. * @param name Define the name of the camera in the scene
  106735. * @param position Define the start position of the camera in the scene
  106736. * @param scene Define the scene the camera belongs to
  106737. */
  106738. constructor(name: string, position: Vector3, scene: Scene);
  106739. /**
  106740. * Gets the current object class name.
  106741. * @return the class name
  106742. */
  106743. getClassName(): string;
  106744. }
  106745. }
  106746. declare module BABYLON {
  106747. /**
  106748. * This represents a FPS type of camera. This is only here for back compat purpose.
  106749. * Please use the UniversalCamera instead as both are identical.
  106750. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106751. */
  106752. export class GamepadCamera extends UniversalCamera {
  106753. /**
  106754. * Instantiates a new Gamepad Camera
  106755. * This represents a FPS type of camera. This is only here for back compat purpose.
  106756. * Please use the UniversalCamera instead as both are identical.
  106757. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106758. * @param name Define the name of the camera in the scene
  106759. * @param position Define the start position of the camera in the scene
  106760. * @param scene Define the scene the camera belongs to
  106761. */
  106762. constructor(name: string, position: Vector3, scene: Scene);
  106763. /**
  106764. * Gets the current object class name.
  106765. * @return the class name
  106766. */
  106767. getClassName(): string;
  106768. }
  106769. }
  106770. declare module BABYLON {
  106771. /** @hidden */
  106772. export var passPixelShader: {
  106773. name: string;
  106774. shader: string;
  106775. };
  106776. }
  106777. declare module BABYLON {
  106778. /** @hidden */
  106779. export var passCubePixelShader: {
  106780. name: string;
  106781. shader: string;
  106782. };
  106783. }
  106784. declare module BABYLON {
  106785. /**
  106786. * PassPostProcess which produces an output the same as it's input
  106787. */
  106788. export class PassPostProcess extends PostProcess {
  106789. /**
  106790. * Creates the PassPostProcess
  106791. * @param name The name of the effect.
  106792. * @param options The required width/height ratio to downsize to before computing the render pass.
  106793. * @param camera The camera to apply the render pass to.
  106794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106795. * @param engine The engine which the post process will be applied. (default: current engine)
  106796. * @param reusable If the post process can be reused on the same frame. (default: false)
  106797. * @param textureType The type of texture to be used when performing the post processing.
  106798. * @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)
  106799. */
  106800. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106801. }
  106802. /**
  106803. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106804. */
  106805. export class PassCubePostProcess extends PostProcess {
  106806. private _face;
  106807. /**
  106808. * Gets or sets the cube face to display.
  106809. * * 0 is +X
  106810. * * 1 is -X
  106811. * * 2 is +Y
  106812. * * 3 is -Y
  106813. * * 4 is +Z
  106814. * * 5 is -Z
  106815. */
  106816. face: number;
  106817. /**
  106818. * Creates the PassCubePostProcess
  106819. * @param name The name of the effect.
  106820. * @param options The required width/height ratio to downsize to before computing the render pass.
  106821. * @param camera The camera to apply the render pass to.
  106822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106823. * @param engine The engine which the post process will be applied. (default: current engine)
  106824. * @param reusable If the post process can be reused on the same frame. (default: false)
  106825. * @param textureType The type of texture to be used when performing the post processing.
  106826. * @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)
  106827. */
  106828. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106829. }
  106830. }
  106831. declare module BABYLON {
  106832. /** @hidden */
  106833. export var anaglyphPixelShader: {
  106834. name: string;
  106835. shader: string;
  106836. };
  106837. }
  106838. declare module BABYLON {
  106839. /**
  106840. * Postprocess used to generate anaglyphic rendering
  106841. */
  106842. export class AnaglyphPostProcess extends PostProcess {
  106843. private _passedProcess;
  106844. /**
  106845. * Creates a new AnaglyphPostProcess
  106846. * @param name defines postprocess name
  106847. * @param options defines creation options or target ratio scale
  106848. * @param rigCameras defines cameras using this postprocess
  106849. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106850. * @param engine defines hosting engine
  106851. * @param reusable defines if the postprocess will be reused multiple times per frame
  106852. */
  106853. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106854. }
  106855. }
  106856. declare module BABYLON {
  106857. /**
  106858. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106859. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106860. */
  106861. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106862. /**
  106863. * Creates a new AnaglyphArcRotateCamera
  106864. * @param name defines camera name
  106865. * @param alpha defines alpha angle (in radians)
  106866. * @param beta defines beta angle (in radians)
  106867. * @param radius defines radius
  106868. * @param target defines camera target
  106869. * @param interaxialDistance defines distance between each color axis
  106870. * @param scene defines the hosting scene
  106871. */
  106872. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106873. /**
  106874. * Gets camera class name
  106875. * @returns AnaglyphArcRotateCamera
  106876. */
  106877. getClassName(): string;
  106878. }
  106879. }
  106880. declare module BABYLON {
  106881. /**
  106882. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106883. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106884. */
  106885. export class AnaglyphFreeCamera extends FreeCamera {
  106886. /**
  106887. * Creates a new AnaglyphFreeCamera
  106888. * @param name defines camera name
  106889. * @param position defines initial position
  106890. * @param interaxialDistance defines distance between each color axis
  106891. * @param scene defines the hosting scene
  106892. */
  106893. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106894. /**
  106895. * Gets camera class name
  106896. * @returns AnaglyphFreeCamera
  106897. */
  106898. getClassName(): string;
  106899. }
  106900. }
  106901. declare module BABYLON {
  106902. /**
  106903. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106904. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106905. */
  106906. export class AnaglyphGamepadCamera extends GamepadCamera {
  106907. /**
  106908. * Creates a new AnaglyphGamepadCamera
  106909. * @param name defines camera name
  106910. * @param position defines initial position
  106911. * @param interaxialDistance defines distance between each color axis
  106912. * @param scene defines the hosting scene
  106913. */
  106914. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106915. /**
  106916. * Gets camera class name
  106917. * @returns AnaglyphGamepadCamera
  106918. */
  106919. getClassName(): string;
  106920. }
  106921. }
  106922. declare module BABYLON {
  106923. /**
  106924. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106925. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106926. */
  106927. export class AnaglyphUniversalCamera extends UniversalCamera {
  106928. /**
  106929. * Creates a new AnaglyphUniversalCamera
  106930. * @param name defines camera name
  106931. * @param position defines initial position
  106932. * @param interaxialDistance defines distance between each color axis
  106933. * @param scene defines the hosting scene
  106934. */
  106935. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106936. /**
  106937. * Gets camera class name
  106938. * @returns AnaglyphUniversalCamera
  106939. */
  106940. getClassName(): string;
  106941. }
  106942. }
  106943. declare module BABYLON {
  106944. /** @hidden */
  106945. export var stereoscopicInterlacePixelShader: {
  106946. name: string;
  106947. shader: string;
  106948. };
  106949. }
  106950. declare module BABYLON {
  106951. /**
  106952. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106953. */
  106954. export class StereoscopicInterlacePostProcess extends PostProcess {
  106955. private _stepSize;
  106956. private _passedProcess;
  106957. /**
  106958. * Initializes a StereoscopicInterlacePostProcess
  106959. * @param name The name of the effect.
  106960. * @param rigCameras The rig cameras to be appled to the post process
  106961. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106963. * @param engine The engine which the post process will be applied. (default: current engine)
  106964. * @param reusable If the post process can be reused on the same frame. (default: false)
  106965. */
  106966. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106967. }
  106968. }
  106969. declare module BABYLON {
  106970. /**
  106971. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106972. * @see http://doc.babylonjs.com/features/cameras
  106973. */
  106974. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106975. /**
  106976. * Creates a new StereoscopicArcRotateCamera
  106977. * @param name defines camera name
  106978. * @param alpha defines alpha angle (in radians)
  106979. * @param beta defines beta angle (in radians)
  106980. * @param radius defines radius
  106981. * @param target defines camera target
  106982. * @param interaxialDistance defines distance between each color axis
  106983. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106984. * @param scene defines the hosting scene
  106985. */
  106986. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106987. /**
  106988. * Gets camera class name
  106989. * @returns StereoscopicArcRotateCamera
  106990. */
  106991. getClassName(): string;
  106992. }
  106993. }
  106994. declare module BABYLON {
  106995. /**
  106996. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106997. * @see http://doc.babylonjs.com/features/cameras
  106998. */
  106999. export class StereoscopicFreeCamera extends FreeCamera {
  107000. /**
  107001. * Creates a new StereoscopicFreeCamera
  107002. * @param name defines camera name
  107003. * @param position defines initial position
  107004. * @param interaxialDistance defines distance between each color axis
  107005. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107006. * @param scene defines the hosting scene
  107007. */
  107008. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107009. /**
  107010. * Gets camera class name
  107011. * @returns StereoscopicFreeCamera
  107012. */
  107013. getClassName(): string;
  107014. }
  107015. }
  107016. declare module BABYLON {
  107017. /**
  107018. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  107019. * @see http://doc.babylonjs.com/features/cameras
  107020. */
  107021. export class StereoscopicGamepadCamera extends GamepadCamera {
  107022. /**
  107023. * Creates a new StereoscopicGamepadCamera
  107024. * @param name defines camera name
  107025. * @param position defines initial position
  107026. * @param interaxialDistance defines distance between each color axis
  107027. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107028. * @param scene defines the hosting scene
  107029. */
  107030. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107031. /**
  107032. * Gets camera class name
  107033. * @returns StereoscopicGamepadCamera
  107034. */
  107035. getClassName(): string;
  107036. }
  107037. }
  107038. declare module BABYLON {
  107039. /**
  107040. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  107041. * @see http://doc.babylonjs.com/features/cameras
  107042. */
  107043. export class StereoscopicUniversalCamera extends UniversalCamera {
  107044. /**
  107045. * Creates a new StereoscopicUniversalCamera
  107046. * @param name defines camera name
  107047. * @param position defines initial position
  107048. * @param interaxialDistance defines distance between each color axis
  107049. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107050. * @param scene defines the hosting scene
  107051. */
  107052. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107053. /**
  107054. * Gets camera class name
  107055. * @returns StereoscopicUniversalCamera
  107056. */
  107057. getClassName(): string;
  107058. }
  107059. }
  107060. declare module BABYLON {
  107061. /**
  107062. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  107063. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107064. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107065. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107066. */
  107067. export class VirtualJoysticksCamera extends FreeCamera {
  107068. /**
  107069. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  107070. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107071. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107072. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107073. * @param name Define the name of the camera in the scene
  107074. * @param position Define the start position of the camera in the scene
  107075. * @param scene Define the scene the camera belongs to
  107076. */
  107077. constructor(name: string, position: Vector3, scene: Scene);
  107078. /**
  107079. * Gets the current object class name.
  107080. * @return the class name
  107081. */
  107082. getClassName(): string;
  107083. }
  107084. }
  107085. declare module BABYLON {
  107086. /**
  107087. * This represents all the required metrics to create a VR camera.
  107088. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  107089. */
  107090. export class VRCameraMetrics {
  107091. /**
  107092. * Define the horizontal resolution off the screen.
  107093. */
  107094. hResolution: number;
  107095. /**
  107096. * Define the vertical resolution off the screen.
  107097. */
  107098. vResolution: number;
  107099. /**
  107100. * Define the horizontal screen size.
  107101. */
  107102. hScreenSize: number;
  107103. /**
  107104. * Define the vertical screen size.
  107105. */
  107106. vScreenSize: number;
  107107. /**
  107108. * Define the vertical screen center position.
  107109. */
  107110. vScreenCenter: number;
  107111. /**
  107112. * Define the distance of the eyes to the screen.
  107113. */
  107114. eyeToScreenDistance: number;
  107115. /**
  107116. * Define the distance between both lenses
  107117. */
  107118. lensSeparationDistance: number;
  107119. /**
  107120. * Define the distance between both viewer's eyes.
  107121. */
  107122. interpupillaryDistance: number;
  107123. /**
  107124. * Define the distortion factor of the VR postprocess.
  107125. * Please, touch with care.
  107126. */
  107127. distortionK: number[];
  107128. /**
  107129. * Define the chromatic aberration correction factors for the VR post process.
  107130. */
  107131. chromaAbCorrection: number[];
  107132. /**
  107133. * Define the scale factor of the post process.
  107134. * The smaller the better but the slower.
  107135. */
  107136. postProcessScaleFactor: number;
  107137. /**
  107138. * Define an offset for the lens center.
  107139. */
  107140. lensCenterOffset: number;
  107141. /**
  107142. * Define if the current vr camera should compensate the distortion of the lense or not.
  107143. */
  107144. compensateDistortion: boolean;
  107145. /**
  107146. * Defines if multiview should be enabled when rendering (Default: false)
  107147. */
  107148. multiviewEnabled: boolean;
  107149. /**
  107150. * Gets the rendering aspect ratio based on the provided resolutions.
  107151. */
  107152. readonly aspectRatio: number;
  107153. /**
  107154. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  107155. */
  107156. readonly aspectRatioFov: number;
  107157. /**
  107158. * @hidden
  107159. */
  107160. readonly leftHMatrix: Matrix;
  107161. /**
  107162. * @hidden
  107163. */
  107164. readonly rightHMatrix: Matrix;
  107165. /**
  107166. * @hidden
  107167. */
  107168. readonly leftPreViewMatrix: Matrix;
  107169. /**
  107170. * @hidden
  107171. */
  107172. readonly rightPreViewMatrix: Matrix;
  107173. /**
  107174. * Get the default VRMetrics based on the most generic setup.
  107175. * @returns the default vr metrics
  107176. */
  107177. static GetDefault(): VRCameraMetrics;
  107178. }
  107179. }
  107180. declare module BABYLON {
  107181. /** @hidden */
  107182. export var vrDistortionCorrectionPixelShader: {
  107183. name: string;
  107184. shader: string;
  107185. };
  107186. }
  107187. declare module BABYLON {
  107188. /**
  107189. * VRDistortionCorrectionPostProcess used for mobile VR
  107190. */
  107191. export class VRDistortionCorrectionPostProcess extends PostProcess {
  107192. private _isRightEye;
  107193. private _distortionFactors;
  107194. private _postProcessScaleFactor;
  107195. private _lensCenterOffset;
  107196. private _scaleIn;
  107197. private _scaleFactor;
  107198. private _lensCenter;
  107199. /**
  107200. * Initializes the VRDistortionCorrectionPostProcess
  107201. * @param name The name of the effect.
  107202. * @param camera The camera to apply the render pass to.
  107203. * @param isRightEye If this is for the right eye distortion
  107204. * @param vrMetrics All the required metrics for the VR camera
  107205. */
  107206. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  107207. }
  107208. }
  107209. declare module BABYLON {
  107210. /**
  107211. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  107212. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107213. */
  107214. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  107215. /**
  107216. * Creates a new VRDeviceOrientationArcRotateCamera
  107217. * @param name defines camera name
  107218. * @param alpha defines the camera rotation along the logitudinal axis
  107219. * @param beta defines the camera rotation along the latitudinal axis
  107220. * @param radius defines the camera distance from its target
  107221. * @param target defines the camera target
  107222. * @param scene defines the scene the camera belongs to
  107223. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107224. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107225. */
  107226. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107227. /**
  107228. * Gets camera class name
  107229. * @returns VRDeviceOrientationArcRotateCamera
  107230. */
  107231. getClassName(): string;
  107232. }
  107233. }
  107234. declare module BABYLON {
  107235. /**
  107236. * Camera used to simulate VR rendering (based on FreeCamera)
  107237. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107238. */
  107239. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  107240. /**
  107241. * Creates a new VRDeviceOrientationFreeCamera
  107242. * @param name defines camera name
  107243. * @param position defines the start position of the camera
  107244. * @param scene defines the scene the camera belongs to
  107245. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107246. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107247. */
  107248. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107249. /**
  107250. * Gets camera class name
  107251. * @returns VRDeviceOrientationFreeCamera
  107252. */
  107253. getClassName(): string;
  107254. }
  107255. }
  107256. declare module BABYLON {
  107257. /**
  107258. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  107259. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107260. */
  107261. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  107262. /**
  107263. * Creates a new VRDeviceOrientationGamepadCamera
  107264. * @param name defines camera name
  107265. * @param position defines the start position of the camera
  107266. * @param scene defines the scene the camera belongs to
  107267. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107268. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107269. */
  107270. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107271. /**
  107272. * Gets camera class name
  107273. * @returns VRDeviceOrientationGamepadCamera
  107274. */
  107275. getClassName(): string;
  107276. }
  107277. }
  107278. declare module BABYLON {
  107279. /**
  107280. * Base class of materials working in push mode in babylon JS
  107281. * @hidden
  107282. */
  107283. export class PushMaterial extends Material {
  107284. protected _activeEffect: Effect;
  107285. protected _normalMatrix: Matrix;
  107286. /**
  107287. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  107288. * This means that the material can keep using a previous shader while a new one is being compiled.
  107289. * This is mostly used when shader parallel compilation is supported (true by default)
  107290. */
  107291. allowShaderHotSwapping: boolean;
  107292. constructor(name: string, scene: Scene);
  107293. getEffect(): Effect;
  107294. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  107295. /**
  107296. * Binds the given world matrix to the active effect
  107297. *
  107298. * @param world the matrix to bind
  107299. */
  107300. bindOnlyWorldMatrix(world: Matrix): void;
  107301. /**
  107302. * Binds the given normal matrix to the active effect
  107303. *
  107304. * @param normalMatrix the matrix to bind
  107305. */
  107306. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  107307. bind(world: Matrix, mesh?: Mesh): void;
  107308. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  107309. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  107310. }
  107311. }
  107312. declare module BABYLON {
  107313. /**
  107314. * This groups all the flags used to control the materials channel.
  107315. */
  107316. export class MaterialFlags {
  107317. private static _DiffuseTextureEnabled;
  107318. /**
  107319. * Are diffuse textures enabled in the application.
  107320. */
  107321. static DiffuseTextureEnabled: boolean;
  107322. private static _AmbientTextureEnabled;
  107323. /**
  107324. * Are ambient textures enabled in the application.
  107325. */
  107326. static AmbientTextureEnabled: boolean;
  107327. private static _OpacityTextureEnabled;
  107328. /**
  107329. * Are opacity textures enabled in the application.
  107330. */
  107331. static OpacityTextureEnabled: boolean;
  107332. private static _ReflectionTextureEnabled;
  107333. /**
  107334. * Are reflection textures enabled in the application.
  107335. */
  107336. static ReflectionTextureEnabled: boolean;
  107337. private static _EmissiveTextureEnabled;
  107338. /**
  107339. * Are emissive textures enabled in the application.
  107340. */
  107341. static EmissiveTextureEnabled: boolean;
  107342. private static _SpecularTextureEnabled;
  107343. /**
  107344. * Are specular textures enabled in the application.
  107345. */
  107346. static SpecularTextureEnabled: boolean;
  107347. private static _BumpTextureEnabled;
  107348. /**
  107349. * Are bump textures enabled in the application.
  107350. */
  107351. static BumpTextureEnabled: boolean;
  107352. private static _LightmapTextureEnabled;
  107353. /**
  107354. * Are lightmap textures enabled in the application.
  107355. */
  107356. static LightmapTextureEnabled: boolean;
  107357. private static _RefractionTextureEnabled;
  107358. /**
  107359. * Are refraction textures enabled in the application.
  107360. */
  107361. static RefractionTextureEnabled: boolean;
  107362. private static _ColorGradingTextureEnabled;
  107363. /**
  107364. * Are color grading textures enabled in the application.
  107365. */
  107366. static ColorGradingTextureEnabled: boolean;
  107367. private static _FresnelEnabled;
  107368. /**
  107369. * Are fresnels enabled in the application.
  107370. */
  107371. static FresnelEnabled: boolean;
  107372. private static _ClearCoatTextureEnabled;
  107373. /**
  107374. * Are clear coat textures enabled in the application.
  107375. */
  107376. static ClearCoatTextureEnabled: boolean;
  107377. private static _ClearCoatBumpTextureEnabled;
  107378. /**
  107379. * Are clear coat bump textures enabled in the application.
  107380. */
  107381. static ClearCoatBumpTextureEnabled: boolean;
  107382. private static _ClearCoatTintTextureEnabled;
  107383. /**
  107384. * Are clear coat tint textures enabled in the application.
  107385. */
  107386. static ClearCoatTintTextureEnabled: boolean;
  107387. private static _SheenTextureEnabled;
  107388. /**
  107389. * Are sheen textures enabled in the application.
  107390. */
  107391. static SheenTextureEnabled: boolean;
  107392. private static _AnisotropicTextureEnabled;
  107393. /**
  107394. * Are anisotropic textures enabled in the application.
  107395. */
  107396. static AnisotropicTextureEnabled: boolean;
  107397. private static _ThicknessTextureEnabled;
  107398. /**
  107399. * Are thickness textures enabled in the application.
  107400. */
  107401. static ThicknessTextureEnabled: boolean;
  107402. }
  107403. }
  107404. declare module BABYLON {
  107405. /** @hidden */
  107406. export var defaultFragmentDeclaration: {
  107407. name: string;
  107408. shader: string;
  107409. };
  107410. }
  107411. declare module BABYLON {
  107412. /** @hidden */
  107413. export var defaultUboDeclaration: {
  107414. name: string;
  107415. shader: string;
  107416. };
  107417. }
  107418. declare module BABYLON {
  107419. /** @hidden */
  107420. export var lightFragmentDeclaration: {
  107421. name: string;
  107422. shader: string;
  107423. };
  107424. }
  107425. declare module BABYLON {
  107426. /** @hidden */
  107427. export var lightUboDeclaration: {
  107428. name: string;
  107429. shader: string;
  107430. };
  107431. }
  107432. declare module BABYLON {
  107433. /** @hidden */
  107434. export var lightsFragmentFunctions: {
  107435. name: string;
  107436. shader: string;
  107437. };
  107438. }
  107439. declare module BABYLON {
  107440. /** @hidden */
  107441. export var shadowsFragmentFunctions: {
  107442. name: string;
  107443. shader: string;
  107444. };
  107445. }
  107446. declare module BABYLON {
  107447. /** @hidden */
  107448. export var fresnelFunction: {
  107449. name: string;
  107450. shader: string;
  107451. };
  107452. }
  107453. declare module BABYLON {
  107454. /** @hidden */
  107455. export var reflectionFunction: {
  107456. name: string;
  107457. shader: string;
  107458. };
  107459. }
  107460. declare module BABYLON {
  107461. /** @hidden */
  107462. export var bumpFragmentFunctions: {
  107463. name: string;
  107464. shader: string;
  107465. };
  107466. }
  107467. declare module BABYLON {
  107468. /** @hidden */
  107469. export var logDepthDeclaration: {
  107470. name: string;
  107471. shader: string;
  107472. };
  107473. }
  107474. declare module BABYLON {
  107475. /** @hidden */
  107476. export var bumpFragment: {
  107477. name: string;
  107478. shader: string;
  107479. };
  107480. }
  107481. declare module BABYLON {
  107482. /** @hidden */
  107483. export var depthPrePass: {
  107484. name: string;
  107485. shader: string;
  107486. };
  107487. }
  107488. declare module BABYLON {
  107489. /** @hidden */
  107490. export var lightFragment: {
  107491. name: string;
  107492. shader: string;
  107493. };
  107494. }
  107495. declare module BABYLON {
  107496. /** @hidden */
  107497. export var logDepthFragment: {
  107498. name: string;
  107499. shader: string;
  107500. };
  107501. }
  107502. declare module BABYLON {
  107503. /** @hidden */
  107504. export var defaultPixelShader: {
  107505. name: string;
  107506. shader: string;
  107507. };
  107508. }
  107509. declare module BABYLON {
  107510. /** @hidden */
  107511. export var defaultVertexDeclaration: {
  107512. name: string;
  107513. shader: string;
  107514. };
  107515. }
  107516. declare module BABYLON {
  107517. /** @hidden */
  107518. export var bumpVertexDeclaration: {
  107519. name: string;
  107520. shader: string;
  107521. };
  107522. }
  107523. declare module BABYLON {
  107524. /** @hidden */
  107525. export var bumpVertex: {
  107526. name: string;
  107527. shader: string;
  107528. };
  107529. }
  107530. declare module BABYLON {
  107531. /** @hidden */
  107532. export var fogVertex: {
  107533. name: string;
  107534. shader: string;
  107535. };
  107536. }
  107537. declare module BABYLON {
  107538. /** @hidden */
  107539. export var shadowsVertex: {
  107540. name: string;
  107541. shader: string;
  107542. };
  107543. }
  107544. declare module BABYLON {
  107545. /** @hidden */
  107546. export var pointCloudVertex: {
  107547. name: string;
  107548. shader: string;
  107549. };
  107550. }
  107551. declare module BABYLON {
  107552. /** @hidden */
  107553. export var logDepthVertex: {
  107554. name: string;
  107555. shader: string;
  107556. };
  107557. }
  107558. declare module BABYLON {
  107559. /** @hidden */
  107560. export var defaultVertexShader: {
  107561. name: string;
  107562. shader: string;
  107563. };
  107564. }
  107565. declare module BABYLON {
  107566. /** @hidden */
  107567. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  107568. MAINUV1: boolean;
  107569. MAINUV2: boolean;
  107570. DIFFUSE: boolean;
  107571. DIFFUSEDIRECTUV: number;
  107572. AMBIENT: boolean;
  107573. AMBIENTDIRECTUV: number;
  107574. OPACITY: boolean;
  107575. OPACITYDIRECTUV: number;
  107576. OPACITYRGB: boolean;
  107577. REFLECTION: boolean;
  107578. EMISSIVE: boolean;
  107579. EMISSIVEDIRECTUV: number;
  107580. SPECULAR: boolean;
  107581. SPECULARDIRECTUV: number;
  107582. BUMP: boolean;
  107583. BUMPDIRECTUV: number;
  107584. PARALLAX: boolean;
  107585. PARALLAXOCCLUSION: boolean;
  107586. SPECULAROVERALPHA: boolean;
  107587. CLIPPLANE: boolean;
  107588. CLIPPLANE2: boolean;
  107589. CLIPPLANE3: boolean;
  107590. CLIPPLANE4: boolean;
  107591. ALPHATEST: boolean;
  107592. DEPTHPREPASS: boolean;
  107593. ALPHAFROMDIFFUSE: boolean;
  107594. POINTSIZE: boolean;
  107595. FOG: boolean;
  107596. SPECULARTERM: boolean;
  107597. DIFFUSEFRESNEL: boolean;
  107598. OPACITYFRESNEL: boolean;
  107599. REFLECTIONFRESNEL: boolean;
  107600. REFRACTIONFRESNEL: boolean;
  107601. EMISSIVEFRESNEL: boolean;
  107602. FRESNEL: boolean;
  107603. NORMAL: boolean;
  107604. UV1: boolean;
  107605. UV2: boolean;
  107606. VERTEXCOLOR: boolean;
  107607. VERTEXALPHA: boolean;
  107608. NUM_BONE_INFLUENCERS: number;
  107609. BonesPerMesh: number;
  107610. BONETEXTURE: boolean;
  107611. INSTANCES: boolean;
  107612. GLOSSINESS: boolean;
  107613. ROUGHNESS: boolean;
  107614. EMISSIVEASILLUMINATION: boolean;
  107615. LINKEMISSIVEWITHDIFFUSE: boolean;
  107616. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107617. LIGHTMAP: boolean;
  107618. LIGHTMAPDIRECTUV: number;
  107619. OBJECTSPACE_NORMALMAP: boolean;
  107620. USELIGHTMAPASSHADOWMAP: boolean;
  107621. REFLECTIONMAP_3D: boolean;
  107622. REFLECTIONMAP_SPHERICAL: boolean;
  107623. REFLECTIONMAP_PLANAR: boolean;
  107624. REFLECTIONMAP_CUBIC: boolean;
  107625. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107626. REFLECTIONMAP_PROJECTION: boolean;
  107627. REFLECTIONMAP_SKYBOX: boolean;
  107628. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107629. REFLECTIONMAP_EXPLICIT: boolean;
  107630. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107631. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107632. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107633. INVERTCUBICMAP: boolean;
  107634. LOGARITHMICDEPTH: boolean;
  107635. REFRACTION: boolean;
  107636. REFRACTIONMAP_3D: boolean;
  107637. REFLECTIONOVERALPHA: boolean;
  107638. TWOSIDEDLIGHTING: boolean;
  107639. SHADOWFLOAT: boolean;
  107640. MORPHTARGETS: boolean;
  107641. MORPHTARGETS_NORMAL: boolean;
  107642. MORPHTARGETS_TANGENT: boolean;
  107643. MORPHTARGETS_UV: boolean;
  107644. NUM_MORPH_INFLUENCERS: number;
  107645. NONUNIFORMSCALING: boolean;
  107646. PREMULTIPLYALPHA: boolean;
  107647. IMAGEPROCESSING: boolean;
  107648. VIGNETTE: boolean;
  107649. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107650. VIGNETTEBLENDMODEOPAQUE: boolean;
  107651. TONEMAPPING: boolean;
  107652. TONEMAPPING_ACES: boolean;
  107653. CONTRAST: boolean;
  107654. COLORCURVES: boolean;
  107655. COLORGRADING: boolean;
  107656. COLORGRADING3D: boolean;
  107657. SAMPLER3DGREENDEPTH: boolean;
  107658. SAMPLER3DBGRMAP: boolean;
  107659. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107660. MULTIVIEW: boolean;
  107661. /**
  107662. * If the reflection texture on this material is in linear color space
  107663. * @hidden
  107664. */
  107665. IS_REFLECTION_LINEAR: boolean;
  107666. /**
  107667. * If the refraction texture on this material is in linear color space
  107668. * @hidden
  107669. */
  107670. IS_REFRACTION_LINEAR: boolean;
  107671. EXPOSURE: boolean;
  107672. constructor();
  107673. setReflectionMode(modeToEnable: string): void;
  107674. }
  107675. /**
  107676. * This is the default material used in Babylon. It is the best trade off between quality
  107677. * and performances.
  107678. * @see http://doc.babylonjs.com/babylon101/materials
  107679. */
  107680. export class StandardMaterial extends PushMaterial {
  107681. private _diffuseTexture;
  107682. /**
  107683. * The basic texture of the material as viewed under a light.
  107684. */
  107685. diffuseTexture: Nullable<BaseTexture>;
  107686. private _ambientTexture;
  107687. /**
  107688. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107689. */
  107690. ambientTexture: Nullable<BaseTexture>;
  107691. private _opacityTexture;
  107692. /**
  107693. * Define the transparency of the material from a texture.
  107694. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107695. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107696. */
  107697. opacityTexture: Nullable<BaseTexture>;
  107698. private _reflectionTexture;
  107699. /**
  107700. * Define the texture used to display the reflection.
  107701. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107702. */
  107703. reflectionTexture: Nullable<BaseTexture>;
  107704. private _emissiveTexture;
  107705. /**
  107706. * Define texture of the material as if self lit.
  107707. * This will be mixed in the final result even in the absence of light.
  107708. */
  107709. emissiveTexture: Nullable<BaseTexture>;
  107710. private _specularTexture;
  107711. /**
  107712. * Define how the color and intensity of the highlight given by the light in the material.
  107713. */
  107714. specularTexture: Nullable<BaseTexture>;
  107715. private _bumpTexture;
  107716. /**
  107717. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107718. * 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.
  107719. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107720. */
  107721. bumpTexture: Nullable<BaseTexture>;
  107722. private _lightmapTexture;
  107723. /**
  107724. * Complex lighting can be computationally expensive to compute at runtime.
  107725. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107726. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107727. */
  107728. lightmapTexture: Nullable<BaseTexture>;
  107729. private _refractionTexture;
  107730. /**
  107731. * Define the texture used to display the refraction.
  107732. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107733. */
  107734. refractionTexture: Nullable<BaseTexture>;
  107735. /**
  107736. * The color of the material lit by the environmental background lighting.
  107737. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107738. */
  107739. ambientColor: Color3;
  107740. /**
  107741. * The basic color of the material as viewed under a light.
  107742. */
  107743. diffuseColor: Color3;
  107744. /**
  107745. * Define how the color and intensity of the highlight given by the light in the material.
  107746. */
  107747. specularColor: Color3;
  107748. /**
  107749. * Define the color of the material as if self lit.
  107750. * This will be mixed in the final result even in the absence of light.
  107751. */
  107752. emissiveColor: Color3;
  107753. /**
  107754. * Defines how sharp are the highlights in the material.
  107755. * The bigger the value the sharper giving a more glossy feeling to the result.
  107756. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107757. */
  107758. specularPower: number;
  107759. private _useAlphaFromDiffuseTexture;
  107760. /**
  107761. * Does the transparency come from the diffuse texture alpha channel.
  107762. */
  107763. useAlphaFromDiffuseTexture: boolean;
  107764. private _useEmissiveAsIllumination;
  107765. /**
  107766. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107767. */
  107768. useEmissiveAsIllumination: boolean;
  107769. private _linkEmissiveWithDiffuse;
  107770. /**
  107771. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107772. * the emissive level when the final color is close to one.
  107773. */
  107774. linkEmissiveWithDiffuse: boolean;
  107775. private _useSpecularOverAlpha;
  107776. /**
  107777. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107778. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107779. */
  107780. useSpecularOverAlpha: boolean;
  107781. private _useReflectionOverAlpha;
  107782. /**
  107783. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107784. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107785. */
  107786. useReflectionOverAlpha: boolean;
  107787. private _disableLighting;
  107788. /**
  107789. * Does lights from the scene impacts this material.
  107790. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107791. */
  107792. disableLighting: boolean;
  107793. private _useObjectSpaceNormalMap;
  107794. /**
  107795. * Allows using an object space normal map (instead of tangent space).
  107796. */
  107797. useObjectSpaceNormalMap: boolean;
  107798. private _useParallax;
  107799. /**
  107800. * Is parallax enabled or not.
  107801. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107802. */
  107803. useParallax: boolean;
  107804. private _useParallaxOcclusion;
  107805. /**
  107806. * Is parallax occlusion enabled or not.
  107807. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107808. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107809. */
  107810. useParallaxOcclusion: boolean;
  107811. /**
  107812. * 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.
  107813. */
  107814. parallaxScaleBias: number;
  107815. private _roughness;
  107816. /**
  107817. * Helps to define how blurry the reflections should appears in the material.
  107818. */
  107819. roughness: number;
  107820. /**
  107821. * In case of refraction, define the value of the index of refraction.
  107822. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107823. */
  107824. indexOfRefraction: number;
  107825. /**
  107826. * Invert the refraction texture alongside the y axis.
  107827. * It can be useful with procedural textures or probe for instance.
  107828. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107829. */
  107830. invertRefractionY: boolean;
  107831. /**
  107832. * Defines the alpha limits in alpha test mode.
  107833. */
  107834. alphaCutOff: number;
  107835. private _useLightmapAsShadowmap;
  107836. /**
  107837. * In case of light mapping, define whether the map contains light or shadow informations.
  107838. */
  107839. useLightmapAsShadowmap: boolean;
  107840. private _diffuseFresnelParameters;
  107841. /**
  107842. * Define the diffuse fresnel parameters of the material.
  107843. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107844. */
  107845. diffuseFresnelParameters: FresnelParameters;
  107846. private _opacityFresnelParameters;
  107847. /**
  107848. * Define the opacity fresnel parameters of the material.
  107849. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107850. */
  107851. opacityFresnelParameters: FresnelParameters;
  107852. private _reflectionFresnelParameters;
  107853. /**
  107854. * Define the reflection fresnel parameters of the material.
  107855. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107856. */
  107857. reflectionFresnelParameters: FresnelParameters;
  107858. private _refractionFresnelParameters;
  107859. /**
  107860. * Define the refraction fresnel parameters of the material.
  107861. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107862. */
  107863. refractionFresnelParameters: FresnelParameters;
  107864. private _emissiveFresnelParameters;
  107865. /**
  107866. * Define the emissive fresnel parameters of the material.
  107867. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107868. */
  107869. emissiveFresnelParameters: FresnelParameters;
  107870. private _useReflectionFresnelFromSpecular;
  107871. /**
  107872. * If true automatically deducts the fresnels values from the material specularity.
  107873. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107874. */
  107875. useReflectionFresnelFromSpecular: boolean;
  107876. private _useGlossinessFromSpecularMapAlpha;
  107877. /**
  107878. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107879. */
  107880. useGlossinessFromSpecularMapAlpha: boolean;
  107881. private _maxSimultaneousLights;
  107882. /**
  107883. * Defines the maximum number of lights that can be used in the material
  107884. */
  107885. maxSimultaneousLights: number;
  107886. private _invertNormalMapX;
  107887. /**
  107888. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107889. */
  107890. invertNormalMapX: boolean;
  107891. private _invertNormalMapY;
  107892. /**
  107893. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107894. */
  107895. invertNormalMapY: boolean;
  107896. private _twoSidedLighting;
  107897. /**
  107898. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107899. */
  107900. twoSidedLighting: boolean;
  107901. /**
  107902. * Default configuration related to image processing available in the standard Material.
  107903. */
  107904. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107905. /**
  107906. * Gets the image processing configuration used either in this material.
  107907. */
  107908. /**
  107909. * Sets the Default image processing configuration used either in the this material.
  107910. *
  107911. * If sets to null, the scene one is in use.
  107912. */
  107913. imageProcessingConfiguration: ImageProcessingConfiguration;
  107914. /**
  107915. * Keep track of the image processing observer to allow dispose and replace.
  107916. */
  107917. private _imageProcessingObserver;
  107918. /**
  107919. * Attaches a new image processing configuration to the Standard Material.
  107920. * @param configuration
  107921. */
  107922. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107923. /**
  107924. * Gets wether the color curves effect is enabled.
  107925. */
  107926. /**
  107927. * Sets wether the color curves effect is enabled.
  107928. */
  107929. cameraColorCurvesEnabled: boolean;
  107930. /**
  107931. * Gets wether the color grading effect is enabled.
  107932. */
  107933. /**
  107934. * Gets wether the color grading effect is enabled.
  107935. */
  107936. cameraColorGradingEnabled: boolean;
  107937. /**
  107938. * Gets wether tonemapping is enabled or not.
  107939. */
  107940. /**
  107941. * Sets wether tonemapping is enabled or not
  107942. */
  107943. cameraToneMappingEnabled: boolean;
  107944. /**
  107945. * The camera exposure used on this material.
  107946. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107947. * This corresponds to a photographic exposure.
  107948. */
  107949. /**
  107950. * The camera exposure used on this material.
  107951. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107952. * This corresponds to a photographic exposure.
  107953. */
  107954. cameraExposure: number;
  107955. /**
  107956. * Gets The camera contrast used on this material.
  107957. */
  107958. /**
  107959. * Sets The camera contrast used on this material.
  107960. */
  107961. cameraContrast: number;
  107962. /**
  107963. * Gets the Color Grading 2D Lookup Texture.
  107964. */
  107965. /**
  107966. * Sets the Color Grading 2D Lookup Texture.
  107967. */
  107968. cameraColorGradingTexture: Nullable<BaseTexture>;
  107969. /**
  107970. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107971. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107972. * 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;
  107973. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107974. */
  107975. /**
  107976. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107977. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107978. * 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;
  107979. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107980. */
  107981. cameraColorCurves: Nullable<ColorCurves>;
  107982. /**
  107983. * Custom callback helping to override the default shader used in the material.
  107984. */
  107985. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107986. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107987. protected _worldViewProjectionMatrix: Matrix;
  107988. protected _globalAmbientColor: Color3;
  107989. protected _useLogarithmicDepth: boolean;
  107990. protected _rebuildInParallel: boolean;
  107991. /**
  107992. * Instantiates a new standard material.
  107993. * This is the default material used in Babylon. It is the best trade off between quality
  107994. * and performances.
  107995. * @see http://doc.babylonjs.com/babylon101/materials
  107996. * @param name Define the name of the material in the scene
  107997. * @param scene Define the scene the material belong to
  107998. */
  107999. constructor(name: string, scene: Scene);
  108000. /**
  108001. * Gets a boolean indicating that current material needs to register RTT
  108002. */
  108003. readonly hasRenderTargetTextures: boolean;
  108004. /**
  108005. * Gets the current class name of the material e.g. "StandardMaterial"
  108006. * Mainly use in serialization.
  108007. * @returns the class name
  108008. */
  108009. getClassName(): string;
  108010. /**
  108011. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108012. * You can try switching to logarithmic depth.
  108013. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108014. */
  108015. useLogarithmicDepth: boolean;
  108016. /**
  108017. * Specifies if the material will require alpha blending
  108018. * @returns a boolean specifying if alpha blending is needed
  108019. */
  108020. needAlphaBlending(): boolean;
  108021. /**
  108022. * Specifies if this material should be rendered in alpha test mode
  108023. * @returns a boolean specifying if an alpha test is needed.
  108024. */
  108025. needAlphaTesting(): boolean;
  108026. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108027. /**
  108028. * Get the texture used for alpha test purpose.
  108029. * @returns the diffuse texture in case of the standard material.
  108030. */
  108031. getAlphaTestTexture(): Nullable<BaseTexture>;
  108032. /**
  108033. * Get if the submesh is ready to be used and all its information available.
  108034. * Child classes can use it to update shaders
  108035. * @param mesh defines the mesh to check
  108036. * @param subMesh defines which submesh to check
  108037. * @param useInstances specifies that instances should be used
  108038. * @returns a boolean indicating that the submesh is ready or not
  108039. */
  108040. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108041. /**
  108042. * Builds the material UBO layouts.
  108043. * Used internally during the effect preparation.
  108044. */
  108045. buildUniformLayout(): void;
  108046. /**
  108047. * Unbinds the material from the mesh
  108048. */
  108049. unbind(): void;
  108050. /**
  108051. * Binds the submesh to this material by preparing the effect and shader to draw
  108052. * @param world defines the world transformation matrix
  108053. * @param mesh defines the mesh containing the submesh
  108054. * @param subMesh defines the submesh to bind the material to
  108055. */
  108056. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108057. /**
  108058. * Get the list of animatables in the material.
  108059. * @returns the list of animatables object used in the material
  108060. */
  108061. getAnimatables(): IAnimatable[];
  108062. /**
  108063. * Gets the active textures from the material
  108064. * @returns an array of textures
  108065. */
  108066. getActiveTextures(): BaseTexture[];
  108067. /**
  108068. * Specifies if the material uses a texture
  108069. * @param texture defines the texture to check against the material
  108070. * @returns a boolean specifying if the material uses the texture
  108071. */
  108072. hasTexture(texture: BaseTexture): boolean;
  108073. /**
  108074. * Disposes the material
  108075. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108076. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108077. */
  108078. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108079. /**
  108080. * Makes a duplicate of the material, and gives it a new name
  108081. * @param name defines the new name for the duplicated material
  108082. * @returns the cloned material
  108083. */
  108084. clone(name: string): StandardMaterial;
  108085. /**
  108086. * Serializes this material in a JSON representation
  108087. * @returns the serialized material object
  108088. */
  108089. serialize(): any;
  108090. /**
  108091. * Creates a standard material from parsed material data
  108092. * @param source defines the JSON representation of the material
  108093. * @param scene defines the hosting scene
  108094. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108095. * @returns a new standard material
  108096. */
  108097. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108098. /**
  108099. * Are diffuse textures enabled in the application.
  108100. */
  108101. static DiffuseTextureEnabled: boolean;
  108102. /**
  108103. * Are ambient textures enabled in the application.
  108104. */
  108105. static AmbientTextureEnabled: boolean;
  108106. /**
  108107. * Are opacity textures enabled in the application.
  108108. */
  108109. static OpacityTextureEnabled: boolean;
  108110. /**
  108111. * Are reflection textures enabled in the application.
  108112. */
  108113. static ReflectionTextureEnabled: boolean;
  108114. /**
  108115. * Are emissive textures enabled in the application.
  108116. */
  108117. static EmissiveTextureEnabled: boolean;
  108118. /**
  108119. * Are specular textures enabled in the application.
  108120. */
  108121. static SpecularTextureEnabled: boolean;
  108122. /**
  108123. * Are bump textures enabled in the application.
  108124. */
  108125. static BumpTextureEnabled: boolean;
  108126. /**
  108127. * Are lightmap textures enabled in the application.
  108128. */
  108129. static LightmapTextureEnabled: boolean;
  108130. /**
  108131. * Are refraction textures enabled in the application.
  108132. */
  108133. static RefractionTextureEnabled: boolean;
  108134. /**
  108135. * Are color grading textures enabled in the application.
  108136. */
  108137. static ColorGradingTextureEnabled: boolean;
  108138. /**
  108139. * Are fresnels enabled in the application.
  108140. */
  108141. static FresnelEnabled: boolean;
  108142. }
  108143. }
  108144. declare module BABYLON {
  108145. /** @hidden */
  108146. export var imageProcessingPixelShader: {
  108147. name: string;
  108148. shader: string;
  108149. };
  108150. }
  108151. declare module BABYLON {
  108152. /**
  108153. * ImageProcessingPostProcess
  108154. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  108155. */
  108156. export class ImageProcessingPostProcess extends PostProcess {
  108157. /**
  108158. * Default configuration related to image processing available in the PBR Material.
  108159. */
  108160. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108161. /**
  108162. * Gets the image processing configuration used either in this material.
  108163. */
  108164. /**
  108165. * Sets the Default image processing configuration used either in the this material.
  108166. *
  108167. * If sets to null, the scene one is in use.
  108168. */
  108169. imageProcessingConfiguration: ImageProcessingConfiguration;
  108170. /**
  108171. * Keep track of the image processing observer to allow dispose and replace.
  108172. */
  108173. private _imageProcessingObserver;
  108174. /**
  108175. * Attaches a new image processing configuration to the PBR Material.
  108176. * @param configuration
  108177. */
  108178. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  108179. /**
  108180. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108181. */
  108182. /**
  108183. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108184. */
  108185. colorCurves: Nullable<ColorCurves>;
  108186. /**
  108187. * Gets wether the color curves effect is enabled.
  108188. */
  108189. /**
  108190. * Sets wether the color curves effect is enabled.
  108191. */
  108192. colorCurvesEnabled: boolean;
  108193. /**
  108194. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108195. */
  108196. /**
  108197. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108198. */
  108199. colorGradingTexture: Nullable<BaseTexture>;
  108200. /**
  108201. * Gets wether the color grading effect is enabled.
  108202. */
  108203. /**
  108204. * Gets wether the color grading effect is enabled.
  108205. */
  108206. colorGradingEnabled: boolean;
  108207. /**
  108208. * Gets exposure used in the effect.
  108209. */
  108210. /**
  108211. * Sets exposure used in the effect.
  108212. */
  108213. exposure: number;
  108214. /**
  108215. * Gets wether tonemapping is enabled or not.
  108216. */
  108217. /**
  108218. * Sets wether tonemapping is enabled or not
  108219. */
  108220. toneMappingEnabled: boolean;
  108221. /**
  108222. * Gets the type of tone mapping effect.
  108223. */
  108224. /**
  108225. * Sets the type of tone mapping effect.
  108226. */
  108227. toneMappingType: number;
  108228. /**
  108229. * Gets contrast used in the effect.
  108230. */
  108231. /**
  108232. * Sets contrast used in the effect.
  108233. */
  108234. contrast: number;
  108235. /**
  108236. * Gets Vignette stretch size.
  108237. */
  108238. /**
  108239. * Sets Vignette stretch size.
  108240. */
  108241. vignetteStretch: number;
  108242. /**
  108243. * Gets Vignette centre X Offset.
  108244. */
  108245. /**
  108246. * Sets Vignette centre X Offset.
  108247. */
  108248. vignetteCentreX: number;
  108249. /**
  108250. * Gets Vignette centre Y Offset.
  108251. */
  108252. /**
  108253. * Sets Vignette centre Y Offset.
  108254. */
  108255. vignetteCentreY: number;
  108256. /**
  108257. * Gets Vignette weight or intensity of the vignette effect.
  108258. */
  108259. /**
  108260. * Sets Vignette weight or intensity of the vignette effect.
  108261. */
  108262. vignetteWeight: number;
  108263. /**
  108264. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108265. * if vignetteEnabled is set to true.
  108266. */
  108267. /**
  108268. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108269. * if vignetteEnabled is set to true.
  108270. */
  108271. vignetteColor: Color4;
  108272. /**
  108273. * Gets Camera field of view used by the Vignette effect.
  108274. */
  108275. /**
  108276. * Sets Camera field of view used by the Vignette effect.
  108277. */
  108278. vignetteCameraFov: number;
  108279. /**
  108280. * Gets the vignette blend mode allowing different kind of effect.
  108281. */
  108282. /**
  108283. * Sets the vignette blend mode allowing different kind of effect.
  108284. */
  108285. vignetteBlendMode: number;
  108286. /**
  108287. * Gets wether the vignette effect is enabled.
  108288. */
  108289. /**
  108290. * Sets wether the vignette effect is enabled.
  108291. */
  108292. vignetteEnabled: boolean;
  108293. private _fromLinearSpace;
  108294. /**
  108295. * Gets wether the input of the processing is in Gamma or Linear Space.
  108296. */
  108297. /**
  108298. * Sets wether the input of the processing is in Gamma or Linear Space.
  108299. */
  108300. fromLinearSpace: boolean;
  108301. /**
  108302. * Defines cache preventing GC.
  108303. */
  108304. private _defines;
  108305. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  108306. /**
  108307. * "ImageProcessingPostProcess"
  108308. * @returns "ImageProcessingPostProcess"
  108309. */
  108310. getClassName(): string;
  108311. protected _updateParameters(): void;
  108312. dispose(camera?: Camera): void;
  108313. }
  108314. }
  108315. declare module BABYLON {
  108316. /**
  108317. * Class containing static functions to help procedurally build meshes
  108318. */
  108319. export class GroundBuilder {
  108320. /**
  108321. * Creates a ground mesh
  108322. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  108323. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  108324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108325. * @param name defines the name of the mesh
  108326. * @param options defines the options used to create the mesh
  108327. * @param scene defines the hosting scene
  108328. * @returns the ground mesh
  108329. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  108330. */
  108331. static CreateGround(name: string, options: {
  108332. width?: number;
  108333. height?: number;
  108334. subdivisions?: number;
  108335. subdivisionsX?: number;
  108336. subdivisionsY?: number;
  108337. updatable?: boolean;
  108338. }, scene: any): Mesh;
  108339. /**
  108340. * Creates a tiled ground mesh
  108341. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  108342. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  108343. * * 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
  108344. * * 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
  108345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108346. * @param name defines the name of the mesh
  108347. * @param options defines the options used to create the mesh
  108348. * @param scene defines the hosting scene
  108349. * @returns the tiled ground mesh
  108350. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  108351. */
  108352. static CreateTiledGround(name: string, options: {
  108353. xmin: number;
  108354. zmin: number;
  108355. xmax: number;
  108356. zmax: number;
  108357. subdivisions?: {
  108358. w: number;
  108359. h: number;
  108360. };
  108361. precision?: {
  108362. w: number;
  108363. h: number;
  108364. };
  108365. updatable?: boolean;
  108366. }, scene?: Nullable<Scene>): Mesh;
  108367. /**
  108368. * Creates a ground mesh from a height map
  108369. * * The parameter `url` sets the URL of the height map image resource.
  108370. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  108371. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  108372. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  108373. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  108374. * * 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.
  108375. * * 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).
  108376. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108378. * @param name defines the name of the mesh
  108379. * @param url defines the url to the height map
  108380. * @param options defines the options used to create the mesh
  108381. * @param scene defines the hosting scene
  108382. * @returns the ground mesh
  108383. * @see https://doc.babylonjs.com/babylon101/height_map
  108384. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  108385. */
  108386. static CreateGroundFromHeightMap(name: string, url: string, options: {
  108387. width?: number;
  108388. height?: number;
  108389. subdivisions?: number;
  108390. minHeight?: number;
  108391. maxHeight?: number;
  108392. colorFilter?: Color3;
  108393. alphaFilter?: number;
  108394. updatable?: boolean;
  108395. onReady?: (mesh: GroundMesh) => void;
  108396. }, scene?: Nullable<Scene>): GroundMesh;
  108397. }
  108398. }
  108399. declare module BABYLON {
  108400. /**
  108401. * Class containing static functions to help procedurally build meshes
  108402. */
  108403. export class TorusBuilder {
  108404. /**
  108405. * Creates a torus mesh
  108406. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  108407. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  108408. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  108409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108412. * @param name defines the name of the mesh
  108413. * @param options defines the options used to create the mesh
  108414. * @param scene defines the hosting scene
  108415. * @returns the torus mesh
  108416. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  108417. */
  108418. static CreateTorus(name: string, options: {
  108419. diameter?: number;
  108420. thickness?: number;
  108421. tessellation?: number;
  108422. updatable?: boolean;
  108423. sideOrientation?: number;
  108424. frontUVs?: Vector4;
  108425. backUVs?: Vector4;
  108426. }, scene: any): Mesh;
  108427. }
  108428. }
  108429. declare module BABYLON {
  108430. /**
  108431. * Class containing static functions to help procedurally build meshes
  108432. */
  108433. export class CylinderBuilder {
  108434. /**
  108435. * Creates a cylinder or a cone mesh
  108436. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  108437. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  108438. * * 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.
  108439. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  108440. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  108441. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  108442. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  108443. * * 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).
  108444. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  108445. * * 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).
  108446. * * 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
  108447. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  108448. * * 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
  108449. * * 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.
  108450. * * If `enclose` is false, a ring surface is one element.
  108451. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  108452. * * 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
  108453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108456. * @param name defines the name of the mesh
  108457. * @param options defines the options used to create the mesh
  108458. * @param scene defines the hosting scene
  108459. * @returns the cylinder mesh
  108460. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  108461. */
  108462. static CreateCylinder(name: string, options: {
  108463. height?: number;
  108464. diameterTop?: number;
  108465. diameterBottom?: number;
  108466. diameter?: number;
  108467. tessellation?: number;
  108468. subdivisions?: number;
  108469. arc?: number;
  108470. faceColors?: Color4[];
  108471. faceUV?: Vector4[];
  108472. updatable?: boolean;
  108473. hasRings?: boolean;
  108474. enclose?: boolean;
  108475. cap?: number;
  108476. sideOrientation?: number;
  108477. frontUVs?: Vector4;
  108478. backUVs?: Vector4;
  108479. }, scene: any): Mesh;
  108480. }
  108481. }
  108482. declare module BABYLON {
  108483. /**
  108484. * Options to modify the vr teleportation behavior.
  108485. */
  108486. export interface VRTeleportationOptions {
  108487. /**
  108488. * The name of the mesh which should be used as the teleportation floor. (default: null)
  108489. */
  108490. floorMeshName?: string;
  108491. /**
  108492. * A list of meshes to be used as the teleportation floor. (default: empty)
  108493. */
  108494. floorMeshes?: Mesh[];
  108495. }
  108496. /**
  108497. * Options to modify the vr experience helper's behavior.
  108498. */
  108499. export interface VRExperienceHelperOptions extends WebVROptions {
  108500. /**
  108501. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  108502. */
  108503. createDeviceOrientationCamera?: boolean;
  108504. /**
  108505. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  108506. */
  108507. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  108508. /**
  108509. * Uses the main button on the controller to toggle the laser casted. (default: true)
  108510. */
  108511. laserToggle?: boolean;
  108512. /**
  108513. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  108514. */
  108515. floorMeshes?: Mesh[];
  108516. /**
  108517. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  108518. */
  108519. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  108520. }
  108521. /**
  108522. * Event containing information after VR has been entered
  108523. */
  108524. export class OnAfterEnteringVRObservableEvent {
  108525. /**
  108526. * If entering vr was successful
  108527. */
  108528. success: boolean;
  108529. }
  108530. /**
  108531. * Helps to quickly add VR support to an existing scene.
  108532. * See http://doc.babylonjs.com/how_to/webvr_helper
  108533. */
  108534. export class VRExperienceHelper {
  108535. /** Options to modify the vr experience helper's behavior. */
  108536. webVROptions: VRExperienceHelperOptions;
  108537. private _scene;
  108538. private _position;
  108539. private _btnVR;
  108540. private _btnVRDisplayed;
  108541. private _webVRsupported;
  108542. private _webVRready;
  108543. private _webVRrequesting;
  108544. private _webVRpresenting;
  108545. private _hasEnteredVR;
  108546. private _fullscreenVRpresenting;
  108547. private _canvas;
  108548. private _webVRCamera;
  108549. private _vrDeviceOrientationCamera;
  108550. private _deviceOrientationCamera;
  108551. private _existingCamera;
  108552. private _onKeyDown;
  108553. private _onVrDisplayPresentChange;
  108554. private _onVRDisplayChanged;
  108555. private _onVRRequestPresentStart;
  108556. private _onVRRequestPresentComplete;
  108557. /**
  108558. * 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)
  108559. */
  108560. enableGazeEvenWhenNoPointerLock: boolean;
  108561. /**
  108562. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  108563. */
  108564. exitVROnDoubleTap: boolean;
  108565. /**
  108566. * Observable raised right before entering VR.
  108567. */
  108568. onEnteringVRObservable: Observable<VRExperienceHelper>;
  108569. /**
  108570. * Observable raised when entering VR has completed.
  108571. */
  108572. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  108573. /**
  108574. * Observable raised when exiting VR.
  108575. */
  108576. onExitingVRObservable: Observable<VRExperienceHelper>;
  108577. /**
  108578. * Observable raised when controller mesh is loaded.
  108579. */
  108580. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108581. /** Return this.onEnteringVRObservable
  108582. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  108583. */
  108584. readonly onEnteringVR: Observable<VRExperienceHelper>;
  108585. /** Return this.onExitingVRObservable
  108586. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  108587. */
  108588. readonly onExitingVR: Observable<VRExperienceHelper>;
  108589. /** Return this.onControllerMeshLoadedObservable
  108590. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  108591. */
  108592. readonly onControllerMeshLoaded: Observable<WebVRController>;
  108593. private _rayLength;
  108594. private _useCustomVRButton;
  108595. private _teleportationRequested;
  108596. private _teleportActive;
  108597. private _floorMeshName;
  108598. private _floorMeshesCollection;
  108599. private _rotationAllowed;
  108600. private _teleportBackwardsVector;
  108601. private _teleportationTarget;
  108602. private _isDefaultTeleportationTarget;
  108603. private _postProcessMove;
  108604. private _teleportationFillColor;
  108605. private _teleportationBorderColor;
  108606. private _rotationAngle;
  108607. private _haloCenter;
  108608. private _cameraGazer;
  108609. private _padSensibilityUp;
  108610. private _padSensibilityDown;
  108611. private _leftController;
  108612. private _rightController;
  108613. /**
  108614. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  108615. */
  108616. onNewMeshSelected: Observable<AbstractMesh>;
  108617. /**
  108618. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  108619. * This observable will provide the mesh and the controller used to select the mesh
  108620. */
  108621. onMeshSelectedWithController: Observable<{
  108622. mesh: AbstractMesh;
  108623. controller: WebVRController;
  108624. }>;
  108625. /**
  108626. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  108627. */
  108628. onNewMeshPicked: Observable<PickingInfo>;
  108629. private _circleEase;
  108630. /**
  108631. * Observable raised before camera teleportation
  108632. */
  108633. onBeforeCameraTeleport: Observable<Vector3>;
  108634. /**
  108635. * Observable raised after camera teleportation
  108636. */
  108637. onAfterCameraTeleport: Observable<Vector3>;
  108638. /**
  108639. * Observable raised when current selected mesh gets unselected
  108640. */
  108641. onSelectedMeshUnselected: Observable<AbstractMesh>;
  108642. private _raySelectionPredicate;
  108643. /**
  108644. * To be optionaly changed by user to define custom ray selection
  108645. */
  108646. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  108647. /**
  108648. * To be optionaly changed by user to define custom selection logic (after ray selection)
  108649. */
  108650. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  108651. /**
  108652. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  108653. */
  108654. teleportationEnabled: boolean;
  108655. private _defaultHeight;
  108656. private _teleportationInitialized;
  108657. private _interactionsEnabled;
  108658. private _interactionsRequested;
  108659. private _displayGaze;
  108660. private _displayLaserPointer;
  108661. /**
  108662. * The mesh used to display where the user is going to teleport.
  108663. */
  108664. /**
  108665. * Sets the mesh to be used to display where the user is going to teleport.
  108666. */
  108667. teleportationTarget: Mesh;
  108668. /**
  108669. * 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
  108670. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  108671. * See http://doc.babylonjs.com/resources/baking_transformations
  108672. */
  108673. gazeTrackerMesh: Mesh;
  108674. /**
  108675. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  108676. */
  108677. updateGazeTrackerScale: boolean;
  108678. /**
  108679. * If the gaze trackers color should be updated when selecting meshes
  108680. */
  108681. updateGazeTrackerColor: boolean;
  108682. /**
  108683. * If the controller laser color should be updated when selecting meshes
  108684. */
  108685. updateControllerLaserColor: boolean;
  108686. /**
  108687. * The gaze tracking mesh corresponding to the left controller
  108688. */
  108689. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108690. /**
  108691. * The gaze tracking mesh corresponding to the right controller
  108692. */
  108693. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108694. /**
  108695. * If the ray of the gaze should be displayed.
  108696. */
  108697. /**
  108698. * Sets if the ray of the gaze should be displayed.
  108699. */
  108700. displayGaze: boolean;
  108701. /**
  108702. * If the ray of the LaserPointer should be displayed.
  108703. */
  108704. /**
  108705. * Sets if the ray of the LaserPointer should be displayed.
  108706. */
  108707. displayLaserPointer: boolean;
  108708. /**
  108709. * The deviceOrientationCamera used as the camera when not in VR.
  108710. */
  108711. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108712. /**
  108713. * Based on the current WebVR support, returns the current VR camera used.
  108714. */
  108715. readonly currentVRCamera: Nullable<Camera>;
  108716. /**
  108717. * The webVRCamera which is used when in VR.
  108718. */
  108719. readonly webVRCamera: WebVRFreeCamera;
  108720. /**
  108721. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108722. */
  108723. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108724. /**
  108725. * The html button that is used to trigger entering into VR.
  108726. */
  108727. readonly vrButton: Nullable<HTMLButtonElement>;
  108728. private readonly _teleportationRequestInitiated;
  108729. /**
  108730. * Defines wether or not Pointer lock should be requested when switching to
  108731. * full screen.
  108732. */
  108733. requestPointerLockOnFullScreen: boolean;
  108734. /**
  108735. * Instantiates a VRExperienceHelper.
  108736. * Helps to quickly add VR support to an existing scene.
  108737. * @param scene The scene the VRExperienceHelper belongs to.
  108738. * @param webVROptions Options to modify the vr experience helper's behavior.
  108739. */
  108740. constructor(scene: Scene,
  108741. /** Options to modify the vr experience helper's behavior. */
  108742. webVROptions?: VRExperienceHelperOptions);
  108743. private _onDefaultMeshLoaded;
  108744. private _onResize;
  108745. private _onFullscreenChange;
  108746. /**
  108747. * Gets a value indicating if we are currently in VR mode.
  108748. */
  108749. readonly isInVRMode: boolean;
  108750. private onVrDisplayPresentChange;
  108751. private onVRDisplayChanged;
  108752. private moveButtonToBottomRight;
  108753. private displayVRButton;
  108754. private updateButtonVisibility;
  108755. private _cachedAngularSensibility;
  108756. /**
  108757. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108758. * Otherwise, will use the fullscreen API.
  108759. */
  108760. enterVR(): void;
  108761. /**
  108762. * Attempt to exit VR, or fullscreen.
  108763. */
  108764. exitVR(): void;
  108765. /**
  108766. * The position of the vr experience helper.
  108767. */
  108768. /**
  108769. * Sets the position of the vr experience helper.
  108770. */
  108771. position: Vector3;
  108772. /**
  108773. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108774. */
  108775. enableInteractions(): void;
  108776. private readonly _noControllerIsActive;
  108777. private beforeRender;
  108778. private _isTeleportationFloor;
  108779. /**
  108780. * Adds a floor mesh to be used for teleportation.
  108781. * @param floorMesh the mesh to be used for teleportation.
  108782. */
  108783. addFloorMesh(floorMesh: Mesh): void;
  108784. /**
  108785. * Removes a floor mesh from being used for teleportation.
  108786. * @param floorMesh the mesh to be removed.
  108787. */
  108788. removeFloorMesh(floorMesh: Mesh): void;
  108789. /**
  108790. * Enables interactions and teleportation using the VR controllers and gaze.
  108791. * @param vrTeleportationOptions options to modify teleportation behavior.
  108792. */
  108793. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108794. private _onNewGamepadConnected;
  108795. private _tryEnableInteractionOnController;
  108796. private _onNewGamepadDisconnected;
  108797. private _enableInteractionOnController;
  108798. private _checkTeleportWithRay;
  108799. private _checkRotate;
  108800. private _checkTeleportBackwards;
  108801. private _enableTeleportationOnController;
  108802. private _createTeleportationCircles;
  108803. private _displayTeleportationTarget;
  108804. private _hideTeleportationTarget;
  108805. private _rotateCamera;
  108806. private _moveTeleportationSelectorTo;
  108807. private _workingVector;
  108808. private _workingQuaternion;
  108809. private _workingMatrix;
  108810. /**
  108811. * Teleports the users feet to the desired location
  108812. * @param location The location where the user's feet should be placed
  108813. */
  108814. teleportCamera(location: Vector3): void;
  108815. private _convertNormalToDirectionOfRay;
  108816. private _castRayAndSelectObject;
  108817. private _notifySelectedMeshUnselected;
  108818. /**
  108819. * Sets the color of the laser ray from the vr controllers.
  108820. * @param color new color for the ray.
  108821. */
  108822. changeLaserColor(color: Color3): void;
  108823. /**
  108824. * Sets the color of the ray from the vr headsets gaze.
  108825. * @param color new color for the ray.
  108826. */
  108827. changeGazeColor(color: Color3): void;
  108828. /**
  108829. * Exits VR and disposes of the vr experience helper
  108830. */
  108831. dispose(): void;
  108832. /**
  108833. * Gets the name of the VRExperienceHelper class
  108834. * @returns "VRExperienceHelper"
  108835. */
  108836. getClassName(): string;
  108837. }
  108838. }
  108839. declare module BABYLON {
  108840. /**
  108841. * Manages an XRSession to work with Babylon's engine
  108842. * @see https://doc.babylonjs.com/how_to/webxr
  108843. */
  108844. export class WebXRSessionManager implements IDisposable {
  108845. private scene;
  108846. /**
  108847. * Fires every time a new xrFrame arrives which can be used to update the camera
  108848. */
  108849. onXRFrameObservable: Observable<any>;
  108850. /**
  108851. * Fires when the xr session is ended either by the device or manually done
  108852. */
  108853. onXRSessionEnded: Observable<any>;
  108854. /**
  108855. * Underlying xr session
  108856. */
  108857. session: XRSession;
  108858. /**
  108859. * Type of reference space used when creating the session
  108860. */
  108861. referenceSpace: XRReferenceSpace;
  108862. /** @hidden */
  108863. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108864. /**
  108865. * Current XR frame
  108866. */
  108867. currentFrame: Nullable<XRFrame>;
  108868. private _xrNavigator;
  108869. private baseLayer;
  108870. private _sessionEnded;
  108871. /**
  108872. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108873. * @param scene The scene which the session should be created for
  108874. */
  108875. constructor(scene: Scene);
  108876. /**
  108877. * Initializes the manager
  108878. * After initialization enterXR can be called to start an XR session
  108879. * @returns Promise which resolves after it is initialized
  108880. */
  108881. initializeAsync(): Promise<void>;
  108882. /**
  108883. * Initializes an xr session
  108884. * @param xrSessionMode mode to initialize
  108885. * @returns a promise which will resolve once the session has been initialized
  108886. */
  108887. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108888. /**
  108889. * Sets the reference space on the xr session
  108890. * @param referenceSpace space to set
  108891. * @returns a promise that will resolve once the reference space has been set
  108892. */
  108893. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108894. /**
  108895. * Updates the render state of the session
  108896. * @param state state to set
  108897. * @returns a promise that resolves once the render state has been updated
  108898. */
  108899. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108900. /**
  108901. * Starts rendering to the xr layer
  108902. * @returns a promise that will resolve once rendering has started
  108903. */
  108904. startRenderingToXRAsync(): Promise<void>;
  108905. /**
  108906. * Stops the xrSession and restores the renderloop
  108907. * @returns Promise which resolves after it exits XR
  108908. */
  108909. exitXRAsync(): Promise<unknown>;
  108910. /**
  108911. * Checks if a session would be supported for the creation options specified
  108912. * @param sessionMode session mode to check if supported eg. immersive-vr
  108913. * @returns true if supported
  108914. */
  108915. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108916. /**
  108917. * @hidden
  108918. * Converts the render layer of xrSession to a render target
  108919. * @param session session to create render target for
  108920. * @param scene scene the new render target should be created for
  108921. */
  108922. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108923. /**
  108924. * Disposes of the session manager
  108925. */
  108926. dispose(): void;
  108927. }
  108928. }
  108929. declare module BABYLON {
  108930. /**
  108931. * WebXR Camera which holds the views for the xrSession
  108932. * @see https://doc.babylonjs.com/how_to/webxr
  108933. */
  108934. export class WebXRCamera extends FreeCamera {
  108935. private static _TmpMatrix;
  108936. /**
  108937. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108938. * @param name the name of the camera
  108939. * @param scene the scene to add the camera to
  108940. */
  108941. constructor(name: string, scene: Scene);
  108942. private _updateNumberOfRigCameras;
  108943. /** @hidden */
  108944. _updateForDualEyeDebugging(): void;
  108945. /**
  108946. * Updates the cameras position from the current pose information of the XR session
  108947. * @param xrSessionManager the session containing pose information
  108948. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108949. */
  108950. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108951. }
  108952. }
  108953. declare module BABYLON {
  108954. /**
  108955. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108956. */
  108957. export class WebXRManagedOutputCanvas implements IDisposable {
  108958. private helper;
  108959. private _canvas;
  108960. /**
  108961. * xrpresent context of the canvas which can be used to display/mirror xr content
  108962. */
  108963. canvasContext: WebGLRenderingContext;
  108964. /**
  108965. * xr layer for the canvas
  108966. */
  108967. xrLayer: Nullable<XRWebGLLayer>;
  108968. /**
  108969. * Initializes the xr layer for the session
  108970. * @param xrSession xr session
  108971. * @returns a promise that will resolve once the XR Layer has been created
  108972. */
  108973. initializeXRLayerAsync(xrSession: any): any;
  108974. /**
  108975. * Initializes the canvas to be added/removed upon entering/exiting xr
  108976. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108977. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108978. */
  108979. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108980. /**
  108981. * Disposes of the object
  108982. */
  108983. dispose(): void;
  108984. private _setManagedOutputCanvas;
  108985. private _addCanvas;
  108986. private _removeCanvas;
  108987. }
  108988. }
  108989. declare module BABYLON {
  108990. /**
  108991. * States of the webXR experience
  108992. */
  108993. export enum WebXRState {
  108994. /**
  108995. * Transitioning to being in XR mode
  108996. */
  108997. ENTERING_XR = 0,
  108998. /**
  108999. * Transitioning to non XR mode
  109000. */
  109001. EXITING_XR = 1,
  109002. /**
  109003. * In XR mode and presenting
  109004. */
  109005. IN_XR = 2,
  109006. /**
  109007. * Not entered XR mode
  109008. */
  109009. NOT_IN_XR = 3
  109010. }
  109011. /**
  109012. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  109013. * @see https://doc.babylonjs.com/how_to/webxr
  109014. */
  109015. export class WebXRExperienceHelper implements IDisposable {
  109016. private scene;
  109017. /**
  109018. * 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
  109019. */
  109020. container: AbstractMesh;
  109021. /**
  109022. * Camera used to render xr content
  109023. */
  109024. camera: WebXRCamera;
  109025. /**
  109026. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  109027. */
  109028. state: WebXRState;
  109029. private _setState;
  109030. private static _TmpVector;
  109031. /**
  109032. * Fires when the state of the experience helper has changed
  109033. */
  109034. onStateChangedObservable: Observable<WebXRState>;
  109035. /** Session manager used to keep track of xr session */
  109036. sessionManager: WebXRSessionManager;
  109037. private _nonVRCamera;
  109038. private _originalSceneAutoClear;
  109039. private _supported;
  109040. /**
  109041. * Creates the experience helper
  109042. * @param scene the scene to attach the experience helper to
  109043. * @returns a promise for the experience helper
  109044. */
  109045. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  109046. /**
  109047. * Creates a WebXRExperienceHelper
  109048. * @param scene The scene the helper should be created in
  109049. */
  109050. private constructor();
  109051. /**
  109052. * Exits XR mode and returns the scene to its original state
  109053. * @returns promise that resolves after xr mode has exited
  109054. */
  109055. exitXRAsync(): Promise<unknown>;
  109056. /**
  109057. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  109058. * @param sessionCreationOptions options for the XR session
  109059. * @param referenceSpaceType frame of reference of the XR session
  109060. * @param outputCanvas the output canvas that will be used to enter XR mode
  109061. * @returns promise that resolves after xr mode has entered
  109062. */
  109063. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  109064. /**
  109065. * Updates the global position of the camera by moving the camera's container
  109066. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  109067. * @param position The desired global position of the camera
  109068. */
  109069. setPositionOfCameraUsingContainer(position: Vector3): void;
  109070. /**
  109071. * Rotates the xr camera by rotating the camera's container around the camera's position
  109072. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  109073. * @param rotation the desired quaternion rotation to apply to the camera
  109074. */
  109075. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  109076. /**
  109077. * Disposes of the experience helper
  109078. */
  109079. dispose(): void;
  109080. }
  109081. }
  109082. declare module BABYLON {
  109083. /**
  109084. * Button which can be used to enter a different mode of XR
  109085. */
  109086. export class WebXREnterExitUIButton {
  109087. /** button element */
  109088. element: HTMLElement;
  109089. /** XR initialization options for the button */
  109090. sessionMode: XRSessionMode;
  109091. /** Reference space type */
  109092. referenceSpaceType: XRReferenceSpaceType;
  109093. /**
  109094. * Creates a WebXREnterExitUIButton
  109095. * @param element button element
  109096. * @param sessionMode XR initialization session mode
  109097. * @param referenceSpaceType the type of reference space to be used
  109098. */
  109099. constructor(
  109100. /** button element */
  109101. element: HTMLElement,
  109102. /** XR initialization options for the button */
  109103. sessionMode: XRSessionMode,
  109104. /** Reference space type */
  109105. referenceSpaceType: XRReferenceSpaceType);
  109106. /**
  109107. * Overwritable function which can be used to update the button's visuals when the state changes
  109108. * @param activeButton the current active button in the UI
  109109. */
  109110. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  109111. }
  109112. /**
  109113. * Options to create the webXR UI
  109114. */
  109115. export class WebXREnterExitUIOptions {
  109116. /**
  109117. * Context to enter xr with
  109118. */
  109119. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  109120. /**
  109121. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  109122. */
  109123. customButtons?: Array<WebXREnterExitUIButton>;
  109124. }
  109125. /**
  109126. * UI to allow the user to enter/exit XR mode
  109127. */
  109128. export class WebXREnterExitUI implements IDisposable {
  109129. private scene;
  109130. private _overlay;
  109131. private _buttons;
  109132. private _activeButton;
  109133. /**
  109134. * Fired every time the active button is changed.
  109135. *
  109136. * When xr is entered via a button that launches xr that button will be the callback parameter
  109137. *
  109138. * When exiting xr the callback parameter will be null)
  109139. */
  109140. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  109141. /**
  109142. * Creates UI to allow the user to enter/exit XR mode
  109143. * @param scene the scene to add the ui to
  109144. * @param helper the xr experience helper to enter/exit xr with
  109145. * @param options options to configure the UI
  109146. * @returns the created ui
  109147. */
  109148. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  109149. private constructor();
  109150. private _updateButtons;
  109151. /**
  109152. * Disposes of the object
  109153. */
  109154. dispose(): void;
  109155. }
  109156. }
  109157. declare module BABYLON {
  109158. /**
  109159. * Represents an XR input
  109160. */
  109161. export class WebXRController {
  109162. private scene;
  109163. /** The underlying input source for the controller */
  109164. inputSource: XRInputSource;
  109165. private parentContainer;
  109166. /**
  109167. * 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
  109168. */
  109169. grip?: AbstractMesh;
  109170. /**
  109171. * Pointer which can be used to select objects or attach a visible laser to
  109172. */
  109173. pointer: AbstractMesh;
  109174. private _gamepadMode;
  109175. /**
  109176. * If available, this is the gamepad object related to this controller.
  109177. * Using this object it is possible to get click events and trackpad changes of the
  109178. * webxr controller that is currently being used.
  109179. */
  109180. gamepadController?: WebVRController;
  109181. /**
  109182. * Event that fires when the controller is removed/disposed
  109183. */
  109184. onDisposeObservable: Observable<{}>;
  109185. private _tmpMatrix;
  109186. private _tmpQuaternion;
  109187. private _tmpVector;
  109188. /**
  109189. * Creates the controller
  109190. * @see https://doc.babylonjs.com/how_to/webxr
  109191. * @param scene the scene which the controller should be associated to
  109192. * @param inputSource the underlying input source for the controller
  109193. * @param parentContainer parent that the controller meshes should be children of
  109194. */
  109195. constructor(scene: Scene,
  109196. /** The underlying input source for the controller */
  109197. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  109198. /**
  109199. * Updates the controller pose based on the given XRFrame
  109200. * @param xrFrame xr frame to update the pose with
  109201. * @param referenceSpace reference space to use
  109202. */
  109203. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  109204. /**
  109205. * Gets a world space ray coming from the controller
  109206. * @param result the resulting ray
  109207. */
  109208. getWorldPointerRayToRef(result: Ray): void;
  109209. /**
  109210. * Get the scene associated with this controller
  109211. * @returns the scene object
  109212. */
  109213. getScene(): Scene;
  109214. /**
  109215. * Disposes of the object
  109216. */
  109217. dispose(): void;
  109218. }
  109219. }
  109220. declare module BABYLON {
  109221. /**
  109222. * XR input used to track XR inputs such as controllers/rays
  109223. */
  109224. export class WebXRInput implements IDisposable {
  109225. /**
  109226. * Base experience the input listens to
  109227. */
  109228. baseExperience: WebXRExperienceHelper;
  109229. /**
  109230. * XR controllers being tracked
  109231. */
  109232. controllers: Array<WebXRController>;
  109233. private _frameObserver;
  109234. private _stateObserver;
  109235. /**
  109236. * Event when a controller has been connected/added
  109237. */
  109238. onControllerAddedObservable: Observable<WebXRController>;
  109239. /**
  109240. * Event when a controller has been removed/disconnected
  109241. */
  109242. onControllerRemovedObservable: Observable<WebXRController>;
  109243. /**
  109244. * Initializes the WebXRInput
  109245. * @param baseExperience experience helper which the input should be created for
  109246. */
  109247. constructor(
  109248. /**
  109249. * Base experience the input listens to
  109250. */
  109251. baseExperience: WebXRExperienceHelper);
  109252. private _onInputSourcesChange;
  109253. private _addAndRemoveControllers;
  109254. /**
  109255. * Disposes of the object
  109256. */
  109257. dispose(): void;
  109258. }
  109259. }
  109260. declare module BABYLON {
  109261. /**
  109262. * Enables teleportation
  109263. */
  109264. export class WebXRControllerTeleportation {
  109265. private _teleportationFillColor;
  109266. private _teleportationBorderColor;
  109267. private _tmpRay;
  109268. private _tmpVector;
  109269. /**
  109270. * Creates a WebXRControllerTeleportation
  109271. * @param input input manager to add teleportation to
  109272. * @param floorMeshes floormeshes which can be teleported to
  109273. */
  109274. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  109275. }
  109276. }
  109277. declare module BABYLON {
  109278. /**
  109279. * Handles pointer input automatically for the pointer of XR controllers
  109280. */
  109281. export class WebXRControllerPointerSelection {
  109282. private static _idCounter;
  109283. private _tmpRay;
  109284. /**
  109285. * Creates a WebXRControllerPointerSelection
  109286. * @param input input manager to setup pointer selection
  109287. */
  109288. constructor(input: WebXRInput);
  109289. private _convertNormalToDirectionOfRay;
  109290. private _updatePointerDistance;
  109291. }
  109292. }
  109293. declare module BABYLON {
  109294. /**
  109295. * Class used to represent data loading progression
  109296. */
  109297. export class SceneLoaderProgressEvent {
  109298. /** defines if data length to load can be evaluated */
  109299. readonly lengthComputable: boolean;
  109300. /** defines the loaded data length */
  109301. readonly loaded: number;
  109302. /** defines the data length to load */
  109303. readonly total: number;
  109304. /**
  109305. * Create a new progress event
  109306. * @param lengthComputable defines if data length to load can be evaluated
  109307. * @param loaded defines the loaded data length
  109308. * @param total defines the data length to load
  109309. */
  109310. constructor(
  109311. /** defines if data length to load can be evaluated */
  109312. lengthComputable: boolean,
  109313. /** defines the loaded data length */
  109314. loaded: number,
  109315. /** defines the data length to load */
  109316. total: number);
  109317. /**
  109318. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  109319. * @param event defines the source event
  109320. * @returns a new SceneLoaderProgressEvent
  109321. */
  109322. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  109323. }
  109324. /**
  109325. * Interface used by SceneLoader plugins to define supported file extensions
  109326. */
  109327. export interface ISceneLoaderPluginExtensions {
  109328. /**
  109329. * Defines the list of supported extensions
  109330. */
  109331. [extension: string]: {
  109332. isBinary: boolean;
  109333. };
  109334. }
  109335. /**
  109336. * Interface used by SceneLoader plugin factory
  109337. */
  109338. export interface ISceneLoaderPluginFactory {
  109339. /**
  109340. * Defines the name of the factory
  109341. */
  109342. name: string;
  109343. /**
  109344. * Function called to create a new plugin
  109345. * @return the new plugin
  109346. */
  109347. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  109348. /**
  109349. * The callback that returns true if the data can be directly loaded.
  109350. * @param data string containing the file data
  109351. * @returns if the data can be loaded directly
  109352. */
  109353. canDirectLoad?(data: string): boolean;
  109354. }
  109355. /**
  109356. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  109357. */
  109358. export interface ISceneLoaderPluginBase {
  109359. /**
  109360. * The friendly name of this plugin.
  109361. */
  109362. name: string;
  109363. /**
  109364. * The file extensions supported by this plugin.
  109365. */
  109366. extensions: string | ISceneLoaderPluginExtensions;
  109367. /**
  109368. * The callback called when loading from a url.
  109369. * @param scene scene loading this url
  109370. * @param url url to load
  109371. * @param onSuccess callback called when the file successfully loads
  109372. * @param onProgress callback called while file is loading (if the server supports this mode)
  109373. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  109374. * @param onError callback called when the file fails to load
  109375. * @returns a file request object
  109376. */
  109377. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  109378. /**
  109379. * The callback called when loading from a file object.
  109380. * @param scene scene loading this file
  109381. * @param file defines the file to load
  109382. * @param onSuccess defines the callback to call when data is loaded
  109383. * @param onProgress defines the callback to call during loading process
  109384. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  109385. * @param onError defines the callback to call when an error occurs
  109386. * @returns a file request object
  109387. */
  109388. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  109389. /**
  109390. * The callback that returns true if the data can be directly loaded.
  109391. * @param data string containing the file data
  109392. * @returns if the data can be loaded directly
  109393. */
  109394. canDirectLoad?(data: string): boolean;
  109395. /**
  109396. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  109397. * @param scene scene loading this data
  109398. * @param data string containing the data
  109399. * @returns data to pass to the plugin
  109400. */
  109401. directLoad?(scene: Scene, data: string): any;
  109402. /**
  109403. * The callback that allows custom handling of the root url based on the response url.
  109404. * @param rootUrl the original root url
  109405. * @param responseURL the response url if available
  109406. * @returns the new root url
  109407. */
  109408. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  109409. }
  109410. /**
  109411. * Interface used to define a SceneLoader plugin
  109412. */
  109413. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  109414. /**
  109415. * Import meshes into a scene.
  109416. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109417. * @param scene The scene to import into
  109418. * @param data The data to import
  109419. * @param rootUrl The root url for scene and resources
  109420. * @param meshes The meshes array to import into
  109421. * @param particleSystems The particle systems array to import into
  109422. * @param skeletons The skeletons array to import into
  109423. * @param onError The callback when import fails
  109424. * @returns True if successful or false otherwise
  109425. */
  109426. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  109427. /**
  109428. * Load into a scene.
  109429. * @param scene The scene to load into
  109430. * @param data The data to import
  109431. * @param rootUrl The root url for scene and resources
  109432. * @param onError The callback when import fails
  109433. * @returns True if successful or false otherwise
  109434. */
  109435. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  109436. /**
  109437. * Load into an asset container.
  109438. * @param scene The scene to load into
  109439. * @param data The data to import
  109440. * @param rootUrl The root url for scene and resources
  109441. * @param onError The callback when import fails
  109442. * @returns The loaded asset container
  109443. */
  109444. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  109445. }
  109446. /**
  109447. * Interface used to define an async SceneLoader plugin
  109448. */
  109449. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  109450. /**
  109451. * Import meshes into a scene.
  109452. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109453. * @param scene The scene to import into
  109454. * @param data The data to import
  109455. * @param rootUrl The root url for scene and resources
  109456. * @param onProgress The callback when the load progresses
  109457. * @param fileName Defines the name of the file to load
  109458. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  109459. */
  109460. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  109461. meshes: AbstractMesh[];
  109462. particleSystems: IParticleSystem[];
  109463. skeletons: Skeleton[];
  109464. animationGroups: AnimationGroup[];
  109465. }>;
  109466. /**
  109467. * Load into a scene.
  109468. * @param scene The scene to load into
  109469. * @param data The data to import
  109470. * @param rootUrl The root url for scene and resources
  109471. * @param onProgress The callback when the load progresses
  109472. * @param fileName Defines the name of the file to load
  109473. * @returns Nothing
  109474. */
  109475. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  109476. /**
  109477. * Load into an asset container.
  109478. * @param scene The scene to load into
  109479. * @param data The data to import
  109480. * @param rootUrl The root url for scene and resources
  109481. * @param onProgress The callback when the load progresses
  109482. * @param fileName Defines the name of the file to load
  109483. * @returns The loaded asset container
  109484. */
  109485. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  109486. }
  109487. /**
  109488. * Class used to load scene from various file formats using registered plugins
  109489. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  109490. */
  109491. export class SceneLoader {
  109492. /**
  109493. * No logging while loading
  109494. */
  109495. static readonly NO_LOGGING: number;
  109496. /**
  109497. * Minimal logging while loading
  109498. */
  109499. static readonly MINIMAL_LOGGING: number;
  109500. /**
  109501. * Summary logging while loading
  109502. */
  109503. static readonly SUMMARY_LOGGING: number;
  109504. /**
  109505. * Detailled logging while loading
  109506. */
  109507. static readonly DETAILED_LOGGING: number;
  109508. /**
  109509. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  109510. */
  109511. static ForceFullSceneLoadingForIncremental: boolean;
  109512. /**
  109513. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  109514. */
  109515. static ShowLoadingScreen: boolean;
  109516. /**
  109517. * Defines the current logging level (while loading the scene)
  109518. * @ignorenaming
  109519. */
  109520. static loggingLevel: number;
  109521. /**
  109522. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  109523. */
  109524. static CleanBoneMatrixWeights: boolean;
  109525. /**
  109526. * Event raised when a plugin is used to load a scene
  109527. */
  109528. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  109529. private static _registeredPlugins;
  109530. private static _getDefaultPlugin;
  109531. private static _getPluginForExtension;
  109532. private static _getPluginForDirectLoad;
  109533. private static _getPluginForFilename;
  109534. private static _getDirectLoad;
  109535. private static _loadData;
  109536. private static _getFileInfo;
  109537. /**
  109538. * Gets a plugin that can load the given extension
  109539. * @param extension defines the extension to load
  109540. * @returns a plugin or null if none works
  109541. */
  109542. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  109543. /**
  109544. * Gets a boolean indicating that the given extension can be loaded
  109545. * @param extension defines the extension to load
  109546. * @returns true if the extension is supported
  109547. */
  109548. static IsPluginForExtensionAvailable(extension: string): boolean;
  109549. /**
  109550. * Adds a new plugin to the list of registered plugins
  109551. * @param plugin defines the plugin to add
  109552. */
  109553. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  109554. /**
  109555. * Import meshes into a scene
  109556. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109557. * @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)
  109558. * @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)
  109559. * @param scene the instance of BABYLON.Scene to append to
  109560. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  109561. * @param onProgress a callback with a progress event for each file being loaded
  109562. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109563. * @param pluginExtension the extension used to determine the plugin
  109564. * @returns The loaded plugin
  109565. */
  109566. 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>;
  109567. /**
  109568. * Import meshes into a scene
  109569. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109570. * @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)
  109571. * @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)
  109572. * @param scene the instance of BABYLON.Scene to append to
  109573. * @param onProgress a callback with a progress event for each file being loaded
  109574. * @param pluginExtension the extension used to determine the plugin
  109575. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  109576. */
  109577. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  109578. meshes: AbstractMesh[];
  109579. particleSystems: IParticleSystem[];
  109580. skeletons: Skeleton[];
  109581. animationGroups: AnimationGroup[];
  109582. }>;
  109583. /**
  109584. * Load a scene
  109585. * @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)
  109586. * @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)
  109587. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109588. * @param onSuccess a callback with the scene when import succeeds
  109589. * @param onProgress a callback with a progress event for each file being loaded
  109590. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109591. * @param pluginExtension the extension used to determine the plugin
  109592. * @returns The loaded plugin
  109593. */
  109594. 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>;
  109595. /**
  109596. * Load a scene
  109597. * @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)
  109598. * @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)
  109599. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109600. * @param onProgress a callback with a progress event for each file being loaded
  109601. * @param pluginExtension the extension used to determine the plugin
  109602. * @returns The loaded scene
  109603. */
  109604. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109605. /**
  109606. * Append a scene
  109607. * @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)
  109608. * @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)
  109609. * @param scene is the instance of BABYLON.Scene to append to
  109610. * @param onSuccess a callback with the scene when import succeeds
  109611. * @param onProgress a callback with a progress event for each file being loaded
  109612. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109613. * @param pluginExtension the extension used to determine the plugin
  109614. * @returns The loaded plugin
  109615. */
  109616. 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>;
  109617. /**
  109618. * Append a scene
  109619. * @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)
  109620. * @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)
  109621. * @param scene is the instance of BABYLON.Scene to append to
  109622. * @param onProgress a callback with a progress event for each file being loaded
  109623. * @param pluginExtension the extension used to determine the plugin
  109624. * @returns The given scene
  109625. */
  109626. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109627. /**
  109628. * Load a scene into an asset container
  109629. * @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)
  109630. * @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)
  109631. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109632. * @param onSuccess a callback with the scene when import succeeds
  109633. * @param onProgress a callback with a progress event for each file being loaded
  109634. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109635. * @param pluginExtension the extension used to determine the plugin
  109636. * @returns The loaded plugin
  109637. */
  109638. 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>;
  109639. /**
  109640. * Load a scene into an asset container
  109641. * @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)
  109642. * @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)
  109643. * @param scene is the instance of Scene to append to
  109644. * @param onProgress a callback with a progress event for each file being loaded
  109645. * @param pluginExtension the extension used to determine the plugin
  109646. * @returns The loaded asset container
  109647. */
  109648. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  109649. }
  109650. }
  109651. declare module BABYLON {
  109652. /**
  109653. * Generic Controller
  109654. */
  109655. export class GenericController extends WebVRController {
  109656. /**
  109657. * Base Url for the controller model.
  109658. */
  109659. static readonly MODEL_BASE_URL: string;
  109660. /**
  109661. * File name for the controller model.
  109662. */
  109663. static readonly MODEL_FILENAME: string;
  109664. /**
  109665. * Creates a new GenericController from a gamepad
  109666. * @param vrGamepad the gamepad that the controller should be created from
  109667. */
  109668. constructor(vrGamepad: any);
  109669. /**
  109670. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109671. * @param scene scene in which to add meshes
  109672. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109673. */
  109674. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109675. /**
  109676. * Called once for each button that changed state since the last frame
  109677. * @param buttonIdx Which button index changed
  109678. * @param state New state of the button
  109679. * @param changes Which properties on the state changed since last frame
  109680. */
  109681. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109682. }
  109683. }
  109684. declare module BABYLON {
  109685. /**
  109686. * Defines the WindowsMotionController object that the state of the windows motion controller
  109687. */
  109688. export class WindowsMotionController extends WebVRController {
  109689. /**
  109690. * The base url used to load the left and right controller models
  109691. */
  109692. static MODEL_BASE_URL: string;
  109693. /**
  109694. * The name of the left controller model file
  109695. */
  109696. static MODEL_LEFT_FILENAME: string;
  109697. /**
  109698. * The name of the right controller model file
  109699. */
  109700. static MODEL_RIGHT_FILENAME: string;
  109701. /**
  109702. * The controller name prefix for this controller type
  109703. */
  109704. static readonly GAMEPAD_ID_PREFIX: string;
  109705. /**
  109706. * The controller id pattern for this controller type
  109707. */
  109708. private static readonly GAMEPAD_ID_PATTERN;
  109709. private _loadedMeshInfo;
  109710. private readonly _mapping;
  109711. /**
  109712. * Fired when the trackpad on this controller is clicked
  109713. */
  109714. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  109715. /**
  109716. * Fired when the trackpad on this controller is modified
  109717. */
  109718. onTrackpadValuesChangedObservable: Observable<StickValues>;
  109719. /**
  109720. * The current x and y values of this controller's trackpad
  109721. */
  109722. trackpad: StickValues;
  109723. /**
  109724. * Creates a new WindowsMotionController from a gamepad
  109725. * @param vrGamepad the gamepad that the controller should be created from
  109726. */
  109727. constructor(vrGamepad: any);
  109728. /**
  109729. * Fired when the trigger on this controller is modified
  109730. */
  109731. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109732. /**
  109733. * Fired when the menu button on this controller is modified
  109734. */
  109735. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109736. /**
  109737. * Fired when the grip button on this controller is modified
  109738. */
  109739. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109740. /**
  109741. * Fired when the thumbstick button on this controller is modified
  109742. */
  109743. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109744. /**
  109745. * Fired when the touchpad button on this controller is modified
  109746. */
  109747. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109748. /**
  109749. * Fired when the touchpad values on this controller are modified
  109750. */
  109751. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109752. private _updateTrackpad;
  109753. /**
  109754. * Called once per frame by the engine.
  109755. */
  109756. update(): void;
  109757. /**
  109758. * Called once for each button that changed state since the last frame
  109759. * @param buttonIdx Which button index changed
  109760. * @param state New state of the button
  109761. * @param changes Which properties on the state changed since last frame
  109762. */
  109763. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109764. /**
  109765. * Moves the buttons on the controller mesh based on their current state
  109766. * @param buttonName the name of the button to move
  109767. * @param buttonValue the value of the button which determines the buttons new position
  109768. */
  109769. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109770. /**
  109771. * Moves the axis on the controller mesh based on its current state
  109772. * @param axis the index of the axis
  109773. * @param axisValue the value of the axis which determines the meshes new position
  109774. * @hidden
  109775. */
  109776. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109777. /**
  109778. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109779. * @param scene scene in which to add meshes
  109780. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109781. */
  109782. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109783. /**
  109784. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109785. * can be transformed by button presses and axes values, based on this._mapping.
  109786. *
  109787. * @param scene scene in which the meshes exist
  109788. * @param meshes list of meshes that make up the controller model to process
  109789. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109790. */
  109791. private processModel;
  109792. private createMeshInfo;
  109793. /**
  109794. * Gets the ray of the controller in the direction the controller is pointing
  109795. * @param length the length the resulting ray should be
  109796. * @returns a ray in the direction the controller is pointing
  109797. */
  109798. getForwardRay(length?: number): Ray;
  109799. /**
  109800. * Disposes of the controller
  109801. */
  109802. dispose(): void;
  109803. }
  109804. }
  109805. declare module BABYLON {
  109806. /**
  109807. * Oculus Touch Controller
  109808. */
  109809. export class OculusTouchController extends WebVRController {
  109810. /**
  109811. * Base Url for the controller model.
  109812. */
  109813. static MODEL_BASE_URL: string;
  109814. /**
  109815. * File name for the left controller model.
  109816. */
  109817. static MODEL_LEFT_FILENAME: string;
  109818. /**
  109819. * File name for the right controller model.
  109820. */
  109821. static MODEL_RIGHT_FILENAME: string;
  109822. /**
  109823. * Base Url for the Quest controller model.
  109824. */
  109825. static QUEST_MODEL_BASE_URL: string;
  109826. /**
  109827. * @hidden
  109828. * If the controllers are running on a device that needs the updated Quest controller models
  109829. */
  109830. static _IsQuest: boolean;
  109831. /**
  109832. * Fired when the secondary trigger on this controller is modified
  109833. */
  109834. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109835. /**
  109836. * Fired when the thumb rest on this controller is modified
  109837. */
  109838. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109839. /**
  109840. * Creates a new OculusTouchController from a gamepad
  109841. * @param vrGamepad the gamepad that the controller should be created from
  109842. */
  109843. constructor(vrGamepad: any);
  109844. /**
  109845. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109846. * @param scene scene in which to add meshes
  109847. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109848. */
  109849. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109850. /**
  109851. * Fired when the A button on this controller is modified
  109852. */
  109853. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109854. /**
  109855. * Fired when the B button on this controller is modified
  109856. */
  109857. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109858. /**
  109859. * Fired when the X button on this controller is modified
  109860. */
  109861. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109862. /**
  109863. * Fired when the Y button on this controller is modified
  109864. */
  109865. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109866. /**
  109867. * Called once for each button that changed state since the last frame
  109868. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109869. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109870. * 2) secondary trigger (same)
  109871. * 3) A (right) X (left), touch, pressed = value
  109872. * 4) B / Y
  109873. * 5) thumb rest
  109874. * @param buttonIdx Which button index changed
  109875. * @param state New state of the button
  109876. * @param changes Which properties on the state changed since last frame
  109877. */
  109878. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109879. }
  109880. }
  109881. declare module BABYLON {
  109882. /**
  109883. * Vive Controller
  109884. */
  109885. export class ViveController extends WebVRController {
  109886. /**
  109887. * Base Url for the controller model.
  109888. */
  109889. static MODEL_BASE_URL: string;
  109890. /**
  109891. * File name for the controller model.
  109892. */
  109893. static MODEL_FILENAME: string;
  109894. /**
  109895. * Creates a new ViveController from a gamepad
  109896. * @param vrGamepad the gamepad that the controller should be created from
  109897. */
  109898. constructor(vrGamepad: any);
  109899. /**
  109900. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109901. * @param scene scene in which to add meshes
  109902. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109903. */
  109904. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109905. /**
  109906. * Fired when the left button on this controller is modified
  109907. */
  109908. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109909. /**
  109910. * Fired when the right button on this controller is modified
  109911. */
  109912. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109913. /**
  109914. * Fired when the menu button on this controller is modified
  109915. */
  109916. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109917. /**
  109918. * Called once for each button that changed state since the last frame
  109919. * Vive mapping:
  109920. * 0: touchpad
  109921. * 1: trigger
  109922. * 2: left AND right buttons
  109923. * 3: menu button
  109924. * @param buttonIdx Which button index changed
  109925. * @param state New state of the button
  109926. * @param changes Which properties on the state changed since last frame
  109927. */
  109928. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109929. }
  109930. }
  109931. declare module BABYLON {
  109932. /**
  109933. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109934. */
  109935. export class WebXRControllerModelLoader {
  109936. /**
  109937. * Creates the WebXRControllerModelLoader
  109938. * @param input xr input that creates the controllers
  109939. */
  109940. constructor(input: WebXRInput);
  109941. }
  109942. }
  109943. declare module BABYLON {
  109944. /**
  109945. * Contains an array of blocks representing the octree
  109946. */
  109947. export interface IOctreeContainer<T> {
  109948. /**
  109949. * Blocks within the octree
  109950. */
  109951. blocks: Array<OctreeBlock<T>>;
  109952. }
  109953. /**
  109954. * Class used to store a cell in an octree
  109955. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109956. */
  109957. export class OctreeBlock<T> {
  109958. /**
  109959. * Gets the content of the current block
  109960. */
  109961. entries: T[];
  109962. /**
  109963. * Gets the list of block children
  109964. */
  109965. blocks: Array<OctreeBlock<T>>;
  109966. private _depth;
  109967. private _maxDepth;
  109968. private _capacity;
  109969. private _minPoint;
  109970. private _maxPoint;
  109971. private _boundingVectors;
  109972. private _creationFunc;
  109973. /**
  109974. * Creates a new block
  109975. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109976. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109977. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109978. * @param depth defines the current depth of this block in the octree
  109979. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109980. * @param creationFunc defines a callback to call when an element is added to the block
  109981. */
  109982. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109983. /**
  109984. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109985. */
  109986. readonly capacity: number;
  109987. /**
  109988. * Gets the minimum vector (in world space) of the block's bounding box
  109989. */
  109990. readonly minPoint: Vector3;
  109991. /**
  109992. * Gets the maximum vector (in world space) of the block's bounding box
  109993. */
  109994. readonly maxPoint: Vector3;
  109995. /**
  109996. * Add a new element to this block
  109997. * @param entry defines the element to add
  109998. */
  109999. addEntry(entry: T): void;
  110000. /**
  110001. * Remove an element from this block
  110002. * @param entry defines the element to remove
  110003. */
  110004. removeEntry(entry: T): void;
  110005. /**
  110006. * Add an array of elements to this block
  110007. * @param entries defines the array of elements to add
  110008. */
  110009. addEntries(entries: T[]): void;
  110010. /**
  110011. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  110012. * @param frustumPlanes defines the frustum planes to test
  110013. * @param selection defines the array to store current content if selection is positive
  110014. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110015. */
  110016. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110017. /**
  110018. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  110019. * @param sphereCenter defines the bounding sphere center
  110020. * @param sphereRadius defines the bounding sphere radius
  110021. * @param selection defines the array to store current content if selection is positive
  110022. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110023. */
  110024. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110025. /**
  110026. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  110027. * @param ray defines the ray to test with
  110028. * @param selection defines the array to store current content if selection is positive
  110029. */
  110030. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  110031. /**
  110032. * Subdivide the content into child blocks (this block will then be empty)
  110033. */
  110034. createInnerBlocks(): void;
  110035. /**
  110036. * @hidden
  110037. */
  110038. 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;
  110039. }
  110040. }
  110041. declare module BABYLON {
  110042. /**
  110043. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  110044. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110045. */
  110046. export class Octree<T> {
  110047. /** 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.) */
  110048. maxDepth: number;
  110049. /**
  110050. * Blocks within the octree containing objects
  110051. */
  110052. blocks: Array<OctreeBlock<T>>;
  110053. /**
  110054. * Content stored in the octree
  110055. */
  110056. dynamicContent: T[];
  110057. private _maxBlockCapacity;
  110058. private _selectionContent;
  110059. private _creationFunc;
  110060. /**
  110061. * Creates a octree
  110062. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110063. * @param creationFunc function to be used to instatiate the octree
  110064. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  110065. * @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.)
  110066. */
  110067. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  110068. /** 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.) */
  110069. maxDepth?: number);
  110070. /**
  110071. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  110072. * @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);
  110073. * @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);
  110074. * @param entries meshes to be added to the octree blocks
  110075. */
  110076. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  110077. /**
  110078. * Adds a mesh to the octree
  110079. * @param entry Mesh to add to the octree
  110080. */
  110081. addMesh(entry: T): void;
  110082. /**
  110083. * Remove an element from the octree
  110084. * @param entry defines the element to remove
  110085. */
  110086. removeMesh(entry: T): void;
  110087. /**
  110088. * Selects an array of meshes within the frustum
  110089. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  110090. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  110091. * @returns array of meshes within the frustum
  110092. */
  110093. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  110094. /**
  110095. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  110096. * @param sphereCenter defines the bounding sphere center
  110097. * @param sphereRadius defines the bounding sphere radius
  110098. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110099. * @returns an array of objects that intersect the sphere
  110100. */
  110101. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  110102. /**
  110103. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  110104. * @param ray defines the ray to test with
  110105. * @returns array of intersected objects
  110106. */
  110107. intersectsRay(ray: Ray): SmartArray<T>;
  110108. /**
  110109. * Adds a mesh into the octree block if it intersects the block
  110110. */
  110111. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  110112. /**
  110113. * Adds a submesh into the octree block if it intersects the block
  110114. */
  110115. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  110116. }
  110117. }
  110118. declare module BABYLON {
  110119. interface Scene {
  110120. /**
  110121. * @hidden
  110122. * Backing Filed
  110123. */
  110124. _selectionOctree: Octree<AbstractMesh>;
  110125. /**
  110126. * Gets the octree used to boost mesh selection (picking)
  110127. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110128. */
  110129. selectionOctree: Octree<AbstractMesh>;
  110130. /**
  110131. * Creates or updates the octree used to boost selection (picking)
  110132. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110133. * @param maxCapacity defines the maximum capacity per leaf
  110134. * @param maxDepth defines the maximum depth of the octree
  110135. * @returns an octree of AbstractMesh
  110136. */
  110137. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  110138. }
  110139. interface AbstractMesh {
  110140. /**
  110141. * @hidden
  110142. * Backing Field
  110143. */
  110144. _submeshesOctree: Octree<SubMesh>;
  110145. /**
  110146. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  110147. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  110148. * @param maxCapacity defines the maximum size of each block (64 by default)
  110149. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  110150. * @returns the new octree
  110151. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  110152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110153. */
  110154. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  110155. }
  110156. /**
  110157. * Defines the octree scene component responsible to manage any octrees
  110158. * in a given scene.
  110159. */
  110160. export class OctreeSceneComponent {
  110161. /**
  110162. * The component name help to identify the component in the list of scene components.
  110163. */
  110164. readonly name: string;
  110165. /**
  110166. * The scene the component belongs to.
  110167. */
  110168. scene: Scene;
  110169. /**
  110170. * Indicates if the meshes have been checked to make sure they are isEnabled()
  110171. */
  110172. readonly checksIsEnabled: boolean;
  110173. /**
  110174. * Creates a new instance of the component for the given scene
  110175. * @param scene Defines the scene to register the component in
  110176. */
  110177. constructor(scene: Scene);
  110178. /**
  110179. * Registers the component in a given scene
  110180. */
  110181. register(): void;
  110182. /**
  110183. * Return the list of active meshes
  110184. * @returns the list of active meshes
  110185. */
  110186. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110187. /**
  110188. * Return the list of active sub meshes
  110189. * @param mesh The mesh to get the candidates sub meshes from
  110190. * @returns the list of active sub meshes
  110191. */
  110192. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110193. private _tempRay;
  110194. /**
  110195. * Return the list of sub meshes intersecting with a given local ray
  110196. * @param mesh defines the mesh to find the submesh for
  110197. * @param localRay defines the ray in local space
  110198. * @returns the list of intersecting sub meshes
  110199. */
  110200. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  110201. /**
  110202. * Return the list of sub meshes colliding with a collider
  110203. * @param mesh defines the mesh to find the submesh for
  110204. * @param collider defines the collider to evaluate the collision against
  110205. * @returns the list of colliding sub meshes
  110206. */
  110207. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  110208. /**
  110209. * Rebuilds the elements related to this component in case of
  110210. * context lost for instance.
  110211. */
  110212. rebuild(): void;
  110213. /**
  110214. * Disposes the component and the associated ressources.
  110215. */
  110216. dispose(): void;
  110217. }
  110218. }
  110219. declare module BABYLON {
  110220. /**
  110221. * Renders a layer on top of an existing scene
  110222. */
  110223. export class UtilityLayerRenderer implements IDisposable {
  110224. /** the original scene that will be rendered on top of */
  110225. originalScene: Scene;
  110226. private _pointerCaptures;
  110227. private _lastPointerEvents;
  110228. private static _DefaultUtilityLayer;
  110229. private static _DefaultKeepDepthUtilityLayer;
  110230. private _sharedGizmoLight;
  110231. private _renderCamera;
  110232. /**
  110233. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  110234. * @returns the camera that is used when rendering the utility layer
  110235. */
  110236. getRenderCamera(): Nullable<Camera>;
  110237. /**
  110238. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  110239. * @param cam the camera that should be used when rendering the utility layer
  110240. */
  110241. setRenderCamera(cam: Nullable<Camera>): void;
  110242. /**
  110243. * @hidden
  110244. * Light which used by gizmos to get light shading
  110245. */
  110246. _getSharedGizmoLight(): HemisphericLight;
  110247. /**
  110248. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  110249. */
  110250. pickUtilitySceneFirst: boolean;
  110251. /**
  110252. * 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)
  110253. */
  110254. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  110255. /**
  110256. * 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)
  110257. */
  110258. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  110259. /**
  110260. * The scene that is rendered on top of the original scene
  110261. */
  110262. utilityLayerScene: Scene;
  110263. /**
  110264. * If the utility layer should automatically be rendered on top of existing scene
  110265. */
  110266. shouldRender: boolean;
  110267. /**
  110268. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  110269. */
  110270. onlyCheckPointerDownEvents: boolean;
  110271. /**
  110272. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  110273. */
  110274. processAllEvents: boolean;
  110275. /**
  110276. * Observable raised when the pointer move from the utility layer scene to the main scene
  110277. */
  110278. onPointerOutObservable: Observable<number>;
  110279. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  110280. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  110281. private _afterRenderObserver;
  110282. private _sceneDisposeObserver;
  110283. private _originalPointerObserver;
  110284. /**
  110285. * Instantiates a UtilityLayerRenderer
  110286. * @param originalScene the original scene that will be rendered on top of
  110287. * @param handleEvents boolean indicating if the utility layer should handle events
  110288. */
  110289. constructor(
  110290. /** the original scene that will be rendered on top of */
  110291. originalScene: Scene, handleEvents?: boolean);
  110292. private _notifyObservers;
  110293. /**
  110294. * Renders the utility layers scene on top of the original scene
  110295. */
  110296. render(): void;
  110297. /**
  110298. * Disposes of the renderer
  110299. */
  110300. dispose(): void;
  110301. private _updateCamera;
  110302. }
  110303. }
  110304. declare module BABYLON {
  110305. /**
  110306. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  110307. */
  110308. export class Gizmo implements IDisposable {
  110309. /** The utility layer the gizmo will be added to */
  110310. gizmoLayer: UtilityLayerRenderer;
  110311. /**
  110312. * The root mesh of the gizmo
  110313. */
  110314. _rootMesh: Mesh;
  110315. private _attachedMesh;
  110316. /**
  110317. * Ratio for the scale of the gizmo (Default: 1)
  110318. */
  110319. scaleRatio: number;
  110320. /**
  110321. * If a custom mesh has been set (Default: false)
  110322. */
  110323. protected _customMeshSet: boolean;
  110324. /**
  110325. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  110326. * * When set, interactions will be enabled
  110327. */
  110328. attachedMesh: Nullable<AbstractMesh>;
  110329. /**
  110330. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110331. * @param mesh The mesh to replace the default mesh of the gizmo
  110332. */
  110333. setCustomMesh(mesh: Mesh): void;
  110334. /**
  110335. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  110336. */
  110337. updateGizmoRotationToMatchAttachedMesh: boolean;
  110338. /**
  110339. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  110340. */
  110341. updateGizmoPositionToMatchAttachedMesh: boolean;
  110342. /**
  110343. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  110344. */
  110345. updateScale: boolean;
  110346. protected _interactionsEnabled: boolean;
  110347. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110348. private _beforeRenderObserver;
  110349. private _tempVector;
  110350. /**
  110351. * Creates a gizmo
  110352. * @param gizmoLayer The utility layer the gizmo will be added to
  110353. */
  110354. constructor(
  110355. /** The utility layer the gizmo will be added to */
  110356. gizmoLayer?: UtilityLayerRenderer);
  110357. /**
  110358. * Updates the gizmo to match the attached mesh's position/rotation
  110359. */
  110360. protected _update(): void;
  110361. /**
  110362. * Disposes of the gizmo
  110363. */
  110364. dispose(): void;
  110365. }
  110366. }
  110367. declare module BABYLON {
  110368. /**
  110369. * Single plane drag gizmo
  110370. */
  110371. export class PlaneDragGizmo extends Gizmo {
  110372. /**
  110373. * Drag behavior responsible for the gizmos dragging interactions
  110374. */
  110375. dragBehavior: PointerDragBehavior;
  110376. private _pointerObserver;
  110377. /**
  110378. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110379. */
  110380. snapDistance: number;
  110381. /**
  110382. * Event that fires each time the gizmo snaps to a new location.
  110383. * * snapDistance is the the change in distance
  110384. */
  110385. onSnapObservable: Observable<{
  110386. snapDistance: number;
  110387. }>;
  110388. private _plane;
  110389. private _coloredMaterial;
  110390. private _hoverMaterial;
  110391. private _isEnabled;
  110392. private _parent;
  110393. /** @hidden */
  110394. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  110395. /** @hidden */
  110396. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110397. /**
  110398. * Creates a PlaneDragGizmo
  110399. * @param gizmoLayer The utility layer the gizmo will be added to
  110400. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  110401. * @param color The color of the gizmo
  110402. */
  110403. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110404. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110405. /**
  110406. * If the gizmo is enabled
  110407. */
  110408. isEnabled: boolean;
  110409. /**
  110410. * Disposes of the gizmo
  110411. */
  110412. dispose(): void;
  110413. }
  110414. }
  110415. declare module BABYLON {
  110416. /**
  110417. * Gizmo that enables dragging a mesh along 3 axis
  110418. */
  110419. export class PositionGizmo extends Gizmo {
  110420. /**
  110421. * Internal gizmo used for interactions on the x axis
  110422. */
  110423. xGizmo: AxisDragGizmo;
  110424. /**
  110425. * Internal gizmo used for interactions on the y axis
  110426. */
  110427. yGizmo: AxisDragGizmo;
  110428. /**
  110429. * Internal gizmo used for interactions on the z axis
  110430. */
  110431. zGizmo: AxisDragGizmo;
  110432. /**
  110433. * Internal gizmo used for interactions on the yz plane
  110434. */
  110435. xPlaneGizmo: PlaneDragGizmo;
  110436. /**
  110437. * Internal gizmo used for interactions on the xz plane
  110438. */
  110439. yPlaneGizmo: PlaneDragGizmo;
  110440. /**
  110441. * Internal gizmo used for interactions on the xy plane
  110442. */
  110443. zPlaneGizmo: PlaneDragGizmo;
  110444. /**
  110445. * private variables
  110446. */
  110447. private _meshAttached;
  110448. private _updateGizmoRotationToMatchAttachedMesh;
  110449. private _snapDistance;
  110450. private _scaleRatio;
  110451. /** Fires an event when any of it's sub gizmos are dragged */
  110452. onDragStartObservable: Observable<unknown>;
  110453. /** Fires an event when any of it's sub gizmos are released from dragging */
  110454. onDragEndObservable: Observable<unknown>;
  110455. /**
  110456. * If set to true, planar drag is enabled
  110457. */
  110458. private _planarGizmoEnabled;
  110459. attachedMesh: Nullable<AbstractMesh>;
  110460. /**
  110461. * Creates a PositionGizmo
  110462. * @param gizmoLayer The utility layer the gizmo will be added to
  110463. */
  110464. constructor(gizmoLayer?: UtilityLayerRenderer);
  110465. /**
  110466. * If the planar drag gizmo is enabled
  110467. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  110468. */
  110469. planarGizmoEnabled: boolean;
  110470. updateGizmoRotationToMatchAttachedMesh: boolean;
  110471. /**
  110472. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110473. */
  110474. snapDistance: number;
  110475. /**
  110476. * Ratio for the scale of the gizmo (Default: 1)
  110477. */
  110478. scaleRatio: number;
  110479. /**
  110480. * Disposes of the gizmo
  110481. */
  110482. dispose(): void;
  110483. /**
  110484. * CustomMeshes are not supported by this gizmo
  110485. * @param mesh The mesh to replace the default mesh of the gizmo
  110486. */
  110487. setCustomMesh(mesh: Mesh): void;
  110488. }
  110489. }
  110490. declare module BABYLON {
  110491. /**
  110492. * Single axis drag gizmo
  110493. */
  110494. export class AxisDragGizmo extends Gizmo {
  110495. /**
  110496. * Drag behavior responsible for the gizmos dragging interactions
  110497. */
  110498. dragBehavior: PointerDragBehavior;
  110499. private _pointerObserver;
  110500. /**
  110501. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110502. */
  110503. snapDistance: number;
  110504. /**
  110505. * Event that fires each time the gizmo snaps to a new location.
  110506. * * snapDistance is the the change in distance
  110507. */
  110508. onSnapObservable: Observable<{
  110509. snapDistance: number;
  110510. }>;
  110511. private _isEnabled;
  110512. private _parent;
  110513. private _arrow;
  110514. private _coloredMaterial;
  110515. private _hoverMaterial;
  110516. /** @hidden */
  110517. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  110518. /** @hidden */
  110519. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110520. /**
  110521. * Creates an AxisDragGizmo
  110522. * @param gizmoLayer The utility layer the gizmo will be added to
  110523. * @param dragAxis The axis which the gizmo will be able to drag on
  110524. * @param color The color of the gizmo
  110525. */
  110526. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110527. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110528. /**
  110529. * If the gizmo is enabled
  110530. */
  110531. isEnabled: boolean;
  110532. /**
  110533. * Disposes of the gizmo
  110534. */
  110535. dispose(): void;
  110536. }
  110537. }
  110538. declare module BABYLON.Debug {
  110539. /**
  110540. * The Axes viewer will show 3 axes in a specific point in space
  110541. */
  110542. export class AxesViewer {
  110543. private _xAxis;
  110544. private _yAxis;
  110545. private _zAxis;
  110546. private _scaleLinesFactor;
  110547. private _instanced;
  110548. /**
  110549. * Gets the hosting scene
  110550. */
  110551. scene: Scene;
  110552. /**
  110553. * Gets or sets a number used to scale line length
  110554. */
  110555. scaleLines: number;
  110556. /** Gets the node hierarchy used to render x-axis */
  110557. readonly xAxis: TransformNode;
  110558. /** Gets the node hierarchy used to render y-axis */
  110559. readonly yAxis: TransformNode;
  110560. /** Gets the node hierarchy used to render z-axis */
  110561. readonly zAxis: TransformNode;
  110562. /**
  110563. * Creates a new AxesViewer
  110564. * @param scene defines the hosting scene
  110565. * @param scaleLines defines a number used to scale line length (1 by default)
  110566. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  110567. * @param xAxis defines the node hierarchy used to render the x-axis
  110568. * @param yAxis defines the node hierarchy used to render the y-axis
  110569. * @param zAxis defines the node hierarchy used to render the z-axis
  110570. */
  110571. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  110572. /**
  110573. * Force the viewer to update
  110574. * @param position defines the position of the viewer
  110575. * @param xaxis defines the x axis of the viewer
  110576. * @param yaxis defines the y axis of the viewer
  110577. * @param zaxis defines the z axis of the viewer
  110578. */
  110579. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  110580. /**
  110581. * Creates an instance of this axes viewer.
  110582. * @returns a new axes viewer with instanced meshes
  110583. */
  110584. createInstance(): AxesViewer;
  110585. /** Releases resources */
  110586. dispose(): void;
  110587. private static _SetRenderingGroupId;
  110588. }
  110589. }
  110590. declare module BABYLON.Debug {
  110591. /**
  110592. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  110593. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  110594. */
  110595. export class BoneAxesViewer extends AxesViewer {
  110596. /**
  110597. * Gets or sets the target mesh where to display the axes viewer
  110598. */
  110599. mesh: Nullable<Mesh>;
  110600. /**
  110601. * Gets or sets the target bone where to display the axes viewer
  110602. */
  110603. bone: Nullable<Bone>;
  110604. /** Gets current position */
  110605. pos: Vector3;
  110606. /** Gets direction of X axis */
  110607. xaxis: Vector3;
  110608. /** Gets direction of Y axis */
  110609. yaxis: Vector3;
  110610. /** Gets direction of Z axis */
  110611. zaxis: Vector3;
  110612. /**
  110613. * Creates a new BoneAxesViewer
  110614. * @param scene defines the hosting scene
  110615. * @param bone defines the target bone
  110616. * @param mesh defines the target mesh
  110617. * @param scaleLines defines a scaling factor for line length (1 by default)
  110618. */
  110619. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  110620. /**
  110621. * Force the viewer to update
  110622. */
  110623. update(): void;
  110624. /** Releases resources */
  110625. dispose(): void;
  110626. }
  110627. }
  110628. declare module BABYLON {
  110629. /**
  110630. * Interface used to define scene explorer extensibility option
  110631. */
  110632. export interface IExplorerExtensibilityOption {
  110633. /**
  110634. * Define the option label
  110635. */
  110636. label: string;
  110637. /**
  110638. * Defines the action to execute on click
  110639. */
  110640. action: (entity: any) => void;
  110641. }
  110642. /**
  110643. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  110644. */
  110645. export interface IExplorerExtensibilityGroup {
  110646. /**
  110647. * Defines a predicate to test if a given type mut be extended
  110648. */
  110649. predicate: (entity: any) => boolean;
  110650. /**
  110651. * Gets the list of options added to a type
  110652. */
  110653. entries: IExplorerExtensibilityOption[];
  110654. }
  110655. /**
  110656. * Interface used to define the options to use to create the Inspector
  110657. */
  110658. export interface IInspectorOptions {
  110659. /**
  110660. * Display in overlay mode (default: false)
  110661. */
  110662. overlay?: boolean;
  110663. /**
  110664. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  110665. */
  110666. globalRoot?: HTMLElement;
  110667. /**
  110668. * Display the Scene explorer
  110669. */
  110670. showExplorer?: boolean;
  110671. /**
  110672. * Display the property inspector
  110673. */
  110674. showInspector?: boolean;
  110675. /**
  110676. * Display in embed mode (both panes on the right)
  110677. */
  110678. embedMode?: boolean;
  110679. /**
  110680. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  110681. */
  110682. handleResize?: boolean;
  110683. /**
  110684. * Allow the panes to popup (default: true)
  110685. */
  110686. enablePopup?: boolean;
  110687. /**
  110688. * Allow the panes to be closed by users (default: true)
  110689. */
  110690. enableClose?: boolean;
  110691. /**
  110692. * Optional list of extensibility entries
  110693. */
  110694. explorerExtensibility?: IExplorerExtensibilityGroup[];
  110695. /**
  110696. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  110697. */
  110698. inspectorURL?: string;
  110699. }
  110700. interface Scene {
  110701. /**
  110702. * @hidden
  110703. * Backing field
  110704. */
  110705. _debugLayer: DebugLayer;
  110706. /**
  110707. * Gets the debug layer (aka Inspector) associated with the scene
  110708. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110709. */
  110710. debugLayer: DebugLayer;
  110711. }
  110712. /**
  110713. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110714. * what is happening in your scene
  110715. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110716. */
  110717. export class DebugLayer {
  110718. /**
  110719. * Define the url to get the inspector script from.
  110720. * By default it uses the babylonjs CDN.
  110721. * @ignoreNaming
  110722. */
  110723. static InspectorURL: string;
  110724. private _scene;
  110725. private BJSINSPECTOR;
  110726. private _onPropertyChangedObservable?;
  110727. /**
  110728. * Observable triggered when a property is changed through the inspector.
  110729. */
  110730. readonly onPropertyChangedObservable: any;
  110731. /**
  110732. * Instantiates a new debug layer.
  110733. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110734. * what is happening in your scene
  110735. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110736. * @param scene Defines the scene to inspect
  110737. */
  110738. constructor(scene: Scene);
  110739. /** Creates the inspector window. */
  110740. private _createInspector;
  110741. /**
  110742. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110743. * @param entity defines the entity to select
  110744. * @param lineContainerTitle defines the specific block to highlight
  110745. */
  110746. select(entity: any, lineContainerTitle?: string): void;
  110747. /** Get the inspector from bundle or global */
  110748. private _getGlobalInspector;
  110749. /**
  110750. * Get if the inspector is visible or not.
  110751. * @returns true if visible otherwise, false
  110752. */
  110753. isVisible(): boolean;
  110754. /**
  110755. * Hide the inspector and close its window.
  110756. */
  110757. hide(): void;
  110758. /**
  110759. * Launch the debugLayer.
  110760. * @param config Define the configuration of the inspector
  110761. * @return a promise fulfilled when the debug layer is visible
  110762. */
  110763. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110764. }
  110765. }
  110766. declare module BABYLON {
  110767. /**
  110768. * Class containing static functions to help procedurally build meshes
  110769. */
  110770. export class BoxBuilder {
  110771. /**
  110772. * Creates a box mesh
  110773. * * The parameter `size` sets the size (float) of each box side (default 1)
  110774. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110775. * * 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)
  110776. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110780. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110781. * @param name defines the name of the mesh
  110782. * @param options defines the options used to create the mesh
  110783. * @param scene defines the hosting scene
  110784. * @returns the box mesh
  110785. */
  110786. static CreateBox(name: string, options: {
  110787. size?: number;
  110788. width?: number;
  110789. height?: number;
  110790. depth?: number;
  110791. faceUV?: Vector4[];
  110792. faceColors?: Color4[];
  110793. sideOrientation?: number;
  110794. frontUVs?: Vector4;
  110795. backUVs?: Vector4;
  110796. wrap?: boolean;
  110797. topBaseAt?: number;
  110798. bottomBaseAt?: number;
  110799. updatable?: boolean;
  110800. }, scene?: Nullable<Scene>): Mesh;
  110801. }
  110802. }
  110803. declare module BABYLON {
  110804. /**
  110805. * Class containing static functions to help procedurally build meshes
  110806. */
  110807. export class SphereBuilder {
  110808. /**
  110809. * Creates a sphere mesh
  110810. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110811. * * 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`)
  110812. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110813. * * 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
  110814. * * 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)
  110815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110818. * @param name defines the name of the mesh
  110819. * @param options defines the options used to create the mesh
  110820. * @param scene defines the hosting scene
  110821. * @returns the sphere mesh
  110822. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110823. */
  110824. static CreateSphere(name: string, options: {
  110825. segments?: number;
  110826. diameter?: number;
  110827. diameterX?: number;
  110828. diameterY?: number;
  110829. diameterZ?: number;
  110830. arc?: number;
  110831. slice?: number;
  110832. sideOrientation?: number;
  110833. frontUVs?: Vector4;
  110834. backUVs?: Vector4;
  110835. updatable?: boolean;
  110836. }, scene?: Nullable<Scene>): Mesh;
  110837. }
  110838. }
  110839. declare module BABYLON.Debug {
  110840. /**
  110841. * Used to show the physics impostor around the specific mesh
  110842. */
  110843. export class PhysicsViewer {
  110844. /** @hidden */
  110845. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110846. /** @hidden */
  110847. protected _meshes: Array<Nullable<AbstractMesh>>;
  110848. /** @hidden */
  110849. protected _scene: Nullable<Scene>;
  110850. /** @hidden */
  110851. protected _numMeshes: number;
  110852. /** @hidden */
  110853. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110854. private _renderFunction;
  110855. private _utilityLayer;
  110856. private _debugBoxMesh;
  110857. private _debugSphereMesh;
  110858. private _debugCylinderMesh;
  110859. private _debugMaterial;
  110860. private _debugMeshMeshes;
  110861. /**
  110862. * Creates a new PhysicsViewer
  110863. * @param scene defines the hosting scene
  110864. */
  110865. constructor(scene: Scene);
  110866. /** @hidden */
  110867. protected _updateDebugMeshes(): void;
  110868. /**
  110869. * Renders a specified physic impostor
  110870. * @param impostor defines the impostor to render
  110871. * @param targetMesh defines the mesh represented by the impostor
  110872. * @returns the new debug mesh used to render the impostor
  110873. */
  110874. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110875. /**
  110876. * Hides a specified physic impostor
  110877. * @param impostor defines the impostor to hide
  110878. */
  110879. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110880. private _getDebugMaterial;
  110881. private _getDebugBoxMesh;
  110882. private _getDebugSphereMesh;
  110883. private _getDebugCylinderMesh;
  110884. private _getDebugMeshMesh;
  110885. private _getDebugMesh;
  110886. /** Releases all resources */
  110887. dispose(): void;
  110888. }
  110889. }
  110890. declare module BABYLON {
  110891. /**
  110892. * Class containing static functions to help procedurally build meshes
  110893. */
  110894. export class LinesBuilder {
  110895. /**
  110896. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110897. * * 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
  110898. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110899. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110900. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110901. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110902. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110903. * * 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
  110904. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110907. * @param name defines the name of the new line system
  110908. * @param options defines the options used to create the line system
  110909. * @param scene defines the hosting scene
  110910. * @returns a new line system mesh
  110911. */
  110912. static CreateLineSystem(name: string, options: {
  110913. lines: Vector3[][];
  110914. updatable?: boolean;
  110915. instance?: Nullable<LinesMesh>;
  110916. colors?: Nullable<Color4[][]>;
  110917. useVertexAlpha?: boolean;
  110918. }, scene: Nullable<Scene>): LinesMesh;
  110919. /**
  110920. * Creates a line mesh
  110921. * 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
  110922. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110923. * * The parameter `points` is an array successive Vector3
  110924. * * 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
  110925. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110926. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110927. * * When updating an instance, remember that only point positions can change, not the number of points
  110928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110930. * @param name defines the name of the new line system
  110931. * @param options defines the options used to create the line system
  110932. * @param scene defines the hosting scene
  110933. * @returns a new line mesh
  110934. */
  110935. static CreateLines(name: string, options: {
  110936. points: Vector3[];
  110937. updatable?: boolean;
  110938. instance?: Nullable<LinesMesh>;
  110939. colors?: Color4[];
  110940. useVertexAlpha?: boolean;
  110941. }, scene?: Nullable<Scene>): LinesMesh;
  110942. /**
  110943. * Creates a dashed line mesh
  110944. * * 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
  110945. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110946. * * The parameter `points` is an array successive Vector3
  110947. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110948. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110949. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110950. * * 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
  110951. * * When updating an instance, remember that only point positions can change, not the number of points
  110952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110953. * @param name defines the name of the mesh
  110954. * @param options defines the options used to create the mesh
  110955. * @param scene defines the hosting scene
  110956. * @returns the dashed line mesh
  110957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110958. */
  110959. static CreateDashedLines(name: string, options: {
  110960. points: Vector3[];
  110961. dashSize?: number;
  110962. gapSize?: number;
  110963. dashNb?: number;
  110964. updatable?: boolean;
  110965. instance?: LinesMesh;
  110966. }, scene?: Nullable<Scene>): LinesMesh;
  110967. }
  110968. }
  110969. declare module BABYLON {
  110970. /**
  110971. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110972. * in order to better appreciate the issue one might have.
  110973. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110974. */
  110975. export class RayHelper {
  110976. /**
  110977. * Defines the ray we are currently tryin to visualize.
  110978. */
  110979. ray: Nullable<Ray>;
  110980. private _renderPoints;
  110981. private _renderLine;
  110982. private _renderFunction;
  110983. private _scene;
  110984. private _updateToMeshFunction;
  110985. private _attachedToMesh;
  110986. private _meshSpaceDirection;
  110987. private _meshSpaceOrigin;
  110988. /**
  110989. * Helper function to create a colored helper in a scene in one line.
  110990. * @param ray Defines the ray we are currently tryin to visualize
  110991. * @param scene Defines the scene the ray is used in
  110992. * @param color Defines the color we want to see the ray in
  110993. * @returns The newly created ray helper.
  110994. */
  110995. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110996. /**
  110997. * Instantiate a new ray helper.
  110998. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110999. * in order to better appreciate the issue one might have.
  111000. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111001. * @param ray Defines the ray we are currently tryin to visualize
  111002. */
  111003. constructor(ray: Ray);
  111004. /**
  111005. * Shows the ray we are willing to debug.
  111006. * @param scene Defines the scene the ray needs to be rendered in
  111007. * @param color Defines the color the ray needs to be rendered in
  111008. */
  111009. show(scene: Scene, color?: Color3): void;
  111010. /**
  111011. * Hides the ray we are debugging.
  111012. */
  111013. hide(): void;
  111014. private _render;
  111015. /**
  111016. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  111017. * @param mesh Defines the mesh we want the helper attached to
  111018. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  111019. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  111020. * @param length Defines the length of the ray
  111021. */
  111022. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  111023. /**
  111024. * Detach the ray helper from the mesh it has previously been attached to.
  111025. */
  111026. detachFromMesh(): void;
  111027. private _updateToMesh;
  111028. /**
  111029. * Dispose the helper and release its associated resources.
  111030. */
  111031. dispose(): void;
  111032. }
  111033. }
  111034. declare module BABYLON.Debug {
  111035. /**
  111036. * Class used to render a debug view of a given skeleton
  111037. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  111038. */
  111039. export class SkeletonViewer {
  111040. /** defines the skeleton to render */
  111041. skeleton: Skeleton;
  111042. /** defines the mesh attached to the skeleton */
  111043. mesh: AbstractMesh;
  111044. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111045. autoUpdateBonesMatrices: boolean;
  111046. /** defines the rendering group id to use with the viewer */
  111047. renderingGroupId: number;
  111048. /** Gets or sets the color used to render the skeleton */
  111049. color: Color3;
  111050. private _scene;
  111051. private _debugLines;
  111052. private _debugMesh;
  111053. private _isEnabled;
  111054. private _renderFunction;
  111055. private _utilityLayer;
  111056. /**
  111057. * Returns the mesh used to render the bones
  111058. */
  111059. readonly debugMesh: Nullable<LinesMesh>;
  111060. /**
  111061. * Creates a new SkeletonViewer
  111062. * @param skeleton defines the skeleton to render
  111063. * @param mesh defines the mesh attached to the skeleton
  111064. * @param scene defines the hosting scene
  111065. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  111066. * @param renderingGroupId defines the rendering group id to use with the viewer
  111067. */
  111068. constructor(
  111069. /** defines the skeleton to render */
  111070. skeleton: Skeleton,
  111071. /** defines the mesh attached to the skeleton */
  111072. mesh: AbstractMesh, scene: Scene,
  111073. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111074. autoUpdateBonesMatrices?: boolean,
  111075. /** defines the rendering group id to use with the viewer */
  111076. renderingGroupId?: number);
  111077. /** Gets or sets a boolean indicating if the viewer is enabled */
  111078. isEnabled: boolean;
  111079. private _getBonePosition;
  111080. private _getLinesForBonesWithLength;
  111081. private _getLinesForBonesNoLength;
  111082. /** Update the viewer to sync with current skeleton state */
  111083. update(): void;
  111084. /** Release associated resources */
  111085. dispose(): void;
  111086. }
  111087. }
  111088. declare module BABYLON {
  111089. /**
  111090. * Options to create the null engine
  111091. */
  111092. export class NullEngineOptions {
  111093. /**
  111094. * Render width (Default: 512)
  111095. */
  111096. renderWidth: number;
  111097. /**
  111098. * Render height (Default: 256)
  111099. */
  111100. renderHeight: number;
  111101. /**
  111102. * Texture size (Default: 512)
  111103. */
  111104. textureSize: number;
  111105. /**
  111106. * If delta time between frames should be constant
  111107. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111108. */
  111109. deterministicLockstep: boolean;
  111110. /**
  111111. * Maximum about of steps between frames (Default: 4)
  111112. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111113. */
  111114. lockstepMaxSteps: number;
  111115. }
  111116. /**
  111117. * The null engine class provides support for headless version of babylon.js.
  111118. * This can be used in server side scenario or for testing purposes
  111119. */
  111120. export class NullEngine extends Engine {
  111121. private _options;
  111122. /**
  111123. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  111124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111125. * @returns true if engine is in deterministic lock step mode
  111126. */
  111127. isDeterministicLockStep(): boolean;
  111128. /**
  111129. * Gets the max steps when engine is running in deterministic lock step
  111130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111131. * @returns the max steps
  111132. */
  111133. getLockstepMaxSteps(): number;
  111134. /**
  111135. * Gets the current hardware scaling level.
  111136. * By default the hardware scaling level is computed from the window device ratio.
  111137. * 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.
  111138. * @returns a number indicating the current hardware scaling level
  111139. */
  111140. getHardwareScalingLevel(): number;
  111141. constructor(options?: NullEngineOptions);
  111142. /**
  111143. * Creates a vertex buffer
  111144. * @param vertices the data for the vertex buffer
  111145. * @returns the new WebGL static buffer
  111146. */
  111147. createVertexBuffer(vertices: FloatArray): DataBuffer;
  111148. /**
  111149. * Creates a new index buffer
  111150. * @param indices defines the content of the index buffer
  111151. * @param updatable defines if the index buffer must be updatable
  111152. * @returns a new webGL buffer
  111153. */
  111154. createIndexBuffer(indices: IndicesArray): DataBuffer;
  111155. /**
  111156. * Clear the current render buffer or the current render target (if any is set up)
  111157. * @param color defines the color to use
  111158. * @param backBuffer defines if the back buffer must be cleared
  111159. * @param depth defines if the depth buffer must be cleared
  111160. * @param stencil defines if the stencil buffer must be cleared
  111161. */
  111162. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111163. /**
  111164. * Gets the current render width
  111165. * @param useScreen defines if screen size must be used (or the current render target if any)
  111166. * @returns a number defining the current render width
  111167. */
  111168. getRenderWidth(useScreen?: boolean): number;
  111169. /**
  111170. * Gets the current render height
  111171. * @param useScreen defines if screen size must be used (or the current render target if any)
  111172. * @returns a number defining the current render height
  111173. */
  111174. getRenderHeight(useScreen?: boolean): number;
  111175. /**
  111176. * Set the WebGL's viewport
  111177. * @param viewport defines the viewport element to be used
  111178. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111179. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111180. */
  111181. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111182. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  111183. /**
  111184. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111185. * @param pipelineContext defines the pipeline context to use
  111186. * @param uniformsNames defines the list of uniform names
  111187. * @returns an array of webGL uniform locations
  111188. */
  111189. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111190. /**
  111191. * Gets the lsit of active attributes for a given webGL program
  111192. * @param pipelineContext defines the pipeline context to use
  111193. * @param attributesNames defines the list of attribute names to get
  111194. * @returns an array of indices indicating the offset of each attribute
  111195. */
  111196. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111197. /**
  111198. * Binds an effect to the webGL context
  111199. * @param effect defines the effect to bind
  111200. */
  111201. bindSamplers(effect: Effect): void;
  111202. /**
  111203. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111204. * @param effect defines the effect to activate
  111205. */
  111206. enableEffect(effect: Effect): void;
  111207. /**
  111208. * Set various states to the webGL context
  111209. * @param culling defines backface culling state
  111210. * @param zOffset defines the value to apply to zOffset (0 by default)
  111211. * @param force defines if states must be applied even if cache is up to date
  111212. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  111213. */
  111214. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111215. /**
  111216. * Set the value of an uniform to an array of int32
  111217. * @param uniform defines the webGL uniform location where to store the value
  111218. * @param array defines the array of int32 to store
  111219. */
  111220. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111221. /**
  111222. * Set the value of an uniform to an array of int32 (stored as vec2)
  111223. * @param uniform defines the webGL uniform location where to store the value
  111224. * @param array defines the array of int32 to store
  111225. */
  111226. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111227. /**
  111228. * Set the value of an uniform to an array of int32 (stored as vec3)
  111229. * @param uniform defines the webGL uniform location where to store the value
  111230. * @param array defines the array of int32 to store
  111231. */
  111232. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111233. /**
  111234. * Set the value of an uniform to an array of int32 (stored as vec4)
  111235. * @param uniform defines the webGL uniform location where to store the value
  111236. * @param array defines the array of int32 to store
  111237. */
  111238. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111239. /**
  111240. * Set the value of an uniform to an array of float32
  111241. * @param uniform defines the webGL uniform location where to store the value
  111242. * @param array defines the array of float32 to store
  111243. */
  111244. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111245. /**
  111246. * Set the value of an uniform to an array of float32 (stored as vec2)
  111247. * @param uniform defines the webGL uniform location where to store the value
  111248. * @param array defines the array of float32 to store
  111249. */
  111250. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111251. /**
  111252. * Set the value of an uniform to an array of float32 (stored as vec3)
  111253. * @param uniform defines the webGL uniform location where to store the value
  111254. * @param array defines the array of float32 to store
  111255. */
  111256. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111257. /**
  111258. * Set the value of an uniform to an array of float32 (stored as vec4)
  111259. * @param uniform defines the webGL uniform location where to store the value
  111260. * @param array defines the array of float32 to store
  111261. */
  111262. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111263. /**
  111264. * Set the value of an uniform to an array of number
  111265. * @param uniform defines the webGL uniform location where to store the value
  111266. * @param array defines the array of number to store
  111267. */
  111268. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111269. /**
  111270. * Set the value of an uniform to an array of number (stored as vec2)
  111271. * @param uniform defines the webGL uniform location where to store the value
  111272. * @param array defines the array of number to store
  111273. */
  111274. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111275. /**
  111276. * Set the value of an uniform to an array of number (stored as vec3)
  111277. * @param uniform defines the webGL uniform location where to store the value
  111278. * @param array defines the array of number to store
  111279. */
  111280. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111281. /**
  111282. * Set the value of an uniform to an array of number (stored as vec4)
  111283. * @param uniform defines the webGL uniform location where to store the value
  111284. * @param array defines the array of number to store
  111285. */
  111286. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111287. /**
  111288. * Set the value of an uniform to an array of float32 (stored as matrices)
  111289. * @param uniform defines the webGL uniform location where to store the value
  111290. * @param matrices defines the array of float32 to store
  111291. */
  111292. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111293. /**
  111294. * Set the value of an uniform to a matrix (3x3)
  111295. * @param uniform defines the webGL uniform location where to store the value
  111296. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111297. */
  111298. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111299. /**
  111300. * Set the value of an uniform to a matrix (2x2)
  111301. * @param uniform defines the webGL uniform location where to store the value
  111302. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111303. */
  111304. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111305. /**
  111306. * Set the value of an uniform to a number (float)
  111307. * @param uniform defines the webGL uniform location where to store the value
  111308. * @param value defines the float number to store
  111309. */
  111310. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111311. /**
  111312. * Set the value of an uniform to a vec2
  111313. * @param uniform defines the webGL uniform location where to store the value
  111314. * @param x defines the 1st component of the value
  111315. * @param y defines the 2nd component of the value
  111316. */
  111317. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111318. /**
  111319. * Set the value of an uniform to a vec3
  111320. * @param uniform defines the webGL uniform location where to store the value
  111321. * @param x defines the 1st component of the value
  111322. * @param y defines the 2nd component of the value
  111323. * @param z defines the 3rd component of the value
  111324. */
  111325. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111326. /**
  111327. * Set the value of an uniform to a boolean
  111328. * @param uniform defines the webGL uniform location where to store the value
  111329. * @param bool defines the boolean to store
  111330. */
  111331. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111332. /**
  111333. * Set the value of an uniform to a vec4
  111334. * @param uniform defines the webGL uniform location where to store the value
  111335. * @param x defines the 1st component of the value
  111336. * @param y defines the 2nd component of the value
  111337. * @param z defines the 3rd component of the value
  111338. * @param w defines the 4th component of the value
  111339. */
  111340. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111341. /**
  111342. * Sets the current alpha mode
  111343. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  111344. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111345. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111346. */
  111347. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111348. /**
  111349. * Bind webGl buffers directly to the webGL context
  111350. * @param vertexBuffers defines the vertex buffer to bind
  111351. * @param indexBuffer defines the index buffer to bind
  111352. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111353. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111354. * @param effect defines the effect associated with the vertex buffer
  111355. */
  111356. bindBuffers(vertexBuffers: {
  111357. [key: string]: VertexBuffer;
  111358. }, indexBuffer: DataBuffer, effect: Effect): void;
  111359. /**
  111360. * Force the entire cache to be cleared
  111361. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  111362. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  111363. */
  111364. wipeCaches(bruteForce?: boolean): void;
  111365. /**
  111366. * Send a draw order
  111367. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111368. * @param indexStart defines the starting index
  111369. * @param indexCount defines the number of index to draw
  111370. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111371. */
  111372. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111373. /**
  111374. * Draw a list of indexed primitives
  111375. * @param fillMode defines the primitive to use
  111376. * @param indexStart defines the starting index
  111377. * @param indexCount defines the number of index to draw
  111378. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111379. */
  111380. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111381. /**
  111382. * Draw a list of unindexed primitives
  111383. * @param fillMode defines the primitive to use
  111384. * @param verticesStart defines the index of first vertex to draw
  111385. * @param verticesCount defines the count of vertices to draw
  111386. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111387. */
  111388. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111389. /** @hidden */
  111390. _createTexture(): WebGLTexture;
  111391. /** @hidden */
  111392. _releaseTexture(texture: InternalTexture): void;
  111393. /**
  111394. * Usually called from Texture.ts.
  111395. * Passed information to create a WebGLTexture
  111396. * @param urlArg defines a value which contains one of the following:
  111397. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111398. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111399. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111400. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111401. * @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)
  111402. * @param scene needed for loading to the correct scene
  111403. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  111404. * @param onLoad optional callback to be called upon successful completion
  111405. * @param onError optional callback to be called upon failure
  111406. * @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
  111407. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111408. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111409. * @param forcedExtension defines the extension to use to pick the right loader
  111410. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  111411. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111412. */
  111413. 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;
  111414. /**
  111415. * Creates a new render target texture
  111416. * @param size defines the size of the texture
  111417. * @param options defines the options used to create the texture
  111418. * @returns a new render target texture stored in an InternalTexture
  111419. */
  111420. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111421. /**
  111422. * Update the sampling mode of a given texture
  111423. * @param samplingMode defines the required sampling mode
  111424. * @param texture defines the texture to update
  111425. */
  111426. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111427. /**
  111428. * Binds the frame buffer to the specified texture.
  111429. * @param texture The texture to render to or null for the default canvas
  111430. * @param faceIndex The face of the texture to render to in case of cube texture
  111431. * @param requiredWidth The width of the target to render to
  111432. * @param requiredHeight The height of the target to render to
  111433. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111434. * @param depthStencilTexture The depth stencil texture to use to render
  111435. * @param lodLevel defines le lod level to bind to the frame buffer
  111436. */
  111437. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111438. /**
  111439. * Unbind the current render target texture from the webGL context
  111440. * @param texture defines the render target texture to unbind
  111441. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111442. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111443. */
  111444. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111445. /**
  111446. * Creates a dynamic vertex buffer
  111447. * @param vertices the data for the dynamic vertex buffer
  111448. * @returns the new WebGL dynamic buffer
  111449. */
  111450. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  111451. /**
  111452. * Update the content of a dynamic texture
  111453. * @param texture defines the texture to update
  111454. * @param canvas defines the canvas containing the source
  111455. * @param invertY defines if data must be stored with Y axis inverted
  111456. * @param premulAlpha defines if alpha is stored as premultiplied
  111457. * @param format defines the format of the data
  111458. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  111459. */
  111460. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  111461. /**
  111462. * Gets a boolean indicating if all created effects are ready
  111463. * @returns true if all effects are ready
  111464. */
  111465. areAllEffectsReady(): boolean;
  111466. /**
  111467. * @hidden
  111468. * Get the current error code of the webGL context
  111469. * @returns the error code
  111470. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  111471. */
  111472. getError(): number;
  111473. /** @hidden */
  111474. _getUnpackAlignement(): number;
  111475. /** @hidden */
  111476. _unpackFlipY(value: boolean): void;
  111477. /**
  111478. * Update a dynamic index buffer
  111479. * @param indexBuffer defines the target index buffer
  111480. * @param indices defines the data to update
  111481. * @param offset defines the offset in the target index buffer where update should start
  111482. */
  111483. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  111484. /**
  111485. * Updates a dynamic vertex buffer.
  111486. * @param vertexBuffer the vertex buffer to update
  111487. * @param vertices the data used to update the vertex buffer
  111488. * @param byteOffset the byte offset of the data (optional)
  111489. * @param byteLength the byte length of the data (optional)
  111490. */
  111491. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  111492. /** @hidden */
  111493. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  111494. /** @hidden */
  111495. _bindTexture(channel: number, texture: InternalTexture): void;
  111496. protected _deleteBuffer(buffer: WebGLBuffer): void;
  111497. /**
  111498. * 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
  111499. */
  111500. releaseEffects(): void;
  111501. displayLoadingUI(): void;
  111502. hideLoadingUI(): void;
  111503. /** @hidden */
  111504. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111505. /** @hidden */
  111506. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111507. /** @hidden */
  111508. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111509. /** @hidden */
  111510. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111511. }
  111512. }
  111513. declare module BABYLON {
  111514. /** @hidden */
  111515. export class _OcclusionDataStorage {
  111516. /** @hidden */
  111517. occlusionInternalRetryCounter: number;
  111518. /** @hidden */
  111519. isOcclusionQueryInProgress: boolean;
  111520. /** @hidden */
  111521. isOccluded: boolean;
  111522. /** @hidden */
  111523. occlusionRetryCount: number;
  111524. /** @hidden */
  111525. occlusionType: number;
  111526. /** @hidden */
  111527. occlusionQueryAlgorithmType: number;
  111528. }
  111529. interface Engine {
  111530. /**
  111531. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  111532. * @return the new query
  111533. */
  111534. createQuery(): WebGLQuery;
  111535. /**
  111536. * Delete and release a webGL query
  111537. * @param query defines the query to delete
  111538. * @return the current engine
  111539. */
  111540. deleteQuery(query: WebGLQuery): Engine;
  111541. /**
  111542. * Check if a given query has resolved and got its value
  111543. * @param query defines the query to check
  111544. * @returns true if the query got its value
  111545. */
  111546. isQueryResultAvailable(query: WebGLQuery): boolean;
  111547. /**
  111548. * Gets the value of a given query
  111549. * @param query defines the query to check
  111550. * @returns the value of the query
  111551. */
  111552. getQueryResult(query: WebGLQuery): number;
  111553. /**
  111554. * Initiates an occlusion query
  111555. * @param algorithmType defines the algorithm to use
  111556. * @param query defines the query to use
  111557. * @returns the current engine
  111558. * @see http://doc.babylonjs.com/features/occlusionquery
  111559. */
  111560. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  111561. /**
  111562. * Ends an occlusion query
  111563. * @see http://doc.babylonjs.com/features/occlusionquery
  111564. * @param algorithmType defines the algorithm to use
  111565. * @returns the current engine
  111566. */
  111567. endOcclusionQuery(algorithmType: number): Engine;
  111568. /**
  111569. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  111570. * Please note that only one query can be issued at a time
  111571. * @returns a time token used to track the time span
  111572. */
  111573. startTimeQuery(): Nullable<_TimeToken>;
  111574. /**
  111575. * Ends a time query
  111576. * @param token defines the token used to measure the time span
  111577. * @returns the time spent (in ns)
  111578. */
  111579. endTimeQuery(token: _TimeToken): int;
  111580. /** @hidden */
  111581. _currentNonTimestampToken: Nullable<_TimeToken>;
  111582. /** @hidden */
  111583. _createTimeQuery(): WebGLQuery;
  111584. /** @hidden */
  111585. _deleteTimeQuery(query: WebGLQuery): void;
  111586. /** @hidden */
  111587. _getGlAlgorithmType(algorithmType: number): number;
  111588. /** @hidden */
  111589. _getTimeQueryResult(query: WebGLQuery): any;
  111590. /** @hidden */
  111591. _getTimeQueryAvailability(query: WebGLQuery): any;
  111592. }
  111593. interface AbstractMesh {
  111594. /**
  111595. * Backing filed
  111596. * @hidden
  111597. */
  111598. __occlusionDataStorage: _OcclusionDataStorage;
  111599. /**
  111600. * Access property
  111601. * @hidden
  111602. */
  111603. _occlusionDataStorage: _OcclusionDataStorage;
  111604. /**
  111605. * 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.
  111606. * The default value is -1 which means don't break the query and wait till the result
  111607. * @see http://doc.babylonjs.com/features/occlusionquery
  111608. */
  111609. occlusionRetryCount: number;
  111610. /**
  111611. * 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:
  111612. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  111613. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  111614. * * 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.
  111615. * @see http://doc.babylonjs.com/features/occlusionquery
  111616. */
  111617. occlusionType: number;
  111618. /**
  111619. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  111620. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  111621. * * 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.
  111622. * @see http://doc.babylonjs.com/features/occlusionquery
  111623. */
  111624. occlusionQueryAlgorithmType: number;
  111625. /**
  111626. * 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
  111627. * @see http://doc.babylonjs.com/features/occlusionquery
  111628. */
  111629. isOccluded: boolean;
  111630. /**
  111631. * Flag to check the progress status of the query
  111632. * @see http://doc.babylonjs.com/features/occlusionquery
  111633. */
  111634. isOcclusionQueryInProgress: boolean;
  111635. }
  111636. }
  111637. declare module BABYLON {
  111638. /** @hidden */
  111639. export var _forceTransformFeedbackToBundle: boolean;
  111640. interface Engine {
  111641. /**
  111642. * Creates a webGL transform feedback object
  111643. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  111644. * @returns the webGL transform feedback object
  111645. */
  111646. createTransformFeedback(): WebGLTransformFeedback;
  111647. /**
  111648. * Delete a webGL transform feedback object
  111649. * @param value defines the webGL transform feedback object to delete
  111650. */
  111651. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  111652. /**
  111653. * Bind a webGL transform feedback object to the webgl context
  111654. * @param value defines the webGL transform feedback object to bind
  111655. */
  111656. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  111657. /**
  111658. * Begins a transform feedback operation
  111659. * @param usePoints defines if points or triangles must be used
  111660. */
  111661. beginTransformFeedback(usePoints: boolean): void;
  111662. /**
  111663. * Ends a transform feedback operation
  111664. */
  111665. endTransformFeedback(): void;
  111666. /**
  111667. * Specify the varyings to use with transform feedback
  111668. * @param program defines the associated webGL program
  111669. * @param value defines the list of strings representing the varying names
  111670. */
  111671. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  111672. /**
  111673. * Bind a webGL buffer for a transform feedback operation
  111674. * @param value defines the webGL buffer to bind
  111675. */
  111676. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  111677. }
  111678. }
  111679. declare module BABYLON {
  111680. /**
  111681. * Creation options of the multi render target texture.
  111682. */
  111683. export interface IMultiRenderTargetOptions {
  111684. /**
  111685. * Define if the texture needs to create mip maps after render.
  111686. */
  111687. generateMipMaps?: boolean;
  111688. /**
  111689. * Define the types of all the draw buffers we want to create
  111690. */
  111691. types?: number[];
  111692. /**
  111693. * Define the sampling modes of all the draw buffers we want to create
  111694. */
  111695. samplingModes?: number[];
  111696. /**
  111697. * Define if a depth buffer is required
  111698. */
  111699. generateDepthBuffer?: boolean;
  111700. /**
  111701. * Define if a stencil buffer is required
  111702. */
  111703. generateStencilBuffer?: boolean;
  111704. /**
  111705. * Define if a depth texture is required instead of a depth buffer
  111706. */
  111707. generateDepthTexture?: boolean;
  111708. /**
  111709. * Define the number of desired draw buffers
  111710. */
  111711. textureCount?: number;
  111712. /**
  111713. * Define if aspect ratio should be adapted to the texture or stay the scene one
  111714. */
  111715. doNotChangeAspectRatio?: boolean;
  111716. /**
  111717. * Define the default type of the buffers we are creating
  111718. */
  111719. defaultType?: number;
  111720. }
  111721. /**
  111722. * A multi render target, like a render target provides the ability to render to a texture.
  111723. * Unlike the render target, it can render to several draw buffers in one draw.
  111724. * This is specially interesting in deferred rendering or for any effects requiring more than
  111725. * just one color from a single pass.
  111726. */
  111727. export class MultiRenderTarget extends RenderTargetTexture {
  111728. private _internalTextures;
  111729. private _textures;
  111730. private _multiRenderTargetOptions;
  111731. /**
  111732. * Get if draw buffers are currently supported by the used hardware and browser.
  111733. */
  111734. readonly isSupported: boolean;
  111735. /**
  111736. * Get the list of textures generated by the multi render target.
  111737. */
  111738. readonly textures: Texture[];
  111739. /**
  111740. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111741. */
  111742. readonly depthTexture: Texture;
  111743. /**
  111744. * Set the wrapping mode on U of all the textures we are rendering to.
  111745. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111746. */
  111747. wrapU: number;
  111748. /**
  111749. * Set the wrapping mode on V of all the textures we are rendering to.
  111750. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111751. */
  111752. wrapV: number;
  111753. /**
  111754. * Instantiate a new multi render target texture.
  111755. * A multi render target, like a render target provides the ability to render to a texture.
  111756. * Unlike the render target, it can render to several draw buffers in one draw.
  111757. * This is specially interesting in deferred rendering or for any effects requiring more than
  111758. * just one color from a single pass.
  111759. * @param name Define the name of the texture
  111760. * @param size Define the size of the buffers to render to
  111761. * @param count Define the number of target we are rendering into
  111762. * @param scene Define the scene the texture belongs to
  111763. * @param options Define the options used to create the multi render target
  111764. */
  111765. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111766. /** @hidden */
  111767. _rebuild(): void;
  111768. private _createInternalTextures;
  111769. private _createTextures;
  111770. /**
  111771. * Define the number of samples used if MSAA is enabled.
  111772. */
  111773. samples: number;
  111774. /**
  111775. * Resize all the textures in the multi render target.
  111776. * Be carrefull as it will recreate all the data in the new texture.
  111777. * @param size Define the new size
  111778. */
  111779. resize(size: any): void;
  111780. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111781. /**
  111782. * Dispose the render targets and their associated resources
  111783. */
  111784. dispose(): void;
  111785. /**
  111786. * Release all the underlying texture used as draw buffers.
  111787. */
  111788. releaseInternalTextures(): void;
  111789. }
  111790. }
  111791. declare module BABYLON {
  111792. interface ThinEngine {
  111793. /**
  111794. * Unbind a list of render target textures from the webGL context
  111795. * This is used only when drawBuffer extension or webGL2 are active
  111796. * @param textures defines the render target textures to unbind
  111797. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111798. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111799. */
  111800. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111801. /**
  111802. * Create a multi render target texture
  111803. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111804. * @param size defines the size of the texture
  111805. * @param options defines the creation options
  111806. * @returns the cube texture as an InternalTexture
  111807. */
  111808. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111809. /**
  111810. * Update the sample count for a given multiple render target texture
  111811. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111812. * @param textures defines the textures to update
  111813. * @param samples defines the sample count to set
  111814. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111815. */
  111816. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111817. }
  111818. }
  111819. declare module BABYLON {
  111820. /**
  111821. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111822. */
  111823. export interface CubeMapInfo {
  111824. /**
  111825. * The pixel array for the front face.
  111826. * This is stored in format, left to right, up to down format.
  111827. */
  111828. front: Nullable<ArrayBufferView>;
  111829. /**
  111830. * The pixel array for the back face.
  111831. * This is stored in format, left to right, up to down format.
  111832. */
  111833. back: Nullable<ArrayBufferView>;
  111834. /**
  111835. * The pixel array for the left face.
  111836. * This is stored in format, left to right, up to down format.
  111837. */
  111838. left: Nullable<ArrayBufferView>;
  111839. /**
  111840. * The pixel array for the right face.
  111841. * This is stored in format, left to right, up to down format.
  111842. */
  111843. right: Nullable<ArrayBufferView>;
  111844. /**
  111845. * The pixel array for the up face.
  111846. * This is stored in format, left to right, up to down format.
  111847. */
  111848. up: Nullable<ArrayBufferView>;
  111849. /**
  111850. * The pixel array for the down face.
  111851. * This is stored in format, left to right, up to down format.
  111852. */
  111853. down: Nullable<ArrayBufferView>;
  111854. /**
  111855. * The size of the cubemap stored.
  111856. *
  111857. * Each faces will be size * size pixels.
  111858. */
  111859. size: number;
  111860. /**
  111861. * The format of the texture.
  111862. *
  111863. * RGBA, RGB.
  111864. */
  111865. format: number;
  111866. /**
  111867. * The type of the texture data.
  111868. *
  111869. * UNSIGNED_INT, FLOAT.
  111870. */
  111871. type: number;
  111872. /**
  111873. * Specifies whether the texture is in gamma space.
  111874. */
  111875. gammaSpace: boolean;
  111876. }
  111877. /**
  111878. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111879. */
  111880. export class PanoramaToCubeMapTools {
  111881. private static FACE_FRONT;
  111882. private static FACE_BACK;
  111883. private static FACE_RIGHT;
  111884. private static FACE_LEFT;
  111885. private static FACE_DOWN;
  111886. private static FACE_UP;
  111887. /**
  111888. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111889. *
  111890. * @param float32Array The source data.
  111891. * @param inputWidth The width of the input panorama.
  111892. * @param inputHeight The height of the input panorama.
  111893. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111894. * @return The cubemap data
  111895. */
  111896. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111897. private static CreateCubemapTexture;
  111898. private static CalcProjectionSpherical;
  111899. }
  111900. }
  111901. declare module BABYLON {
  111902. /**
  111903. * Helper class dealing with the extraction of spherical polynomial dataArray
  111904. * from a cube map.
  111905. */
  111906. export class CubeMapToSphericalPolynomialTools {
  111907. private static FileFaces;
  111908. /**
  111909. * Converts a texture to the according Spherical Polynomial data.
  111910. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111911. *
  111912. * @param texture The texture to extract the information from.
  111913. * @return The Spherical Polynomial data.
  111914. */
  111915. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  111916. /**
  111917. * Converts a cubemap to the according Spherical Polynomial data.
  111918. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111919. *
  111920. * @param cubeInfo The Cube map to extract the information from.
  111921. * @return The Spherical Polynomial data.
  111922. */
  111923. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  111924. }
  111925. }
  111926. declare module BABYLON {
  111927. interface BaseTexture {
  111928. /**
  111929. * Get the polynomial representation of the texture data.
  111930. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  111931. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  111932. */
  111933. sphericalPolynomial: Nullable<SphericalPolynomial>;
  111934. }
  111935. }
  111936. declare module BABYLON {
  111937. /** @hidden */
  111938. export var rgbdEncodePixelShader: {
  111939. name: string;
  111940. shader: string;
  111941. };
  111942. }
  111943. declare module BABYLON {
  111944. /** @hidden */
  111945. export var rgbdDecodePixelShader: {
  111946. name: string;
  111947. shader: string;
  111948. };
  111949. }
  111950. declare module BABYLON {
  111951. /**
  111952. * Raw texture data and descriptor sufficient for WebGL texture upload
  111953. */
  111954. export interface EnvironmentTextureInfo {
  111955. /**
  111956. * Version of the environment map
  111957. */
  111958. version: number;
  111959. /**
  111960. * Width of image
  111961. */
  111962. width: number;
  111963. /**
  111964. * Irradiance information stored in the file.
  111965. */
  111966. irradiance: any;
  111967. /**
  111968. * Specular information stored in the file.
  111969. */
  111970. specular: any;
  111971. }
  111972. /**
  111973. * Defines One Image in the file. It requires only the position in the file
  111974. * as well as the length.
  111975. */
  111976. interface BufferImageData {
  111977. /**
  111978. * Length of the image data.
  111979. */
  111980. length: number;
  111981. /**
  111982. * Position of the data from the null terminator delimiting the end of the JSON.
  111983. */
  111984. position: number;
  111985. }
  111986. /**
  111987. * Defines the specular data enclosed in the file.
  111988. * This corresponds to the version 1 of the data.
  111989. */
  111990. export interface EnvironmentTextureSpecularInfoV1 {
  111991. /**
  111992. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111993. */
  111994. specularDataPosition?: number;
  111995. /**
  111996. * This contains all the images data needed to reconstruct the cubemap.
  111997. */
  111998. mipmaps: Array<BufferImageData>;
  111999. /**
  112000. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  112001. */
  112002. lodGenerationScale: number;
  112003. }
  112004. /**
  112005. * Sets of helpers addressing the serialization and deserialization of environment texture
  112006. * stored in a BabylonJS env file.
  112007. * Those files are usually stored as .env files.
  112008. */
  112009. export class EnvironmentTextureTools {
  112010. /**
  112011. * Magic number identifying the env file.
  112012. */
  112013. private static _MagicBytes;
  112014. /**
  112015. * Gets the environment info from an env file.
  112016. * @param data The array buffer containing the .env bytes.
  112017. * @returns the environment file info (the json header) if successfully parsed.
  112018. */
  112019. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112020. /**
  112021. * Creates an environment texture from a loaded cube texture.
  112022. * @param texture defines the cube texture to convert in env file
  112023. * @return a promise containing the environment data if succesfull.
  112024. */
  112025. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112026. /**
  112027. * Creates a JSON representation of the spherical data.
  112028. * @param texture defines the texture containing the polynomials
  112029. * @return the JSON representation of the spherical info
  112030. */
  112031. private static _CreateEnvTextureIrradiance;
  112032. /**
  112033. * Creates the ArrayBufferViews used for initializing environment texture image data.
  112034. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  112035. * @param info parameters that determine what views will be created for accessing the underlying buffer
  112036. * @return the views described by info providing access to the underlying buffer
  112037. */
  112038. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  112039. /**
  112040. * Uploads the texture info contained in the env file to the GPU.
  112041. * @param texture defines the internal texture to upload to
  112042. * @param arrayBuffer defines the buffer cotaining the data to load
  112043. * @param info defines the texture info retrieved through the GetEnvInfo method
  112044. * @returns a promise
  112045. */
  112046. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112047. private static _OnImageReadyAsync;
  112048. /**
  112049. * Uploads the levels of image data to the GPU.
  112050. * @param texture defines the internal texture to upload to
  112051. * @param imageData defines the array buffer views of image data [mipmap][face]
  112052. * @returns a promise
  112053. */
  112054. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112055. /**
  112056. * Uploads spherical polynomials information to the texture.
  112057. * @param texture defines the texture we are trying to upload the information to
  112058. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112059. */
  112060. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112061. /** @hidden */
  112062. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112063. }
  112064. }
  112065. declare module BABYLON {
  112066. /**
  112067. * Contains position and normal vectors for a vertex
  112068. */
  112069. export class PositionNormalVertex {
  112070. /** the position of the vertex (defaut: 0,0,0) */
  112071. position: Vector3;
  112072. /** the normal of the vertex (defaut: 0,1,0) */
  112073. normal: Vector3;
  112074. /**
  112075. * Creates a PositionNormalVertex
  112076. * @param position the position of the vertex (defaut: 0,0,0)
  112077. * @param normal the normal of the vertex (defaut: 0,1,0)
  112078. */
  112079. constructor(
  112080. /** the position of the vertex (defaut: 0,0,0) */
  112081. position?: Vector3,
  112082. /** the normal of the vertex (defaut: 0,1,0) */
  112083. normal?: Vector3);
  112084. /**
  112085. * Clones the PositionNormalVertex
  112086. * @returns the cloned PositionNormalVertex
  112087. */
  112088. clone(): PositionNormalVertex;
  112089. }
  112090. /**
  112091. * Contains position, normal and uv vectors for a vertex
  112092. */
  112093. export class PositionNormalTextureVertex {
  112094. /** the position of the vertex (defaut: 0,0,0) */
  112095. position: Vector3;
  112096. /** the normal of the vertex (defaut: 0,1,0) */
  112097. normal: Vector3;
  112098. /** the uv of the vertex (default: 0,0) */
  112099. uv: Vector2;
  112100. /**
  112101. * Creates a PositionNormalTextureVertex
  112102. * @param position the position of the vertex (defaut: 0,0,0)
  112103. * @param normal the normal of the vertex (defaut: 0,1,0)
  112104. * @param uv the uv of the vertex (default: 0,0)
  112105. */
  112106. constructor(
  112107. /** the position of the vertex (defaut: 0,0,0) */
  112108. position?: Vector3,
  112109. /** the normal of the vertex (defaut: 0,1,0) */
  112110. normal?: Vector3,
  112111. /** the uv of the vertex (default: 0,0) */
  112112. uv?: Vector2);
  112113. /**
  112114. * Clones the PositionNormalTextureVertex
  112115. * @returns the cloned PositionNormalTextureVertex
  112116. */
  112117. clone(): PositionNormalTextureVertex;
  112118. }
  112119. }
  112120. declare module BABYLON {
  112121. /** @hidden */
  112122. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  112123. private _genericAttributeLocation;
  112124. private _varyingLocationCount;
  112125. private _varyingLocationMap;
  112126. private _replacements;
  112127. private _textureCount;
  112128. private _uniforms;
  112129. lineProcessor(line: string): string;
  112130. attributeProcessor(attribute: string): string;
  112131. varyingProcessor(varying: string, isFragment: boolean): string;
  112132. uniformProcessor(uniform: string): string;
  112133. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  112134. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112135. }
  112136. }
  112137. declare module BABYLON {
  112138. /**
  112139. * Container for accessors for natively-stored mesh data buffers.
  112140. */
  112141. class NativeDataBuffer extends DataBuffer {
  112142. /**
  112143. * Accessor value used to identify/retrieve a natively-stored index buffer.
  112144. */
  112145. nativeIndexBuffer?: any;
  112146. /**
  112147. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  112148. */
  112149. nativeVertexBuffer?: any;
  112150. }
  112151. /** @hidden */
  112152. export class NativeEngine extends Engine {
  112153. private readonly _native;
  112154. getHardwareScalingLevel(): number;
  112155. constructor();
  112156. /**
  112157. * Can be used to override the current requestAnimationFrame requester.
  112158. * @hidden
  112159. */
  112160. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  112161. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112162. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  112163. createVertexBuffer(data: DataArray): NativeDataBuffer;
  112164. recordVertexArrayObject(vertexBuffers: {
  112165. [key: string]: VertexBuffer;
  112166. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112167. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112168. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112169. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112170. /**
  112171. * Draw a list of indexed primitives
  112172. * @param fillMode defines the primitive to use
  112173. * @param indexStart defines the starting index
  112174. * @param indexCount defines the number of index to draw
  112175. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112176. */
  112177. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112178. /**
  112179. * Draw a list of unindexed primitives
  112180. * @param fillMode defines the primitive to use
  112181. * @param verticesStart defines the index of first vertex to draw
  112182. * @param verticesCount defines the count of vertices to draw
  112183. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112184. */
  112185. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112186. createPipelineContext(): IPipelineContext;
  112187. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112188. /** @hidden */
  112189. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112190. /** @hidden */
  112191. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112192. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112193. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112194. protected _setProgram(program: WebGLProgram): void;
  112195. _releaseEffect(effect: Effect): void;
  112196. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112197. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  112198. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  112199. bindSamplers(effect: Effect): void;
  112200. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  112201. getRenderWidth(useScreen?: boolean): number;
  112202. getRenderHeight(useScreen?: boolean): number;
  112203. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  112204. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112205. /**
  112206. * Set the z offset to apply to current rendering
  112207. * @param value defines the offset to apply
  112208. */
  112209. setZOffset(value: number): void;
  112210. /**
  112211. * Gets the current value of the zOffset
  112212. * @returns the current zOffset state
  112213. */
  112214. getZOffset(): number;
  112215. /**
  112216. * Enable or disable depth buffering
  112217. * @param enable defines the state to set
  112218. */
  112219. setDepthBuffer(enable: boolean): void;
  112220. /**
  112221. * Gets a boolean indicating if depth writing is enabled
  112222. * @returns the current depth writing state
  112223. */
  112224. getDepthWrite(): boolean;
  112225. /**
  112226. * Enable or disable depth writing
  112227. * @param enable defines the state to set
  112228. */
  112229. setDepthWrite(enable: boolean): void;
  112230. /**
  112231. * Enable or disable color writing
  112232. * @param enable defines the state to set
  112233. */
  112234. setColorWrite(enable: boolean): void;
  112235. /**
  112236. * Gets a boolean indicating if color writing is enabled
  112237. * @returns the current color writing state
  112238. */
  112239. getColorWrite(): boolean;
  112240. /**
  112241. * Sets alpha constants used by some alpha blending modes
  112242. * @param r defines the red component
  112243. * @param g defines the green component
  112244. * @param b defines the blue component
  112245. * @param a defines the alpha component
  112246. */
  112247. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  112248. /**
  112249. * Sets the current alpha mode
  112250. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  112251. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112252. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112253. */
  112254. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112255. /**
  112256. * Gets the current alpha mode
  112257. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112258. * @returns the current alpha mode
  112259. */
  112260. getAlphaMode(): number;
  112261. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112262. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112263. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112264. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112265. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112266. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112267. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112268. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112269. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112270. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112271. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112272. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112273. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112274. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112275. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112276. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112277. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112278. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112279. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112280. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112281. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  112282. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  112283. wipeCaches(bruteForce?: boolean): void;
  112284. _createTexture(): WebGLTexture;
  112285. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112286. /**
  112287. * Usually called from BABYLON.Texture.ts.
  112288. * Passed information to create a WebGLTexture
  112289. * @param urlArg defines a value which contains one of the following:
  112290. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112291. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112292. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112293. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112294. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  112295. * @param scene needed for loading to the correct scene
  112296. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  112297. * @param onLoad optional callback to be called upon successful completion
  112298. * @param onError optional callback to be called upon failure
  112299. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  112300. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112301. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112302. * @param forcedExtension defines the extension to use to pick the right loader
  112303. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112304. */
  112305. 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;
  112306. /**
  112307. * Creates a cube texture
  112308. * @param rootUrl defines the url where the files to load is located
  112309. * @param scene defines the current scene
  112310. * @param files defines the list of files to load (1 per face)
  112311. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  112312. * @param onLoad defines an optional callback raised when the texture is loaded
  112313. * @param onError defines an optional callback raised if there is an issue to load the texture
  112314. * @param format defines the format of the data
  112315. * @param forcedExtension defines the extension to use to pick the right loader
  112316. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  112317. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112318. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112319. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  112320. * @returns the cube texture as an InternalTexture
  112321. */
  112322. 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;
  112323. private _getSamplingFilter;
  112324. private static _GetNativeTextureFormat;
  112325. createRenderTargetTexture(size: number | {
  112326. width: number;
  112327. height: number;
  112328. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112329. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112330. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112331. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112332. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112333. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  112334. /**
  112335. * Updates a dynamic vertex buffer.
  112336. * @param vertexBuffer the vertex buffer to update
  112337. * @param data the data used to update the vertex buffer
  112338. * @param byteOffset the byte offset of the data (optional)
  112339. * @param byteLength the byte length of the data (optional)
  112340. */
  112341. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  112342. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112343. private _updateAnisotropicLevel;
  112344. private _getAddressMode;
  112345. /** @hidden */
  112346. _bindTexture(channel: number, texture: InternalTexture): void;
  112347. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  112348. releaseEffects(): void;
  112349. /** @hidden */
  112350. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112351. /** @hidden */
  112352. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112353. /** @hidden */
  112354. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112355. /** @hidden */
  112356. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112357. }
  112358. }
  112359. declare module BABYLON {
  112360. /**
  112361. * Gather the list of clipboard event types as constants.
  112362. */
  112363. export class ClipboardEventTypes {
  112364. /**
  112365. * The clipboard event is fired when a copy command is active (pressed).
  112366. */
  112367. static readonly COPY: number;
  112368. /**
  112369. * The clipboard event is fired when a cut command is active (pressed).
  112370. */
  112371. static readonly CUT: number;
  112372. /**
  112373. * The clipboard event is fired when a paste command is active (pressed).
  112374. */
  112375. static readonly PASTE: number;
  112376. }
  112377. /**
  112378. * This class is used to store clipboard related info for the onClipboardObservable event.
  112379. */
  112380. export class ClipboardInfo {
  112381. /**
  112382. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112383. */
  112384. type: number;
  112385. /**
  112386. * Defines the related dom event
  112387. */
  112388. event: ClipboardEvent;
  112389. /**
  112390. *Creates an instance of ClipboardInfo.
  112391. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  112392. * @param event Defines the related dom event
  112393. */
  112394. constructor(
  112395. /**
  112396. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112397. */
  112398. type: number,
  112399. /**
  112400. * Defines the related dom event
  112401. */
  112402. event: ClipboardEvent);
  112403. /**
  112404. * Get the clipboard event's type from the keycode.
  112405. * @param keyCode Defines the keyCode for the current keyboard event.
  112406. * @return {number}
  112407. */
  112408. static GetTypeFromCharacter(keyCode: number): number;
  112409. }
  112410. }
  112411. declare module BABYLON {
  112412. /**
  112413. * Google Daydream controller
  112414. */
  112415. export class DaydreamController extends WebVRController {
  112416. /**
  112417. * Base Url for the controller model.
  112418. */
  112419. static MODEL_BASE_URL: string;
  112420. /**
  112421. * File name for the controller model.
  112422. */
  112423. static MODEL_FILENAME: string;
  112424. /**
  112425. * Gamepad Id prefix used to identify Daydream Controller.
  112426. */
  112427. static readonly GAMEPAD_ID_PREFIX: string;
  112428. /**
  112429. * Creates a new DaydreamController from a gamepad
  112430. * @param vrGamepad the gamepad that the controller should be created from
  112431. */
  112432. constructor(vrGamepad: any);
  112433. /**
  112434. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112435. * @param scene scene in which to add meshes
  112436. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112437. */
  112438. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112439. /**
  112440. * Called once for each button that changed state since the last frame
  112441. * @param buttonIdx Which button index changed
  112442. * @param state New state of the button
  112443. * @param changes Which properties on the state changed since last frame
  112444. */
  112445. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112446. }
  112447. }
  112448. declare module BABYLON {
  112449. /**
  112450. * Gear VR Controller
  112451. */
  112452. export class GearVRController extends WebVRController {
  112453. /**
  112454. * Base Url for the controller model.
  112455. */
  112456. static MODEL_BASE_URL: string;
  112457. /**
  112458. * File name for the controller model.
  112459. */
  112460. static MODEL_FILENAME: string;
  112461. /**
  112462. * Gamepad Id prefix used to identify this controller.
  112463. */
  112464. static readonly GAMEPAD_ID_PREFIX: string;
  112465. private readonly _buttonIndexToObservableNameMap;
  112466. /**
  112467. * Creates a new GearVRController from a gamepad
  112468. * @param vrGamepad the gamepad that the controller should be created from
  112469. */
  112470. constructor(vrGamepad: any);
  112471. /**
  112472. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112473. * @param scene scene in which to add meshes
  112474. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112475. */
  112476. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112477. /**
  112478. * Called once for each button that changed state since the last frame
  112479. * @param buttonIdx Which button index changed
  112480. * @param state New state of the button
  112481. * @param changes Which properties on the state changed since last frame
  112482. */
  112483. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112484. }
  112485. }
  112486. declare module BABYLON {
  112487. /**
  112488. * Class containing static functions to help procedurally build meshes
  112489. */
  112490. export class PolyhedronBuilder {
  112491. /**
  112492. * Creates a polyhedron mesh
  112493. * * 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
  112494. * * The parameter `size` (positive float, default 1) sets the polygon size
  112495. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  112496. * * 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`
  112497. * * 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
  112498. * * 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)`)
  112499. * * 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
  112500. * * 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
  112501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112504. * @param name defines the name of the mesh
  112505. * @param options defines the options used to create the mesh
  112506. * @param scene defines the hosting scene
  112507. * @returns the polyhedron mesh
  112508. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  112509. */
  112510. static CreatePolyhedron(name: string, options: {
  112511. type?: number;
  112512. size?: number;
  112513. sizeX?: number;
  112514. sizeY?: number;
  112515. sizeZ?: number;
  112516. custom?: any;
  112517. faceUV?: Vector4[];
  112518. faceColors?: Color4[];
  112519. flat?: boolean;
  112520. updatable?: boolean;
  112521. sideOrientation?: number;
  112522. frontUVs?: Vector4;
  112523. backUVs?: Vector4;
  112524. }, scene?: Nullable<Scene>): Mesh;
  112525. }
  112526. }
  112527. declare module BABYLON {
  112528. /**
  112529. * Gizmo that enables scaling a mesh along 3 axis
  112530. */
  112531. export class ScaleGizmo extends Gizmo {
  112532. /**
  112533. * Internal gizmo used for interactions on the x axis
  112534. */
  112535. xGizmo: AxisScaleGizmo;
  112536. /**
  112537. * Internal gizmo used for interactions on the y axis
  112538. */
  112539. yGizmo: AxisScaleGizmo;
  112540. /**
  112541. * Internal gizmo used for interactions on the z axis
  112542. */
  112543. zGizmo: AxisScaleGizmo;
  112544. /**
  112545. * Internal gizmo used to scale all axis equally
  112546. */
  112547. uniformScaleGizmo: AxisScaleGizmo;
  112548. private _meshAttached;
  112549. private _updateGizmoRotationToMatchAttachedMesh;
  112550. private _snapDistance;
  112551. private _scaleRatio;
  112552. private _uniformScalingMesh;
  112553. private _octahedron;
  112554. /** Fires an event when any of it's sub gizmos are dragged */
  112555. onDragStartObservable: Observable<unknown>;
  112556. /** Fires an event when any of it's sub gizmos are released from dragging */
  112557. onDragEndObservable: Observable<unknown>;
  112558. attachedMesh: Nullable<AbstractMesh>;
  112559. /**
  112560. * Creates a ScaleGizmo
  112561. * @param gizmoLayer The utility layer the gizmo will be added to
  112562. */
  112563. constructor(gizmoLayer?: UtilityLayerRenderer);
  112564. updateGizmoRotationToMatchAttachedMesh: boolean;
  112565. /**
  112566. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112567. */
  112568. snapDistance: number;
  112569. /**
  112570. * Ratio for the scale of the gizmo (Default: 1)
  112571. */
  112572. scaleRatio: number;
  112573. /**
  112574. * Disposes of the gizmo
  112575. */
  112576. dispose(): void;
  112577. }
  112578. }
  112579. declare module BABYLON {
  112580. /**
  112581. * Single axis scale gizmo
  112582. */
  112583. export class AxisScaleGizmo extends Gizmo {
  112584. /**
  112585. * Drag behavior responsible for the gizmos dragging interactions
  112586. */
  112587. dragBehavior: PointerDragBehavior;
  112588. private _pointerObserver;
  112589. /**
  112590. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112591. */
  112592. snapDistance: number;
  112593. /**
  112594. * Event that fires each time the gizmo snaps to a new location.
  112595. * * snapDistance is the the change in distance
  112596. */
  112597. onSnapObservable: Observable<{
  112598. snapDistance: number;
  112599. }>;
  112600. /**
  112601. * If the scaling operation should be done on all axis (default: false)
  112602. */
  112603. uniformScaling: boolean;
  112604. private _isEnabled;
  112605. private _parent;
  112606. private _arrow;
  112607. private _coloredMaterial;
  112608. private _hoverMaterial;
  112609. /**
  112610. * Creates an AxisScaleGizmo
  112611. * @param gizmoLayer The utility layer the gizmo will be added to
  112612. * @param dragAxis The axis which the gizmo will be able to scale on
  112613. * @param color The color of the gizmo
  112614. */
  112615. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  112616. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112617. /**
  112618. * If the gizmo is enabled
  112619. */
  112620. isEnabled: boolean;
  112621. /**
  112622. * Disposes of the gizmo
  112623. */
  112624. dispose(): void;
  112625. /**
  112626. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112627. * @param mesh The mesh to replace the default mesh of the gizmo
  112628. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  112629. */
  112630. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  112631. }
  112632. }
  112633. declare module BABYLON {
  112634. /**
  112635. * Bounding box gizmo
  112636. */
  112637. export class BoundingBoxGizmo extends Gizmo {
  112638. private _lineBoundingBox;
  112639. private _rotateSpheresParent;
  112640. private _scaleBoxesParent;
  112641. private _boundingDimensions;
  112642. private _renderObserver;
  112643. private _pointerObserver;
  112644. private _scaleDragSpeed;
  112645. private _tmpQuaternion;
  112646. private _tmpVector;
  112647. private _tmpRotationMatrix;
  112648. /**
  112649. * 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)
  112650. */
  112651. ignoreChildren: boolean;
  112652. /**
  112653. * 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)
  112654. */
  112655. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  112656. /**
  112657. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  112658. */
  112659. rotationSphereSize: number;
  112660. /**
  112661. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  112662. */
  112663. scaleBoxSize: number;
  112664. /**
  112665. * 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)
  112666. */
  112667. fixedDragMeshScreenSize: boolean;
  112668. /**
  112669. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  112670. */
  112671. fixedDragMeshScreenSizeDistanceFactor: number;
  112672. /**
  112673. * Fired when a rotation sphere or scale box is dragged
  112674. */
  112675. onDragStartObservable: Observable<{}>;
  112676. /**
  112677. * Fired when a scale box is dragged
  112678. */
  112679. onScaleBoxDragObservable: Observable<{}>;
  112680. /**
  112681. * Fired when a scale box drag is ended
  112682. */
  112683. onScaleBoxDragEndObservable: Observable<{}>;
  112684. /**
  112685. * Fired when a rotation sphere is dragged
  112686. */
  112687. onRotationSphereDragObservable: Observable<{}>;
  112688. /**
  112689. * Fired when a rotation sphere drag is ended
  112690. */
  112691. onRotationSphereDragEndObservable: Observable<{}>;
  112692. /**
  112693. * 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)
  112694. */
  112695. scalePivot: Nullable<Vector3>;
  112696. /**
  112697. * Mesh used as a pivot to rotate the attached mesh
  112698. */
  112699. private _anchorMesh;
  112700. private _existingMeshScale;
  112701. private _dragMesh;
  112702. private pointerDragBehavior;
  112703. private coloredMaterial;
  112704. private hoverColoredMaterial;
  112705. /**
  112706. * Sets the color of the bounding box gizmo
  112707. * @param color the color to set
  112708. */
  112709. setColor(color: Color3): void;
  112710. /**
  112711. * Creates an BoundingBoxGizmo
  112712. * @param gizmoLayer The utility layer the gizmo will be added to
  112713. * @param color The color of the gizmo
  112714. */
  112715. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  112716. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112717. private _selectNode;
  112718. /**
  112719. * Updates the bounding box information for the Gizmo
  112720. */
  112721. updateBoundingBox(): void;
  112722. private _updateRotationSpheres;
  112723. private _updateScaleBoxes;
  112724. /**
  112725. * Enables rotation on the specified axis and disables rotation on the others
  112726. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  112727. */
  112728. setEnabledRotationAxis(axis: string): void;
  112729. /**
  112730. * Enables/disables scaling
  112731. * @param enable if scaling should be enabled
  112732. */
  112733. setEnabledScaling(enable: boolean): void;
  112734. private _updateDummy;
  112735. /**
  112736. * Enables a pointer drag behavior on the bounding box of the gizmo
  112737. */
  112738. enableDragBehavior(): void;
  112739. /**
  112740. * Disposes of the gizmo
  112741. */
  112742. dispose(): void;
  112743. /**
  112744. * 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)
  112745. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112746. * @returns the bounding box mesh with the passed in mesh as a child
  112747. */
  112748. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112749. /**
  112750. * CustomMeshes are not supported by this gizmo
  112751. * @param mesh The mesh to replace the default mesh of the gizmo
  112752. */
  112753. setCustomMesh(mesh: Mesh): void;
  112754. }
  112755. }
  112756. declare module BABYLON {
  112757. /**
  112758. * Single plane rotation gizmo
  112759. */
  112760. export class PlaneRotationGizmo extends Gizmo {
  112761. /**
  112762. * Drag behavior responsible for the gizmos dragging interactions
  112763. */
  112764. dragBehavior: PointerDragBehavior;
  112765. private _pointerObserver;
  112766. /**
  112767. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112768. */
  112769. snapDistance: number;
  112770. /**
  112771. * Event that fires each time the gizmo snaps to a new location.
  112772. * * snapDistance is the the change in distance
  112773. */
  112774. onSnapObservable: Observable<{
  112775. snapDistance: number;
  112776. }>;
  112777. private _isEnabled;
  112778. private _parent;
  112779. /**
  112780. * Creates a PlaneRotationGizmo
  112781. * @param gizmoLayer The utility layer the gizmo will be added to
  112782. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112783. * @param color The color of the gizmo
  112784. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112785. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112786. */
  112787. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112788. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112789. /**
  112790. * If the gizmo is enabled
  112791. */
  112792. isEnabled: boolean;
  112793. /**
  112794. * Disposes of the gizmo
  112795. */
  112796. dispose(): void;
  112797. }
  112798. }
  112799. declare module BABYLON {
  112800. /**
  112801. * Gizmo that enables rotating a mesh along 3 axis
  112802. */
  112803. export class RotationGizmo extends Gizmo {
  112804. /**
  112805. * Internal gizmo used for interactions on the x axis
  112806. */
  112807. xGizmo: PlaneRotationGizmo;
  112808. /**
  112809. * Internal gizmo used for interactions on the y axis
  112810. */
  112811. yGizmo: PlaneRotationGizmo;
  112812. /**
  112813. * Internal gizmo used for interactions on the z axis
  112814. */
  112815. zGizmo: PlaneRotationGizmo;
  112816. /** Fires an event when any of it's sub gizmos are dragged */
  112817. onDragStartObservable: Observable<unknown>;
  112818. /** Fires an event when any of it's sub gizmos are released from dragging */
  112819. onDragEndObservable: Observable<unknown>;
  112820. private _meshAttached;
  112821. attachedMesh: Nullable<AbstractMesh>;
  112822. /**
  112823. * Creates a RotationGizmo
  112824. * @param gizmoLayer The utility layer the gizmo will be added to
  112825. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112826. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112827. */
  112828. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112829. updateGizmoRotationToMatchAttachedMesh: boolean;
  112830. /**
  112831. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112832. */
  112833. snapDistance: number;
  112834. /**
  112835. * Ratio for the scale of the gizmo (Default: 1)
  112836. */
  112837. scaleRatio: number;
  112838. /**
  112839. * Disposes of the gizmo
  112840. */
  112841. dispose(): void;
  112842. /**
  112843. * CustomMeshes are not supported by this gizmo
  112844. * @param mesh The mesh to replace the default mesh of the gizmo
  112845. */
  112846. setCustomMesh(mesh: Mesh): void;
  112847. }
  112848. }
  112849. declare module BABYLON {
  112850. /**
  112851. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112852. */
  112853. export class GizmoManager implements IDisposable {
  112854. private scene;
  112855. /**
  112856. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112857. */
  112858. gizmos: {
  112859. positionGizmo: Nullable<PositionGizmo>;
  112860. rotationGizmo: Nullable<RotationGizmo>;
  112861. scaleGizmo: Nullable<ScaleGizmo>;
  112862. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112863. };
  112864. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112865. clearGizmoOnEmptyPointerEvent: boolean;
  112866. /** Fires an event when the manager is attached to a mesh */
  112867. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112868. private _gizmosEnabled;
  112869. private _pointerObserver;
  112870. private _attachedMesh;
  112871. private _boundingBoxColor;
  112872. private _defaultUtilityLayer;
  112873. private _defaultKeepDepthUtilityLayer;
  112874. /**
  112875. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112876. */
  112877. boundingBoxDragBehavior: SixDofDragBehavior;
  112878. /**
  112879. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112880. */
  112881. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112882. /**
  112883. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112884. */
  112885. usePointerToAttachGizmos: boolean;
  112886. /**
  112887. * Utility layer that the bounding box gizmo belongs to
  112888. */
  112889. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112890. /**
  112891. * Utility layer that all gizmos besides bounding box belong to
  112892. */
  112893. readonly utilityLayer: UtilityLayerRenderer;
  112894. /**
  112895. * Instatiates a gizmo manager
  112896. * @param scene the scene to overlay the gizmos on top of
  112897. */
  112898. constructor(scene: Scene);
  112899. /**
  112900. * Attaches a set of gizmos to the specified mesh
  112901. * @param mesh The mesh the gizmo's should be attached to
  112902. */
  112903. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112904. /**
  112905. * If the position gizmo is enabled
  112906. */
  112907. positionGizmoEnabled: boolean;
  112908. /**
  112909. * If the rotation gizmo is enabled
  112910. */
  112911. rotationGizmoEnabled: boolean;
  112912. /**
  112913. * If the scale gizmo is enabled
  112914. */
  112915. scaleGizmoEnabled: boolean;
  112916. /**
  112917. * If the boundingBox gizmo is enabled
  112918. */
  112919. boundingBoxGizmoEnabled: boolean;
  112920. /**
  112921. * Disposes of the gizmo manager
  112922. */
  112923. dispose(): void;
  112924. }
  112925. }
  112926. declare module BABYLON {
  112927. /**
  112928. * A directional light is defined by a direction (what a surprise!).
  112929. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112930. * 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.
  112931. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112932. */
  112933. export class DirectionalLight extends ShadowLight {
  112934. private _shadowFrustumSize;
  112935. /**
  112936. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112937. */
  112938. /**
  112939. * Specifies a fix frustum size for the shadow generation.
  112940. */
  112941. shadowFrustumSize: number;
  112942. private _shadowOrthoScale;
  112943. /**
  112944. * Gets the shadow projection scale against the optimal computed one.
  112945. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112946. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112947. */
  112948. /**
  112949. * Sets the shadow projection scale against the optimal computed one.
  112950. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112951. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112952. */
  112953. shadowOrthoScale: number;
  112954. /**
  112955. * Automatically compute the projection matrix to best fit (including all the casters)
  112956. * on each frame.
  112957. */
  112958. autoUpdateExtends: boolean;
  112959. private _orthoLeft;
  112960. private _orthoRight;
  112961. private _orthoTop;
  112962. private _orthoBottom;
  112963. /**
  112964. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112965. * The directional light is emitted from everywhere in the given direction.
  112966. * It can cast shadows.
  112967. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112968. * @param name The friendly name of the light
  112969. * @param direction The direction of the light
  112970. * @param scene The scene the light belongs to
  112971. */
  112972. constructor(name: string, direction: Vector3, scene: Scene);
  112973. /**
  112974. * Returns the string "DirectionalLight".
  112975. * @return The class name
  112976. */
  112977. getClassName(): string;
  112978. /**
  112979. * Returns the integer 1.
  112980. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112981. */
  112982. getTypeID(): number;
  112983. /**
  112984. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112985. * Returns the DirectionalLight Shadow projection matrix.
  112986. */
  112987. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112988. /**
  112989. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112990. * Returns the DirectionalLight Shadow projection matrix.
  112991. */
  112992. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112993. /**
  112994. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112995. * Returns the DirectionalLight Shadow projection matrix.
  112996. */
  112997. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112998. protected _buildUniformLayout(): void;
  112999. /**
  113000. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  113001. * @param effect The effect to update
  113002. * @param lightIndex The index of the light in the effect to update
  113003. * @returns The directional light
  113004. */
  113005. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  113006. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  113007. /**
  113008. * Gets the minZ used for shadow according to both the scene and the light.
  113009. *
  113010. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113011. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113012. * @param activeCamera The camera we are returning the min for
  113013. * @returns the depth min z
  113014. */
  113015. getDepthMinZ(activeCamera: Camera): number;
  113016. /**
  113017. * Gets the maxZ used for shadow according to both the scene and the light.
  113018. *
  113019. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113020. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113021. * @param activeCamera The camera we are returning the max for
  113022. * @returns the depth max z
  113023. */
  113024. getDepthMaxZ(activeCamera: Camera): number;
  113025. /**
  113026. * Prepares the list of defines specific to the light type.
  113027. * @param defines the list of defines
  113028. * @param lightIndex defines the index of the light for the effect
  113029. */
  113030. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113031. }
  113032. }
  113033. declare module BABYLON {
  113034. /**
  113035. * Class containing static functions to help procedurally build meshes
  113036. */
  113037. export class HemisphereBuilder {
  113038. /**
  113039. * Creates a hemisphere mesh
  113040. * @param name defines the name of the mesh
  113041. * @param options defines the options used to create the mesh
  113042. * @param scene defines the hosting scene
  113043. * @returns the hemisphere mesh
  113044. */
  113045. static CreateHemisphere(name: string, options: {
  113046. segments?: number;
  113047. diameter?: number;
  113048. sideOrientation?: number;
  113049. }, scene: any): Mesh;
  113050. }
  113051. }
  113052. declare module BABYLON {
  113053. /**
  113054. * A spot light is defined by a position, a direction, an angle, and an exponent.
  113055. * These values define a cone of light starting from the position, emitting toward the direction.
  113056. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  113057. * and the exponent defines the speed of the decay of the light with distance (reach).
  113058. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113059. */
  113060. export class SpotLight extends ShadowLight {
  113061. private _angle;
  113062. private _innerAngle;
  113063. private _cosHalfAngle;
  113064. private _lightAngleScale;
  113065. private _lightAngleOffset;
  113066. /**
  113067. * Gets the cone angle of the spot light in Radians.
  113068. */
  113069. /**
  113070. * Sets the cone angle of the spot light in Radians.
  113071. */
  113072. angle: number;
  113073. /**
  113074. * Only used in gltf falloff mode, this defines the angle where
  113075. * the directional falloff will start before cutting at angle which could be seen
  113076. * as outer angle.
  113077. */
  113078. /**
  113079. * Only used in gltf falloff mode, this defines the angle where
  113080. * the directional falloff will start before cutting at angle which could be seen
  113081. * as outer angle.
  113082. */
  113083. innerAngle: number;
  113084. private _shadowAngleScale;
  113085. /**
  113086. * Allows scaling the angle of the light for shadow generation only.
  113087. */
  113088. /**
  113089. * Allows scaling the angle of the light for shadow generation only.
  113090. */
  113091. shadowAngleScale: number;
  113092. /**
  113093. * The light decay speed with the distance from the emission spot.
  113094. */
  113095. exponent: number;
  113096. private _projectionTextureMatrix;
  113097. /**
  113098. * Allows reading the projecton texture
  113099. */
  113100. readonly projectionTextureMatrix: Matrix;
  113101. protected _projectionTextureLightNear: number;
  113102. /**
  113103. * Gets the near clip of the Spotlight for texture projection.
  113104. */
  113105. /**
  113106. * Sets the near clip of the Spotlight for texture projection.
  113107. */
  113108. projectionTextureLightNear: number;
  113109. protected _projectionTextureLightFar: number;
  113110. /**
  113111. * Gets the far clip of the Spotlight for texture projection.
  113112. */
  113113. /**
  113114. * Sets the far clip of the Spotlight for texture projection.
  113115. */
  113116. projectionTextureLightFar: number;
  113117. protected _projectionTextureUpDirection: Vector3;
  113118. /**
  113119. * Gets the Up vector of the Spotlight for texture projection.
  113120. */
  113121. /**
  113122. * Sets the Up vector of the Spotlight for texture projection.
  113123. */
  113124. projectionTextureUpDirection: Vector3;
  113125. private _projectionTexture;
  113126. /**
  113127. * Gets the projection texture of the light.
  113128. */
  113129. /**
  113130. * Sets the projection texture of the light.
  113131. */
  113132. projectionTexture: Nullable<BaseTexture>;
  113133. private _projectionTextureViewLightDirty;
  113134. private _projectionTextureProjectionLightDirty;
  113135. private _projectionTextureDirty;
  113136. private _projectionTextureViewTargetVector;
  113137. private _projectionTextureViewLightMatrix;
  113138. private _projectionTextureProjectionLightMatrix;
  113139. private _projectionTextureScalingMatrix;
  113140. /**
  113141. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  113142. * It can cast shadows.
  113143. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113144. * @param name The light friendly name
  113145. * @param position The position of the spot light in the scene
  113146. * @param direction The direction of the light in the scene
  113147. * @param angle The cone angle of the light in Radians
  113148. * @param exponent The light decay speed with the distance from the emission spot
  113149. * @param scene The scene the lights belongs to
  113150. */
  113151. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  113152. /**
  113153. * Returns the string "SpotLight".
  113154. * @returns the class name
  113155. */
  113156. getClassName(): string;
  113157. /**
  113158. * Returns the integer 2.
  113159. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113160. */
  113161. getTypeID(): number;
  113162. /**
  113163. * Overrides the direction setter to recompute the projection texture view light Matrix.
  113164. */
  113165. protected _setDirection(value: Vector3): void;
  113166. /**
  113167. * Overrides the position setter to recompute the projection texture view light Matrix.
  113168. */
  113169. protected _setPosition(value: Vector3): void;
  113170. /**
  113171. * 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.
  113172. * Returns the SpotLight.
  113173. */
  113174. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113175. protected _computeProjectionTextureViewLightMatrix(): void;
  113176. protected _computeProjectionTextureProjectionLightMatrix(): void;
  113177. /**
  113178. * Main function for light texture projection matrix computing.
  113179. */
  113180. protected _computeProjectionTextureMatrix(): void;
  113181. protected _buildUniformLayout(): void;
  113182. private _computeAngleValues;
  113183. /**
  113184. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  113185. * @param effect The effect to update
  113186. * @param lightIndex The index of the light in the effect to update
  113187. * @returns The spot light
  113188. */
  113189. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  113190. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  113191. /**
  113192. * Disposes the light and the associated resources.
  113193. */
  113194. dispose(): void;
  113195. /**
  113196. * Prepares the list of defines specific to the light type.
  113197. * @param defines the list of defines
  113198. * @param lightIndex defines the index of the light for the effect
  113199. */
  113200. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113201. }
  113202. }
  113203. declare module BABYLON {
  113204. /**
  113205. * Gizmo that enables viewing a light
  113206. */
  113207. export class LightGizmo extends Gizmo {
  113208. private _lightMesh;
  113209. private _material;
  113210. private cachedPosition;
  113211. private cachedForward;
  113212. /**
  113213. * Creates a LightGizmo
  113214. * @param gizmoLayer The utility layer the gizmo will be added to
  113215. */
  113216. constructor(gizmoLayer?: UtilityLayerRenderer);
  113217. private _light;
  113218. /**
  113219. * The light that the gizmo is attached to
  113220. */
  113221. light: Nullable<Light>;
  113222. /**
  113223. * Gets the material used to render the light gizmo
  113224. */
  113225. readonly material: StandardMaterial;
  113226. /**
  113227. * @hidden
  113228. * Updates the gizmo to match the attached mesh's position/rotation
  113229. */
  113230. protected _update(): void;
  113231. private static _Scale;
  113232. /**
  113233. * Creates the lines for a light mesh
  113234. */
  113235. private static _createLightLines;
  113236. /**
  113237. * Disposes of the light gizmo
  113238. */
  113239. dispose(): void;
  113240. private static _CreateHemisphericLightMesh;
  113241. private static _CreatePointLightMesh;
  113242. private static _CreateSpotLightMesh;
  113243. private static _CreateDirectionalLightMesh;
  113244. }
  113245. }
  113246. declare module BABYLON {
  113247. /** @hidden */
  113248. export var backgroundFragmentDeclaration: {
  113249. name: string;
  113250. shader: string;
  113251. };
  113252. }
  113253. declare module BABYLON {
  113254. /** @hidden */
  113255. export var backgroundUboDeclaration: {
  113256. name: string;
  113257. shader: string;
  113258. };
  113259. }
  113260. declare module BABYLON {
  113261. /** @hidden */
  113262. export var backgroundPixelShader: {
  113263. name: string;
  113264. shader: string;
  113265. };
  113266. }
  113267. declare module BABYLON {
  113268. /** @hidden */
  113269. export var backgroundVertexDeclaration: {
  113270. name: string;
  113271. shader: string;
  113272. };
  113273. }
  113274. declare module BABYLON {
  113275. /** @hidden */
  113276. export var backgroundVertexShader: {
  113277. name: string;
  113278. shader: string;
  113279. };
  113280. }
  113281. declare module BABYLON {
  113282. /**
  113283. * Background material used to create an efficient environement around your scene.
  113284. */
  113285. export class BackgroundMaterial extends PushMaterial {
  113286. /**
  113287. * Standard reflectance value at parallel view angle.
  113288. */
  113289. static StandardReflectance0: number;
  113290. /**
  113291. * Standard reflectance value at grazing angle.
  113292. */
  113293. static StandardReflectance90: number;
  113294. protected _primaryColor: Color3;
  113295. /**
  113296. * Key light Color (multiply against the environement texture)
  113297. */
  113298. primaryColor: Color3;
  113299. protected __perceptualColor: Nullable<Color3>;
  113300. /**
  113301. * Experimental Internal Use Only.
  113302. *
  113303. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  113304. * This acts as a helper to set the primary color to a more "human friendly" value.
  113305. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  113306. * output color as close as possible from the chosen value.
  113307. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  113308. * part of lighting setup.)
  113309. */
  113310. _perceptualColor: Nullable<Color3>;
  113311. protected _primaryColorShadowLevel: float;
  113312. /**
  113313. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  113314. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  113315. */
  113316. primaryColorShadowLevel: float;
  113317. protected _primaryColorHighlightLevel: float;
  113318. /**
  113319. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  113320. * The primary color is used at the level chosen to define what the white area would look.
  113321. */
  113322. primaryColorHighlightLevel: float;
  113323. protected _reflectionTexture: Nullable<BaseTexture>;
  113324. /**
  113325. * Reflection Texture used in the material.
  113326. * Should be author in a specific way for the best result (refer to the documentation).
  113327. */
  113328. reflectionTexture: Nullable<BaseTexture>;
  113329. protected _reflectionBlur: float;
  113330. /**
  113331. * Reflection Texture level of blur.
  113332. *
  113333. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  113334. * texture twice.
  113335. */
  113336. reflectionBlur: float;
  113337. protected _diffuseTexture: Nullable<BaseTexture>;
  113338. /**
  113339. * Diffuse Texture used in the material.
  113340. * Should be author in a specific way for the best result (refer to the documentation).
  113341. */
  113342. diffuseTexture: Nullable<BaseTexture>;
  113343. protected _shadowLights: Nullable<IShadowLight[]>;
  113344. /**
  113345. * Specify the list of lights casting shadow on the material.
  113346. * All scene shadow lights will be included if null.
  113347. */
  113348. shadowLights: Nullable<IShadowLight[]>;
  113349. protected _shadowLevel: float;
  113350. /**
  113351. * Helps adjusting the shadow to a softer level if required.
  113352. * 0 means black shadows and 1 means no shadows.
  113353. */
  113354. shadowLevel: float;
  113355. protected _sceneCenter: Vector3;
  113356. /**
  113357. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  113358. * It is usually zero but might be interesting to modify according to your setup.
  113359. */
  113360. sceneCenter: Vector3;
  113361. protected _opacityFresnel: boolean;
  113362. /**
  113363. * This helps specifying that the material is falling off to the sky box at grazing angle.
  113364. * This helps ensuring a nice transition when the camera goes under the ground.
  113365. */
  113366. opacityFresnel: boolean;
  113367. protected _reflectionFresnel: boolean;
  113368. /**
  113369. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  113370. * This helps adding a mirror texture on the ground.
  113371. */
  113372. reflectionFresnel: boolean;
  113373. protected _reflectionFalloffDistance: number;
  113374. /**
  113375. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  113376. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  113377. */
  113378. reflectionFalloffDistance: number;
  113379. protected _reflectionAmount: number;
  113380. /**
  113381. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  113382. */
  113383. reflectionAmount: number;
  113384. protected _reflectionReflectance0: number;
  113385. /**
  113386. * This specifies the weight of the reflection at grazing angle.
  113387. */
  113388. reflectionReflectance0: number;
  113389. protected _reflectionReflectance90: number;
  113390. /**
  113391. * This specifies the weight of the reflection at a perpendicular point of view.
  113392. */
  113393. reflectionReflectance90: number;
  113394. /**
  113395. * Sets the reflection reflectance fresnel values according to the default standard
  113396. * empirically know to work well :-)
  113397. */
  113398. reflectionStandardFresnelWeight: number;
  113399. protected _useRGBColor: boolean;
  113400. /**
  113401. * Helps to directly use the maps channels instead of their level.
  113402. */
  113403. useRGBColor: boolean;
  113404. protected _enableNoise: boolean;
  113405. /**
  113406. * This helps reducing the banding effect that could occur on the background.
  113407. */
  113408. enableNoise: boolean;
  113409. /**
  113410. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113411. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  113412. * Recommended to be keep at 1.0 except for special cases.
  113413. */
  113414. fovMultiplier: number;
  113415. private _fovMultiplier;
  113416. /**
  113417. * Enable the FOV adjustment feature controlled by fovMultiplier.
  113418. */
  113419. useEquirectangularFOV: boolean;
  113420. private _maxSimultaneousLights;
  113421. /**
  113422. * Number of Simultaneous lights allowed on the material.
  113423. */
  113424. maxSimultaneousLights: int;
  113425. /**
  113426. * Default configuration related to image processing available in the Background Material.
  113427. */
  113428. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113429. /**
  113430. * Keep track of the image processing observer to allow dispose and replace.
  113431. */
  113432. private _imageProcessingObserver;
  113433. /**
  113434. * Attaches a new image processing configuration to the PBR Material.
  113435. * @param configuration (if null the scene configuration will be use)
  113436. */
  113437. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113438. /**
  113439. * Gets the image processing configuration used either in this material.
  113440. */
  113441. /**
  113442. * Sets the Default image processing configuration used either in the this material.
  113443. *
  113444. * If sets to null, the scene one is in use.
  113445. */
  113446. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  113447. /**
  113448. * Gets wether the color curves effect is enabled.
  113449. */
  113450. /**
  113451. * Sets wether the color curves effect is enabled.
  113452. */
  113453. cameraColorCurvesEnabled: boolean;
  113454. /**
  113455. * Gets wether the color grading effect is enabled.
  113456. */
  113457. /**
  113458. * Gets wether the color grading effect is enabled.
  113459. */
  113460. cameraColorGradingEnabled: boolean;
  113461. /**
  113462. * Gets wether tonemapping is enabled or not.
  113463. */
  113464. /**
  113465. * Sets wether tonemapping is enabled or not
  113466. */
  113467. cameraToneMappingEnabled: boolean;
  113468. /**
  113469. * The camera exposure used on this material.
  113470. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113471. * This corresponds to a photographic exposure.
  113472. */
  113473. /**
  113474. * The camera exposure used on this material.
  113475. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113476. * This corresponds to a photographic exposure.
  113477. */
  113478. cameraExposure: float;
  113479. /**
  113480. * Gets The camera contrast used on this material.
  113481. */
  113482. /**
  113483. * Sets The camera contrast used on this material.
  113484. */
  113485. cameraContrast: float;
  113486. /**
  113487. * Gets the Color Grading 2D Lookup Texture.
  113488. */
  113489. /**
  113490. * Sets the Color Grading 2D Lookup Texture.
  113491. */
  113492. cameraColorGradingTexture: Nullable<BaseTexture>;
  113493. /**
  113494. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113495. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113496. * 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;
  113497. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113498. */
  113499. /**
  113500. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113501. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113502. * 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;
  113503. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113504. */
  113505. cameraColorCurves: Nullable<ColorCurves>;
  113506. /**
  113507. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  113508. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  113509. */
  113510. switchToBGR: boolean;
  113511. private _renderTargets;
  113512. private _reflectionControls;
  113513. private _white;
  113514. private _primaryShadowColor;
  113515. private _primaryHighlightColor;
  113516. /**
  113517. * Instantiates a Background Material in the given scene
  113518. * @param name The friendly name of the material
  113519. * @param scene The scene to add the material to
  113520. */
  113521. constructor(name: string, scene: Scene);
  113522. /**
  113523. * Gets a boolean indicating that current material needs to register RTT
  113524. */
  113525. readonly hasRenderTargetTextures: boolean;
  113526. /**
  113527. * The entire material has been created in order to prevent overdraw.
  113528. * @returns false
  113529. */
  113530. needAlphaTesting(): boolean;
  113531. /**
  113532. * The entire material has been created in order to prevent overdraw.
  113533. * @returns true if blending is enable
  113534. */
  113535. needAlphaBlending(): boolean;
  113536. /**
  113537. * Checks wether the material is ready to be rendered for a given mesh.
  113538. * @param mesh The mesh to render
  113539. * @param subMesh The submesh to check against
  113540. * @param useInstances Specify wether or not the material is used with instances
  113541. * @returns true if all the dependencies are ready (Textures, Effects...)
  113542. */
  113543. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113544. /**
  113545. * Compute the primary color according to the chosen perceptual color.
  113546. */
  113547. private _computePrimaryColorFromPerceptualColor;
  113548. /**
  113549. * Compute the highlights and shadow colors according to their chosen levels.
  113550. */
  113551. private _computePrimaryColors;
  113552. /**
  113553. * Build the uniform buffer used in the material.
  113554. */
  113555. buildUniformLayout(): void;
  113556. /**
  113557. * Unbind the material.
  113558. */
  113559. unbind(): void;
  113560. /**
  113561. * Bind only the world matrix to the material.
  113562. * @param world The world matrix to bind.
  113563. */
  113564. bindOnlyWorldMatrix(world: Matrix): void;
  113565. /**
  113566. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  113567. * @param world The world matrix to bind.
  113568. * @param subMesh The submesh to bind for.
  113569. */
  113570. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113571. /**
  113572. * Checks to see if a texture is used in the material.
  113573. * @param texture - Base texture to use.
  113574. * @returns - Boolean specifying if a texture is used in the material.
  113575. */
  113576. hasTexture(texture: BaseTexture): boolean;
  113577. /**
  113578. * Dispose the material.
  113579. * @param forceDisposeEffect Force disposal of the associated effect.
  113580. * @param forceDisposeTextures Force disposal of the associated textures.
  113581. */
  113582. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113583. /**
  113584. * Clones the material.
  113585. * @param name The cloned name.
  113586. * @returns The cloned material.
  113587. */
  113588. clone(name: string): BackgroundMaterial;
  113589. /**
  113590. * Serializes the current material to its JSON representation.
  113591. * @returns The JSON representation.
  113592. */
  113593. serialize(): any;
  113594. /**
  113595. * Gets the class name of the material
  113596. * @returns "BackgroundMaterial"
  113597. */
  113598. getClassName(): string;
  113599. /**
  113600. * Parse a JSON input to create back a background material.
  113601. * @param source The JSON data to parse
  113602. * @param scene The scene to create the parsed material in
  113603. * @param rootUrl The root url of the assets the material depends upon
  113604. * @returns the instantiated BackgroundMaterial.
  113605. */
  113606. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  113607. }
  113608. }
  113609. declare module BABYLON {
  113610. /**
  113611. * Represents the different options available during the creation of
  113612. * a Environment helper.
  113613. *
  113614. * This can control the default ground, skybox and image processing setup of your scene.
  113615. */
  113616. export interface IEnvironmentHelperOptions {
  113617. /**
  113618. * Specifies wether or not to create a ground.
  113619. * True by default.
  113620. */
  113621. createGround: boolean;
  113622. /**
  113623. * Specifies the ground size.
  113624. * 15 by default.
  113625. */
  113626. groundSize: number;
  113627. /**
  113628. * The texture used on the ground for the main color.
  113629. * Comes from the BabylonJS CDN by default.
  113630. *
  113631. * Remarks: Can be either a texture or a url.
  113632. */
  113633. groundTexture: string | BaseTexture;
  113634. /**
  113635. * The color mixed in the ground texture by default.
  113636. * BabylonJS clearColor by default.
  113637. */
  113638. groundColor: Color3;
  113639. /**
  113640. * Specifies the ground opacity.
  113641. * 1 by default.
  113642. */
  113643. groundOpacity: number;
  113644. /**
  113645. * Enables the ground to receive shadows.
  113646. * True by default.
  113647. */
  113648. enableGroundShadow: boolean;
  113649. /**
  113650. * Helps preventing the shadow to be fully black on the ground.
  113651. * 0.5 by default.
  113652. */
  113653. groundShadowLevel: number;
  113654. /**
  113655. * Creates a mirror texture attach to the ground.
  113656. * false by default.
  113657. */
  113658. enableGroundMirror: boolean;
  113659. /**
  113660. * Specifies the ground mirror size ratio.
  113661. * 0.3 by default as the default kernel is 64.
  113662. */
  113663. groundMirrorSizeRatio: number;
  113664. /**
  113665. * Specifies the ground mirror blur kernel size.
  113666. * 64 by default.
  113667. */
  113668. groundMirrorBlurKernel: number;
  113669. /**
  113670. * Specifies the ground mirror visibility amount.
  113671. * 1 by default
  113672. */
  113673. groundMirrorAmount: number;
  113674. /**
  113675. * Specifies the ground mirror reflectance weight.
  113676. * This uses the standard weight of the background material to setup the fresnel effect
  113677. * of the mirror.
  113678. * 1 by default.
  113679. */
  113680. groundMirrorFresnelWeight: number;
  113681. /**
  113682. * Specifies the ground mirror Falloff distance.
  113683. * This can helps reducing the size of the reflection.
  113684. * 0 by Default.
  113685. */
  113686. groundMirrorFallOffDistance: number;
  113687. /**
  113688. * Specifies the ground mirror texture type.
  113689. * Unsigned Int by Default.
  113690. */
  113691. groundMirrorTextureType: number;
  113692. /**
  113693. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  113694. * the shown objects.
  113695. */
  113696. groundYBias: number;
  113697. /**
  113698. * Specifies wether or not to create a skybox.
  113699. * True by default.
  113700. */
  113701. createSkybox: boolean;
  113702. /**
  113703. * Specifies the skybox size.
  113704. * 20 by default.
  113705. */
  113706. skyboxSize: number;
  113707. /**
  113708. * The texture used on the skybox for the main color.
  113709. * Comes from the BabylonJS CDN by default.
  113710. *
  113711. * Remarks: Can be either a texture or a url.
  113712. */
  113713. skyboxTexture: string | BaseTexture;
  113714. /**
  113715. * The color mixed in the skybox texture by default.
  113716. * BabylonJS clearColor by default.
  113717. */
  113718. skyboxColor: Color3;
  113719. /**
  113720. * The background rotation around the Y axis of the scene.
  113721. * This helps aligning the key lights of your scene with the background.
  113722. * 0 by default.
  113723. */
  113724. backgroundYRotation: number;
  113725. /**
  113726. * Compute automatically the size of the elements to best fit with the scene.
  113727. */
  113728. sizeAuto: boolean;
  113729. /**
  113730. * Default position of the rootMesh if autoSize is not true.
  113731. */
  113732. rootPosition: Vector3;
  113733. /**
  113734. * Sets up the image processing in the scene.
  113735. * true by default.
  113736. */
  113737. setupImageProcessing: boolean;
  113738. /**
  113739. * The texture used as your environment texture in the scene.
  113740. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113741. *
  113742. * Remarks: Can be either a texture or a url.
  113743. */
  113744. environmentTexture: string | BaseTexture;
  113745. /**
  113746. * The value of the exposure to apply to the scene.
  113747. * 0.6 by default if setupImageProcessing is true.
  113748. */
  113749. cameraExposure: number;
  113750. /**
  113751. * The value of the contrast to apply to the scene.
  113752. * 1.6 by default if setupImageProcessing is true.
  113753. */
  113754. cameraContrast: number;
  113755. /**
  113756. * Specifies wether or not tonemapping should be enabled in the scene.
  113757. * true by default if setupImageProcessing is true.
  113758. */
  113759. toneMappingEnabled: boolean;
  113760. }
  113761. /**
  113762. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113763. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113764. * It also helps with the default setup of your imageProcessing configuration.
  113765. */
  113766. export class EnvironmentHelper {
  113767. /**
  113768. * Default ground texture URL.
  113769. */
  113770. private static _groundTextureCDNUrl;
  113771. /**
  113772. * Default skybox texture URL.
  113773. */
  113774. private static _skyboxTextureCDNUrl;
  113775. /**
  113776. * Default environment texture URL.
  113777. */
  113778. private static _environmentTextureCDNUrl;
  113779. /**
  113780. * Creates the default options for the helper.
  113781. */
  113782. private static _getDefaultOptions;
  113783. private _rootMesh;
  113784. /**
  113785. * Gets the root mesh created by the helper.
  113786. */
  113787. readonly rootMesh: Mesh;
  113788. private _skybox;
  113789. /**
  113790. * Gets the skybox created by the helper.
  113791. */
  113792. readonly skybox: Nullable<Mesh>;
  113793. private _skyboxTexture;
  113794. /**
  113795. * Gets the skybox texture created by the helper.
  113796. */
  113797. readonly skyboxTexture: Nullable<BaseTexture>;
  113798. private _skyboxMaterial;
  113799. /**
  113800. * Gets the skybox material created by the helper.
  113801. */
  113802. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113803. private _ground;
  113804. /**
  113805. * Gets the ground mesh created by the helper.
  113806. */
  113807. readonly ground: Nullable<Mesh>;
  113808. private _groundTexture;
  113809. /**
  113810. * Gets the ground texture created by the helper.
  113811. */
  113812. readonly groundTexture: Nullable<BaseTexture>;
  113813. private _groundMirror;
  113814. /**
  113815. * Gets the ground mirror created by the helper.
  113816. */
  113817. readonly groundMirror: Nullable<MirrorTexture>;
  113818. /**
  113819. * Gets the ground mirror render list to helps pushing the meshes
  113820. * you wish in the ground reflection.
  113821. */
  113822. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113823. private _groundMaterial;
  113824. /**
  113825. * Gets the ground material created by the helper.
  113826. */
  113827. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113828. /**
  113829. * Stores the creation options.
  113830. */
  113831. private readonly _scene;
  113832. private _options;
  113833. /**
  113834. * This observable will be notified with any error during the creation of the environment,
  113835. * mainly texture creation errors.
  113836. */
  113837. onErrorObservable: Observable<{
  113838. message?: string;
  113839. exception?: any;
  113840. }>;
  113841. /**
  113842. * constructor
  113843. * @param options Defines the options we want to customize the helper
  113844. * @param scene The scene to add the material to
  113845. */
  113846. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113847. /**
  113848. * Updates the background according to the new options
  113849. * @param options
  113850. */
  113851. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113852. /**
  113853. * Sets the primary color of all the available elements.
  113854. * @param color the main color to affect to the ground and the background
  113855. */
  113856. setMainColor(color: Color3): void;
  113857. /**
  113858. * Setup the image processing according to the specified options.
  113859. */
  113860. private _setupImageProcessing;
  113861. /**
  113862. * Setup the environment texture according to the specified options.
  113863. */
  113864. private _setupEnvironmentTexture;
  113865. /**
  113866. * Setup the background according to the specified options.
  113867. */
  113868. private _setupBackground;
  113869. /**
  113870. * Get the scene sizes according to the setup.
  113871. */
  113872. private _getSceneSize;
  113873. /**
  113874. * Setup the ground according to the specified options.
  113875. */
  113876. private _setupGround;
  113877. /**
  113878. * Setup the ground material according to the specified options.
  113879. */
  113880. private _setupGroundMaterial;
  113881. /**
  113882. * Setup the ground diffuse texture according to the specified options.
  113883. */
  113884. private _setupGroundDiffuseTexture;
  113885. /**
  113886. * Setup the ground mirror texture according to the specified options.
  113887. */
  113888. private _setupGroundMirrorTexture;
  113889. /**
  113890. * Setup the ground to receive the mirror texture.
  113891. */
  113892. private _setupMirrorInGroundMaterial;
  113893. /**
  113894. * Setup the skybox according to the specified options.
  113895. */
  113896. private _setupSkybox;
  113897. /**
  113898. * Setup the skybox material according to the specified options.
  113899. */
  113900. private _setupSkyboxMaterial;
  113901. /**
  113902. * Setup the skybox reflection texture according to the specified options.
  113903. */
  113904. private _setupSkyboxReflectionTexture;
  113905. private _errorHandler;
  113906. /**
  113907. * Dispose all the elements created by the Helper.
  113908. */
  113909. dispose(): void;
  113910. }
  113911. }
  113912. declare module BABYLON {
  113913. /**
  113914. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113915. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113916. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113917. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113918. */
  113919. export class PhotoDome extends TransformNode {
  113920. /**
  113921. * Define the image as a Monoscopic panoramic 360 image.
  113922. */
  113923. static readonly MODE_MONOSCOPIC: number;
  113924. /**
  113925. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113926. */
  113927. static readonly MODE_TOPBOTTOM: number;
  113928. /**
  113929. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113930. */
  113931. static readonly MODE_SIDEBYSIDE: number;
  113932. private _useDirectMapping;
  113933. /**
  113934. * The texture being displayed on the sphere
  113935. */
  113936. protected _photoTexture: Texture;
  113937. /**
  113938. * Gets or sets the texture being displayed on the sphere
  113939. */
  113940. photoTexture: Texture;
  113941. /**
  113942. * Observable raised when an error occured while loading the 360 image
  113943. */
  113944. onLoadErrorObservable: Observable<string>;
  113945. /**
  113946. * The skybox material
  113947. */
  113948. protected _material: BackgroundMaterial;
  113949. /**
  113950. * The surface used for the skybox
  113951. */
  113952. protected _mesh: Mesh;
  113953. /**
  113954. * Gets the mesh used for the skybox.
  113955. */
  113956. readonly mesh: Mesh;
  113957. /**
  113958. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113959. * Also see the options.resolution property.
  113960. */
  113961. fovMultiplier: number;
  113962. private _imageMode;
  113963. /**
  113964. * Gets or set the current video mode for the video. It can be:
  113965. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113966. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113967. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113968. */
  113969. imageMode: number;
  113970. /**
  113971. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113972. * @param name Element's name, child elements will append suffixes for their own names.
  113973. * @param urlsOfPhoto defines the url of the photo to display
  113974. * @param options defines an object containing optional or exposed sub element properties
  113975. * @param onError defines a callback called when an error occured while loading the texture
  113976. */
  113977. constructor(name: string, urlOfPhoto: string, options: {
  113978. resolution?: number;
  113979. size?: number;
  113980. useDirectMapping?: boolean;
  113981. faceForward?: boolean;
  113982. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113983. private _onBeforeCameraRenderObserver;
  113984. private _changeImageMode;
  113985. /**
  113986. * Releases resources associated with this node.
  113987. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113988. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113989. */
  113990. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113991. }
  113992. }
  113993. declare module BABYLON {
  113994. /**
  113995. * Class used to host RGBD texture specific utilities
  113996. */
  113997. export class RGBDTextureTools {
  113998. /**
  113999. * Expand the RGBD Texture from RGBD to Half Float if possible.
  114000. * @param texture the texture to expand.
  114001. */
  114002. static ExpandRGBDTexture(texture: Texture): void;
  114003. }
  114004. }
  114005. declare module BABYLON {
  114006. /**
  114007. * Class used to host texture specific utilities
  114008. */
  114009. export class BRDFTextureTools {
  114010. /**
  114011. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  114012. * @param scene defines the hosting scene
  114013. * @returns the environment BRDF texture
  114014. */
  114015. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  114016. private static _environmentBRDFBase64Texture;
  114017. }
  114018. }
  114019. declare module BABYLON {
  114020. /**
  114021. * @hidden
  114022. */
  114023. export interface IMaterialClearCoatDefines {
  114024. CLEARCOAT: boolean;
  114025. CLEARCOAT_DEFAULTIOR: boolean;
  114026. CLEARCOAT_TEXTURE: boolean;
  114027. CLEARCOAT_TEXTUREDIRECTUV: number;
  114028. CLEARCOAT_BUMP: boolean;
  114029. CLEARCOAT_BUMPDIRECTUV: number;
  114030. CLEARCOAT_TINT: boolean;
  114031. CLEARCOAT_TINT_TEXTURE: boolean;
  114032. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114033. /** @hidden */
  114034. _areTexturesDirty: boolean;
  114035. }
  114036. /**
  114037. * Define the code related to the clear coat parameters of the pbr material.
  114038. */
  114039. export class PBRClearCoatConfiguration {
  114040. /**
  114041. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114042. * The default fits with a polyurethane material.
  114043. */
  114044. private static readonly _DefaultIndexOfRefraction;
  114045. private _isEnabled;
  114046. /**
  114047. * Defines if the clear coat is enabled in the material.
  114048. */
  114049. isEnabled: boolean;
  114050. /**
  114051. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  114052. */
  114053. intensity: number;
  114054. /**
  114055. * Defines the clear coat layer roughness.
  114056. */
  114057. roughness: number;
  114058. private _indexOfRefraction;
  114059. /**
  114060. * Defines the index of refraction of the clear coat.
  114061. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114062. * The default fits with a polyurethane material.
  114063. * Changing the default value is more performance intensive.
  114064. */
  114065. indexOfRefraction: number;
  114066. private _texture;
  114067. /**
  114068. * Stores the clear coat values in a texture.
  114069. */
  114070. texture: Nullable<BaseTexture>;
  114071. private _bumpTexture;
  114072. /**
  114073. * Define the clear coat specific bump texture.
  114074. */
  114075. bumpTexture: Nullable<BaseTexture>;
  114076. private _isTintEnabled;
  114077. /**
  114078. * Defines if the clear coat tint is enabled in the material.
  114079. */
  114080. isTintEnabled: boolean;
  114081. /**
  114082. * Defines the clear coat tint of the material.
  114083. * This is only use if tint is enabled
  114084. */
  114085. tintColor: Color3;
  114086. /**
  114087. * Defines the distance at which the tint color should be found in the
  114088. * clear coat media.
  114089. * This is only use if tint is enabled
  114090. */
  114091. tintColorAtDistance: number;
  114092. /**
  114093. * Defines the clear coat layer thickness.
  114094. * This is only use if tint is enabled
  114095. */
  114096. tintThickness: number;
  114097. private _tintTexture;
  114098. /**
  114099. * Stores the clear tint values in a texture.
  114100. * rgb is tint
  114101. * a is a thickness factor
  114102. */
  114103. tintTexture: Nullable<BaseTexture>;
  114104. /** @hidden */
  114105. private _internalMarkAllSubMeshesAsTexturesDirty;
  114106. /** @hidden */
  114107. _markAllSubMeshesAsTexturesDirty(): void;
  114108. /**
  114109. * Instantiate a new istance of clear coat configuration.
  114110. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114111. */
  114112. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114113. /**
  114114. * Gets wehter the submesh is ready to be used or not.
  114115. * @param defines the list of "defines" to update.
  114116. * @param scene defines the scene the material belongs to.
  114117. * @param engine defines the engine the material belongs to.
  114118. * @param disableBumpMap defines wether the material disables bump or not.
  114119. * @returns - boolean indicating that the submesh is ready or not.
  114120. */
  114121. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  114122. /**
  114123. * Checks to see if a texture is used in the material.
  114124. * @param defines the list of "defines" to update.
  114125. * @param scene defines the scene to the material belongs to.
  114126. */
  114127. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  114128. /**
  114129. * Binds the material data.
  114130. * @param uniformBuffer defines the Uniform buffer to fill in.
  114131. * @param scene defines the scene the material belongs to.
  114132. * @param engine defines the engine the material belongs to.
  114133. * @param disableBumpMap defines wether the material disables bump or not.
  114134. * @param isFrozen defines wether the material is frozen or not.
  114135. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114136. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114137. */
  114138. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  114139. /**
  114140. * Checks to see if a texture is used in the material.
  114141. * @param texture - Base texture to use.
  114142. * @returns - Boolean specifying if a texture is used in the material.
  114143. */
  114144. hasTexture(texture: BaseTexture): boolean;
  114145. /**
  114146. * Returns an array of the actively used textures.
  114147. * @param activeTextures Array of BaseTextures
  114148. */
  114149. getActiveTextures(activeTextures: BaseTexture[]): void;
  114150. /**
  114151. * Returns the animatable textures.
  114152. * @param animatables Array of animatable textures.
  114153. */
  114154. getAnimatables(animatables: IAnimatable[]): void;
  114155. /**
  114156. * Disposes the resources of the material.
  114157. * @param forceDisposeTextures - Forces the disposal of all textures.
  114158. */
  114159. dispose(forceDisposeTextures?: boolean): void;
  114160. /**
  114161. * Get the current class name of the texture useful for serialization or dynamic coding.
  114162. * @returns "PBRClearCoatConfiguration"
  114163. */
  114164. getClassName(): string;
  114165. /**
  114166. * Add fallbacks to the effect fallbacks list.
  114167. * @param defines defines the Base texture to use.
  114168. * @param fallbacks defines the current fallback list.
  114169. * @param currentRank defines the current fallback rank.
  114170. * @returns the new fallback rank.
  114171. */
  114172. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114173. /**
  114174. * Add the required uniforms to the current list.
  114175. * @param uniforms defines the current uniform list.
  114176. */
  114177. static AddUniforms(uniforms: string[]): void;
  114178. /**
  114179. * Add the required samplers to the current list.
  114180. * @param samplers defines the current sampler list.
  114181. */
  114182. static AddSamplers(samplers: string[]): void;
  114183. /**
  114184. * Add the required uniforms to the current buffer.
  114185. * @param uniformBuffer defines the current uniform buffer.
  114186. */
  114187. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114188. /**
  114189. * Makes a duplicate of the current configuration into another one.
  114190. * @param clearCoatConfiguration define the config where to copy the info
  114191. */
  114192. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  114193. /**
  114194. * Serializes this clear coat configuration.
  114195. * @returns - An object with the serialized config.
  114196. */
  114197. serialize(): any;
  114198. /**
  114199. * Parses a anisotropy Configuration from a serialized object.
  114200. * @param source - Serialized object.
  114201. * @param scene Defines the scene we are parsing for
  114202. * @param rootUrl Defines the rootUrl to load from
  114203. */
  114204. parse(source: any, scene: Scene, rootUrl: string): void;
  114205. }
  114206. }
  114207. declare module BABYLON {
  114208. /**
  114209. * @hidden
  114210. */
  114211. export interface IMaterialAnisotropicDefines {
  114212. ANISOTROPIC: boolean;
  114213. ANISOTROPIC_TEXTURE: boolean;
  114214. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114215. MAINUV1: boolean;
  114216. _areTexturesDirty: boolean;
  114217. _needUVs: boolean;
  114218. }
  114219. /**
  114220. * Define the code related to the anisotropic parameters of the pbr material.
  114221. */
  114222. export class PBRAnisotropicConfiguration {
  114223. private _isEnabled;
  114224. /**
  114225. * Defines if the anisotropy is enabled in the material.
  114226. */
  114227. isEnabled: boolean;
  114228. /**
  114229. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  114230. */
  114231. intensity: number;
  114232. /**
  114233. * Defines if the effect is along the tangents, bitangents or in between.
  114234. * By default, the effect is "strectching" the highlights along the tangents.
  114235. */
  114236. direction: Vector2;
  114237. private _texture;
  114238. /**
  114239. * Stores the anisotropy values in a texture.
  114240. * rg is direction (like normal from -1 to 1)
  114241. * b is a intensity
  114242. */
  114243. texture: Nullable<BaseTexture>;
  114244. /** @hidden */
  114245. private _internalMarkAllSubMeshesAsTexturesDirty;
  114246. /** @hidden */
  114247. _markAllSubMeshesAsTexturesDirty(): void;
  114248. /**
  114249. * Instantiate a new istance of anisotropy configuration.
  114250. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114251. */
  114252. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114253. /**
  114254. * Specifies that the submesh is ready to be used.
  114255. * @param defines the list of "defines" to update.
  114256. * @param scene defines the scene the material belongs to.
  114257. * @returns - boolean indicating that the submesh is ready or not.
  114258. */
  114259. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  114260. /**
  114261. * Checks to see if a texture is used in the material.
  114262. * @param defines the list of "defines" to update.
  114263. * @param mesh the mesh we are preparing the defines for.
  114264. * @param scene defines the scene the material belongs to.
  114265. */
  114266. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  114267. /**
  114268. * Binds the material data.
  114269. * @param uniformBuffer defines the Uniform buffer to fill in.
  114270. * @param scene defines the scene the material belongs to.
  114271. * @param isFrozen defines wether the material is frozen or not.
  114272. */
  114273. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114274. /**
  114275. * Checks to see if a texture is used in the material.
  114276. * @param texture - Base texture to use.
  114277. * @returns - Boolean specifying if a texture is used in the material.
  114278. */
  114279. hasTexture(texture: BaseTexture): boolean;
  114280. /**
  114281. * Returns an array of the actively used textures.
  114282. * @param activeTextures Array of BaseTextures
  114283. */
  114284. getActiveTextures(activeTextures: BaseTexture[]): void;
  114285. /**
  114286. * Returns the animatable textures.
  114287. * @param animatables Array of animatable textures.
  114288. */
  114289. getAnimatables(animatables: IAnimatable[]): void;
  114290. /**
  114291. * Disposes the resources of the material.
  114292. * @param forceDisposeTextures - Forces the disposal of all textures.
  114293. */
  114294. dispose(forceDisposeTextures?: boolean): void;
  114295. /**
  114296. * Get the current class name of the texture useful for serialization or dynamic coding.
  114297. * @returns "PBRAnisotropicConfiguration"
  114298. */
  114299. getClassName(): string;
  114300. /**
  114301. * Add fallbacks to the effect fallbacks list.
  114302. * @param defines defines the Base texture to use.
  114303. * @param fallbacks defines the current fallback list.
  114304. * @param currentRank defines the current fallback rank.
  114305. * @returns the new fallback rank.
  114306. */
  114307. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114308. /**
  114309. * Add the required uniforms to the current list.
  114310. * @param uniforms defines the current uniform list.
  114311. */
  114312. static AddUniforms(uniforms: string[]): void;
  114313. /**
  114314. * Add the required uniforms to the current buffer.
  114315. * @param uniformBuffer defines the current uniform buffer.
  114316. */
  114317. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114318. /**
  114319. * Add the required samplers to the current list.
  114320. * @param samplers defines the current sampler list.
  114321. */
  114322. static AddSamplers(samplers: string[]): void;
  114323. /**
  114324. * Makes a duplicate of the current configuration into another one.
  114325. * @param anisotropicConfiguration define the config where to copy the info
  114326. */
  114327. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  114328. /**
  114329. * Serializes this anisotropy configuration.
  114330. * @returns - An object with the serialized config.
  114331. */
  114332. serialize(): any;
  114333. /**
  114334. * Parses a anisotropy Configuration from a serialized object.
  114335. * @param source - Serialized object.
  114336. * @param scene Defines the scene we are parsing for
  114337. * @param rootUrl Defines the rootUrl to load from
  114338. */
  114339. parse(source: any, scene: Scene, rootUrl: string): void;
  114340. }
  114341. }
  114342. declare module BABYLON {
  114343. /**
  114344. * @hidden
  114345. */
  114346. export interface IMaterialBRDFDefines {
  114347. BRDF_V_HEIGHT_CORRELATED: boolean;
  114348. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114349. SPHERICAL_HARMONICS: boolean;
  114350. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114351. /** @hidden */
  114352. _areMiscDirty: boolean;
  114353. }
  114354. /**
  114355. * Define the code related to the BRDF parameters of the pbr material.
  114356. */
  114357. export class PBRBRDFConfiguration {
  114358. /**
  114359. * Default value used for the energy conservation.
  114360. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114361. */
  114362. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  114363. /**
  114364. * Default value used for the Smith Visibility Height Correlated mode.
  114365. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114366. */
  114367. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  114368. /**
  114369. * Default value used for the IBL diffuse part.
  114370. * This can help switching back to the polynomials mode globally which is a tiny bit
  114371. * less GPU intensive at the drawback of a lower quality.
  114372. */
  114373. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  114374. /**
  114375. * Default value used for activating energy conservation for the specular workflow.
  114376. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114377. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114378. */
  114379. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  114380. private _useEnergyConservation;
  114381. /**
  114382. * Defines if the material uses energy conservation.
  114383. */
  114384. useEnergyConservation: boolean;
  114385. private _useSmithVisibilityHeightCorrelated;
  114386. /**
  114387. * LEGACY Mode set to false
  114388. * Defines if the material uses height smith correlated visibility term.
  114389. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  114390. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  114391. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  114392. * Not relying on height correlated will also disable energy conservation.
  114393. */
  114394. useSmithVisibilityHeightCorrelated: boolean;
  114395. private _useSphericalHarmonics;
  114396. /**
  114397. * LEGACY Mode set to false
  114398. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  114399. * diffuse part of the IBL.
  114400. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  114401. * to the ground truth.
  114402. */
  114403. useSphericalHarmonics: boolean;
  114404. private _useSpecularGlossinessInputEnergyConservation;
  114405. /**
  114406. * Defines if the material uses energy conservation, when the specular workflow is active.
  114407. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114408. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114409. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  114410. */
  114411. useSpecularGlossinessInputEnergyConservation: boolean;
  114412. /** @hidden */
  114413. private _internalMarkAllSubMeshesAsMiscDirty;
  114414. /** @hidden */
  114415. _markAllSubMeshesAsMiscDirty(): void;
  114416. /**
  114417. * Instantiate a new istance of clear coat configuration.
  114418. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  114419. */
  114420. constructor(markAllSubMeshesAsMiscDirty: () => void);
  114421. /**
  114422. * Checks to see if a texture is used in the material.
  114423. * @param defines the list of "defines" to update.
  114424. */
  114425. prepareDefines(defines: IMaterialBRDFDefines): void;
  114426. /**
  114427. * Get the current class name of the texture useful for serialization or dynamic coding.
  114428. * @returns "PBRClearCoatConfiguration"
  114429. */
  114430. getClassName(): string;
  114431. /**
  114432. * Makes a duplicate of the current configuration into another one.
  114433. * @param brdfConfiguration define the config where to copy the info
  114434. */
  114435. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  114436. /**
  114437. * Serializes this BRDF configuration.
  114438. * @returns - An object with the serialized config.
  114439. */
  114440. serialize(): any;
  114441. /**
  114442. * Parses a anisotropy Configuration from a serialized object.
  114443. * @param source - Serialized object.
  114444. * @param scene Defines the scene we are parsing for
  114445. * @param rootUrl Defines the rootUrl to load from
  114446. */
  114447. parse(source: any, scene: Scene, rootUrl: string): void;
  114448. }
  114449. }
  114450. declare module BABYLON {
  114451. /**
  114452. * @hidden
  114453. */
  114454. export interface IMaterialSheenDefines {
  114455. SHEEN: boolean;
  114456. SHEEN_TEXTURE: boolean;
  114457. SHEEN_TEXTUREDIRECTUV: number;
  114458. SHEEN_LINKWITHALBEDO: boolean;
  114459. /** @hidden */
  114460. _areTexturesDirty: boolean;
  114461. }
  114462. /**
  114463. * Define the code related to the Sheen parameters of the pbr material.
  114464. */
  114465. export class PBRSheenConfiguration {
  114466. private _isEnabled;
  114467. /**
  114468. * Defines if the material uses sheen.
  114469. */
  114470. isEnabled: boolean;
  114471. private _linkSheenWithAlbedo;
  114472. /**
  114473. * Defines if the sheen is linked to the sheen color.
  114474. */
  114475. linkSheenWithAlbedo: boolean;
  114476. /**
  114477. * Defines the sheen intensity.
  114478. */
  114479. intensity: number;
  114480. /**
  114481. * Defines the sheen color.
  114482. */
  114483. color: Color3;
  114484. private _texture;
  114485. /**
  114486. * Stores the sheen tint values in a texture.
  114487. * rgb is tint
  114488. * a is a intensity
  114489. */
  114490. texture: Nullable<BaseTexture>;
  114491. /** @hidden */
  114492. private _internalMarkAllSubMeshesAsTexturesDirty;
  114493. /** @hidden */
  114494. _markAllSubMeshesAsTexturesDirty(): void;
  114495. /**
  114496. * Instantiate a new istance of clear coat configuration.
  114497. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114498. */
  114499. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114500. /**
  114501. * Specifies that the submesh is ready to be used.
  114502. * @param defines the list of "defines" to update.
  114503. * @param scene defines the scene the material belongs to.
  114504. * @returns - boolean indicating that the submesh is ready or not.
  114505. */
  114506. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  114507. /**
  114508. * Checks to see if a texture is used in the material.
  114509. * @param defines the list of "defines" to update.
  114510. * @param scene defines the scene the material belongs to.
  114511. */
  114512. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  114513. /**
  114514. * Binds the material data.
  114515. * @param uniformBuffer defines the Uniform buffer to fill in.
  114516. * @param scene defines the scene the material belongs to.
  114517. * @param isFrozen defines wether the material is frozen or not.
  114518. */
  114519. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114520. /**
  114521. * Checks to see if a texture is used in the material.
  114522. * @param texture - Base texture to use.
  114523. * @returns - Boolean specifying if a texture is used in the material.
  114524. */
  114525. hasTexture(texture: BaseTexture): boolean;
  114526. /**
  114527. * Returns an array of the actively used textures.
  114528. * @param activeTextures Array of BaseTextures
  114529. */
  114530. getActiveTextures(activeTextures: BaseTexture[]): void;
  114531. /**
  114532. * Returns the animatable textures.
  114533. * @param animatables Array of animatable textures.
  114534. */
  114535. getAnimatables(animatables: IAnimatable[]): void;
  114536. /**
  114537. * Disposes the resources of the material.
  114538. * @param forceDisposeTextures - Forces the disposal of all textures.
  114539. */
  114540. dispose(forceDisposeTextures?: boolean): void;
  114541. /**
  114542. * Get the current class name of the texture useful for serialization or dynamic coding.
  114543. * @returns "PBRSheenConfiguration"
  114544. */
  114545. getClassName(): string;
  114546. /**
  114547. * Add fallbacks to the effect fallbacks list.
  114548. * @param defines defines the Base texture to use.
  114549. * @param fallbacks defines the current fallback list.
  114550. * @param currentRank defines the current fallback rank.
  114551. * @returns the new fallback rank.
  114552. */
  114553. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114554. /**
  114555. * Add the required uniforms to the current list.
  114556. * @param uniforms defines the current uniform list.
  114557. */
  114558. static AddUniforms(uniforms: string[]): void;
  114559. /**
  114560. * Add the required uniforms to the current buffer.
  114561. * @param uniformBuffer defines the current uniform buffer.
  114562. */
  114563. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114564. /**
  114565. * Add the required samplers to the current list.
  114566. * @param samplers defines the current sampler list.
  114567. */
  114568. static AddSamplers(samplers: string[]): void;
  114569. /**
  114570. * Makes a duplicate of the current configuration into another one.
  114571. * @param sheenConfiguration define the config where to copy the info
  114572. */
  114573. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  114574. /**
  114575. * Serializes this BRDF configuration.
  114576. * @returns - An object with the serialized config.
  114577. */
  114578. serialize(): any;
  114579. /**
  114580. * Parses a anisotropy Configuration from a serialized object.
  114581. * @param source - Serialized object.
  114582. * @param scene Defines the scene we are parsing for
  114583. * @param rootUrl Defines the rootUrl to load from
  114584. */
  114585. parse(source: any, scene: Scene, rootUrl: string): void;
  114586. }
  114587. }
  114588. declare module BABYLON {
  114589. /**
  114590. * @hidden
  114591. */
  114592. export interface IMaterialSubSurfaceDefines {
  114593. SUBSURFACE: boolean;
  114594. SS_REFRACTION: boolean;
  114595. SS_TRANSLUCENCY: boolean;
  114596. SS_SCATERRING: boolean;
  114597. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114598. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114599. SS_REFRACTIONMAP_3D: boolean;
  114600. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114601. SS_LODINREFRACTIONALPHA: boolean;
  114602. SS_GAMMAREFRACTION: boolean;
  114603. SS_RGBDREFRACTION: boolean;
  114604. SS_LINEARSPECULARREFRACTION: boolean;
  114605. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114606. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114607. /** @hidden */
  114608. _areTexturesDirty: boolean;
  114609. }
  114610. /**
  114611. * Define the code related to the sub surface parameters of the pbr material.
  114612. */
  114613. export class PBRSubSurfaceConfiguration {
  114614. private _isRefractionEnabled;
  114615. /**
  114616. * Defines if the refraction is enabled in the material.
  114617. */
  114618. isRefractionEnabled: boolean;
  114619. private _isTranslucencyEnabled;
  114620. /**
  114621. * Defines if the translucency is enabled in the material.
  114622. */
  114623. isTranslucencyEnabled: boolean;
  114624. private _isScatteringEnabled;
  114625. /**
  114626. * Defines the refraction intensity of the material.
  114627. * The refraction when enabled replaces the Diffuse part of the material.
  114628. * The intensity helps transitionning between diffuse and refraction.
  114629. */
  114630. refractionIntensity: number;
  114631. /**
  114632. * Defines the translucency intensity of the material.
  114633. * When translucency has been enabled, this defines how much of the "translucency"
  114634. * is addded to the diffuse part of the material.
  114635. */
  114636. translucencyIntensity: number;
  114637. /**
  114638. * Defines the scattering intensity of the material.
  114639. * When scattering has been enabled, this defines how much of the "scattered light"
  114640. * is addded to the diffuse part of the material.
  114641. */
  114642. scatteringIntensity: number;
  114643. private _thicknessTexture;
  114644. /**
  114645. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  114646. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  114647. * 0 would mean minimumThickness
  114648. * 1 would mean maximumThickness
  114649. * The other channels might be use as a mask to vary the different effects intensity.
  114650. */
  114651. thicknessTexture: Nullable<BaseTexture>;
  114652. private _refractionTexture;
  114653. /**
  114654. * Defines the texture to use for refraction.
  114655. */
  114656. refractionTexture: Nullable<BaseTexture>;
  114657. private _indexOfRefraction;
  114658. /**
  114659. * Defines the index of refraction used in the material.
  114660. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  114661. */
  114662. indexOfRefraction: number;
  114663. private _invertRefractionY;
  114664. /**
  114665. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114666. */
  114667. invertRefractionY: boolean;
  114668. private _linkRefractionWithTransparency;
  114669. /**
  114670. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114671. * Materials half opaque for instance using refraction could benefit from this control.
  114672. */
  114673. linkRefractionWithTransparency: boolean;
  114674. /**
  114675. * Defines the minimum thickness stored in the thickness map.
  114676. * If no thickness map is defined, this value will be used to simulate thickness.
  114677. */
  114678. minimumThickness: number;
  114679. /**
  114680. * Defines the maximum thickness stored in the thickness map.
  114681. */
  114682. maximumThickness: number;
  114683. /**
  114684. * Defines the volume tint of the material.
  114685. * This is used for both translucency and scattering.
  114686. */
  114687. tintColor: Color3;
  114688. /**
  114689. * Defines the distance at which the tint color should be found in the media.
  114690. * This is used for refraction only.
  114691. */
  114692. tintColorAtDistance: number;
  114693. /**
  114694. * Defines how far each channel transmit through the media.
  114695. * It is defined as a color to simplify it selection.
  114696. */
  114697. diffusionDistance: Color3;
  114698. private _useMaskFromThicknessTexture;
  114699. /**
  114700. * Stores the intensity of the different subsurface effects in the thickness texture.
  114701. * * the green channel is the translucency intensity.
  114702. * * the blue channel is the scattering intensity.
  114703. * * the alpha channel is the refraction intensity.
  114704. */
  114705. useMaskFromThicknessTexture: boolean;
  114706. /** @hidden */
  114707. private _internalMarkAllSubMeshesAsTexturesDirty;
  114708. /** @hidden */
  114709. _markAllSubMeshesAsTexturesDirty(): void;
  114710. /**
  114711. * Instantiate a new istance of sub surface configuration.
  114712. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114713. */
  114714. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114715. /**
  114716. * Gets wehter the submesh is ready to be used or not.
  114717. * @param defines the list of "defines" to update.
  114718. * @param scene defines the scene the material belongs to.
  114719. * @returns - boolean indicating that the submesh is ready or not.
  114720. */
  114721. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  114722. /**
  114723. * Checks to see if a texture is used in the material.
  114724. * @param defines the list of "defines" to update.
  114725. * @param scene defines the scene to the material belongs to.
  114726. */
  114727. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  114728. /**
  114729. * Binds the material data.
  114730. * @param uniformBuffer defines the Uniform buffer to fill in.
  114731. * @param scene defines the scene the material belongs to.
  114732. * @param engine defines the engine the material belongs to.
  114733. * @param isFrozen defines wether the material is frozen or not.
  114734. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  114735. */
  114736. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  114737. /**
  114738. * Unbinds the material from the mesh.
  114739. * @param activeEffect defines the effect that should be unbound from.
  114740. * @returns true if unbound, otherwise false
  114741. */
  114742. unbind(activeEffect: Effect): boolean;
  114743. /**
  114744. * Returns the texture used for refraction or null if none is used.
  114745. * @param scene defines the scene the material belongs to.
  114746. * @returns - Refraction texture if present. If no refraction texture and refraction
  114747. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114748. */
  114749. private _getRefractionTexture;
  114750. /**
  114751. * Returns true if alpha blending should be disabled.
  114752. */
  114753. readonly disableAlphaBlending: boolean;
  114754. /**
  114755. * Fills the list of render target textures.
  114756. * @param renderTargets the list of render targets to update
  114757. */
  114758. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114759. /**
  114760. * Checks to see if a texture is used in the material.
  114761. * @param texture - Base texture to use.
  114762. * @returns - Boolean specifying if a texture is used in the material.
  114763. */
  114764. hasTexture(texture: BaseTexture): boolean;
  114765. /**
  114766. * Gets a boolean indicating that current material needs to register RTT
  114767. * @returns true if this uses a render target otherwise false.
  114768. */
  114769. hasRenderTargetTextures(): boolean;
  114770. /**
  114771. * Returns an array of the actively used textures.
  114772. * @param activeTextures Array of BaseTextures
  114773. */
  114774. getActiveTextures(activeTextures: BaseTexture[]): void;
  114775. /**
  114776. * Returns the animatable textures.
  114777. * @param animatables Array of animatable textures.
  114778. */
  114779. getAnimatables(animatables: IAnimatable[]): void;
  114780. /**
  114781. * Disposes the resources of the material.
  114782. * @param forceDisposeTextures - Forces the disposal of all textures.
  114783. */
  114784. dispose(forceDisposeTextures?: boolean): void;
  114785. /**
  114786. * Get the current class name of the texture useful for serialization or dynamic coding.
  114787. * @returns "PBRSubSurfaceConfiguration"
  114788. */
  114789. getClassName(): string;
  114790. /**
  114791. * Add fallbacks to the effect fallbacks list.
  114792. * @param defines defines the Base texture to use.
  114793. * @param fallbacks defines the current fallback list.
  114794. * @param currentRank defines the current fallback rank.
  114795. * @returns the new fallback rank.
  114796. */
  114797. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114798. /**
  114799. * Add the required uniforms to the current list.
  114800. * @param uniforms defines the current uniform list.
  114801. */
  114802. static AddUniforms(uniforms: string[]): void;
  114803. /**
  114804. * Add the required samplers to the current list.
  114805. * @param samplers defines the current sampler list.
  114806. */
  114807. static AddSamplers(samplers: string[]): void;
  114808. /**
  114809. * Add the required uniforms to the current buffer.
  114810. * @param uniformBuffer defines the current uniform buffer.
  114811. */
  114812. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114813. /**
  114814. * Makes a duplicate of the current configuration into another one.
  114815. * @param configuration define the config where to copy the info
  114816. */
  114817. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114818. /**
  114819. * Serializes this Sub Surface configuration.
  114820. * @returns - An object with the serialized config.
  114821. */
  114822. serialize(): any;
  114823. /**
  114824. * Parses a anisotropy Configuration from a serialized object.
  114825. * @param source - Serialized object.
  114826. * @param scene Defines the scene we are parsing for
  114827. * @param rootUrl Defines the rootUrl to load from
  114828. */
  114829. parse(source: any, scene: Scene, rootUrl: string): void;
  114830. }
  114831. }
  114832. declare module BABYLON {
  114833. /** @hidden */
  114834. export var pbrFragmentDeclaration: {
  114835. name: string;
  114836. shader: string;
  114837. };
  114838. }
  114839. declare module BABYLON {
  114840. /** @hidden */
  114841. export var pbrUboDeclaration: {
  114842. name: string;
  114843. shader: string;
  114844. };
  114845. }
  114846. declare module BABYLON {
  114847. /** @hidden */
  114848. export var pbrFragmentExtraDeclaration: {
  114849. name: string;
  114850. shader: string;
  114851. };
  114852. }
  114853. declare module BABYLON {
  114854. /** @hidden */
  114855. export var pbrFragmentSamplersDeclaration: {
  114856. name: string;
  114857. shader: string;
  114858. };
  114859. }
  114860. declare module BABYLON {
  114861. /** @hidden */
  114862. export var pbrHelperFunctions: {
  114863. name: string;
  114864. shader: string;
  114865. };
  114866. }
  114867. declare module BABYLON {
  114868. /** @hidden */
  114869. export var harmonicsFunctions: {
  114870. name: string;
  114871. shader: string;
  114872. };
  114873. }
  114874. declare module BABYLON {
  114875. /** @hidden */
  114876. export var pbrDirectLightingSetupFunctions: {
  114877. name: string;
  114878. shader: string;
  114879. };
  114880. }
  114881. declare module BABYLON {
  114882. /** @hidden */
  114883. export var pbrDirectLightingFalloffFunctions: {
  114884. name: string;
  114885. shader: string;
  114886. };
  114887. }
  114888. declare module BABYLON {
  114889. /** @hidden */
  114890. export var pbrBRDFFunctions: {
  114891. name: string;
  114892. shader: string;
  114893. };
  114894. }
  114895. declare module BABYLON {
  114896. /** @hidden */
  114897. export var pbrDirectLightingFunctions: {
  114898. name: string;
  114899. shader: string;
  114900. };
  114901. }
  114902. declare module BABYLON {
  114903. /** @hidden */
  114904. export var pbrIBLFunctions: {
  114905. name: string;
  114906. shader: string;
  114907. };
  114908. }
  114909. declare module BABYLON {
  114910. /** @hidden */
  114911. export var pbrDebug: {
  114912. name: string;
  114913. shader: string;
  114914. };
  114915. }
  114916. declare module BABYLON {
  114917. /** @hidden */
  114918. export var pbrPixelShader: {
  114919. name: string;
  114920. shader: string;
  114921. };
  114922. }
  114923. declare module BABYLON {
  114924. /** @hidden */
  114925. export var pbrVertexDeclaration: {
  114926. name: string;
  114927. shader: string;
  114928. };
  114929. }
  114930. declare module BABYLON {
  114931. /** @hidden */
  114932. export var pbrVertexShader: {
  114933. name: string;
  114934. shader: string;
  114935. };
  114936. }
  114937. declare module BABYLON {
  114938. /**
  114939. * Manages the defines for the PBR Material.
  114940. * @hidden
  114941. */
  114942. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114943. PBR: boolean;
  114944. MAINUV1: boolean;
  114945. MAINUV2: boolean;
  114946. UV1: boolean;
  114947. UV2: boolean;
  114948. ALBEDO: boolean;
  114949. ALBEDODIRECTUV: number;
  114950. VERTEXCOLOR: boolean;
  114951. AMBIENT: boolean;
  114952. AMBIENTDIRECTUV: number;
  114953. AMBIENTINGRAYSCALE: boolean;
  114954. OPACITY: boolean;
  114955. VERTEXALPHA: boolean;
  114956. OPACITYDIRECTUV: number;
  114957. OPACITYRGB: boolean;
  114958. ALPHATEST: boolean;
  114959. DEPTHPREPASS: boolean;
  114960. ALPHABLEND: boolean;
  114961. ALPHAFROMALBEDO: boolean;
  114962. ALPHATESTVALUE: string;
  114963. SPECULAROVERALPHA: boolean;
  114964. RADIANCEOVERALPHA: boolean;
  114965. ALPHAFRESNEL: boolean;
  114966. LINEARALPHAFRESNEL: boolean;
  114967. PREMULTIPLYALPHA: boolean;
  114968. EMISSIVE: boolean;
  114969. EMISSIVEDIRECTUV: number;
  114970. REFLECTIVITY: boolean;
  114971. REFLECTIVITYDIRECTUV: number;
  114972. SPECULARTERM: boolean;
  114973. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114974. MICROSURFACEAUTOMATIC: boolean;
  114975. LODBASEDMICROSFURACE: boolean;
  114976. MICROSURFACEMAP: boolean;
  114977. MICROSURFACEMAPDIRECTUV: number;
  114978. METALLICWORKFLOW: boolean;
  114979. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114980. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114981. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114982. AOSTOREINMETALMAPRED: boolean;
  114983. ENVIRONMENTBRDF: boolean;
  114984. ENVIRONMENTBRDF_RGBD: boolean;
  114985. NORMAL: boolean;
  114986. TANGENT: boolean;
  114987. BUMP: boolean;
  114988. BUMPDIRECTUV: number;
  114989. OBJECTSPACE_NORMALMAP: boolean;
  114990. PARALLAX: boolean;
  114991. PARALLAXOCCLUSION: boolean;
  114992. NORMALXYSCALE: boolean;
  114993. LIGHTMAP: boolean;
  114994. LIGHTMAPDIRECTUV: number;
  114995. USELIGHTMAPASSHADOWMAP: boolean;
  114996. GAMMALIGHTMAP: boolean;
  114997. RGBDLIGHTMAP: boolean;
  114998. REFLECTION: boolean;
  114999. REFLECTIONMAP_3D: boolean;
  115000. REFLECTIONMAP_SPHERICAL: boolean;
  115001. REFLECTIONMAP_PLANAR: boolean;
  115002. REFLECTIONMAP_CUBIC: boolean;
  115003. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  115004. REFLECTIONMAP_PROJECTION: boolean;
  115005. REFLECTIONMAP_SKYBOX: boolean;
  115006. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  115007. REFLECTIONMAP_EXPLICIT: boolean;
  115008. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  115009. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  115010. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  115011. INVERTCUBICMAP: boolean;
  115012. USESPHERICALFROMREFLECTIONMAP: boolean;
  115013. USEIRRADIANCEMAP: boolean;
  115014. SPHERICAL_HARMONICS: boolean;
  115015. USESPHERICALINVERTEX: boolean;
  115016. REFLECTIONMAP_OPPOSITEZ: boolean;
  115017. LODINREFLECTIONALPHA: boolean;
  115018. GAMMAREFLECTION: boolean;
  115019. RGBDREFLECTION: boolean;
  115020. LINEARSPECULARREFLECTION: boolean;
  115021. RADIANCEOCCLUSION: boolean;
  115022. HORIZONOCCLUSION: boolean;
  115023. INSTANCES: boolean;
  115024. NUM_BONE_INFLUENCERS: number;
  115025. BonesPerMesh: number;
  115026. BONETEXTURE: boolean;
  115027. NONUNIFORMSCALING: boolean;
  115028. MORPHTARGETS: boolean;
  115029. MORPHTARGETS_NORMAL: boolean;
  115030. MORPHTARGETS_TANGENT: boolean;
  115031. MORPHTARGETS_UV: boolean;
  115032. NUM_MORPH_INFLUENCERS: number;
  115033. IMAGEPROCESSING: boolean;
  115034. VIGNETTE: boolean;
  115035. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115036. VIGNETTEBLENDMODEOPAQUE: boolean;
  115037. TONEMAPPING: boolean;
  115038. TONEMAPPING_ACES: boolean;
  115039. CONTRAST: boolean;
  115040. COLORCURVES: boolean;
  115041. COLORGRADING: boolean;
  115042. COLORGRADING3D: boolean;
  115043. SAMPLER3DGREENDEPTH: boolean;
  115044. SAMPLER3DBGRMAP: boolean;
  115045. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115046. EXPOSURE: boolean;
  115047. MULTIVIEW: boolean;
  115048. USEPHYSICALLIGHTFALLOFF: boolean;
  115049. USEGLTFLIGHTFALLOFF: boolean;
  115050. TWOSIDEDLIGHTING: boolean;
  115051. SHADOWFLOAT: boolean;
  115052. CLIPPLANE: boolean;
  115053. CLIPPLANE2: boolean;
  115054. CLIPPLANE3: boolean;
  115055. CLIPPLANE4: boolean;
  115056. POINTSIZE: boolean;
  115057. FOG: boolean;
  115058. LOGARITHMICDEPTH: boolean;
  115059. FORCENORMALFORWARD: boolean;
  115060. SPECULARAA: boolean;
  115061. CLEARCOAT: boolean;
  115062. CLEARCOAT_DEFAULTIOR: boolean;
  115063. CLEARCOAT_TEXTURE: boolean;
  115064. CLEARCOAT_TEXTUREDIRECTUV: number;
  115065. CLEARCOAT_BUMP: boolean;
  115066. CLEARCOAT_BUMPDIRECTUV: number;
  115067. CLEARCOAT_TINT: boolean;
  115068. CLEARCOAT_TINT_TEXTURE: boolean;
  115069. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115070. ANISOTROPIC: boolean;
  115071. ANISOTROPIC_TEXTURE: boolean;
  115072. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115073. BRDF_V_HEIGHT_CORRELATED: boolean;
  115074. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115075. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115076. SHEEN: boolean;
  115077. SHEEN_TEXTURE: boolean;
  115078. SHEEN_TEXTUREDIRECTUV: number;
  115079. SHEEN_LINKWITHALBEDO: boolean;
  115080. SUBSURFACE: boolean;
  115081. SS_REFRACTION: boolean;
  115082. SS_TRANSLUCENCY: boolean;
  115083. SS_SCATERRING: boolean;
  115084. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115085. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115086. SS_REFRACTIONMAP_3D: boolean;
  115087. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115088. SS_LODINREFRACTIONALPHA: boolean;
  115089. SS_GAMMAREFRACTION: boolean;
  115090. SS_RGBDREFRACTION: boolean;
  115091. SS_LINEARSPECULARREFRACTION: boolean;
  115092. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115093. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115094. UNLIT: boolean;
  115095. DEBUGMODE: number;
  115096. /**
  115097. * Initializes the PBR Material defines.
  115098. */
  115099. constructor();
  115100. /**
  115101. * Resets the PBR Material defines.
  115102. */
  115103. reset(): void;
  115104. }
  115105. /**
  115106. * The Physically based material base class of BJS.
  115107. *
  115108. * This offers the main features of a standard PBR material.
  115109. * For more information, please refer to the documentation :
  115110. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115111. */
  115112. export abstract class PBRBaseMaterial extends PushMaterial {
  115113. /**
  115114. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115115. */
  115116. static readonly PBRMATERIAL_OPAQUE: number;
  115117. /**
  115118. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115119. */
  115120. static readonly PBRMATERIAL_ALPHATEST: number;
  115121. /**
  115122. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115123. */
  115124. static readonly PBRMATERIAL_ALPHABLEND: number;
  115125. /**
  115126. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115127. * They are also discarded below the alpha cutoff threshold to improve performances.
  115128. */
  115129. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115130. /**
  115131. * Defines the default value of how much AO map is occluding the analytical lights
  115132. * (point spot...).
  115133. */
  115134. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115135. /**
  115136. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  115137. */
  115138. static readonly LIGHTFALLOFF_PHYSICAL: number;
  115139. /**
  115140. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  115141. * to enhance interoperability with other engines.
  115142. */
  115143. static readonly LIGHTFALLOFF_GLTF: number;
  115144. /**
  115145. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  115146. * to enhance interoperability with other materials.
  115147. */
  115148. static readonly LIGHTFALLOFF_STANDARD: number;
  115149. /**
  115150. * Intensity of the direct lights e.g. the four lights available in your scene.
  115151. * This impacts both the direct diffuse and specular highlights.
  115152. */
  115153. protected _directIntensity: number;
  115154. /**
  115155. * Intensity of the emissive part of the material.
  115156. * This helps controlling the emissive effect without modifying the emissive color.
  115157. */
  115158. protected _emissiveIntensity: number;
  115159. /**
  115160. * Intensity of the environment e.g. how much the environment will light the object
  115161. * either through harmonics for rough material or through the refelction for shiny ones.
  115162. */
  115163. protected _environmentIntensity: number;
  115164. /**
  115165. * This is a special control allowing the reduction of the specular highlights coming from the
  115166. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115167. */
  115168. protected _specularIntensity: number;
  115169. /**
  115170. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  115171. */
  115172. private _lightingInfos;
  115173. /**
  115174. * Debug Control allowing disabling the bump map on this material.
  115175. */
  115176. protected _disableBumpMap: boolean;
  115177. /**
  115178. * AKA Diffuse Texture in standard nomenclature.
  115179. */
  115180. protected _albedoTexture: Nullable<BaseTexture>;
  115181. /**
  115182. * AKA Occlusion Texture in other nomenclature.
  115183. */
  115184. protected _ambientTexture: Nullable<BaseTexture>;
  115185. /**
  115186. * AKA Occlusion Texture Intensity in other nomenclature.
  115187. */
  115188. protected _ambientTextureStrength: number;
  115189. /**
  115190. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115191. * 1 means it completely occludes it
  115192. * 0 mean it has no impact
  115193. */
  115194. protected _ambientTextureImpactOnAnalyticalLights: number;
  115195. /**
  115196. * Stores the alpha values in a texture.
  115197. */
  115198. protected _opacityTexture: Nullable<BaseTexture>;
  115199. /**
  115200. * Stores the reflection values in a texture.
  115201. */
  115202. protected _reflectionTexture: Nullable<BaseTexture>;
  115203. /**
  115204. * Stores the emissive values in a texture.
  115205. */
  115206. protected _emissiveTexture: Nullable<BaseTexture>;
  115207. /**
  115208. * AKA Specular texture in other nomenclature.
  115209. */
  115210. protected _reflectivityTexture: Nullable<BaseTexture>;
  115211. /**
  115212. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115213. */
  115214. protected _metallicTexture: Nullable<BaseTexture>;
  115215. /**
  115216. * Specifies the metallic scalar of the metallic/roughness workflow.
  115217. * Can also be used to scale the metalness values of the metallic texture.
  115218. */
  115219. protected _metallic: Nullable<number>;
  115220. /**
  115221. * Specifies the roughness scalar of the metallic/roughness workflow.
  115222. * Can also be used to scale the roughness values of the metallic texture.
  115223. */
  115224. protected _roughness: Nullable<number>;
  115225. /**
  115226. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115227. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115228. */
  115229. protected _microSurfaceTexture: Nullable<BaseTexture>;
  115230. /**
  115231. * Stores surface normal data used to displace a mesh in a texture.
  115232. */
  115233. protected _bumpTexture: Nullable<BaseTexture>;
  115234. /**
  115235. * Stores the pre-calculated light information of a mesh in a texture.
  115236. */
  115237. protected _lightmapTexture: Nullable<BaseTexture>;
  115238. /**
  115239. * The color of a material in ambient lighting.
  115240. */
  115241. protected _ambientColor: Color3;
  115242. /**
  115243. * AKA Diffuse Color in other nomenclature.
  115244. */
  115245. protected _albedoColor: Color3;
  115246. /**
  115247. * AKA Specular Color in other nomenclature.
  115248. */
  115249. protected _reflectivityColor: Color3;
  115250. /**
  115251. * The color applied when light is reflected from a material.
  115252. */
  115253. protected _reflectionColor: Color3;
  115254. /**
  115255. * The color applied when light is emitted from a material.
  115256. */
  115257. protected _emissiveColor: Color3;
  115258. /**
  115259. * AKA Glossiness in other nomenclature.
  115260. */
  115261. protected _microSurface: number;
  115262. /**
  115263. * Specifies that the material will use the light map as a show map.
  115264. */
  115265. protected _useLightmapAsShadowmap: boolean;
  115266. /**
  115267. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115268. * makes the reflect vector face the model (under horizon).
  115269. */
  115270. protected _useHorizonOcclusion: boolean;
  115271. /**
  115272. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115273. * too much the area relying on ambient texture to define their ambient occlusion.
  115274. */
  115275. protected _useRadianceOcclusion: boolean;
  115276. /**
  115277. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115278. */
  115279. protected _useAlphaFromAlbedoTexture: boolean;
  115280. /**
  115281. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  115282. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115283. */
  115284. protected _useSpecularOverAlpha: boolean;
  115285. /**
  115286. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115287. */
  115288. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115289. /**
  115290. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115291. */
  115292. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  115293. /**
  115294. * Specifies if the metallic texture contains the roughness information in its green channel.
  115295. */
  115296. protected _useRoughnessFromMetallicTextureGreen: boolean;
  115297. /**
  115298. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115299. */
  115300. protected _useMetallnessFromMetallicTextureBlue: boolean;
  115301. /**
  115302. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115303. */
  115304. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  115305. /**
  115306. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115307. */
  115308. protected _useAmbientInGrayScale: boolean;
  115309. /**
  115310. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115311. * The material will try to infer what glossiness each pixel should be.
  115312. */
  115313. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  115314. /**
  115315. * Defines the falloff type used in this material.
  115316. * It by default is Physical.
  115317. */
  115318. protected _lightFalloff: number;
  115319. /**
  115320. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115321. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115322. */
  115323. protected _useRadianceOverAlpha: boolean;
  115324. /**
  115325. * Allows using an object space normal map (instead of tangent space).
  115326. */
  115327. protected _useObjectSpaceNormalMap: boolean;
  115328. /**
  115329. * Allows using the bump map in parallax mode.
  115330. */
  115331. protected _useParallax: boolean;
  115332. /**
  115333. * Allows using the bump map in parallax occlusion mode.
  115334. */
  115335. protected _useParallaxOcclusion: boolean;
  115336. /**
  115337. * Controls the scale bias of the parallax mode.
  115338. */
  115339. protected _parallaxScaleBias: number;
  115340. /**
  115341. * If sets to true, disables all the lights affecting the material.
  115342. */
  115343. protected _disableLighting: boolean;
  115344. /**
  115345. * Number of Simultaneous lights allowed on the material.
  115346. */
  115347. protected _maxSimultaneousLights: number;
  115348. /**
  115349. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115350. */
  115351. protected _invertNormalMapX: boolean;
  115352. /**
  115353. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115354. */
  115355. protected _invertNormalMapY: boolean;
  115356. /**
  115357. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115358. */
  115359. protected _twoSidedLighting: boolean;
  115360. /**
  115361. * Defines the alpha limits in alpha test mode.
  115362. */
  115363. protected _alphaCutOff: number;
  115364. /**
  115365. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115366. */
  115367. protected _forceAlphaTest: boolean;
  115368. /**
  115369. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115370. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115371. */
  115372. protected _useAlphaFresnel: boolean;
  115373. /**
  115374. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115375. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115376. */
  115377. protected _useLinearAlphaFresnel: boolean;
  115378. /**
  115379. * The transparency mode of the material.
  115380. */
  115381. protected _transparencyMode: Nullable<number>;
  115382. /**
  115383. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  115384. * from cos thetav and roughness:
  115385. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  115386. */
  115387. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  115388. /**
  115389. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115390. */
  115391. protected _forceIrradianceInFragment: boolean;
  115392. /**
  115393. * Force normal to face away from face.
  115394. */
  115395. protected _forceNormalForward: boolean;
  115396. /**
  115397. * Enables specular anti aliasing in the PBR shader.
  115398. * It will both interacts on the Geometry for analytical and IBL lighting.
  115399. * It also prefilter the roughness map based on the bump values.
  115400. */
  115401. protected _enableSpecularAntiAliasing: boolean;
  115402. /**
  115403. * Default configuration related to image processing available in the PBR Material.
  115404. */
  115405. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115406. /**
  115407. * Keep track of the image processing observer to allow dispose and replace.
  115408. */
  115409. private _imageProcessingObserver;
  115410. /**
  115411. * Attaches a new image processing configuration to the PBR Material.
  115412. * @param configuration
  115413. */
  115414. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115415. /**
  115416. * Stores the available render targets.
  115417. */
  115418. private _renderTargets;
  115419. /**
  115420. * Sets the global ambient color for the material used in lighting calculations.
  115421. */
  115422. private _globalAmbientColor;
  115423. /**
  115424. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  115425. */
  115426. private _useLogarithmicDepth;
  115427. /**
  115428. * If set to true, no lighting calculations will be applied.
  115429. */
  115430. private _unlit;
  115431. private _debugMode;
  115432. /**
  115433. * @hidden
  115434. * This is reserved for the inspector.
  115435. * Defines the material debug mode.
  115436. * It helps seeing only some components of the material while troubleshooting.
  115437. */
  115438. debugMode: number;
  115439. /**
  115440. * @hidden
  115441. * This is reserved for the inspector.
  115442. * Specify from where on screen the debug mode should start.
  115443. * The value goes from -1 (full screen) to 1 (not visible)
  115444. * It helps with side by side comparison against the final render
  115445. * This defaults to -1
  115446. */
  115447. private debugLimit;
  115448. /**
  115449. * @hidden
  115450. * This is reserved for the inspector.
  115451. * As the default viewing range might not be enough (if the ambient is really small for instance)
  115452. * You can use the factor to better multiply the final value.
  115453. */
  115454. private debugFactor;
  115455. /**
  115456. * Defines the clear coat layer parameters for the material.
  115457. */
  115458. readonly clearCoat: PBRClearCoatConfiguration;
  115459. /**
  115460. * Defines the anisotropic parameters for the material.
  115461. */
  115462. readonly anisotropy: PBRAnisotropicConfiguration;
  115463. /**
  115464. * Defines the BRDF parameters for the material.
  115465. */
  115466. readonly brdf: PBRBRDFConfiguration;
  115467. /**
  115468. * Defines the Sheen parameters for the material.
  115469. */
  115470. readonly sheen: PBRSheenConfiguration;
  115471. /**
  115472. * Defines the SubSurface parameters for the material.
  115473. */
  115474. readonly subSurface: PBRSubSurfaceConfiguration;
  115475. /**
  115476. * Custom callback helping to override the default shader used in the material.
  115477. */
  115478. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  115479. protected _rebuildInParallel: boolean;
  115480. /**
  115481. * Instantiates a new PBRMaterial instance.
  115482. *
  115483. * @param name The material name
  115484. * @param scene The scene the material will be use in.
  115485. */
  115486. constructor(name: string, scene: Scene);
  115487. /**
  115488. * Gets a boolean indicating that current material needs to register RTT
  115489. */
  115490. readonly hasRenderTargetTextures: boolean;
  115491. /**
  115492. * Gets the name of the material class.
  115493. */
  115494. getClassName(): string;
  115495. /**
  115496. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115497. */
  115498. /**
  115499. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115500. */
  115501. useLogarithmicDepth: boolean;
  115502. /**
  115503. * Gets the current transparency mode.
  115504. */
  115505. /**
  115506. * Sets the transparency mode of the material.
  115507. *
  115508. * | Value | Type | Description |
  115509. * | ----- | ----------------------------------- | ----------- |
  115510. * | 0 | OPAQUE | |
  115511. * | 1 | ALPHATEST | |
  115512. * | 2 | ALPHABLEND | |
  115513. * | 3 | ALPHATESTANDBLEND | |
  115514. *
  115515. */
  115516. transparencyMode: Nullable<number>;
  115517. /**
  115518. * Returns true if alpha blending should be disabled.
  115519. */
  115520. private readonly _disableAlphaBlending;
  115521. /**
  115522. * Specifies whether or not this material should be rendered in alpha blend mode.
  115523. */
  115524. needAlphaBlending(): boolean;
  115525. /**
  115526. * Specifies if the mesh will require alpha blending.
  115527. * @param mesh - BJS mesh.
  115528. */
  115529. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  115530. /**
  115531. * Specifies whether or not this material should be rendered in alpha test mode.
  115532. */
  115533. needAlphaTesting(): boolean;
  115534. /**
  115535. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  115536. */
  115537. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  115538. /**
  115539. * Gets the texture used for the alpha test.
  115540. */
  115541. getAlphaTestTexture(): Nullable<BaseTexture>;
  115542. /**
  115543. * Specifies that the submesh is ready to be used.
  115544. * @param mesh - BJS mesh.
  115545. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  115546. * @param useInstances - Specifies that instances should be used.
  115547. * @returns - boolean indicating that the submesh is ready or not.
  115548. */
  115549. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115550. /**
  115551. * Specifies if the material uses metallic roughness workflow.
  115552. * @returns boolean specifiying if the material uses metallic roughness workflow.
  115553. */
  115554. isMetallicWorkflow(): boolean;
  115555. private _prepareEffect;
  115556. private _prepareDefines;
  115557. /**
  115558. * Force shader compilation
  115559. */
  115560. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  115561. /**
  115562. * Initializes the uniform buffer layout for the shader.
  115563. */
  115564. buildUniformLayout(): void;
  115565. /**
  115566. * Unbinds the material from the mesh
  115567. */
  115568. unbind(): void;
  115569. /**
  115570. * Binds the submesh data.
  115571. * @param world - The world matrix.
  115572. * @param mesh - The BJS mesh.
  115573. * @param subMesh - A submesh of the BJS mesh.
  115574. */
  115575. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115576. /**
  115577. * Returns the animatable textures.
  115578. * @returns - Array of animatable textures.
  115579. */
  115580. getAnimatables(): IAnimatable[];
  115581. /**
  115582. * Returns the texture used for reflections.
  115583. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  115584. */
  115585. private _getReflectionTexture;
  115586. /**
  115587. * Returns an array of the actively used textures.
  115588. * @returns - Array of BaseTextures
  115589. */
  115590. getActiveTextures(): BaseTexture[];
  115591. /**
  115592. * Checks to see if a texture is used in the material.
  115593. * @param texture - Base texture to use.
  115594. * @returns - Boolean specifying if a texture is used in the material.
  115595. */
  115596. hasTexture(texture: BaseTexture): boolean;
  115597. /**
  115598. * Disposes the resources of the material.
  115599. * @param forceDisposeEffect - Forces the disposal of effects.
  115600. * @param forceDisposeTextures - Forces the disposal of all textures.
  115601. */
  115602. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115603. }
  115604. }
  115605. declare module BABYLON {
  115606. /**
  115607. * The Physically based material of BJS.
  115608. *
  115609. * This offers the main features of a standard PBR material.
  115610. * For more information, please refer to the documentation :
  115611. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115612. */
  115613. export class PBRMaterial extends PBRBaseMaterial {
  115614. /**
  115615. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115616. */
  115617. static readonly PBRMATERIAL_OPAQUE: number;
  115618. /**
  115619. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115620. */
  115621. static readonly PBRMATERIAL_ALPHATEST: number;
  115622. /**
  115623. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115624. */
  115625. static readonly PBRMATERIAL_ALPHABLEND: number;
  115626. /**
  115627. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115628. * They are also discarded below the alpha cutoff threshold to improve performances.
  115629. */
  115630. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115631. /**
  115632. * Defines the default value of how much AO map is occluding the analytical lights
  115633. * (point spot...).
  115634. */
  115635. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115636. /**
  115637. * Intensity of the direct lights e.g. the four lights available in your scene.
  115638. * This impacts both the direct diffuse and specular highlights.
  115639. */
  115640. directIntensity: number;
  115641. /**
  115642. * Intensity of the emissive part of the material.
  115643. * This helps controlling the emissive effect without modifying the emissive color.
  115644. */
  115645. emissiveIntensity: number;
  115646. /**
  115647. * Intensity of the environment e.g. how much the environment will light the object
  115648. * either through harmonics for rough material or through the refelction for shiny ones.
  115649. */
  115650. environmentIntensity: number;
  115651. /**
  115652. * This is a special control allowing the reduction of the specular highlights coming from the
  115653. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115654. */
  115655. specularIntensity: number;
  115656. /**
  115657. * Debug Control allowing disabling the bump map on this material.
  115658. */
  115659. disableBumpMap: boolean;
  115660. /**
  115661. * AKA Diffuse Texture in standard nomenclature.
  115662. */
  115663. albedoTexture: BaseTexture;
  115664. /**
  115665. * AKA Occlusion Texture in other nomenclature.
  115666. */
  115667. ambientTexture: BaseTexture;
  115668. /**
  115669. * AKA Occlusion Texture Intensity in other nomenclature.
  115670. */
  115671. ambientTextureStrength: number;
  115672. /**
  115673. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115674. * 1 means it completely occludes it
  115675. * 0 mean it has no impact
  115676. */
  115677. ambientTextureImpactOnAnalyticalLights: number;
  115678. /**
  115679. * Stores the alpha values in a texture.
  115680. */
  115681. opacityTexture: BaseTexture;
  115682. /**
  115683. * Stores the reflection values in a texture.
  115684. */
  115685. reflectionTexture: Nullable<BaseTexture>;
  115686. /**
  115687. * Stores the emissive values in a texture.
  115688. */
  115689. emissiveTexture: BaseTexture;
  115690. /**
  115691. * AKA Specular texture in other nomenclature.
  115692. */
  115693. reflectivityTexture: BaseTexture;
  115694. /**
  115695. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115696. */
  115697. metallicTexture: BaseTexture;
  115698. /**
  115699. * Specifies the metallic scalar of the metallic/roughness workflow.
  115700. * Can also be used to scale the metalness values of the metallic texture.
  115701. */
  115702. metallic: Nullable<number>;
  115703. /**
  115704. * Specifies the roughness scalar of the metallic/roughness workflow.
  115705. * Can also be used to scale the roughness values of the metallic texture.
  115706. */
  115707. roughness: Nullable<number>;
  115708. /**
  115709. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115710. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115711. */
  115712. microSurfaceTexture: BaseTexture;
  115713. /**
  115714. * Stores surface normal data used to displace a mesh in a texture.
  115715. */
  115716. bumpTexture: BaseTexture;
  115717. /**
  115718. * Stores the pre-calculated light information of a mesh in a texture.
  115719. */
  115720. lightmapTexture: BaseTexture;
  115721. /**
  115722. * Stores the refracted light information in a texture.
  115723. */
  115724. refractionTexture: Nullable<BaseTexture>;
  115725. /**
  115726. * The color of a material in ambient lighting.
  115727. */
  115728. ambientColor: Color3;
  115729. /**
  115730. * AKA Diffuse Color in other nomenclature.
  115731. */
  115732. albedoColor: Color3;
  115733. /**
  115734. * AKA Specular Color in other nomenclature.
  115735. */
  115736. reflectivityColor: Color3;
  115737. /**
  115738. * The color reflected from the material.
  115739. */
  115740. reflectionColor: Color3;
  115741. /**
  115742. * The color emitted from the material.
  115743. */
  115744. emissiveColor: Color3;
  115745. /**
  115746. * AKA Glossiness in other nomenclature.
  115747. */
  115748. microSurface: number;
  115749. /**
  115750. * source material index of refraction (IOR)' / 'destination material IOR.
  115751. */
  115752. indexOfRefraction: number;
  115753. /**
  115754. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115755. */
  115756. invertRefractionY: boolean;
  115757. /**
  115758. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115759. * Materials half opaque for instance using refraction could benefit from this control.
  115760. */
  115761. linkRefractionWithTransparency: boolean;
  115762. /**
  115763. * If true, the light map contains occlusion information instead of lighting info.
  115764. */
  115765. useLightmapAsShadowmap: boolean;
  115766. /**
  115767. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115768. */
  115769. useAlphaFromAlbedoTexture: boolean;
  115770. /**
  115771. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115772. */
  115773. forceAlphaTest: boolean;
  115774. /**
  115775. * Defines the alpha limits in alpha test mode.
  115776. */
  115777. alphaCutOff: number;
  115778. /**
  115779. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115780. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115781. */
  115782. useSpecularOverAlpha: boolean;
  115783. /**
  115784. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115785. */
  115786. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115787. /**
  115788. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115789. */
  115790. useRoughnessFromMetallicTextureAlpha: boolean;
  115791. /**
  115792. * Specifies if the metallic texture contains the roughness information in its green channel.
  115793. */
  115794. useRoughnessFromMetallicTextureGreen: boolean;
  115795. /**
  115796. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115797. */
  115798. useMetallnessFromMetallicTextureBlue: boolean;
  115799. /**
  115800. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115801. */
  115802. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115803. /**
  115804. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115805. */
  115806. useAmbientInGrayScale: boolean;
  115807. /**
  115808. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115809. * The material will try to infer what glossiness each pixel should be.
  115810. */
  115811. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115812. /**
  115813. * BJS is using an harcoded light falloff based on a manually sets up range.
  115814. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115815. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115816. */
  115817. /**
  115818. * BJS is using an harcoded light falloff based on a manually sets up range.
  115819. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115820. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115821. */
  115822. usePhysicalLightFalloff: boolean;
  115823. /**
  115824. * In order to support the falloff compatibility with gltf, a special mode has been added
  115825. * to reproduce the gltf light falloff.
  115826. */
  115827. /**
  115828. * In order to support the falloff compatibility with gltf, a special mode has been added
  115829. * to reproduce the gltf light falloff.
  115830. */
  115831. useGLTFLightFalloff: boolean;
  115832. /**
  115833. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115834. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115835. */
  115836. useRadianceOverAlpha: boolean;
  115837. /**
  115838. * Allows using an object space normal map (instead of tangent space).
  115839. */
  115840. useObjectSpaceNormalMap: boolean;
  115841. /**
  115842. * Allows using the bump map in parallax mode.
  115843. */
  115844. useParallax: boolean;
  115845. /**
  115846. * Allows using the bump map in parallax occlusion mode.
  115847. */
  115848. useParallaxOcclusion: boolean;
  115849. /**
  115850. * Controls the scale bias of the parallax mode.
  115851. */
  115852. parallaxScaleBias: number;
  115853. /**
  115854. * If sets to true, disables all the lights affecting the material.
  115855. */
  115856. disableLighting: boolean;
  115857. /**
  115858. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115859. */
  115860. forceIrradianceInFragment: boolean;
  115861. /**
  115862. * Number of Simultaneous lights allowed on the material.
  115863. */
  115864. maxSimultaneousLights: number;
  115865. /**
  115866. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115867. */
  115868. invertNormalMapX: boolean;
  115869. /**
  115870. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115871. */
  115872. invertNormalMapY: boolean;
  115873. /**
  115874. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115875. */
  115876. twoSidedLighting: boolean;
  115877. /**
  115878. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115879. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115880. */
  115881. useAlphaFresnel: boolean;
  115882. /**
  115883. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115884. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115885. */
  115886. useLinearAlphaFresnel: boolean;
  115887. /**
  115888. * Let user defines the brdf lookup texture used for IBL.
  115889. * A default 8bit version is embedded but you could point at :
  115890. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115891. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115892. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115893. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115894. */
  115895. environmentBRDFTexture: Nullable<BaseTexture>;
  115896. /**
  115897. * Force normal to face away from face.
  115898. */
  115899. forceNormalForward: boolean;
  115900. /**
  115901. * Enables specular anti aliasing in the PBR shader.
  115902. * It will both interacts on the Geometry for analytical and IBL lighting.
  115903. * It also prefilter the roughness map based on the bump values.
  115904. */
  115905. enableSpecularAntiAliasing: boolean;
  115906. /**
  115907. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115908. * makes the reflect vector face the model (under horizon).
  115909. */
  115910. useHorizonOcclusion: boolean;
  115911. /**
  115912. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115913. * too much the area relying on ambient texture to define their ambient occlusion.
  115914. */
  115915. useRadianceOcclusion: boolean;
  115916. /**
  115917. * If set to true, no lighting calculations will be applied.
  115918. */
  115919. unlit: boolean;
  115920. /**
  115921. * Gets the image processing configuration used either in this material.
  115922. */
  115923. /**
  115924. * Sets the Default image processing configuration used either in the this material.
  115925. *
  115926. * If sets to null, the scene one is in use.
  115927. */
  115928. imageProcessingConfiguration: ImageProcessingConfiguration;
  115929. /**
  115930. * Gets wether the color curves effect is enabled.
  115931. */
  115932. /**
  115933. * Sets wether the color curves effect is enabled.
  115934. */
  115935. cameraColorCurvesEnabled: boolean;
  115936. /**
  115937. * Gets wether the color grading effect is enabled.
  115938. */
  115939. /**
  115940. * Gets wether the color grading effect is enabled.
  115941. */
  115942. cameraColorGradingEnabled: boolean;
  115943. /**
  115944. * Gets wether tonemapping is enabled or not.
  115945. */
  115946. /**
  115947. * Sets wether tonemapping is enabled or not
  115948. */
  115949. cameraToneMappingEnabled: boolean;
  115950. /**
  115951. * The camera exposure used on this material.
  115952. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115953. * This corresponds to a photographic exposure.
  115954. */
  115955. /**
  115956. * The camera exposure used on this material.
  115957. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115958. * This corresponds to a photographic exposure.
  115959. */
  115960. cameraExposure: number;
  115961. /**
  115962. * Gets The camera contrast used on this material.
  115963. */
  115964. /**
  115965. * Sets The camera contrast used on this material.
  115966. */
  115967. cameraContrast: number;
  115968. /**
  115969. * Gets the Color Grading 2D Lookup Texture.
  115970. */
  115971. /**
  115972. * Sets the Color Grading 2D Lookup Texture.
  115973. */
  115974. cameraColorGradingTexture: Nullable<BaseTexture>;
  115975. /**
  115976. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115977. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115978. * 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;
  115979. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115980. */
  115981. /**
  115982. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115983. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115984. * 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;
  115985. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115986. */
  115987. cameraColorCurves: Nullable<ColorCurves>;
  115988. /**
  115989. * Instantiates a new PBRMaterial instance.
  115990. *
  115991. * @param name The material name
  115992. * @param scene The scene the material will be use in.
  115993. */
  115994. constructor(name: string, scene: Scene);
  115995. /**
  115996. * Returns the name of this material class.
  115997. */
  115998. getClassName(): string;
  115999. /**
  116000. * Makes a duplicate of the current material.
  116001. * @param name - name to use for the new material.
  116002. */
  116003. clone(name: string): PBRMaterial;
  116004. /**
  116005. * Serializes this PBR Material.
  116006. * @returns - An object with the serialized material.
  116007. */
  116008. serialize(): any;
  116009. /**
  116010. * Parses a PBR Material from a serialized object.
  116011. * @param source - Serialized object.
  116012. * @param scene - BJS scene instance.
  116013. * @param rootUrl - url for the scene object
  116014. * @returns - PBRMaterial
  116015. */
  116016. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  116017. }
  116018. }
  116019. declare module BABYLON {
  116020. /**
  116021. * Direct draw surface info
  116022. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  116023. */
  116024. export interface DDSInfo {
  116025. /**
  116026. * Width of the texture
  116027. */
  116028. width: number;
  116029. /**
  116030. * Width of the texture
  116031. */
  116032. height: number;
  116033. /**
  116034. * Number of Mipmaps for the texture
  116035. * @see https://en.wikipedia.org/wiki/Mipmap
  116036. */
  116037. mipmapCount: number;
  116038. /**
  116039. * If the textures format is a known fourCC format
  116040. * @see https://www.fourcc.org/
  116041. */
  116042. isFourCC: boolean;
  116043. /**
  116044. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  116045. */
  116046. isRGB: boolean;
  116047. /**
  116048. * If the texture is a lumincance format
  116049. */
  116050. isLuminance: boolean;
  116051. /**
  116052. * If this is a cube texture
  116053. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  116054. */
  116055. isCube: boolean;
  116056. /**
  116057. * If the texture is a compressed format eg. FOURCC_DXT1
  116058. */
  116059. isCompressed: boolean;
  116060. /**
  116061. * The dxgiFormat of the texture
  116062. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  116063. */
  116064. dxgiFormat: number;
  116065. /**
  116066. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  116067. */
  116068. textureType: number;
  116069. /**
  116070. * Sphericle polynomial created for the dds texture
  116071. */
  116072. sphericalPolynomial?: SphericalPolynomial;
  116073. }
  116074. /**
  116075. * Class used to provide DDS decompression tools
  116076. */
  116077. export class DDSTools {
  116078. /**
  116079. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  116080. */
  116081. static StoreLODInAlphaChannel: boolean;
  116082. /**
  116083. * Gets DDS information from an array buffer
  116084. * @param arrayBuffer defines the array buffer to read data from
  116085. * @returns the DDS information
  116086. */
  116087. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  116088. private static _FloatView;
  116089. private static _Int32View;
  116090. private static _ToHalfFloat;
  116091. private static _FromHalfFloat;
  116092. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  116093. private static _GetHalfFloatRGBAArrayBuffer;
  116094. private static _GetFloatRGBAArrayBuffer;
  116095. private static _GetFloatAsUIntRGBAArrayBuffer;
  116096. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  116097. private static _GetRGBAArrayBuffer;
  116098. private static _ExtractLongWordOrder;
  116099. private static _GetRGBArrayBuffer;
  116100. private static _GetLuminanceArrayBuffer;
  116101. /**
  116102. * Uploads DDS Levels to a Babylon Texture
  116103. * @hidden
  116104. */
  116105. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  116106. }
  116107. interface ThinEngine {
  116108. /**
  116109. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  116110. * @param rootUrl defines the url where the file to load is located
  116111. * @param scene defines the current scene
  116112. * @param lodScale defines scale to apply to the mip map selection
  116113. * @param lodOffset defines offset to apply to the mip map selection
  116114. * @param onLoad defines an optional callback raised when the texture is loaded
  116115. * @param onError defines an optional callback raised if there is an issue to load the texture
  116116. * @param format defines the format of the data
  116117. * @param forcedExtension defines the extension to use to pick the right loader
  116118. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  116119. * @returns the cube texture as an InternalTexture
  116120. */
  116121. 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;
  116122. }
  116123. }
  116124. declare module BABYLON {
  116125. /**
  116126. * Implementation of the DDS Texture Loader.
  116127. * @hidden
  116128. */
  116129. export class _DDSTextureLoader implements IInternalTextureLoader {
  116130. /**
  116131. * Defines wether the loader supports cascade loading the different faces.
  116132. */
  116133. readonly supportCascades: boolean;
  116134. /**
  116135. * This returns if the loader support the current file information.
  116136. * @param extension defines the file extension of the file being loaded
  116137. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116138. * @param fallback defines the fallback internal texture if any
  116139. * @param isBase64 defines whether the texture is encoded as a base64
  116140. * @param isBuffer defines whether the texture data are stored as a buffer
  116141. * @returns true if the loader can load the specified file
  116142. */
  116143. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116144. /**
  116145. * Transform the url before loading if required.
  116146. * @param rootUrl the url of the texture
  116147. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116148. * @returns the transformed texture
  116149. */
  116150. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116151. /**
  116152. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116153. * @param rootUrl the url of the texture
  116154. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116155. * @returns the fallback texture
  116156. */
  116157. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116158. /**
  116159. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116160. * @param data contains the texture data
  116161. * @param texture defines the BabylonJS internal texture
  116162. * @param createPolynomials will be true if polynomials have been requested
  116163. * @param onLoad defines the callback to trigger once the texture is ready
  116164. * @param onError defines the callback to trigger in case of error
  116165. */
  116166. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116167. /**
  116168. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116169. * @param data contains the texture data
  116170. * @param texture defines the BabylonJS internal texture
  116171. * @param callback defines the method to call once ready to upload
  116172. */
  116173. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116174. }
  116175. }
  116176. declare module BABYLON {
  116177. /**
  116178. * Implementation of the ENV Texture Loader.
  116179. * @hidden
  116180. */
  116181. export class _ENVTextureLoader implements IInternalTextureLoader {
  116182. /**
  116183. * Defines wether the loader supports cascade loading the different faces.
  116184. */
  116185. readonly supportCascades: boolean;
  116186. /**
  116187. * This returns if the loader support the current file information.
  116188. * @param extension defines the file extension of the file being loaded
  116189. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116190. * @param fallback defines the fallback internal texture if any
  116191. * @param isBase64 defines whether the texture is encoded as a base64
  116192. * @param isBuffer defines whether the texture data are stored as a buffer
  116193. * @returns true if the loader can load the specified file
  116194. */
  116195. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116196. /**
  116197. * Transform the url before loading if required.
  116198. * @param rootUrl the url of the texture
  116199. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116200. * @returns the transformed texture
  116201. */
  116202. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116203. /**
  116204. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116205. * @param rootUrl the url of the texture
  116206. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116207. * @returns the fallback texture
  116208. */
  116209. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116210. /**
  116211. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116212. * @param data contains the texture data
  116213. * @param texture defines the BabylonJS internal texture
  116214. * @param createPolynomials will be true if polynomials have been requested
  116215. * @param onLoad defines the callback to trigger once the texture is ready
  116216. * @param onError defines the callback to trigger in case of error
  116217. */
  116218. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116219. /**
  116220. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116221. * @param data contains the texture data
  116222. * @param texture defines the BabylonJS internal texture
  116223. * @param callback defines the method to call once ready to upload
  116224. */
  116225. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116226. }
  116227. }
  116228. declare module BABYLON {
  116229. /**
  116230. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  116231. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  116232. */
  116233. export class KhronosTextureContainer {
  116234. /** contents of the KTX container file */
  116235. arrayBuffer: any;
  116236. private static HEADER_LEN;
  116237. private static COMPRESSED_2D;
  116238. private static COMPRESSED_3D;
  116239. private static TEX_2D;
  116240. private static TEX_3D;
  116241. /**
  116242. * Gets the openGL type
  116243. */
  116244. glType: number;
  116245. /**
  116246. * Gets the openGL type size
  116247. */
  116248. glTypeSize: number;
  116249. /**
  116250. * Gets the openGL format
  116251. */
  116252. glFormat: number;
  116253. /**
  116254. * Gets the openGL internal format
  116255. */
  116256. glInternalFormat: number;
  116257. /**
  116258. * Gets the base internal format
  116259. */
  116260. glBaseInternalFormat: number;
  116261. /**
  116262. * Gets image width in pixel
  116263. */
  116264. pixelWidth: number;
  116265. /**
  116266. * Gets image height in pixel
  116267. */
  116268. pixelHeight: number;
  116269. /**
  116270. * Gets image depth in pixels
  116271. */
  116272. pixelDepth: number;
  116273. /**
  116274. * Gets the number of array elements
  116275. */
  116276. numberOfArrayElements: number;
  116277. /**
  116278. * Gets the number of faces
  116279. */
  116280. numberOfFaces: number;
  116281. /**
  116282. * Gets the number of mipmap levels
  116283. */
  116284. numberOfMipmapLevels: number;
  116285. /**
  116286. * Gets the bytes of key value data
  116287. */
  116288. bytesOfKeyValueData: number;
  116289. /**
  116290. * Gets the load type
  116291. */
  116292. loadType: number;
  116293. /**
  116294. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  116295. */
  116296. isInvalid: boolean;
  116297. /**
  116298. * Creates a new KhronosTextureContainer
  116299. * @param arrayBuffer contents of the KTX container file
  116300. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  116301. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  116302. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  116303. */
  116304. constructor(
  116305. /** contents of the KTX container file */
  116306. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  116307. /**
  116308. * Uploads KTX content to a Babylon Texture.
  116309. * It is assumed that the texture has already been created & is currently bound
  116310. * @hidden
  116311. */
  116312. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  116313. private _upload2DCompressedLevels;
  116314. }
  116315. }
  116316. declare module BABYLON {
  116317. /**
  116318. * Implementation of the KTX Texture Loader.
  116319. * @hidden
  116320. */
  116321. export class _KTXTextureLoader implements IInternalTextureLoader {
  116322. /**
  116323. * Defines wether the loader supports cascade loading the different faces.
  116324. */
  116325. readonly supportCascades: boolean;
  116326. /**
  116327. * This returns if the loader support the current file information.
  116328. * @param extension defines the file extension of the file being loaded
  116329. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116330. * @param fallback defines the fallback internal texture if any
  116331. * @param isBase64 defines whether the texture is encoded as a base64
  116332. * @param isBuffer defines whether the texture data are stored as a buffer
  116333. * @returns true if the loader can load the specified file
  116334. */
  116335. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116336. /**
  116337. * Transform the url before loading if required.
  116338. * @param rootUrl the url of the texture
  116339. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116340. * @returns the transformed texture
  116341. */
  116342. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116343. /**
  116344. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116345. * @param rootUrl the url of the texture
  116346. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116347. * @returns the fallback texture
  116348. */
  116349. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116350. /**
  116351. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116352. * @param data contains the texture data
  116353. * @param texture defines the BabylonJS internal texture
  116354. * @param createPolynomials will be true if polynomials have been requested
  116355. * @param onLoad defines the callback to trigger once the texture is ready
  116356. * @param onError defines the callback to trigger in case of error
  116357. */
  116358. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116359. /**
  116360. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116361. * @param data contains the texture data
  116362. * @param texture defines the BabylonJS internal texture
  116363. * @param callback defines the method to call once ready to upload
  116364. */
  116365. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  116366. }
  116367. }
  116368. declare module BABYLON {
  116369. /**
  116370. * Options for the default xr helper
  116371. */
  116372. export class WebXRDefaultExperienceOptions {
  116373. /**
  116374. * Floor meshes that should be used for teleporting
  116375. */
  116376. floorMeshes: Array<AbstractMesh>;
  116377. }
  116378. /**
  116379. * Default experience which provides a similar setup to the previous webVRExperience
  116380. */
  116381. export class WebXRDefaultExperience {
  116382. /**
  116383. * Base experience
  116384. */
  116385. baseExperience: WebXRExperienceHelper;
  116386. /**
  116387. * Input experience extension
  116388. */
  116389. input: WebXRInput;
  116390. /**
  116391. * Loads the controller models
  116392. */
  116393. controllerModelLoader: WebXRControllerModelLoader;
  116394. /**
  116395. * Enables laser pointer and selection
  116396. */
  116397. pointerSelection: WebXRControllerPointerSelection;
  116398. /**
  116399. * Enables teleportation
  116400. */
  116401. teleportation: WebXRControllerTeleportation;
  116402. /**
  116403. * Enables ui for enetering/exiting xr
  116404. */
  116405. enterExitUI: WebXREnterExitUI;
  116406. /**
  116407. * Default output canvas xr should render to
  116408. */
  116409. outputCanvas: WebXRManagedOutputCanvas;
  116410. /**
  116411. * Creates the default xr experience
  116412. * @param scene scene
  116413. * @param options options for basic configuration
  116414. * @returns resulting WebXRDefaultExperience
  116415. */
  116416. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116417. private constructor();
  116418. /**
  116419. * DIsposes of the experience helper
  116420. */
  116421. dispose(): void;
  116422. }
  116423. }
  116424. declare module BABYLON {
  116425. /** @hidden */
  116426. export var _forceSceneHelpersToBundle: boolean;
  116427. interface Scene {
  116428. /**
  116429. * Creates a default light for the scene.
  116430. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  116431. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  116432. */
  116433. createDefaultLight(replace?: boolean): void;
  116434. /**
  116435. * Creates a default camera for the scene.
  116436. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  116437. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116438. * @param replace has default false, when true replaces the active camera in the scene
  116439. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  116440. */
  116441. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116442. /**
  116443. * Creates a default camera and a default light.
  116444. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  116445. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116446. * @param replace has the default false, when true replaces the active camera/light in the scene
  116447. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  116448. */
  116449. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116450. /**
  116451. * Creates a new sky box
  116452. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  116453. * @param environmentTexture defines the texture to use as environment texture
  116454. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  116455. * @param scale defines the overall scale of the skybox
  116456. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  116457. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  116458. * @returns a new mesh holding the sky box
  116459. */
  116460. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  116461. /**
  116462. * Creates a new environment
  116463. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  116464. * @param options defines the options you can use to configure the environment
  116465. * @returns the new EnvironmentHelper
  116466. */
  116467. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  116468. /**
  116469. * Creates a new VREXperienceHelper
  116470. * @see http://doc.babylonjs.com/how_to/webvr_helper
  116471. * @param webVROptions defines the options used to create the new VREXperienceHelper
  116472. * @returns a new VREXperienceHelper
  116473. */
  116474. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  116475. /**
  116476. * Creates a new WebXRDefaultExperience
  116477. * @see http://doc.babylonjs.com/how_to/webxr
  116478. * @param options experience options
  116479. * @returns a promise for a new WebXRDefaultExperience
  116480. */
  116481. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116482. }
  116483. }
  116484. declare module BABYLON {
  116485. /**
  116486. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  116487. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  116488. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  116489. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116490. */
  116491. export class VideoDome extends TransformNode {
  116492. /**
  116493. * Define the video source as a Monoscopic panoramic 360 video.
  116494. */
  116495. static readonly MODE_MONOSCOPIC: number;
  116496. /**
  116497. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116498. */
  116499. static readonly MODE_TOPBOTTOM: number;
  116500. /**
  116501. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116502. */
  116503. static readonly MODE_SIDEBYSIDE: number;
  116504. private _halfDome;
  116505. private _useDirectMapping;
  116506. /**
  116507. * The video texture being displayed on the sphere
  116508. */
  116509. protected _videoTexture: VideoTexture;
  116510. /**
  116511. * Gets the video texture being displayed on the sphere
  116512. */
  116513. readonly videoTexture: VideoTexture;
  116514. /**
  116515. * The skybox material
  116516. */
  116517. protected _material: BackgroundMaterial;
  116518. /**
  116519. * The surface used for the skybox
  116520. */
  116521. protected _mesh: Mesh;
  116522. /**
  116523. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  116524. */
  116525. private _halfDomeMask;
  116526. /**
  116527. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116528. * Also see the options.resolution property.
  116529. */
  116530. fovMultiplier: number;
  116531. private _videoMode;
  116532. /**
  116533. * Gets or set the current video mode for the video. It can be:
  116534. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  116535. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116536. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116537. */
  116538. videoMode: number;
  116539. /**
  116540. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  116541. *
  116542. */
  116543. /**
  116544. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  116545. */
  116546. halfDome: boolean;
  116547. /**
  116548. * Oberserver used in Stereoscopic VR Mode.
  116549. */
  116550. private _onBeforeCameraRenderObserver;
  116551. /**
  116552. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  116553. * @param name Element's name, child elements will append suffixes for their own names.
  116554. * @param urlsOrVideo defines the url(s) or the video element to use
  116555. * @param options An object containing optional or exposed sub element properties
  116556. */
  116557. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  116558. resolution?: number;
  116559. clickToPlay?: boolean;
  116560. autoPlay?: boolean;
  116561. loop?: boolean;
  116562. size?: number;
  116563. poster?: string;
  116564. faceForward?: boolean;
  116565. useDirectMapping?: boolean;
  116566. halfDomeMode?: boolean;
  116567. }, scene: Scene);
  116568. private _changeVideoMode;
  116569. /**
  116570. * Releases resources associated with this node.
  116571. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116572. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116573. */
  116574. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116575. }
  116576. }
  116577. declare module BABYLON {
  116578. /**
  116579. * This class can be used to get instrumentation data from a Babylon engine
  116580. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116581. */
  116582. export class EngineInstrumentation implements IDisposable {
  116583. /**
  116584. * Define the instrumented engine.
  116585. */
  116586. engine: Engine;
  116587. private _captureGPUFrameTime;
  116588. private _gpuFrameTimeToken;
  116589. private _gpuFrameTime;
  116590. private _captureShaderCompilationTime;
  116591. private _shaderCompilationTime;
  116592. private _onBeginFrameObserver;
  116593. private _onEndFrameObserver;
  116594. private _onBeforeShaderCompilationObserver;
  116595. private _onAfterShaderCompilationObserver;
  116596. /**
  116597. * Gets the perf counter used for GPU frame time
  116598. */
  116599. readonly gpuFrameTimeCounter: PerfCounter;
  116600. /**
  116601. * Gets the GPU frame time capture status
  116602. */
  116603. /**
  116604. * Enable or disable the GPU frame time capture
  116605. */
  116606. captureGPUFrameTime: boolean;
  116607. /**
  116608. * Gets the perf counter used for shader compilation time
  116609. */
  116610. readonly shaderCompilationTimeCounter: PerfCounter;
  116611. /**
  116612. * Gets the shader compilation time capture status
  116613. */
  116614. /**
  116615. * Enable or disable the shader compilation time capture
  116616. */
  116617. captureShaderCompilationTime: boolean;
  116618. /**
  116619. * Instantiates a new engine instrumentation.
  116620. * This class can be used to get instrumentation data from a Babylon engine
  116621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116622. * @param engine Defines the engine to instrument
  116623. */
  116624. constructor(
  116625. /**
  116626. * Define the instrumented engine.
  116627. */
  116628. engine: Engine);
  116629. /**
  116630. * Dispose and release associated resources.
  116631. */
  116632. dispose(): void;
  116633. }
  116634. }
  116635. declare module BABYLON {
  116636. /**
  116637. * This class can be used to get instrumentation data from a Babylon engine
  116638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116639. */
  116640. export class SceneInstrumentation implements IDisposable {
  116641. /**
  116642. * Defines the scene to instrument
  116643. */
  116644. scene: Scene;
  116645. private _captureActiveMeshesEvaluationTime;
  116646. private _activeMeshesEvaluationTime;
  116647. private _captureRenderTargetsRenderTime;
  116648. private _renderTargetsRenderTime;
  116649. private _captureFrameTime;
  116650. private _frameTime;
  116651. private _captureRenderTime;
  116652. private _renderTime;
  116653. private _captureInterFrameTime;
  116654. private _interFrameTime;
  116655. private _captureParticlesRenderTime;
  116656. private _particlesRenderTime;
  116657. private _captureSpritesRenderTime;
  116658. private _spritesRenderTime;
  116659. private _capturePhysicsTime;
  116660. private _physicsTime;
  116661. private _captureAnimationsTime;
  116662. private _animationsTime;
  116663. private _captureCameraRenderTime;
  116664. private _cameraRenderTime;
  116665. private _onBeforeActiveMeshesEvaluationObserver;
  116666. private _onAfterActiveMeshesEvaluationObserver;
  116667. private _onBeforeRenderTargetsRenderObserver;
  116668. private _onAfterRenderTargetsRenderObserver;
  116669. private _onAfterRenderObserver;
  116670. private _onBeforeDrawPhaseObserver;
  116671. private _onAfterDrawPhaseObserver;
  116672. private _onBeforeAnimationsObserver;
  116673. private _onBeforeParticlesRenderingObserver;
  116674. private _onAfterParticlesRenderingObserver;
  116675. private _onBeforeSpritesRenderingObserver;
  116676. private _onAfterSpritesRenderingObserver;
  116677. private _onBeforePhysicsObserver;
  116678. private _onAfterPhysicsObserver;
  116679. private _onAfterAnimationsObserver;
  116680. private _onBeforeCameraRenderObserver;
  116681. private _onAfterCameraRenderObserver;
  116682. /**
  116683. * Gets the perf counter used for active meshes evaluation time
  116684. */
  116685. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  116686. /**
  116687. * Gets the active meshes evaluation time capture status
  116688. */
  116689. /**
  116690. * Enable or disable the active meshes evaluation time capture
  116691. */
  116692. captureActiveMeshesEvaluationTime: boolean;
  116693. /**
  116694. * Gets the perf counter used for render targets render time
  116695. */
  116696. readonly renderTargetsRenderTimeCounter: PerfCounter;
  116697. /**
  116698. * Gets the render targets render time capture status
  116699. */
  116700. /**
  116701. * Enable or disable the render targets render time capture
  116702. */
  116703. captureRenderTargetsRenderTime: boolean;
  116704. /**
  116705. * Gets the perf counter used for particles render time
  116706. */
  116707. readonly particlesRenderTimeCounter: PerfCounter;
  116708. /**
  116709. * Gets the particles render time capture status
  116710. */
  116711. /**
  116712. * Enable or disable the particles render time capture
  116713. */
  116714. captureParticlesRenderTime: boolean;
  116715. /**
  116716. * Gets the perf counter used for sprites render time
  116717. */
  116718. readonly spritesRenderTimeCounter: PerfCounter;
  116719. /**
  116720. * Gets the sprites render time capture status
  116721. */
  116722. /**
  116723. * Enable or disable the sprites render time capture
  116724. */
  116725. captureSpritesRenderTime: boolean;
  116726. /**
  116727. * Gets the perf counter used for physics time
  116728. */
  116729. readonly physicsTimeCounter: PerfCounter;
  116730. /**
  116731. * Gets the physics time capture status
  116732. */
  116733. /**
  116734. * Enable or disable the physics time capture
  116735. */
  116736. capturePhysicsTime: boolean;
  116737. /**
  116738. * Gets the perf counter used for animations time
  116739. */
  116740. readonly animationsTimeCounter: PerfCounter;
  116741. /**
  116742. * Gets the animations time capture status
  116743. */
  116744. /**
  116745. * Enable or disable the animations time capture
  116746. */
  116747. captureAnimationsTime: boolean;
  116748. /**
  116749. * Gets the perf counter used for frame time capture
  116750. */
  116751. readonly frameTimeCounter: PerfCounter;
  116752. /**
  116753. * Gets the frame time capture status
  116754. */
  116755. /**
  116756. * Enable or disable the frame time capture
  116757. */
  116758. captureFrameTime: boolean;
  116759. /**
  116760. * Gets the perf counter used for inter-frames time capture
  116761. */
  116762. readonly interFrameTimeCounter: PerfCounter;
  116763. /**
  116764. * Gets the inter-frames time capture status
  116765. */
  116766. /**
  116767. * Enable or disable the inter-frames time capture
  116768. */
  116769. captureInterFrameTime: boolean;
  116770. /**
  116771. * Gets the perf counter used for render time capture
  116772. */
  116773. readonly renderTimeCounter: PerfCounter;
  116774. /**
  116775. * Gets the render time capture status
  116776. */
  116777. /**
  116778. * Enable or disable the render time capture
  116779. */
  116780. captureRenderTime: boolean;
  116781. /**
  116782. * Gets the perf counter used for camera render time capture
  116783. */
  116784. readonly cameraRenderTimeCounter: PerfCounter;
  116785. /**
  116786. * Gets the camera render time capture status
  116787. */
  116788. /**
  116789. * Enable or disable the camera render time capture
  116790. */
  116791. captureCameraRenderTime: boolean;
  116792. /**
  116793. * Gets the perf counter used for draw calls
  116794. */
  116795. readonly drawCallsCounter: PerfCounter;
  116796. /**
  116797. * Instantiates a new scene instrumentation.
  116798. * This class can be used to get instrumentation data from a Babylon engine
  116799. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116800. * @param scene Defines the scene to instrument
  116801. */
  116802. constructor(
  116803. /**
  116804. * Defines the scene to instrument
  116805. */
  116806. scene: Scene);
  116807. /**
  116808. * Dispose and release associated resources.
  116809. */
  116810. dispose(): void;
  116811. }
  116812. }
  116813. declare module BABYLON {
  116814. /** @hidden */
  116815. export var glowMapGenerationPixelShader: {
  116816. name: string;
  116817. shader: string;
  116818. };
  116819. }
  116820. declare module BABYLON {
  116821. /** @hidden */
  116822. export var glowMapGenerationVertexShader: {
  116823. name: string;
  116824. shader: string;
  116825. };
  116826. }
  116827. declare module BABYLON {
  116828. /**
  116829. * Effect layer options. This helps customizing the behaviour
  116830. * of the effect layer.
  116831. */
  116832. export interface IEffectLayerOptions {
  116833. /**
  116834. * Multiplication factor apply to the canvas size to compute the render target size
  116835. * used to generated the objects (the smaller the faster).
  116836. */
  116837. mainTextureRatio: number;
  116838. /**
  116839. * Enforces a fixed size texture to ensure effect stability across devices.
  116840. */
  116841. mainTextureFixedSize?: number;
  116842. /**
  116843. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116844. */
  116845. alphaBlendingMode: number;
  116846. /**
  116847. * The camera attached to the layer.
  116848. */
  116849. camera: Nullable<Camera>;
  116850. /**
  116851. * The rendering group to draw the layer in.
  116852. */
  116853. renderingGroupId: number;
  116854. }
  116855. /**
  116856. * The effect layer Helps adding post process effect blended with the main pass.
  116857. *
  116858. * This can be for instance use to generate glow or higlight effects on the scene.
  116859. *
  116860. * The effect layer class can not be used directly and is intented to inherited from to be
  116861. * customized per effects.
  116862. */
  116863. export abstract class EffectLayer {
  116864. private _vertexBuffers;
  116865. private _indexBuffer;
  116866. private _cachedDefines;
  116867. private _effectLayerMapGenerationEffect;
  116868. private _effectLayerOptions;
  116869. private _mergeEffect;
  116870. protected _scene: Scene;
  116871. protected _engine: Engine;
  116872. protected _maxSize: number;
  116873. protected _mainTextureDesiredSize: ISize;
  116874. protected _mainTexture: RenderTargetTexture;
  116875. protected _shouldRender: boolean;
  116876. protected _postProcesses: PostProcess[];
  116877. protected _textures: BaseTexture[];
  116878. protected _emissiveTextureAndColor: {
  116879. texture: Nullable<BaseTexture>;
  116880. color: Color4;
  116881. };
  116882. /**
  116883. * The name of the layer
  116884. */
  116885. name: string;
  116886. /**
  116887. * The clear color of the texture used to generate the glow map.
  116888. */
  116889. neutralColor: Color4;
  116890. /**
  116891. * Specifies wether the highlight layer is enabled or not.
  116892. */
  116893. isEnabled: boolean;
  116894. /**
  116895. * Gets the camera attached to the layer.
  116896. */
  116897. readonly camera: Nullable<Camera>;
  116898. /**
  116899. * Gets the rendering group id the layer should render in.
  116900. */
  116901. renderingGroupId: number;
  116902. /**
  116903. * An event triggered when the effect layer has been disposed.
  116904. */
  116905. onDisposeObservable: Observable<EffectLayer>;
  116906. /**
  116907. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116908. */
  116909. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116910. /**
  116911. * An event triggered when the generated texture is being merged in the scene.
  116912. */
  116913. onBeforeComposeObservable: Observable<EffectLayer>;
  116914. /**
  116915. * An event triggered when the generated texture has been merged in the scene.
  116916. */
  116917. onAfterComposeObservable: Observable<EffectLayer>;
  116918. /**
  116919. * An event triggered when the efffect layer changes its size.
  116920. */
  116921. onSizeChangedObservable: Observable<EffectLayer>;
  116922. /** @hidden */
  116923. static _SceneComponentInitialization: (scene: Scene) => void;
  116924. /**
  116925. * Instantiates a new effect Layer and references it in the scene.
  116926. * @param name The name of the layer
  116927. * @param scene The scene to use the layer in
  116928. */
  116929. constructor(
  116930. /** The Friendly of the effect in the scene */
  116931. name: string, scene: Scene);
  116932. /**
  116933. * Get the effect name of the layer.
  116934. * @return The effect name
  116935. */
  116936. abstract getEffectName(): string;
  116937. /**
  116938. * Checks for the readiness of the element composing the layer.
  116939. * @param subMesh the mesh to check for
  116940. * @param useInstances specify wether or not to use instances to render the mesh
  116941. * @return true if ready otherwise, false
  116942. */
  116943. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116944. /**
  116945. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116946. * @returns true if the effect requires stencil during the main canvas render pass.
  116947. */
  116948. abstract needStencil(): boolean;
  116949. /**
  116950. * Create the merge effect. This is the shader use to blit the information back
  116951. * to the main canvas at the end of the scene rendering.
  116952. * @returns The effect containing the shader used to merge the effect on the main canvas
  116953. */
  116954. protected abstract _createMergeEffect(): Effect;
  116955. /**
  116956. * Creates the render target textures and post processes used in the effect layer.
  116957. */
  116958. protected abstract _createTextureAndPostProcesses(): void;
  116959. /**
  116960. * Implementation specific of rendering the generating effect on the main canvas.
  116961. * @param effect The effect used to render through
  116962. */
  116963. protected abstract _internalRender(effect: Effect): void;
  116964. /**
  116965. * Sets the required values for both the emissive texture and and the main color.
  116966. */
  116967. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116968. /**
  116969. * Free any resources and references associated to a mesh.
  116970. * Internal use
  116971. * @param mesh The mesh to free.
  116972. */
  116973. abstract _disposeMesh(mesh: Mesh): void;
  116974. /**
  116975. * Serializes this layer (Glow or Highlight for example)
  116976. * @returns a serialized layer object
  116977. */
  116978. abstract serialize?(): any;
  116979. /**
  116980. * Initializes the effect layer with the required options.
  116981. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116982. */
  116983. protected _init(options: Partial<IEffectLayerOptions>): void;
  116984. /**
  116985. * Generates the index buffer of the full screen quad blending to the main canvas.
  116986. */
  116987. private _generateIndexBuffer;
  116988. /**
  116989. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116990. */
  116991. private _generateVertexBuffer;
  116992. /**
  116993. * Sets the main texture desired size which is the closest power of two
  116994. * of the engine canvas size.
  116995. */
  116996. private _setMainTextureSize;
  116997. /**
  116998. * Creates the main texture for the effect layer.
  116999. */
  117000. protected _createMainTexture(): void;
  117001. /**
  117002. * Adds specific effects defines.
  117003. * @param defines The defines to add specifics to.
  117004. */
  117005. protected _addCustomEffectDefines(defines: string[]): void;
  117006. /**
  117007. * Checks for the readiness of the element composing the layer.
  117008. * @param subMesh the mesh to check for
  117009. * @param useInstances specify wether or not to use instances to render the mesh
  117010. * @param emissiveTexture the associated emissive texture used to generate the glow
  117011. * @return true if ready otherwise, false
  117012. */
  117013. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  117014. /**
  117015. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  117016. */
  117017. render(): void;
  117018. /**
  117019. * Determine if a given mesh will be used in the current effect.
  117020. * @param mesh mesh to test
  117021. * @returns true if the mesh will be used
  117022. */
  117023. hasMesh(mesh: AbstractMesh): boolean;
  117024. /**
  117025. * Returns true if the layer contains information to display, otherwise false.
  117026. * @returns true if the glow layer should be rendered
  117027. */
  117028. shouldRender(): boolean;
  117029. /**
  117030. * Returns true if the mesh should render, otherwise false.
  117031. * @param mesh The mesh to render
  117032. * @returns true if it should render otherwise false
  117033. */
  117034. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  117035. /**
  117036. * Returns true if the mesh can be rendered, otherwise false.
  117037. * @param mesh The mesh to render
  117038. * @param material The material used on the mesh
  117039. * @returns true if it can be rendered otherwise false
  117040. */
  117041. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117042. /**
  117043. * Returns true if the mesh should render, otherwise false.
  117044. * @param mesh The mesh to render
  117045. * @returns true if it should render otherwise false
  117046. */
  117047. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  117048. /**
  117049. * Renders the submesh passed in parameter to the generation map.
  117050. */
  117051. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  117052. /**
  117053. * Rebuild the required buffers.
  117054. * @hidden Internal use only.
  117055. */
  117056. _rebuild(): void;
  117057. /**
  117058. * Dispose only the render target textures and post process.
  117059. */
  117060. private _disposeTextureAndPostProcesses;
  117061. /**
  117062. * Dispose the highlight layer and free resources.
  117063. */
  117064. dispose(): void;
  117065. /**
  117066. * Gets the class name of the effect layer
  117067. * @returns the string with the class name of the effect layer
  117068. */
  117069. getClassName(): string;
  117070. /**
  117071. * Creates an effect layer from parsed effect layer data
  117072. * @param parsedEffectLayer defines effect layer data
  117073. * @param scene defines the current scene
  117074. * @param rootUrl defines the root URL containing the effect layer information
  117075. * @returns a parsed effect Layer
  117076. */
  117077. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  117078. }
  117079. }
  117080. declare module BABYLON {
  117081. interface AbstractScene {
  117082. /**
  117083. * The list of effect layers (highlights/glow) added to the scene
  117084. * @see http://doc.babylonjs.com/how_to/highlight_layer
  117085. * @see http://doc.babylonjs.com/how_to/glow_layer
  117086. */
  117087. effectLayers: Array<EffectLayer>;
  117088. /**
  117089. * Removes the given effect layer from this scene.
  117090. * @param toRemove defines the effect layer to remove
  117091. * @returns the index of the removed effect layer
  117092. */
  117093. removeEffectLayer(toRemove: EffectLayer): number;
  117094. /**
  117095. * Adds the given effect layer to this scene
  117096. * @param newEffectLayer defines the effect layer to add
  117097. */
  117098. addEffectLayer(newEffectLayer: EffectLayer): void;
  117099. }
  117100. /**
  117101. * Defines the layer scene component responsible to manage any effect layers
  117102. * in a given scene.
  117103. */
  117104. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  117105. /**
  117106. * The component name helpfull to identify the component in the list of scene components.
  117107. */
  117108. readonly name: string;
  117109. /**
  117110. * The scene the component belongs to.
  117111. */
  117112. scene: Scene;
  117113. private _engine;
  117114. private _renderEffects;
  117115. private _needStencil;
  117116. private _previousStencilState;
  117117. /**
  117118. * Creates a new instance of the component for the given scene
  117119. * @param scene Defines the scene to register the component in
  117120. */
  117121. constructor(scene: Scene);
  117122. /**
  117123. * Registers the component in a given scene
  117124. */
  117125. register(): void;
  117126. /**
  117127. * Rebuilds the elements related to this component in case of
  117128. * context lost for instance.
  117129. */
  117130. rebuild(): void;
  117131. /**
  117132. * Serializes the component data to the specified json object
  117133. * @param serializationObject The object to serialize to
  117134. */
  117135. serialize(serializationObject: any): void;
  117136. /**
  117137. * Adds all the elements from the container to the scene
  117138. * @param container the container holding the elements
  117139. */
  117140. addFromContainer(container: AbstractScene): void;
  117141. /**
  117142. * Removes all the elements in the container from the scene
  117143. * @param container contains the elements to remove
  117144. * @param dispose if the removed element should be disposed (default: false)
  117145. */
  117146. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117147. /**
  117148. * Disposes the component and the associated ressources.
  117149. */
  117150. dispose(): void;
  117151. private _isReadyForMesh;
  117152. private _renderMainTexture;
  117153. private _setStencil;
  117154. private _setStencilBack;
  117155. private _draw;
  117156. private _drawCamera;
  117157. private _drawRenderingGroup;
  117158. }
  117159. }
  117160. declare module BABYLON {
  117161. /** @hidden */
  117162. export var glowMapMergePixelShader: {
  117163. name: string;
  117164. shader: string;
  117165. };
  117166. }
  117167. declare module BABYLON {
  117168. /** @hidden */
  117169. export var glowMapMergeVertexShader: {
  117170. name: string;
  117171. shader: string;
  117172. };
  117173. }
  117174. declare module BABYLON {
  117175. interface AbstractScene {
  117176. /**
  117177. * Return a the first highlight layer of the scene with a given name.
  117178. * @param name The name of the highlight layer to look for.
  117179. * @return The highlight layer if found otherwise null.
  117180. */
  117181. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  117182. }
  117183. /**
  117184. * Glow layer options. This helps customizing the behaviour
  117185. * of the glow layer.
  117186. */
  117187. export interface IGlowLayerOptions {
  117188. /**
  117189. * Multiplication factor apply to the canvas size to compute the render target size
  117190. * used to generated the glowing objects (the smaller the faster).
  117191. */
  117192. mainTextureRatio: number;
  117193. /**
  117194. * Enforces a fixed size texture to ensure resize independant blur.
  117195. */
  117196. mainTextureFixedSize?: number;
  117197. /**
  117198. * How big is the kernel of the blur texture.
  117199. */
  117200. blurKernelSize: number;
  117201. /**
  117202. * The camera attached to the layer.
  117203. */
  117204. camera: Nullable<Camera>;
  117205. /**
  117206. * Enable MSAA by chosing the number of samples.
  117207. */
  117208. mainTextureSamples?: number;
  117209. /**
  117210. * The rendering group to draw the layer in.
  117211. */
  117212. renderingGroupId: number;
  117213. }
  117214. /**
  117215. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  117216. *
  117217. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  117218. * glowy meshes to your scene.
  117219. *
  117220. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  117221. */
  117222. export class GlowLayer extends EffectLayer {
  117223. /**
  117224. * Effect Name of the layer.
  117225. */
  117226. static readonly EffectName: string;
  117227. /**
  117228. * The default blur kernel size used for the glow.
  117229. */
  117230. static DefaultBlurKernelSize: number;
  117231. /**
  117232. * The default texture size ratio used for the glow.
  117233. */
  117234. static DefaultTextureRatio: number;
  117235. /**
  117236. * Sets the kernel size of the blur.
  117237. */
  117238. /**
  117239. * Gets the kernel size of the blur.
  117240. */
  117241. blurKernelSize: number;
  117242. /**
  117243. * Sets the glow intensity.
  117244. */
  117245. /**
  117246. * Gets the glow intensity.
  117247. */
  117248. intensity: number;
  117249. private _options;
  117250. private _intensity;
  117251. private _horizontalBlurPostprocess1;
  117252. private _verticalBlurPostprocess1;
  117253. private _horizontalBlurPostprocess2;
  117254. private _verticalBlurPostprocess2;
  117255. private _blurTexture1;
  117256. private _blurTexture2;
  117257. private _postProcesses1;
  117258. private _postProcesses2;
  117259. private _includedOnlyMeshes;
  117260. private _excludedMeshes;
  117261. /**
  117262. * Callback used to let the user override the color selection on a per mesh basis
  117263. */
  117264. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  117265. /**
  117266. * Callback used to let the user override the texture selection on a per mesh basis
  117267. */
  117268. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  117269. /**
  117270. * Instantiates a new glow Layer and references it to the scene.
  117271. * @param name The name of the layer
  117272. * @param scene The scene to use the layer in
  117273. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  117274. */
  117275. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  117276. /**
  117277. * Get the effect name of the layer.
  117278. * @return The effect name
  117279. */
  117280. getEffectName(): string;
  117281. /**
  117282. * Create the merge effect. This is the shader use to blit the information back
  117283. * to the main canvas at the end of the scene rendering.
  117284. */
  117285. protected _createMergeEffect(): Effect;
  117286. /**
  117287. * Creates the render target textures and post processes used in the glow layer.
  117288. */
  117289. protected _createTextureAndPostProcesses(): void;
  117290. /**
  117291. * Checks for the readiness of the element composing the layer.
  117292. * @param subMesh the mesh to check for
  117293. * @param useInstances specify wether or not to use instances to render the mesh
  117294. * @param emissiveTexture the associated emissive texture used to generate the glow
  117295. * @return true if ready otherwise, false
  117296. */
  117297. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117298. /**
  117299. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117300. */
  117301. needStencil(): boolean;
  117302. /**
  117303. * Returns true if the mesh can be rendered, otherwise false.
  117304. * @param mesh The mesh to render
  117305. * @param material The material used on the mesh
  117306. * @returns true if it can be rendered otherwise false
  117307. */
  117308. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117309. /**
  117310. * Implementation specific of rendering the generating effect on the main canvas.
  117311. * @param effect The effect used to render through
  117312. */
  117313. protected _internalRender(effect: Effect): void;
  117314. /**
  117315. * Sets the required values for both the emissive texture and and the main color.
  117316. */
  117317. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117318. /**
  117319. * Returns true if the mesh should render, otherwise false.
  117320. * @param mesh The mesh to render
  117321. * @returns true if it should render otherwise false
  117322. */
  117323. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117324. /**
  117325. * Adds specific effects defines.
  117326. * @param defines The defines to add specifics to.
  117327. */
  117328. protected _addCustomEffectDefines(defines: string[]): void;
  117329. /**
  117330. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  117331. * @param mesh The mesh to exclude from the glow layer
  117332. */
  117333. addExcludedMesh(mesh: Mesh): void;
  117334. /**
  117335. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  117336. * @param mesh The mesh to remove
  117337. */
  117338. removeExcludedMesh(mesh: Mesh): void;
  117339. /**
  117340. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  117341. * @param mesh The mesh to include in the glow layer
  117342. */
  117343. addIncludedOnlyMesh(mesh: Mesh): void;
  117344. /**
  117345. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  117346. * @param mesh The mesh to remove
  117347. */
  117348. removeIncludedOnlyMesh(mesh: Mesh): void;
  117349. /**
  117350. * Determine if a given mesh will be used in the glow layer
  117351. * @param mesh The mesh to test
  117352. * @returns true if the mesh will be highlighted by the current glow layer
  117353. */
  117354. hasMesh(mesh: AbstractMesh): boolean;
  117355. /**
  117356. * Free any resources and references associated to a mesh.
  117357. * Internal use
  117358. * @param mesh The mesh to free.
  117359. * @hidden
  117360. */
  117361. _disposeMesh(mesh: Mesh): void;
  117362. /**
  117363. * Gets the class name of the effect layer
  117364. * @returns the string with the class name of the effect layer
  117365. */
  117366. getClassName(): string;
  117367. /**
  117368. * Serializes this glow layer
  117369. * @returns a serialized glow layer object
  117370. */
  117371. serialize(): any;
  117372. /**
  117373. * Creates a Glow Layer from parsed glow layer data
  117374. * @param parsedGlowLayer defines glow layer data
  117375. * @param scene defines the current scene
  117376. * @param rootUrl defines the root URL containing the glow layer information
  117377. * @returns a parsed Glow Layer
  117378. */
  117379. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  117380. }
  117381. }
  117382. declare module BABYLON {
  117383. /** @hidden */
  117384. export var glowBlurPostProcessPixelShader: {
  117385. name: string;
  117386. shader: string;
  117387. };
  117388. }
  117389. declare module BABYLON {
  117390. interface AbstractScene {
  117391. /**
  117392. * Return a the first highlight layer of the scene with a given name.
  117393. * @param name The name of the highlight layer to look for.
  117394. * @return The highlight layer if found otherwise null.
  117395. */
  117396. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  117397. }
  117398. /**
  117399. * Highlight layer options. This helps customizing the behaviour
  117400. * of the highlight layer.
  117401. */
  117402. export interface IHighlightLayerOptions {
  117403. /**
  117404. * Multiplication factor apply to the canvas size to compute the render target size
  117405. * used to generated the glowing objects (the smaller the faster).
  117406. */
  117407. mainTextureRatio: number;
  117408. /**
  117409. * Enforces a fixed size texture to ensure resize independant blur.
  117410. */
  117411. mainTextureFixedSize?: number;
  117412. /**
  117413. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  117414. * of the picture to blur (the smaller the faster).
  117415. */
  117416. blurTextureSizeRatio: number;
  117417. /**
  117418. * How big in texel of the blur texture is the vertical blur.
  117419. */
  117420. blurVerticalSize: number;
  117421. /**
  117422. * How big in texel of the blur texture is the horizontal blur.
  117423. */
  117424. blurHorizontalSize: number;
  117425. /**
  117426. * Alpha blending mode used to apply the blur. Default is combine.
  117427. */
  117428. alphaBlendingMode: number;
  117429. /**
  117430. * The camera attached to the layer.
  117431. */
  117432. camera: Nullable<Camera>;
  117433. /**
  117434. * Should we display highlight as a solid stroke?
  117435. */
  117436. isStroke?: boolean;
  117437. /**
  117438. * The rendering group to draw the layer in.
  117439. */
  117440. renderingGroupId: number;
  117441. }
  117442. /**
  117443. * The highlight layer Helps adding a glow effect around a mesh.
  117444. *
  117445. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  117446. * glowy meshes to your scene.
  117447. *
  117448. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  117449. */
  117450. export class HighlightLayer extends EffectLayer {
  117451. name: string;
  117452. /**
  117453. * Effect Name of the highlight layer.
  117454. */
  117455. static readonly EffectName: string;
  117456. /**
  117457. * The neutral color used during the preparation of the glow effect.
  117458. * This is black by default as the blend operation is a blend operation.
  117459. */
  117460. static NeutralColor: Color4;
  117461. /**
  117462. * Stencil value used for glowing meshes.
  117463. */
  117464. static GlowingMeshStencilReference: number;
  117465. /**
  117466. * Stencil value used for the other meshes in the scene.
  117467. */
  117468. static NormalMeshStencilReference: number;
  117469. /**
  117470. * Specifies whether or not the inner glow is ACTIVE in the layer.
  117471. */
  117472. innerGlow: boolean;
  117473. /**
  117474. * Specifies whether or not the outer glow is ACTIVE in the layer.
  117475. */
  117476. outerGlow: boolean;
  117477. /**
  117478. * Specifies the horizontal size of the blur.
  117479. */
  117480. /**
  117481. * Gets the horizontal size of the blur.
  117482. */
  117483. blurHorizontalSize: number;
  117484. /**
  117485. * Specifies the vertical size of the blur.
  117486. */
  117487. /**
  117488. * Gets the vertical size of the blur.
  117489. */
  117490. blurVerticalSize: number;
  117491. /**
  117492. * An event triggered when the highlight layer is being blurred.
  117493. */
  117494. onBeforeBlurObservable: Observable<HighlightLayer>;
  117495. /**
  117496. * An event triggered when the highlight layer has been blurred.
  117497. */
  117498. onAfterBlurObservable: Observable<HighlightLayer>;
  117499. private _instanceGlowingMeshStencilReference;
  117500. private _options;
  117501. private _downSamplePostprocess;
  117502. private _horizontalBlurPostprocess;
  117503. private _verticalBlurPostprocess;
  117504. private _blurTexture;
  117505. private _meshes;
  117506. private _excludedMeshes;
  117507. /**
  117508. * Instantiates a new highlight Layer and references it to the scene..
  117509. * @param name The name of the layer
  117510. * @param scene The scene to use the layer in
  117511. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  117512. */
  117513. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  117514. /**
  117515. * Get the effect name of the layer.
  117516. * @return The effect name
  117517. */
  117518. getEffectName(): string;
  117519. /**
  117520. * Create the merge effect. This is the shader use to blit the information back
  117521. * to the main canvas at the end of the scene rendering.
  117522. */
  117523. protected _createMergeEffect(): Effect;
  117524. /**
  117525. * Creates the render target textures and post processes used in the highlight layer.
  117526. */
  117527. protected _createTextureAndPostProcesses(): void;
  117528. /**
  117529. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117530. */
  117531. needStencil(): boolean;
  117532. /**
  117533. * Checks for the readiness of the element composing the layer.
  117534. * @param subMesh the mesh to check for
  117535. * @param useInstances specify wether or not to use instances to render the mesh
  117536. * @param emissiveTexture the associated emissive texture used to generate the glow
  117537. * @return true if ready otherwise, false
  117538. */
  117539. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117540. /**
  117541. * Implementation specific of rendering the generating effect on the main canvas.
  117542. * @param effect The effect used to render through
  117543. */
  117544. protected _internalRender(effect: Effect): void;
  117545. /**
  117546. * Returns true if the layer contains information to display, otherwise false.
  117547. */
  117548. shouldRender(): boolean;
  117549. /**
  117550. * Returns true if the mesh should render, otherwise false.
  117551. * @param mesh The mesh to render
  117552. * @returns true if it should render otherwise false
  117553. */
  117554. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117555. /**
  117556. * Sets the required values for both the emissive texture and and the main color.
  117557. */
  117558. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117559. /**
  117560. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  117561. * @param mesh The mesh to exclude from the highlight layer
  117562. */
  117563. addExcludedMesh(mesh: Mesh): void;
  117564. /**
  117565. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  117566. * @param mesh The mesh to highlight
  117567. */
  117568. removeExcludedMesh(mesh: Mesh): void;
  117569. /**
  117570. * Determine if a given mesh will be highlighted by the current HighlightLayer
  117571. * @param mesh mesh to test
  117572. * @returns true if the mesh will be highlighted by the current HighlightLayer
  117573. */
  117574. hasMesh(mesh: AbstractMesh): boolean;
  117575. /**
  117576. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  117577. * @param mesh The mesh to highlight
  117578. * @param color The color of the highlight
  117579. * @param glowEmissiveOnly Extract the glow from the emissive texture
  117580. */
  117581. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  117582. /**
  117583. * Remove a mesh from the highlight layer in order to make it stop glowing.
  117584. * @param mesh The mesh to highlight
  117585. */
  117586. removeMesh(mesh: Mesh): void;
  117587. /**
  117588. * Force the stencil to the normal expected value for none glowing parts
  117589. */
  117590. private _defaultStencilReference;
  117591. /**
  117592. * Free any resources and references associated to a mesh.
  117593. * Internal use
  117594. * @param mesh The mesh to free.
  117595. * @hidden
  117596. */
  117597. _disposeMesh(mesh: Mesh): void;
  117598. /**
  117599. * Dispose the highlight layer and free resources.
  117600. */
  117601. dispose(): void;
  117602. /**
  117603. * Gets the class name of the effect layer
  117604. * @returns the string with the class name of the effect layer
  117605. */
  117606. getClassName(): string;
  117607. /**
  117608. * Serializes this Highlight layer
  117609. * @returns a serialized Highlight layer object
  117610. */
  117611. serialize(): any;
  117612. /**
  117613. * Creates a Highlight layer from parsed Highlight layer data
  117614. * @param parsedHightlightLayer defines the Highlight layer data
  117615. * @param scene defines the current scene
  117616. * @param rootUrl defines the root URL containing the Highlight layer information
  117617. * @returns a parsed Highlight layer
  117618. */
  117619. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  117620. }
  117621. }
  117622. declare module BABYLON {
  117623. interface AbstractScene {
  117624. /**
  117625. * The list of layers (background and foreground) of the scene
  117626. */
  117627. layers: Array<Layer>;
  117628. }
  117629. /**
  117630. * Defines the layer scene component responsible to manage any layers
  117631. * in a given scene.
  117632. */
  117633. export class LayerSceneComponent implements ISceneComponent {
  117634. /**
  117635. * The component name helpfull to identify the component in the list of scene components.
  117636. */
  117637. readonly name: string;
  117638. /**
  117639. * The scene the component belongs to.
  117640. */
  117641. scene: Scene;
  117642. private _engine;
  117643. /**
  117644. * Creates a new instance of the component for the given scene
  117645. * @param scene Defines the scene to register the component in
  117646. */
  117647. constructor(scene: Scene);
  117648. /**
  117649. * Registers the component in a given scene
  117650. */
  117651. register(): void;
  117652. /**
  117653. * Rebuilds the elements related to this component in case of
  117654. * context lost for instance.
  117655. */
  117656. rebuild(): void;
  117657. /**
  117658. * Disposes the component and the associated ressources.
  117659. */
  117660. dispose(): void;
  117661. private _draw;
  117662. private _drawCameraPredicate;
  117663. private _drawCameraBackground;
  117664. private _drawCameraForeground;
  117665. private _drawRenderTargetPredicate;
  117666. private _drawRenderTargetBackground;
  117667. private _drawRenderTargetForeground;
  117668. /**
  117669. * Adds all the elements from the container to the scene
  117670. * @param container the container holding the elements
  117671. */
  117672. addFromContainer(container: AbstractScene): void;
  117673. /**
  117674. * Removes all the elements in the container from the scene
  117675. * @param container contains the elements to remove
  117676. * @param dispose if the removed element should be disposed (default: false)
  117677. */
  117678. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117679. }
  117680. }
  117681. declare module BABYLON {
  117682. /** @hidden */
  117683. export var layerPixelShader: {
  117684. name: string;
  117685. shader: string;
  117686. };
  117687. }
  117688. declare module BABYLON {
  117689. /** @hidden */
  117690. export var layerVertexShader: {
  117691. name: string;
  117692. shader: string;
  117693. };
  117694. }
  117695. declare module BABYLON {
  117696. /**
  117697. * This represents a full screen 2d layer.
  117698. * This can be useful to display a picture in the background of your scene for instance.
  117699. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117700. */
  117701. export class Layer {
  117702. /**
  117703. * Define the name of the layer.
  117704. */
  117705. name: string;
  117706. /**
  117707. * Define the texture the layer should display.
  117708. */
  117709. texture: Nullable<Texture>;
  117710. /**
  117711. * Is the layer in background or foreground.
  117712. */
  117713. isBackground: boolean;
  117714. /**
  117715. * Define the color of the layer (instead of texture).
  117716. */
  117717. color: Color4;
  117718. /**
  117719. * Define the scale of the layer in order to zoom in out of the texture.
  117720. */
  117721. scale: Vector2;
  117722. /**
  117723. * Define an offset for the layer in order to shift the texture.
  117724. */
  117725. offset: Vector2;
  117726. /**
  117727. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  117728. */
  117729. alphaBlendingMode: number;
  117730. /**
  117731. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  117732. * Alpha test will not mix with the background color in case of transparency.
  117733. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  117734. */
  117735. alphaTest: boolean;
  117736. /**
  117737. * Define a mask to restrict the layer to only some of the scene cameras.
  117738. */
  117739. layerMask: number;
  117740. /**
  117741. * Define the list of render target the layer is visible into.
  117742. */
  117743. renderTargetTextures: RenderTargetTexture[];
  117744. /**
  117745. * Define if the layer is only used in renderTarget or if it also
  117746. * renders in the main frame buffer of the canvas.
  117747. */
  117748. renderOnlyInRenderTargetTextures: boolean;
  117749. private _scene;
  117750. private _vertexBuffers;
  117751. private _indexBuffer;
  117752. private _effect;
  117753. private _alphaTestEffect;
  117754. /**
  117755. * An event triggered when the layer is disposed.
  117756. */
  117757. onDisposeObservable: Observable<Layer>;
  117758. private _onDisposeObserver;
  117759. /**
  117760. * Back compatibility with callback before the onDisposeObservable existed.
  117761. * The set callback will be triggered when the layer has been disposed.
  117762. */
  117763. onDispose: () => void;
  117764. /**
  117765. * An event triggered before rendering the scene
  117766. */
  117767. onBeforeRenderObservable: Observable<Layer>;
  117768. private _onBeforeRenderObserver;
  117769. /**
  117770. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117771. * The set callback will be triggered just before rendering the layer.
  117772. */
  117773. onBeforeRender: () => void;
  117774. /**
  117775. * An event triggered after rendering the scene
  117776. */
  117777. onAfterRenderObservable: Observable<Layer>;
  117778. private _onAfterRenderObserver;
  117779. /**
  117780. * Back compatibility with callback before the onAfterRenderObservable existed.
  117781. * The set callback will be triggered just after rendering the layer.
  117782. */
  117783. onAfterRender: () => void;
  117784. /**
  117785. * Instantiates a new layer.
  117786. * This represents a full screen 2d layer.
  117787. * This can be useful to display a picture in the background of your scene for instance.
  117788. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117789. * @param name Define the name of the layer in the scene
  117790. * @param imgUrl Define the url of the texture to display in the layer
  117791. * @param scene Define the scene the layer belongs to
  117792. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117793. * @param color Defines a color for the layer
  117794. */
  117795. constructor(
  117796. /**
  117797. * Define the name of the layer.
  117798. */
  117799. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117800. private _createIndexBuffer;
  117801. /** @hidden */
  117802. _rebuild(): void;
  117803. /**
  117804. * Renders the layer in the scene.
  117805. */
  117806. render(): void;
  117807. /**
  117808. * Disposes and releases the associated ressources.
  117809. */
  117810. dispose(): void;
  117811. }
  117812. }
  117813. declare module BABYLON {
  117814. /** @hidden */
  117815. export var lensFlarePixelShader: {
  117816. name: string;
  117817. shader: string;
  117818. };
  117819. }
  117820. declare module BABYLON {
  117821. /** @hidden */
  117822. export var lensFlareVertexShader: {
  117823. name: string;
  117824. shader: string;
  117825. };
  117826. }
  117827. declare module BABYLON {
  117828. /**
  117829. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117830. * It is usually composed of several `lensFlare`.
  117831. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117832. */
  117833. export class LensFlareSystem {
  117834. /**
  117835. * Define the name of the lens flare system
  117836. */
  117837. name: string;
  117838. /**
  117839. * List of lens flares used in this system.
  117840. */
  117841. lensFlares: LensFlare[];
  117842. /**
  117843. * Define a limit from the border the lens flare can be visible.
  117844. */
  117845. borderLimit: number;
  117846. /**
  117847. * Define a viewport border we do not want to see the lens flare in.
  117848. */
  117849. viewportBorder: number;
  117850. /**
  117851. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117852. */
  117853. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117854. /**
  117855. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117856. */
  117857. layerMask: number;
  117858. /**
  117859. * Define the id of the lens flare system in the scene.
  117860. * (equal to name by default)
  117861. */
  117862. id: string;
  117863. private _scene;
  117864. private _emitter;
  117865. private _vertexBuffers;
  117866. private _indexBuffer;
  117867. private _effect;
  117868. private _positionX;
  117869. private _positionY;
  117870. private _isEnabled;
  117871. /** @hidden */
  117872. static _SceneComponentInitialization: (scene: Scene) => void;
  117873. /**
  117874. * Instantiates a lens flare system.
  117875. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117876. * It is usually composed of several `lensFlare`.
  117877. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117878. * @param name Define the name of the lens flare system in the scene
  117879. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117880. * @param scene Define the scene the lens flare system belongs to
  117881. */
  117882. constructor(
  117883. /**
  117884. * Define the name of the lens flare system
  117885. */
  117886. name: string, emitter: any, scene: Scene);
  117887. /**
  117888. * Define if the lens flare system is enabled.
  117889. */
  117890. isEnabled: boolean;
  117891. /**
  117892. * Get the scene the effects belongs to.
  117893. * @returns the scene holding the lens flare system
  117894. */
  117895. getScene(): Scene;
  117896. /**
  117897. * Get the emitter of the lens flare system.
  117898. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117899. * @returns the emitter of the lens flare system
  117900. */
  117901. getEmitter(): any;
  117902. /**
  117903. * Set the emitter of the lens flare system.
  117904. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117905. * @param newEmitter Define the new emitter of the system
  117906. */
  117907. setEmitter(newEmitter: any): void;
  117908. /**
  117909. * Get the lens flare system emitter position.
  117910. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117911. * @returns the position
  117912. */
  117913. getEmitterPosition(): Vector3;
  117914. /**
  117915. * @hidden
  117916. */
  117917. computeEffectivePosition(globalViewport: Viewport): boolean;
  117918. /** @hidden */
  117919. _isVisible(): boolean;
  117920. /**
  117921. * @hidden
  117922. */
  117923. render(): boolean;
  117924. /**
  117925. * Dispose and release the lens flare with its associated resources.
  117926. */
  117927. dispose(): void;
  117928. /**
  117929. * Parse a lens flare system from a JSON repressentation
  117930. * @param parsedLensFlareSystem Define the JSON to parse
  117931. * @param scene Define the scene the parsed system should be instantiated in
  117932. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117933. * @returns the parsed system
  117934. */
  117935. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117936. /**
  117937. * Serialize the current Lens Flare System into a JSON representation.
  117938. * @returns the serialized JSON
  117939. */
  117940. serialize(): any;
  117941. }
  117942. }
  117943. declare module BABYLON {
  117944. /**
  117945. * This represents one of the lens effect in a `lensFlareSystem`.
  117946. * It controls one of the indiviual texture used in the effect.
  117947. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117948. */
  117949. export class LensFlare {
  117950. /**
  117951. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117952. */
  117953. size: number;
  117954. /**
  117955. * 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.
  117956. */
  117957. position: number;
  117958. /**
  117959. * Define the lens color.
  117960. */
  117961. color: Color3;
  117962. /**
  117963. * Define the lens texture.
  117964. */
  117965. texture: Nullable<Texture>;
  117966. /**
  117967. * Define the alpha mode to render this particular lens.
  117968. */
  117969. alphaMode: number;
  117970. private _system;
  117971. /**
  117972. * Creates a new Lens Flare.
  117973. * This represents one of the lens effect in a `lensFlareSystem`.
  117974. * It controls one of the indiviual texture used in the effect.
  117975. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117976. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117977. * @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.
  117978. * @param color Define the lens color
  117979. * @param imgUrl Define the lens texture url
  117980. * @param system Define the `lensFlareSystem` this flare is part of
  117981. * @returns The newly created Lens Flare
  117982. */
  117983. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117984. /**
  117985. * Instantiates a new Lens Flare.
  117986. * This represents one of the lens effect in a `lensFlareSystem`.
  117987. * It controls one of the indiviual texture used in the effect.
  117988. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117989. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117990. * @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.
  117991. * @param color Define the lens color
  117992. * @param imgUrl Define the lens texture url
  117993. * @param system Define the `lensFlareSystem` this flare is part of
  117994. */
  117995. constructor(
  117996. /**
  117997. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117998. */
  117999. size: number,
  118000. /**
  118001. * 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.
  118002. */
  118003. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  118004. /**
  118005. * Dispose and release the lens flare with its associated resources.
  118006. */
  118007. dispose(): void;
  118008. }
  118009. }
  118010. declare module BABYLON {
  118011. interface AbstractScene {
  118012. /**
  118013. * The list of lens flare system added to the scene
  118014. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118015. */
  118016. lensFlareSystems: Array<LensFlareSystem>;
  118017. /**
  118018. * Removes the given lens flare system from this scene.
  118019. * @param toRemove The lens flare system to remove
  118020. * @returns The index of the removed lens flare system
  118021. */
  118022. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  118023. /**
  118024. * Adds the given lens flare system to this scene
  118025. * @param newLensFlareSystem The lens flare system to add
  118026. */
  118027. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  118028. /**
  118029. * Gets a lens flare system using its name
  118030. * @param name defines the name to look for
  118031. * @returns the lens flare system or null if not found
  118032. */
  118033. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  118034. /**
  118035. * Gets a lens flare system using its id
  118036. * @param id defines the id to look for
  118037. * @returns the lens flare system or null if not found
  118038. */
  118039. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  118040. }
  118041. /**
  118042. * Defines the lens flare scene component responsible to manage any lens flares
  118043. * in a given scene.
  118044. */
  118045. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  118046. /**
  118047. * The component name helpfull to identify the component in the list of scene components.
  118048. */
  118049. readonly name: string;
  118050. /**
  118051. * The scene the component belongs to.
  118052. */
  118053. scene: Scene;
  118054. /**
  118055. * Creates a new instance of the component for the given scene
  118056. * @param scene Defines the scene to register the component in
  118057. */
  118058. constructor(scene: Scene);
  118059. /**
  118060. * Registers the component in a given scene
  118061. */
  118062. register(): void;
  118063. /**
  118064. * Rebuilds the elements related to this component in case of
  118065. * context lost for instance.
  118066. */
  118067. rebuild(): void;
  118068. /**
  118069. * Adds all the elements from the container to the scene
  118070. * @param container the container holding the elements
  118071. */
  118072. addFromContainer(container: AbstractScene): void;
  118073. /**
  118074. * Removes all the elements in the container from the scene
  118075. * @param container contains the elements to remove
  118076. * @param dispose if the removed element should be disposed (default: false)
  118077. */
  118078. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118079. /**
  118080. * Serializes the component data to the specified json object
  118081. * @param serializationObject The object to serialize to
  118082. */
  118083. serialize(serializationObject: any): void;
  118084. /**
  118085. * Disposes the component and the associated ressources.
  118086. */
  118087. dispose(): void;
  118088. private _draw;
  118089. }
  118090. }
  118091. declare module BABYLON {
  118092. /**
  118093. * Defines the shadow generator component responsible to manage any shadow generators
  118094. * in a given scene.
  118095. */
  118096. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  118097. /**
  118098. * The component name helpfull to identify the component in the list of scene components.
  118099. */
  118100. readonly name: string;
  118101. /**
  118102. * The scene the component belongs to.
  118103. */
  118104. scene: Scene;
  118105. /**
  118106. * Creates a new instance of the component for the given scene
  118107. * @param scene Defines the scene to register the component in
  118108. */
  118109. constructor(scene: Scene);
  118110. /**
  118111. * Registers the component in a given scene
  118112. */
  118113. register(): void;
  118114. /**
  118115. * Rebuilds the elements related to this component in case of
  118116. * context lost for instance.
  118117. */
  118118. rebuild(): void;
  118119. /**
  118120. * Serializes the component data to the specified json object
  118121. * @param serializationObject The object to serialize to
  118122. */
  118123. serialize(serializationObject: any): void;
  118124. /**
  118125. * Adds all the elements from the container to the scene
  118126. * @param container the container holding the elements
  118127. */
  118128. addFromContainer(container: AbstractScene): void;
  118129. /**
  118130. * Removes all the elements in the container from the scene
  118131. * @param container contains the elements to remove
  118132. * @param dispose if the removed element should be disposed (default: false)
  118133. */
  118134. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118135. /**
  118136. * Rebuilds the elements related to this component in case of
  118137. * context lost for instance.
  118138. */
  118139. dispose(): void;
  118140. private _gatherRenderTargets;
  118141. }
  118142. }
  118143. declare module BABYLON {
  118144. /**
  118145. * A point light is a light defined by an unique point in world space.
  118146. * The light is emitted in every direction from this point.
  118147. * A good example of a point light is a standard light bulb.
  118148. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118149. */
  118150. export class PointLight extends ShadowLight {
  118151. private _shadowAngle;
  118152. /**
  118153. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118154. * This specifies what angle the shadow will use to be created.
  118155. *
  118156. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118157. */
  118158. /**
  118159. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118160. * This specifies what angle the shadow will use to be created.
  118161. *
  118162. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118163. */
  118164. shadowAngle: number;
  118165. /**
  118166. * Gets the direction if it has been set.
  118167. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118168. */
  118169. /**
  118170. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118171. */
  118172. direction: Vector3;
  118173. /**
  118174. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  118175. * A PointLight emits the light in every direction.
  118176. * It can cast shadows.
  118177. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  118178. * ```javascript
  118179. * var pointLight = new PointLight("pl", camera.position, scene);
  118180. * ```
  118181. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118182. * @param name The light friendly name
  118183. * @param position The position of the point light in the scene
  118184. * @param scene The scene the lights belongs to
  118185. */
  118186. constructor(name: string, position: Vector3, scene: Scene);
  118187. /**
  118188. * Returns the string "PointLight"
  118189. * @returns the class name
  118190. */
  118191. getClassName(): string;
  118192. /**
  118193. * Returns the integer 0.
  118194. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118195. */
  118196. getTypeID(): number;
  118197. /**
  118198. * Specifies wether or not the shadowmap should be a cube texture.
  118199. * @returns true if the shadowmap needs to be a cube texture.
  118200. */
  118201. needCube(): boolean;
  118202. /**
  118203. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  118204. * @param faceIndex The index of the face we are computed the direction to generate shadow
  118205. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  118206. */
  118207. getShadowDirection(faceIndex?: number): Vector3;
  118208. /**
  118209. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  118210. * - fov = PI / 2
  118211. * - aspect ratio : 1.0
  118212. * - z-near and far equal to the active camera minZ and maxZ.
  118213. * Returns the PointLight.
  118214. */
  118215. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118216. protected _buildUniformLayout(): void;
  118217. /**
  118218. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  118219. * @param effect The effect to update
  118220. * @param lightIndex The index of the light in the effect to update
  118221. * @returns The point light
  118222. */
  118223. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  118224. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118225. /**
  118226. * Prepares the list of defines specific to the light type.
  118227. * @param defines the list of defines
  118228. * @param lightIndex defines the index of the light for the effect
  118229. */
  118230. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118231. }
  118232. }
  118233. declare module BABYLON {
  118234. /**
  118235. * Header information of HDR texture files.
  118236. */
  118237. export interface HDRInfo {
  118238. /**
  118239. * The height of the texture in pixels.
  118240. */
  118241. height: number;
  118242. /**
  118243. * The width of the texture in pixels.
  118244. */
  118245. width: number;
  118246. /**
  118247. * The index of the beginning of the data in the binary file.
  118248. */
  118249. dataPosition: number;
  118250. }
  118251. /**
  118252. * This groups tools to convert HDR texture to native colors array.
  118253. */
  118254. export class HDRTools {
  118255. private static Ldexp;
  118256. private static Rgbe2float;
  118257. private static readStringLine;
  118258. /**
  118259. * Reads header information from an RGBE texture stored in a native array.
  118260. * More information on this format are available here:
  118261. * https://en.wikipedia.org/wiki/RGBE_image_format
  118262. *
  118263. * @param uint8array The binary file stored in native array.
  118264. * @return The header information.
  118265. */
  118266. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  118267. /**
  118268. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  118269. * This RGBE texture needs to store the information as a panorama.
  118270. *
  118271. * More information on this format are available here:
  118272. * https://en.wikipedia.org/wiki/RGBE_image_format
  118273. *
  118274. * @param buffer The binary file stored in an array buffer.
  118275. * @param size The expected size of the extracted cubemap.
  118276. * @return The Cube Map information.
  118277. */
  118278. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  118279. /**
  118280. * Returns the pixels data extracted from an RGBE texture.
  118281. * This pixels will be stored left to right up to down in the R G B order in one array.
  118282. *
  118283. * More information on this format are available here:
  118284. * https://en.wikipedia.org/wiki/RGBE_image_format
  118285. *
  118286. * @param uint8array The binary file stored in an array buffer.
  118287. * @param hdrInfo The header information of the file.
  118288. * @return The pixels data in RGB right to left up to down order.
  118289. */
  118290. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  118291. private static RGBE_ReadPixels_RLE;
  118292. }
  118293. }
  118294. declare module BABYLON {
  118295. /**
  118296. * This represents a texture coming from an HDR input.
  118297. *
  118298. * The only supported format is currently panorama picture stored in RGBE format.
  118299. * Example of such files can be found on HDRLib: http://hdrlib.com/
  118300. */
  118301. export class HDRCubeTexture extends BaseTexture {
  118302. private static _facesMapping;
  118303. private _generateHarmonics;
  118304. private _noMipmap;
  118305. private _textureMatrix;
  118306. private _size;
  118307. private _onLoad;
  118308. private _onError;
  118309. /**
  118310. * The texture URL.
  118311. */
  118312. url: string;
  118313. /**
  118314. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  118315. */
  118316. coordinatesMode: number;
  118317. protected _isBlocking: boolean;
  118318. /**
  118319. * Sets wether or not the texture is blocking during loading.
  118320. */
  118321. /**
  118322. * Gets wether or not the texture is blocking during loading.
  118323. */
  118324. isBlocking: boolean;
  118325. protected _rotationY: number;
  118326. /**
  118327. * Sets texture matrix rotation angle around Y axis in radians.
  118328. */
  118329. /**
  118330. * Gets texture matrix rotation angle around Y axis radians.
  118331. */
  118332. rotationY: number;
  118333. /**
  118334. * Gets or sets the center of the bounding box associated with the cube texture
  118335. * It must define where the camera used to render the texture was set
  118336. */
  118337. boundingBoxPosition: Vector3;
  118338. private _boundingBoxSize;
  118339. /**
  118340. * Gets or sets the size of the bounding box associated with the cube texture
  118341. * When defined, the cubemap will switch to local mode
  118342. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  118343. * @example https://www.babylonjs-playground.com/#RNASML
  118344. */
  118345. boundingBoxSize: Vector3;
  118346. /**
  118347. * Instantiates an HDRTexture from the following parameters.
  118348. *
  118349. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  118350. * @param scene The scene the texture will be used in
  118351. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118352. * @param noMipmap Forces to not generate the mipmap if true
  118353. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  118354. * @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)
  118355. * @param reserved Reserved flag for internal use.
  118356. */
  118357. 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>);
  118358. /**
  118359. * Get the current class name of the texture useful for serialization or dynamic coding.
  118360. * @returns "HDRCubeTexture"
  118361. */
  118362. getClassName(): string;
  118363. /**
  118364. * Occurs when the file is raw .hdr file.
  118365. */
  118366. private loadTexture;
  118367. clone(): HDRCubeTexture;
  118368. delayLoad(): void;
  118369. /**
  118370. * Get the texture reflection matrix used to rotate/transform the reflection.
  118371. * @returns the reflection matrix
  118372. */
  118373. getReflectionTextureMatrix(): Matrix;
  118374. /**
  118375. * Set the texture reflection matrix used to rotate/transform the reflection.
  118376. * @param value Define the reflection matrix to set
  118377. */
  118378. setReflectionTextureMatrix(value: Matrix): void;
  118379. /**
  118380. * Parses a JSON representation of an HDR Texture in order to create the texture
  118381. * @param parsedTexture Define the JSON representation
  118382. * @param scene Define the scene the texture should be created in
  118383. * @param rootUrl Define the root url in case we need to load relative dependencies
  118384. * @returns the newly created texture after parsing
  118385. */
  118386. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  118387. serialize(): any;
  118388. }
  118389. }
  118390. declare module BABYLON {
  118391. /**
  118392. * Class used to control physics engine
  118393. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  118394. */
  118395. export class PhysicsEngine implements IPhysicsEngine {
  118396. private _physicsPlugin;
  118397. /**
  118398. * Global value used to control the smallest number supported by the simulation
  118399. */
  118400. static Epsilon: number;
  118401. private _impostors;
  118402. private _joints;
  118403. /**
  118404. * Gets the gravity vector used by the simulation
  118405. */
  118406. gravity: Vector3;
  118407. /**
  118408. * Factory used to create the default physics plugin.
  118409. * @returns The default physics plugin
  118410. */
  118411. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  118412. /**
  118413. * Creates a new Physics Engine
  118414. * @param gravity defines the gravity vector used by the simulation
  118415. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  118416. */
  118417. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  118418. /**
  118419. * Sets the gravity vector used by the simulation
  118420. * @param gravity defines the gravity vector to use
  118421. */
  118422. setGravity(gravity: Vector3): void;
  118423. /**
  118424. * Set the time step of the physics engine.
  118425. * Default is 1/60.
  118426. * To slow it down, enter 1/600 for example.
  118427. * To speed it up, 1/30
  118428. * @param newTimeStep defines the new timestep to apply to this world.
  118429. */
  118430. setTimeStep(newTimeStep?: number): void;
  118431. /**
  118432. * Get the time step of the physics engine.
  118433. * @returns the current time step
  118434. */
  118435. getTimeStep(): number;
  118436. /**
  118437. * Release all resources
  118438. */
  118439. dispose(): void;
  118440. /**
  118441. * Gets the name of the current physics plugin
  118442. * @returns the name of the plugin
  118443. */
  118444. getPhysicsPluginName(): string;
  118445. /**
  118446. * Adding a new impostor for the impostor tracking.
  118447. * This will be done by the impostor itself.
  118448. * @param impostor the impostor to add
  118449. */
  118450. addImpostor(impostor: PhysicsImpostor): void;
  118451. /**
  118452. * Remove an impostor from the engine.
  118453. * This impostor and its mesh will not longer be updated by the physics engine.
  118454. * @param impostor the impostor to remove
  118455. */
  118456. removeImpostor(impostor: PhysicsImpostor): void;
  118457. /**
  118458. * Add a joint to the physics engine
  118459. * @param mainImpostor defines the main impostor to which the joint is added.
  118460. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  118461. * @param joint defines the joint that will connect both impostors.
  118462. */
  118463. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118464. /**
  118465. * Removes a joint from the simulation
  118466. * @param mainImpostor defines the impostor used with the joint
  118467. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  118468. * @param joint defines the joint to remove
  118469. */
  118470. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118471. /**
  118472. * Called by the scene. No need to call it.
  118473. * @param delta defines the timespam between frames
  118474. */
  118475. _step(delta: number): void;
  118476. /**
  118477. * Gets the current plugin used to run the simulation
  118478. * @returns current plugin
  118479. */
  118480. getPhysicsPlugin(): IPhysicsEnginePlugin;
  118481. /**
  118482. * Gets the list of physic impostors
  118483. * @returns an array of PhysicsImpostor
  118484. */
  118485. getImpostors(): Array<PhysicsImpostor>;
  118486. /**
  118487. * Gets the impostor for a physics enabled object
  118488. * @param object defines the object impersonated by the impostor
  118489. * @returns the PhysicsImpostor or null if not found
  118490. */
  118491. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  118492. /**
  118493. * Gets the impostor for a physics body object
  118494. * @param body defines physics body used by the impostor
  118495. * @returns the PhysicsImpostor or null if not found
  118496. */
  118497. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  118498. /**
  118499. * Does a raycast in the physics world
  118500. * @param from when should the ray start?
  118501. * @param to when should the ray end?
  118502. * @returns PhysicsRaycastResult
  118503. */
  118504. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118505. }
  118506. }
  118507. declare module BABYLON {
  118508. /** @hidden */
  118509. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  118510. private _useDeltaForWorldStep;
  118511. world: any;
  118512. name: string;
  118513. private _physicsMaterials;
  118514. private _fixedTimeStep;
  118515. private _cannonRaycastResult;
  118516. private _raycastResult;
  118517. private _physicsBodysToRemoveAfterStep;
  118518. BJSCANNON: any;
  118519. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  118520. setGravity(gravity: Vector3): void;
  118521. setTimeStep(timeStep: number): void;
  118522. getTimeStep(): number;
  118523. executeStep(delta: number): void;
  118524. private _removeMarkedPhysicsBodiesFromWorld;
  118525. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118526. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118527. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118528. private _processChildMeshes;
  118529. removePhysicsBody(impostor: PhysicsImpostor): void;
  118530. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118531. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118532. private _addMaterial;
  118533. private _checkWithEpsilon;
  118534. private _createShape;
  118535. private _createHeightmap;
  118536. private _minus90X;
  118537. private _plus90X;
  118538. private _tmpPosition;
  118539. private _tmpDeltaPosition;
  118540. private _tmpUnityRotation;
  118541. private _updatePhysicsBodyTransformation;
  118542. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118543. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118544. isSupported(): boolean;
  118545. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118546. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118547. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118548. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118549. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118550. getBodyMass(impostor: PhysicsImpostor): number;
  118551. getBodyFriction(impostor: PhysicsImpostor): number;
  118552. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118553. getBodyRestitution(impostor: PhysicsImpostor): number;
  118554. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118555. sleepBody(impostor: PhysicsImpostor): void;
  118556. wakeUpBody(impostor: PhysicsImpostor): void;
  118557. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  118558. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118559. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118560. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118561. getRadius(impostor: PhysicsImpostor): number;
  118562. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118563. dispose(): void;
  118564. private _extendNamespace;
  118565. /**
  118566. * Does a raycast in the physics world
  118567. * @param from when should the ray start?
  118568. * @param to when should the ray end?
  118569. * @returns PhysicsRaycastResult
  118570. */
  118571. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118572. }
  118573. }
  118574. declare module BABYLON {
  118575. /** @hidden */
  118576. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  118577. world: any;
  118578. name: string;
  118579. BJSOIMO: any;
  118580. private _raycastResult;
  118581. constructor(iterations?: number, oimoInjection?: any);
  118582. setGravity(gravity: Vector3): void;
  118583. setTimeStep(timeStep: number): void;
  118584. getTimeStep(): number;
  118585. private _tmpImpostorsArray;
  118586. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118587. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118588. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118589. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118590. private _tmpPositionVector;
  118591. removePhysicsBody(impostor: PhysicsImpostor): void;
  118592. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118593. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118594. isSupported(): boolean;
  118595. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118596. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118597. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118598. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118599. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118600. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118601. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118602. getBodyMass(impostor: PhysicsImpostor): number;
  118603. getBodyFriction(impostor: PhysicsImpostor): number;
  118604. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118605. getBodyRestitution(impostor: PhysicsImpostor): number;
  118606. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118607. sleepBody(impostor: PhysicsImpostor): void;
  118608. wakeUpBody(impostor: PhysicsImpostor): void;
  118609. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118610. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  118611. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  118612. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118613. getRadius(impostor: PhysicsImpostor): number;
  118614. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118615. dispose(): void;
  118616. /**
  118617. * Does a raycast in the physics world
  118618. * @param from when should the ray start?
  118619. * @param to when should the ray end?
  118620. * @returns PhysicsRaycastResult
  118621. */
  118622. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118623. }
  118624. }
  118625. declare module BABYLON {
  118626. /**
  118627. * Class containing static functions to help procedurally build meshes
  118628. */
  118629. export class RibbonBuilder {
  118630. /**
  118631. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118632. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  118633. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  118634. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  118635. * * 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
  118636. * * 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
  118637. * * 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
  118638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118639. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118640. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118641. * * 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
  118642. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  118643. * * 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
  118644. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  118645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118646. * @param name defines the name of the mesh
  118647. * @param options defines the options used to create the mesh
  118648. * @param scene defines the hosting scene
  118649. * @returns the ribbon mesh
  118650. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  118651. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118652. */
  118653. static CreateRibbon(name: string, options: {
  118654. pathArray: Vector3[][];
  118655. closeArray?: boolean;
  118656. closePath?: boolean;
  118657. offset?: number;
  118658. updatable?: boolean;
  118659. sideOrientation?: number;
  118660. frontUVs?: Vector4;
  118661. backUVs?: Vector4;
  118662. instance?: Mesh;
  118663. invertUV?: boolean;
  118664. uvs?: Vector2[];
  118665. colors?: Color4[];
  118666. }, scene?: Nullable<Scene>): Mesh;
  118667. }
  118668. }
  118669. declare module BABYLON {
  118670. /**
  118671. * Class containing static functions to help procedurally build meshes
  118672. */
  118673. export class ShapeBuilder {
  118674. /**
  118675. * 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.
  118676. * * 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.
  118677. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118678. * * 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.
  118679. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118680. * * 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
  118681. * * 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
  118682. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118687. * @param name defines the name of the mesh
  118688. * @param options defines the options used to create the mesh
  118689. * @param scene defines the hosting scene
  118690. * @returns the extruded shape mesh
  118691. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118692. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118693. */
  118694. static ExtrudeShape(name: string, options: {
  118695. shape: Vector3[];
  118696. path: Vector3[];
  118697. scale?: number;
  118698. rotation?: number;
  118699. cap?: number;
  118700. updatable?: boolean;
  118701. sideOrientation?: number;
  118702. frontUVs?: Vector4;
  118703. backUVs?: Vector4;
  118704. instance?: Mesh;
  118705. invertUV?: boolean;
  118706. }, scene?: Nullable<Scene>): Mesh;
  118707. /**
  118708. * Creates an custom extruded shape mesh.
  118709. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118710. * * 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.
  118711. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118712. * * 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
  118713. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118714. * * 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
  118715. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118716. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118717. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118718. * * 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
  118719. * * 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
  118720. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118723. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118725. * @param name defines the name of the mesh
  118726. * @param options defines the options used to create the mesh
  118727. * @param scene defines the hosting scene
  118728. * @returns the custom extruded shape mesh
  118729. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118730. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118732. */
  118733. static ExtrudeShapeCustom(name: string, options: {
  118734. shape: Vector3[];
  118735. path: Vector3[];
  118736. scaleFunction?: any;
  118737. rotationFunction?: any;
  118738. ribbonCloseArray?: boolean;
  118739. ribbonClosePath?: boolean;
  118740. cap?: number;
  118741. updatable?: boolean;
  118742. sideOrientation?: number;
  118743. frontUVs?: Vector4;
  118744. backUVs?: Vector4;
  118745. instance?: Mesh;
  118746. invertUV?: boolean;
  118747. }, scene?: Nullable<Scene>): Mesh;
  118748. private static _ExtrudeShapeGeneric;
  118749. }
  118750. }
  118751. declare module BABYLON {
  118752. /**
  118753. * AmmoJS Physics plugin
  118754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118755. * @see https://github.com/kripken/ammo.js/
  118756. */
  118757. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118758. private _useDeltaForWorldStep;
  118759. /**
  118760. * Reference to the Ammo library
  118761. */
  118762. bjsAMMO: any;
  118763. /**
  118764. * Created ammoJS world which physics bodies are added to
  118765. */
  118766. world: any;
  118767. /**
  118768. * Name of the plugin
  118769. */
  118770. name: string;
  118771. private _timeStep;
  118772. private _fixedTimeStep;
  118773. private _maxSteps;
  118774. private _tmpQuaternion;
  118775. private _tmpAmmoTransform;
  118776. private _tmpAmmoQuaternion;
  118777. private _tmpAmmoConcreteContactResultCallback;
  118778. private _collisionConfiguration;
  118779. private _dispatcher;
  118780. private _overlappingPairCache;
  118781. private _solver;
  118782. private _softBodySolver;
  118783. private _tmpAmmoVectorA;
  118784. private _tmpAmmoVectorB;
  118785. private _tmpAmmoVectorC;
  118786. private _tmpAmmoVectorD;
  118787. private _tmpContactCallbackResult;
  118788. private _tmpAmmoVectorRCA;
  118789. private _tmpAmmoVectorRCB;
  118790. private _raycastResult;
  118791. private static readonly DISABLE_COLLISION_FLAG;
  118792. private static readonly KINEMATIC_FLAG;
  118793. private static readonly DISABLE_DEACTIVATION_FLAG;
  118794. /**
  118795. * Initializes the ammoJS plugin
  118796. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118797. * @param ammoInjection can be used to inject your own ammo reference
  118798. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118799. */
  118800. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118801. /**
  118802. * Sets the gravity of the physics world (m/(s^2))
  118803. * @param gravity Gravity to set
  118804. */
  118805. setGravity(gravity: Vector3): void;
  118806. /**
  118807. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118808. * @param timeStep timestep to use in seconds
  118809. */
  118810. setTimeStep(timeStep: number): void;
  118811. /**
  118812. * 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)
  118813. * @param fixedTimeStep fixedTimeStep to use in seconds
  118814. */
  118815. setFixedTimeStep(fixedTimeStep: number): void;
  118816. /**
  118817. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118818. * @param maxSteps the maximum number of steps by the physics engine per frame
  118819. */
  118820. setMaxSteps(maxSteps: number): void;
  118821. /**
  118822. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118823. * @returns the current timestep in seconds
  118824. */
  118825. getTimeStep(): number;
  118826. private _isImpostorInContact;
  118827. private _isImpostorPairInContact;
  118828. private _stepSimulation;
  118829. /**
  118830. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118831. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118832. * After the step the babylon meshes are set to the position of the physics imposters
  118833. * @param delta amount of time to step forward
  118834. * @param impostors array of imposters to update before/after the step
  118835. */
  118836. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118837. /**
  118838. * Update babylon mesh to match physics world object
  118839. * @param impostor imposter to match
  118840. */
  118841. private _afterSoftStep;
  118842. /**
  118843. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118844. * @param impostor imposter to match
  118845. */
  118846. private _ropeStep;
  118847. /**
  118848. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118849. * @param impostor imposter to match
  118850. */
  118851. private _softbodyOrClothStep;
  118852. private _tmpVector;
  118853. private _tmpMatrix;
  118854. /**
  118855. * Applies an impulse on the imposter
  118856. * @param impostor imposter to apply impulse to
  118857. * @param force amount of force to be applied to the imposter
  118858. * @param contactPoint the location to apply the impulse on the imposter
  118859. */
  118860. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118861. /**
  118862. * Applies a force on the imposter
  118863. * @param impostor imposter to apply force
  118864. * @param force amount of force to be applied to the imposter
  118865. * @param contactPoint the location to apply the force on the imposter
  118866. */
  118867. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118868. /**
  118869. * Creates a physics body using the plugin
  118870. * @param impostor the imposter to create the physics body on
  118871. */
  118872. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118873. /**
  118874. * Removes the physics body from the imposter and disposes of the body's memory
  118875. * @param impostor imposter to remove the physics body from
  118876. */
  118877. removePhysicsBody(impostor: PhysicsImpostor): void;
  118878. /**
  118879. * Generates a joint
  118880. * @param impostorJoint the imposter joint to create the joint with
  118881. */
  118882. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118883. /**
  118884. * Removes a joint
  118885. * @param impostorJoint the imposter joint to remove the joint from
  118886. */
  118887. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118888. private _addMeshVerts;
  118889. /**
  118890. * Initialise the soft body vertices to match its object's (mesh) vertices
  118891. * Softbody vertices (nodes) are in world space and to match this
  118892. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118893. * @param impostor to create the softbody for
  118894. */
  118895. private _softVertexData;
  118896. /**
  118897. * Create an impostor's soft body
  118898. * @param impostor to create the softbody for
  118899. */
  118900. private _createSoftbody;
  118901. /**
  118902. * Create cloth for an impostor
  118903. * @param impostor to create the softbody for
  118904. */
  118905. private _createCloth;
  118906. /**
  118907. * Create rope for an impostor
  118908. * @param impostor to create the softbody for
  118909. */
  118910. private _createRope;
  118911. private _addHullVerts;
  118912. private _createShape;
  118913. /**
  118914. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118915. * @param impostor imposter containing the physics body and babylon object
  118916. */
  118917. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118918. /**
  118919. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118920. * @param impostor imposter containing the physics body and babylon object
  118921. * @param newPosition new position
  118922. * @param newRotation new rotation
  118923. */
  118924. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118925. /**
  118926. * If this plugin is supported
  118927. * @returns true if its supported
  118928. */
  118929. isSupported(): boolean;
  118930. /**
  118931. * Sets the linear velocity of the physics body
  118932. * @param impostor imposter to set the velocity on
  118933. * @param velocity velocity to set
  118934. */
  118935. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118936. /**
  118937. * Sets the angular velocity of the physics body
  118938. * @param impostor imposter to set the velocity on
  118939. * @param velocity velocity to set
  118940. */
  118941. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118942. /**
  118943. * gets the linear velocity
  118944. * @param impostor imposter to get linear velocity from
  118945. * @returns linear velocity
  118946. */
  118947. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118948. /**
  118949. * gets the angular velocity
  118950. * @param impostor imposter to get angular velocity from
  118951. * @returns angular velocity
  118952. */
  118953. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118954. /**
  118955. * Sets the mass of physics body
  118956. * @param impostor imposter to set the mass on
  118957. * @param mass mass to set
  118958. */
  118959. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118960. /**
  118961. * Gets the mass of the physics body
  118962. * @param impostor imposter to get the mass from
  118963. * @returns mass
  118964. */
  118965. getBodyMass(impostor: PhysicsImpostor): number;
  118966. /**
  118967. * Gets friction of the impostor
  118968. * @param impostor impostor to get friction from
  118969. * @returns friction value
  118970. */
  118971. getBodyFriction(impostor: PhysicsImpostor): number;
  118972. /**
  118973. * Sets friction of the impostor
  118974. * @param impostor impostor to set friction on
  118975. * @param friction friction value
  118976. */
  118977. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118978. /**
  118979. * Gets restitution of the impostor
  118980. * @param impostor impostor to get restitution from
  118981. * @returns restitution value
  118982. */
  118983. getBodyRestitution(impostor: PhysicsImpostor): number;
  118984. /**
  118985. * Sets resitution of the impostor
  118986. * @param impostor impostor to set resitution on
  118987. * @param restitution resitution value
  118988. */
  118989. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118990. /**
  118991. * Gets pressure inside the impostor
  118992. * @param impostor impostor to get pressure from
  118993. * @returns pressure value
  118994. */
  118995. getBodyPressure(impostor: PhysicsImpostor): number;
  118996. /**
  118997. * Sets pressure inside a soft body impostor
  118998. * Cloth and rope must remain 0 pressure
  118999. * @param impostor impostor to set pressure on
  119000. * @param pressure pressure value
  119001. */
  119002. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  119003. /**
  119004. * Gets stiffness of the impostor
  119005. * @param impostor impostor to get stiffness from
  119006. * @returns pressure value
  119007. */
  119008. getBodyStiffness(impostor: PhysicsImpostor): number;
  119009. /**
  119010. * Sets stiffness of the impostor
  119011. * @param impostor impostor to set stiffness on
  119012. * @param stiffness stiffness value from 0 to 1
  119013. */
  119014. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  119015. /**
  119016. * Gets velocityIterations of the impostor
  119017. * @param impostor impostor to get velocity iterations from
  119018. * @returns velocityIterations value
  119019. */
  119020. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  119021. /**
  119022. * Sets velocityIterations of the impostor
  119023. * @param impostor impostor to set velocity iterations on
  119024. * @param velocityIterations velocityIterations value
  119025. */
  119026. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  119027. /**
  119028. * Gets positionIterations of the impostor
  119029. * @param impostor impostor to get position iterations from
  119030. * @returns positionIterations value
  119031. */
  119032. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  119033. /**
  119034. * Sets positionIterations of the impostor
  119035. * @param impostor impostor to set position on
  119036. * @param positionIterations positionIterations value
  119037. */
  119038. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  119039. /**
  119040. * Append an anchor to a cloth object
  119041. * @param impostor is the cloth impostor to add anchor to
  119042. * @param otherImpostor is the rigid impostor to anchor to
  119043. * @param width ratio across width from 0 to 1
  119044. * @param height ratio up height from 0 to 1
  119045. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  119046. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119047. */
  119048. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119049. /**
  119050. * Append an hook to a rope object
  119051. * @param impostor is the rope impostor to add hook to
  119052. * @param otherImpostor is the rigid impostor to hook to
  119053. * @param length ratio along the rope from 0 to 1
  119054. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  119055. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119056. */
  119057. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119058. /**
  119059. * Sleeps the physics body and stops it from being active
  119060. * @param impostor impostor to sleep
  119061. */
  119062. sleepBody(impostor: PhysicsImpostor): void;
  119063. /**
  119064. * Activates the physics body
  119065. * @param impostor impostor to activate
  119066. */
  119067. wakeUpBody(impostor: PhysicsImpostor): void;
  119068. /**
  119069. * Updates the distance parameters of the joint
  119070. * @param joint joint to update
  119071. * @param maxDistance maximum distance of the joint
  119072. * @param minDistance minimum distance of the joint
  119073. */
  119074. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119075. /**
  119076. * Sets a motor on the joint
  119077. * @param joint joint to set motor on
  119078. * @param speed speed of the motor
  119079. * @param maxForce maximum force of the motor
  119080. * @param motorIndex index of the motor
  119081. */
  119082. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119083. /**
  119084. * Sets the motors limit
  119085. * @param joint joint to set limit on
  119086. * @param upperLimit upper limit
  119087. * @param lowerLimit lower limit
  119088. */
  119089. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119090. /**
  119091. * Syncs the position and rotation of a mesh with the impostor
  119092. * @param mesh mesh to sync
  119093. * @param impostor impostor to update the mesh with
  119094. */
  119095. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119096. /**
  119097. * Gets the radius of the impostor
  119098. * @param impostor impostor to get radius from
  119099. * @returns the radius
  119100. */
  119101. getRadius(impostor: PhysicsImpostor): number;
  119102. /**
  119103. * Gets the box size of the impostor
  119104. * @param impostor impostor to get box size from
  119105. * @param result the resulting box size
  119106. */
  119107. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119108. /**
  119109. * Disposes of the impostor
  119110. */
  119111. dispose(): void;
  119112. /**
  119113. * Does a raycast in the physics world
  119114. * @param from when should the ray start?
  119115. * @param to when should the ray end?
  119116. * @returns PhysicsRaycastResult
  119117. */
  119118. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119119. }
  119120. }
  119121. declare module BABYLON {
  119122. interface AbstractScene {
  119123. /**
  119124. * The list of reflection probes added to the scene
  119125. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119126. */
  119127. reflectionProbes: Array<ReflectionProbe>;
  119128. /**
  119129. * Removes the given reflection probe from this scene.
  119130. * @param toRemove The reflection probe to remove
  119131. * @returns The index of the removed reflection probe
  119132. */
  119133. removeReflectionProbe(toRemove: ReflectionProbe): number;
  119134. /**
  119135. * Adds the given reflection probe to this scene.
  119136. * @param newReflectionProbe The reflection probe to add
  119137. */
  119138. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  119139. }
  119140. /**
  119141. * Class used to generate realtime reflection / refraction cube textures
  119142. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119143. */
  119144. export class ReflectionProbe {
  119145. /** defines the name of the probe */
  119146. name: string;
  119147. private _scene;
  119148. private _renderTargetTexture;
  119149. private _projectionMatrix;
  119150. private _viewMatrix;
  119151. private _target;
  119152. private _add;
  119153. private _attachedMesh;
  119154. private _invertYAxis;
  119155. /** Gets or sets probe position (center of the cube map) */
  119156. position: Vector3;
  119157. /**
  119158. * Creates a new reflection probe
  119159. * @param name defines the name of the probe
  119160. * @param size defines the texture resolution (for each face)
  119161. * @param scene defines the hosting scene
  119162. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119163. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119164. */
  119165. constructor(
  119166. /** defines the name of the probe */
  119167. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  119168. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  119169. samples: number;
  119170. /** Gets or sets the refresh rate to use (on every frame by default) */
  119171. refreshRate: number;
  119172. /**
  119173. * Gets the hosting scene
  119174. * @returns a Scene
  119175. */
  119176. getScene(): Scene;
  119177. /** Gets the internal CubeTexture used to render to */
  119178. readonly cubeTexture: RenderTargetTexture;
  119179. /** Gets the list of meshes to render */
  119180. readonly renderList: Nullable<AbstractMesh[]>;
  119181. /**
  119182. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  119183. * @param mesh defines the mesh to attach to
  119184. */
  119185. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  119186. /**
  119187. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  119188. * @param renderingGroupId The rendering group id corresponding to its index
  119189. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119190. */
  119191. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119192. /**
  119193. * Clean all associated resources
  119194. */
  119195. dispose(): void;
  119196. /**
  119197. * Converts the reflection probe information to a readable string for debug purpose.
  119198. * @param fullDetails Supports for multiple levels of logging within scene loading
  119199. * @returns the human readable reflection probe info
  119200. */
  119201. toString(fullDetails?: boolean): string;
  119202. /**
  119203. * Get the class name of the relfection probe.
  119204. * @returns "ReflectionProbe"
  119205. */
  119206. getClassName(): string;
  119207. /**
  119208. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  119209. * @returns The JSON representation of the texture
  119210. */
  119211. serialize(): any;
  119212. /**
  119213. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  119214. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  119215. * @param scene Define the scene the parsed reflection probe should be instantiated in
  119216. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  119217. * @returns The parsed reflection probe if successful
  119218. */
  119219. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  119220. }
  119221. }
  119222. declare module BABYLON {
  119223. /** @hidden */
  119224. export var _BabylonLoaderRegistered: boolean;
  119225. }
  119226. declare module BABYLON {
  119227. /**
  119228. * The Physically based simple base material of BJS.
  119229. *
  119230. * This enables better naming and convention enforcements on top of the pbrMaterial.
  119231. * It is used as the base class for both the specGloss and metalRough conventions.
  119232. */
  119233. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  119234. /**
  119235. * Number of Simultaneous lights allowed on the material.
  119236. */
  119237. maxSimultaneousLights: number;
  119238. /**
  119239. * If sets to true, disables all the lights affecting the material.
  119240. */
  119241. disableLighting: boolean;
  119242. /**
  119243. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  119244. */
  119245. environmentTexture: BaseTexture;
  119246. /**
  119247. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  119248. */
  119249. invertNormalMapX: boolean;
  119250. /**
  119251. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  119252. */
  119253. invertNormalMapY: boolean;
  119254. /**
  119255. * Normal map used in the model.
  119256. */
  119257. normalTexture: BaseTexture;
  119258. /**
  119259. * Emissivie color used to self-illuminate the model.
  119260. */
  119261. emissiveColor: Color3;
  119262. /**
  119263. * Emissivie texture used to self-illuminate the model.
  119264. */
  119265. emissiveTexture: BaseTexture;
  119266. /**
  119267. * Occlusion Channel Strenght.
  119268. */
  119269. occlusionStrength: number;
  119270. /**
  119271. * Occlusion Texture of the material (adding extra occlusion effects).
  119272. */
  119273. occlusionTexture: BaseTexture;
  119274. /**
  119275. * Defines the alpha limits in alpha test mode.
  119276. */
  119277. alphaCutOff: number;
  119278. /**
  119279. * Gets the current double sided mode.
  119280. */
  119281. /**
  119282. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  119283. */
  119284. doubleSided: boolean;
  119285. /**
  119286. * Stores the pre-calculated light information of a mesh in a texture.
  119287. */
  119288. lightmapTexture: BaseTexture;
  119289. /**
  119290. * If true, the light map contains occlusion information instead of lighting info.
  119291. */
  119292. useLightmapAsShadowmap: boolean;
  119293. /**
  119294. * Instantiates a new PBRMaterial instance.
  119295. *
  119296. * @param name The material name
  119297. * @param scene The scene the material will be use in.
  119298. */
  119299. constructor(name: string, scene: Scene);
  119300. getClassName(): string;
  119301. }
  119302. }
  119303. declare module BABYLON {
  119304. /**
  119305. * The PBR material of BJS following the metal roughness convention.
  119306. *
  119307. * This fits to the PBR convention in the GLTF definition:
  119308. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  119309. */
  119310. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  119311. /**
  119312. * The base color has two different interpretations depending on the value of metalness.
  119313. * When the material is a metal, the base color is the specific measured reflectance value
  119314. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  119315. * of the material.
  119316. */
  119317. baseColor: Color3;
  119318. /**
  119319. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  119320. * well as opacity information in the alpha channel.
  119321. */
  119322. baseTexture: BaseTexture;
  119323. /**
  119324. * Specifies the metallic scalar value of the material.
  119325. * Can also be used to scale the metalness values of the metallic texture.
  119326. */
  119327. metallic: number;
  119328. /**
  119329. * Specifies the roughness scalar value of the material.
  119330. * Can also be used to scale the roughness values of the metallic texture.
  119331. */
  119332. roughness: number;
  119333. /**
  119334. * Texture containing both the metallic value in the B channel and the
  119335. * roughness value in the G channel to keep better precision.
  119336. */
  119337. metallicRoughnessTexture: BaseTexture;
  119338. /**
  119339. * Instantiates a new PBRMetalRoughnessMaterial instance.
  119340. *
  119341. * @param name The material name
  119342. * @param scene The scene the material will be use in.
  119343. */
  119344. constructor(name: string, scene: Scene);
  119345. /**
  119346. * Return the currrent class name of the material.
  119347. */
  119348. getClassName(): string;
  119349. /**
  119350. * Makes a duplicate of the current material.
  119351. * @param name - name to use for the new material.
  119352. */
  119353. clone(name: string): PBRMetallicRoughnessMaterial;
  119354. /**
  119355. * Serialize the material to a parsable JSON object.
  119356. */
  119357. serialize(): any;
  119358. /**
  119359. * Parses a JSON object correponding to the serialize function.
  119360. */
  119361. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  119362. }
  119363. }
  119364. declare module BABYLON {
  119365. /**
  119366. * The PBR material of BJS following the specular glossiness convention.
  119367. *
  119368. * This fits to the PBR convention in the GLTF definition:
  119369. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  119370. */
  119371. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  119372. /**
  119373. * Specifies the diffuse color of the material.
  119374. */
  119375. diffuseColor: Color3;
  119376. /**
  119377. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  119378. * channel.
  119379. */
  119380. diffuseTexture: BaseTexture;
  119381. /**
  119382. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  119383. */
  119384. specularColor: Color3;
  119385. /**
  119386. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  119387. */
  119388. glossiness: number;
  119389. /**
  119390. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  119391. */
  119392. specularGlossinessTexture: BaseTexture;
  119393. /**
  119394. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  119395. *
  119396. * @param name The material name
  119397. * @param scene The scene the material will be use in.
  119398. */
  119399. constructor(name: string, scene: Scene);
  119400. /**
  119401. * Return the currrent class name of the material.
  119402. */
  119403. getClassName(): string;
  119404. /**
  119405. * Makes a duplicate of the current material.
  119406. * @param name - name to use for the new material.
  119407. */
  119408. clone(name: string): PBRSpecularGlossinessMaterial;
  119409. /**
  119410. * Serialize the material to a parsable JSON object.
  119411. */
  119412. serialize(): any;
  119413. /**
  119414. * Parses a JSON object correponding to the serialize function.
  119415. */
  119416. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  119417. }
  119418. }
  119419. declare module BABYLON {
  119420. /**
  119421. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  119422. * It can help converting any input color in a desired output one. This can then be used to create effects
  119423. * from sepia, black and white to sixties or futuristic rendering...
  119424. *
  119425. * The only supported format is currently 3dl.
  119426. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  119427. */
  119428. export class ColorGradingTexture extends BaseTexture {
  119429. /**
  119430. * The current texture matrix. (will always be identity in color grading texture)
  119431. */
  119432. private _textureMatrix;
  119433. /**
  119434. * The texture URL.
  119435. */
  119436. url: string;
  119437. /**
  119438. * Empty line regex stored for GC.
  119439. */
  119440. private static _noneEmptyLineRegex;
  119441. private _engine;
  119442. /**
  119443. * Instantiates a ColorGradingTexture from the following parameters.
  119444. *
  119445. * @param url The location of the color gradind data (currently only supporting 3dl)
  119446. * @param scene The scene the texture will be used in
  119447. */
  119448. constructor(url: string, scene: Scene);
  119449. /**
  119450. * Returns the texture matrix used in most of the material.
  119451. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  119452. */
  119453. getTextureMatrix(): Matrix;
  119454. /**
  119455. * Occurs when the file being loaded is a .3dl LUT file.
  119456. */
  119457. private load3dlTexture;
  119458. /**
  119459. * Starts the loading process of the texture.
  119460. */
  119461. private loadTexture;
  119462. /**
  119463. * Clones the color gradind texture.
  119464. */
  119465. clone(): ColorGradingTexture;
  119466. /**
  119467. * Called during delayed load for textures.
  119468. */
  119469. delayLoad(): void;
  119470. /**
  119471. * Parses a color grading texture serialized by Babylon.
  119472. * @param parsedTexture The texture information being parsedTexture
  119473. * @param scene The scene to load the texture in
  119474. * @param rootUrl The root url of the data assets to load
  119475. * @return A color gradind texture
  119476. */
  119477. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  119478. /**
  119479. * Serializes the LUT texture to json format.
  119480. */
  119481. serialize(): any;
  119482. }
  119483. }
  119484. declare module BABYLON {
  119485. /**
  119486. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  119487. */
  119488. export class EquiRectangularCubeTexture extends BaseTexture {
  119489. /** The six faces of the cube. */
  119490. private static _FacesMapping;
  119491. private _noMipmap;
  119492. private _onLoad;
  119493. private _onError;
  119494. /** The size of the cubemap. */
  119495. private _size;
  119496. /** The buffer of the image. */
  119497. private _buffer;
  119498. /** The width of the input image. */
  119499. private _width;
  119500. /** The height of the input image. */
  119501. private _height;
  119502. /** The URL to the image. */
  119503. url: string;
  119504. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  119505. coordinatesMode: number;
  119506. /**
  119507. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  119508. * @param url The location of the image
  119509. * @param scene The scene the texture will be used in
  119510. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119511. * @param noMipmap Forces to not generate the mipmap if true
  119512. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  119513. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  119514. * @param onLoad — defines a callback called when texture is loaded
  119515. * @param onError — defines a callback called if there is an error
  119516. */
  119517. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  119518. /**
  119519. * Load the image data, by putting the image on a canvas and extracting its buffer.
  119520. */
  119521. private loadImage;
  119522. /**
  119523. * Convert the image buffer into a cubemap and create a CubeTexture.
  119524. */
  119525. private loadTexture;
  119526. /**
  119527. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  119528. * @param buffer The ArrayBuffer that should be converted.
  119529. * @returns The buffer as Float32Array.
  119530. */
  119531. private getFloat32ArrayFromArrayBuffer;
  119532. /**
  119533. * Get the current class name of the texture useful for serialization or dynamic coding.
  119534. * @returns "EquiRectangularCubeTexture"
  119535. */
  119536. getClassName(): string;
  119537. /**
  119538. * Create a clone of the current EquiRectangularCubeTexture and return it.
  119539. * @returns A clone of the current EquiRectangularCubeTexture.
  119540. */
  119541. clone(): EquiRectangularCubeTexture;
  119542. }
  119543. }
  119544. declare module BABYLON {
  119545. /**
  119546. * Based on jsTGALoader - Javascript loader for TGA file
  119547. * By Vincent Thibault
  119548. * @see http://blog.robrowser.com/javascript-tga-loader.html
  119549. */
  119550. export class TGATools {
  119551. private static _TYPE_INDEXED;
  119552. private static _TYPE_RGB;
  119553. private static _TYPE_GREY;
  119554. private static _TYPE_RLE_INDEXED;
  119555. private static _TYPE_RLE_RGB;
  119556. private static _TYPE_RLE_GREY;
  119557. private static _ORIGIN_MASK;
  119558. private static _ORIGIN_SHIFT;
  119559. private static _ORIGIN_BL;
  119560. private static _ORIGIN_BR;
  119561. private static _ORIGIN_UL;
  119562. private static _ORIGIN_UR;
  119563. /**
  119564. * Gets the header of a TGA file
  119565. * @param data defines the TGA data
  119566. * @returns the header
  119567. */
  119568. static GetTGAHeader(data: Uint8Array): any;
  119569. /**
  119570. * Uploads TGA content to a Babylon Texture
  119571. * @hidden
  119572. */
  119573. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  119574. /** @hidden */
  119575. 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;
  119576. /** @hidden */
  119577. 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;
  119578. /** @hidden */
  119579. 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;
  119580. /** @hidden */
  119581. 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;
  119582. /** @hidden */
  119583. 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;
  119584. /** @hidden */
  119585. 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;
  119586. }
  119587. }
  119588. declare module BABYLON {
  119589. /**
  119590. * Implementation of the TGA Texture Loader.
  119591. * @hidden
  119592. */
  119593. export class _TGATextureLoader implements IInternalTextureLoader {
  119594. /**
  119595. * Defines wether the loader supports cascade loading the different faces.
  119596. */
  119597. readonly supportCascades: boolean;
  119598. /**
  119599. * This returns if the loader support the current file information.
  119600. * @param extension defines the file extension of the file being loaded
  119601. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119602. * @param fallback defines the fallback internal texture if any
  119603. * @param isBase64 defines whether the texture is encoded as a base64
  119604. * @param isBuffer defines whether the texture data are stored as a buffer
  119605. * @returns true if the loader can load the specified file
  119606. */
  119607. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119608. /**
  119609. * Transform the url before loading if required.
  119610. * @param rootUrl the url of the texture
  119611. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119612. * @returns the transformed texture
  119613. */
  119614. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119615. /**
  119616. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119617. * @param rootUrl the url of the texture
  119618. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119619. * @returns the fallback texture
  119620. */
  119621. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119622. /**
  119623. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119624. * @param data contains the texture data
  119625. * @param texture defines the BabylonJS internal texture
  119626. * @param createPolynomials will be true if polynomials have been requested
  119627. * @param onLoad defines the callback to trigger once the texture is ready
  119628. * @param onError defines the callback to trigger in case of error
  119629. */
  119630. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119631. /**
  119632. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119633. * @param data contains the texture data
  119634. * @param texture defines the BabylonJS internal texture
  119635. * @param callback defines the method to call once ready to upload
  119636. */
  119637. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119638. }
  119639. }
  119640. declare module BABYLON {
  119641. /**
  119642. * Info about the .basis files
  119643. */
  119644. class BasisFileInfo {
  119645. /**
  119646. * If the file has alpha
  119647. */
  119648. hasAlpha: boolean;
  119649. /**
  119650. * Info about each image of the basis file
  119651. */
  119652. images: Array<{
  119653. levels: Array<{
  119654. width: number;
  119655. height: number;
  119656. transcodedPixels: ArrayBufferView;
  119657. }>;
  119658. }>;
  119659. }
  119660. /**
  119661. * Result of transcoding a basis file
  119662. */
  119663. class TranscodeResult {
  119664. /**
  119665. * Info about the .basis file
  119666. */
  119667. fileInfo: BasisFileInfo;
  119668. /**
  119669. * Format to use when loading the file
  119670. */
  119671. format: number;
  119672. }
  119673. /**
  119674. * Configuration options for the Basis transcoder
  119675. */
  119676. export class BasisTranscodeConfiguration {
  119677. /**
  119678. * Supported compression formats used to determine the supported output format of the transcoder
  119679. */
  119680. supportedCompressionFormats?: {
  119681. /**
  119682. * etc1 compression format
  119683. */
  119684. etc1?: boolean;
  119685. /**
  119686. * s3tc compression format
  119687. */
  119688. s3tc?: boolean;
  119689. /**
  119690. * pvrtc compression format
  119691. */
  119692. pvrtc?: boolean;
  119693. /**
  119694. * etc2 compression format
  119695. */
  119696. etc2?: boolean;
  119697. };
  119698. /**
  119699. * If mipmap levels should be loaded for transcoded images (Default: true)
  119700. */
  119701. loadMipmapLevels?: boolean;
  119702. /**
  119703. * Index of a single image to load (Default: all images)
  119704. */
  119705. loadSingleImage?: number;
  119706. }
  119707. /**
  119708. * Used to load .Basis files
  119709. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  119710. */
  119711. export class BasisTools {
  119712. private static _IgnoreSupportedFormats;
  119713. /**
  119714. * URL to use when loading the basis transcoder
  119715. */
  119716. static JSModuleURL: string;
  119717. /**
  119718. * URL to use when loading the wasm module for the transcoder
  119719. */
  119720. static WasmModuleURL: string;
  119721. /**
  119722. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  119723. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  119724. * @returns internal format corresponding to the Basis format
  119725. */
  119726. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  119727. private static _WorkerPromise;
  119728. private static _Worker;
  119729. private static _actionId;
  119730. private static _CreateWorkerAsync;
  119731. /**
  119732. * Transcodes a loaded image file to compressed pixel data
  119733. * @param imageData image data to transcode
  119734. * @param config configuration options for the transcoding
  119735. * @returns a promise resulting in the transcoded image
  119736. */
  119737. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  119738. /**
  119739. * Loads a texture from the transcode result
  119740. * @param texture texture load to
  119741. * @param transcodeResult the result of transcoding the basis file to load from
  119742. */
  119743. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119744. }
  119745. }
  119746. declare module BABYLON {
  119747. /**
  119748. * Loader for .basis file format
  119749. */
  119750. export class _BasisTextureLoader implements IInternalTextureLoader {
  119751. /**
  119752. * Defines whether the loader supports cascade loading the different faces.
  119753. */
  119754. readonly supportCascades: boolean;
  119755. /**
  119756. * This returns if the loader support the current file information.
  119757. * @param extension defines the file extension of the file being loaded
  119758. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119759. * @param fallback defines the fallback internal texture if any
  119760. * @param isBase64 defines whether the texture is encoded as a base64
  119761. * @param isBuffer defines whether the texture data are stored as a buffer
  119762. * @returns true if the loader can load the specified file
  119763. */
  119764. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119765. /**
  119766. * Transform the url before loading if required.
  119767. * @param rootUrl the url of the texture
  119768. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119769. * @returns the transformed texture
  119770. */
  119771. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119772. /**
  119773. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119774. * @param rootUrl the url of the texture
  119775. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119776. * @returns the fallback texture
  119777. */
  119778. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119779. /**
  119780. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119781. * @param data contains the texture data
  119782. * @param texture defines the BabylonJS internal texture
  119783. * @param createPolynomials will be true if polynomials have been requested
  119784. * @param onLoad defines the callback to trigger once the texture is ready
  119785. * @param onError defines the callback to trigger in case of error
  119786. */
  119787. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119788. /**
  119789. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119790. * @param data contains the texture data
  119791. * @param texture defines the BabylonJS internal texture
  119792. * @param callback defines the method to call once ready to upload
  119793. */
  119794. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119795. }
  119796. }
  119797. declare module BABYLON {
  119798. /**
  119799. * 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.
  119800. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119801. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119802. */
  119803. export class CustomProceduralTexture extends ProceduralTexture {
  119804. private _animate;
  119805. private _time;
  119806. private _config;
  119807. private _texturePath;
  119808. /**
  119809. * Instantiates a new Custom Procedural Texture.
  119810. * 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.
  119811. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119812. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119813. * @param name Define the name of the texture
  119814. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119815. * @param size Define the size of the texture to create
  119816. * @param scene Define the scene the texture belongs to
  119817. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119818. * @param generateMipMaps Define if the texture should creates mip maps or not
  119819. */
  119820. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119821. private _loadJson;
  119822. /**
  119823. * Is the texture ready to be used ? (rendered at least once)
  119824. * @returns true if ready, otherwise, false.
  119825. */
  119826. isReady(): boolean;
  119827. /**
  119828. * Render the texture to its associated render target.
  119829. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119830. */
  119831. render(useCameraPostProcess?: boolean): void;
  119832. /**
  119833. * Update the list of dependant textures samplers in the shader.
  119834. */
  119835. updateTextures(): void;
  119836. /**
  119837. * Update the uniform values of the procedural texture in the shader.
  119838. */
  119839. updateShaderUniforms(): void;
  119840. /**
  119841. * Define if the texture animates or not.
  119842. */
  119843. animate: boolean;
  119844. }
  119845. }
  119846. declare module BABYLON {
  119847. /** @hidden */
  119848. export var noisePixelShader: {
  119849. name: string;
  119850. shader: string;
  119851. };
  119852. }
  119853. declare module BABYLON {
  119854. /**
  119855. * Class used to generate noise procedural textures
  119856. */
  119857. export class NoiseProceduralTexture extends ProceduralTexture {
  119858. private _time;
  119859. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119860. brightness: number;
  119861. /** Defines the number of octaves to process */
  119862. octaves: number;
  119863. /** Defines the level of persistence (0.8 by default) */
  119864. persistence: number;
  119865. /** Gets or sets animation speed factor (default is 1) */
  119866. animationSpeedFactor: number;
  119867. /**
  119868. * Creates a new NoiseProceduralTexture
  119869. * @param name defines the name fo the texture
  119870. * @param size defines the size of the texture (default is 256)
  119871. * @param scene defines the hosting scene
  119872. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119873. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119874. */
  119875. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119876. private _updateShaderUniforms;
  119877. protected _getDefines(): string;
  119878. /** Generate the current state of the procedural texture */
  119879. render(useCameraPostProcess?: boolean): void;
  119880. /**
  119881. * Serializes this noise procedural texture
  119882. * @returns a serialized noise procedural texture object
  119883. */
  119884. serialize(): any;
  119885. /**
  119886. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119887. * @param parsedTexture defines parsed texture data
  119888. * @param scene defines the current scene
  119889. * @param rootUrl defines the root URL containing noise procedural texture information
  119890. * @returns a parsed NoiseProceduralTexture
  119891. */
  119892. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119893. }
  119894. }
  119895. declare module BABYLON {
  119896. /**
  119897. * Raw cube texture where the raw buffers are passed in
  119898. */
  119899. export class RawCubeTexture extends CubeTexture {
  119900. /**
  119901. * Creates a cube texture where the raw buffers are passed in.
  119902. * @param scene defines the scene the texture is attached to
  119903. * @param data defines the array of data to use to create each face
  119904. * @param size defines the size of the textures
  119905. * @param format defines the format of the data
  119906. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119907. * @param generateMipMaps defines if the engine should generate the mip levels
  119908. * @param invertY defines if data must be stored with Y axis inverted
  119909. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119910. * @param compression defines the compression used (null by default)
  119911. */
  119912. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119913. /**
  119914. * Updates the raw cube texture.
  119915. * @param data defines the data to store
  119916. * @param format defines the data format
  119917. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119918. * @param invertY defines if data must be stored with Y axis inverted
  119919. * @param compression defines the compression used (null by default)
  119920. * @param level defines which level of the texture to update
  119921. */
  119922. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119923. /**
  119924. * Updates a raw cube texture with RGBD encoded data.
  119925. * @param data defines the array of data [mipmap][face] to use to create each face
  119926. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119927. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119928. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119929. * @returns a promsie that resolves when the operation is complete
  119930. */
  119931. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119932. /**
  119933. * Clones the raw cube texture.
  119934. * @return a new cube texture
  119935. */
  119936. clone(): CubeTexture;
  119937. /** @hidden */
  119938. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119939. }
  119940. }
  119941. declare module BABYLON {
  119942. /**
  119943. * Class used to store 3D textures containing user data
  119944. */
  119945. export class RawTexture3D extends Texture {
  119946. /** Gets or sets the texture format to use */
  119947. format: number;
  119948. private _engine;
  119949. /**
  119950. * Create a new RawTexture3D
  119951. * @param data defines the data of the texture
  119952. * @param width defines the width of the texture
  119953. * @param height defines the height of the texture
  119954. * @param depth defines the depth of the texture
  119955. * @param format defines the texture format to use
  119956. * @param scene defines the hosting scene
  119957. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119958. * @param invertY defines if texture must be stored with Y axis inverted
  119959. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119960. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119961. */
  119962. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119963. /** Gets or sets the texture format to use */
  119964. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119965. /**
  119966. * Update the texture with new data
  119967. * @param data defines the data to store in the texture
  119968. */
  119969. update(data: ArrayBufferView): void;
  119970. }
  119971. }
  119972. declare module BABYLON {
  119973. /**
  119974. * Creates a refraction texture used by refraction channel of the standard material.
  119975. * It is like a mirror but to see through a material.
  119976. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119977. */
  119978. export class RefractionTexture extends RenderTargetTexture {
  119979. /**
  119980. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119981. * 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.
  119982. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119983. */
  119984. refractionPlane: Plane;
  119985. /**
  119986. * Define how deep under the surface we should see.
  119987. */
  119988. depth: number;
  119989. /**
  119990. * Creates a refraction texture used by refraction channel of the standard material.
  119991. * It is like a mirror but to see through a material.
  119992. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119993. * @param name Define the texture name
  119994. * @param size Define the size of the underlying texture
  119995. * @param scene Define the scene the refraction belongs to
  119996. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119997. */
  119998. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119999. /**
  120000. * Clone the refraction texture.
  120001. * @returns the cloned texture
  120002. */
  120003. clone(): RefractionTexture;
  120004. /**
  120005. * Serialize the texture to a JSON representation you could use in Parse later on
  120006. * @returns the serialized JSON representation
  120007. */
  120008. serialize(): any;
  120009. }
  120010. }
  120011. declare module BABYLON {
  120012. /**
  120013. * Defines the options related to the creation of an HtmlElementTexture
  120014. */
  120015. export interface IHtmlElementTextureOptions {
  120016. /**
  120017. * Defines wether mip maps should be created or not.
  120018. */
  120019. generateMipMaps?: boolean;
  120020. /**
  120021. * Defines the sampling mode of the texture.
  120022. */
  120023. samplingMode?: number;
  120024. /**
  120025. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  120026. */
  120027. engine: Nullable<ThinEngine>;
  120028. /**
  120029. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  120030. */
  120031. scene: Nullable<Scene>;
  120032. }
  120033. /**
  120034. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  120035. * To be as efficient as possible depending on your constraints nothing aside the first upload
  120036. * is automatically managed.
  120037. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  120038. * in your application.
  120039. *
  120040. * As the update is not automatic, you need to call them manually.
  120041. */
  120042. export class HtmlElementTexture extends BaseTexture {
  120043. /**
  120044. * The texture URL.
  120045. */
  120046. element: HTMLVideoElement | HTMLCanvasElement;
  120047. private static readonly DefaultOptions;
  120048. private _textureMatrix;
  120049. private _engine;
  120050. private _isVideo;
  120051. private _generateMipMaps;
  120052. private _samplingMode;
  120053. /**
  120054. * Instantiates a HtmlElementTexture from the following parameters.
  120055. *
  120056. * @param name Defines the name of the texture
  120057. * @param element Defines the video or canvas the texture is filled with
  120058. * @param options Defines the other none mandatory texture creation options
  120059. */
  120060. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  120061. private _createInternalTexture;
  120062. /**
  120063. * Returns the texture matrix used in most of the material.
  120064. */
  120065. getTextureMatrix(): Matrix;
  120066. /**
  120067. * Updates the content of the texture.
  120068. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  120069. */
  120070. update(invertY?: Nullable<boolean>): void;
  120071. }
  120072. }
  120073. declare module BABYLON {
  120074. /**
  120075. * Enum used to define the target of a block
  120076. */
  120077. export enum NodeMaterialBlockTargets {
  120078. /** Vertex shader */
  120079. Vertex = 1,
  120080. /** Fragment shader */
  120081. Fragment = 2,
  120082. /** Neutral */
  120083. Neutral = 4,
  120084. /** Vertex and Fragment */
  120085. VertexAndFragment = 3
  120086. }
  120087. }
  120088. declare module BABYLON {
  120089. /**
  120090. * Defines the kind of connection point for node based material
  120091. */
  120092. export enum NodeMaterialBlockConnectionPointTypes {
  120093. /** Float */
  120094. Float = 1,
  120095. /** Int */
  120096. Int = 2,
  120097. /** Vector2 */
  120098. Vector2 = 4,
  120099. /** Vector3 */
  120100. Vector3 = 8,
  120101. /** Vector4 */
  120102. Vector4 = 16,
  120103. /** Color3 */
  120104. Color3 = 32,
  120105. /** Color4 */
  120106. Color4 = 64,
  120107. /** Matrix */
  120108. Matrix = 128,
  120109. /** Detect type based on connection */
  120110. AutoDetect = 1024,
  120111. /** Output type that will be defined by input type */
  120112. BasedOnInput = 2048
  120113. }
  120114. }
  120115. declare module BABYLON {
  120116. /**
  120117. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  120118. */
  120119. export enum NodeMaterialBlockConnectionPointMode {
  120120. /** Value is an uniform */
  120121. Uniform = 0,
  120122. /** Value is a mesh attribute */
  120123. Attribute = 1,
  120124. /** Value is a varying between vertex and fragment shaders */
  120125. Varying = 2,
  120126. /** Mode is undefined */
  120127. Undefined = 3
  120128. }
  120129. }
  120130. declare module BABYLON {
  120131. /**
  120132. * Enum used to define system values e.g. values automatically provided by the system
  120133. */
  120134. export enum NodeMaterialSystemValues {
  120135. /** World */
  120136. World = 1,
  120137. /** View */
  120138. View = 2,
  120139. /** Projection */
  120140. Projection = 3,
  120141. /** ViewProjection */
  120142. ViewProjection = 4,
  120143. /** WorldView */
  120144. WorldView = 5,
  120145. /** WorldViewProjection */
  120146. WorldViewProjection = 6,
  120147. /** CameraPosition */
  120148. CameraPosition = 7,
  120149. /** Fog Color */
  120150. FogColor = 8,
  120151. /** Delta time */
  120152. DeltaTime = 9
  120153. }
  120154. }
  120155. declare module BABYLON {
  120156. /**
  120157. * Root class for all node material optimizers
  120158. */
  120159. export class NodeMaterialOptimizer {
  120160. /**
  120161. * Function used to optimize a NodeMaterial graph
  120162. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  120163. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  120164. */
  120165. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  120166. }
  120167. }
  120168. declare module BABYLON {
  120169. /**
  120170. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  120171. */
  120172. export class TransformBlock extends NodeMaterialBlock {
  120173. /**
  120174. * Defines the value to use to complement W value to transform it to a Vector4
  120175. */
  120176. complementW: number;
  120177. /**
  120178. * Defines the value to use to complement z value to transform it to a Vector4
  120179. */
  120180. complementZ: number;
  120181. /**
  120182. * Creates a new TransformBlock
  120183. * @param name defines the block name
  120184. */
  120185. constructor(name: string);
  120186. /**
  120187. * Gets the current class name
  120188. * @returns the class name
  120189. */
  120190. getClassName(): string;
  120191. /**
  120192. * Gets the vector input
  120193. */
  120194. readonly vector: NodeMaterialConnectionPoint;
  120195. /**
  120196. * Gets the output component
  120197. */
  120198. readonly output: NodeMaterialConnectionPoint;
  120199. /**
  120200. * Gets the matrix transform input
  120201. */
  120202. readonly transform: NodeMaterialConnectionPoint;
  120203. protected _buildBlock(state: NodeMaterialBuildState): this;
  120204. serialize(): any;
  120205. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120206. protected _dumpPropertiesCode(): string;
  120207. }
  120208. }
  120209. declare module BABYLON {
  120210. /**
  120211. * Block used to output the vertex position
  120212. */
  120213. export class VertexOutputBlock extends NodeMaterialBlock {
  120214. /**
  120215. * Creates a new VertexOutputBlock
  120216. * @param name defines the block name
  120217. */
  120218. constructor(name: string);
  120219. /**
  120220. * Gets the current class name
  120221. * @returns the class name
  120222. */
  120223. getClassName(): string;
  120224. /**
  120225. * Gets the vector input component
  120226. */
  120227. readonly vector: NodeMaterialConnectionPoint;
  120228. protected _buildBlock(state: NodeMaterialBuildState): this;
  120229. }
  120230. }
  120231. declare module BABYLON {
  120232. /**
  120233. * Block used to output the final color
  120234. */
  120235. export class FragmentOutputBlock extends NodeMaterialBlock {
  120236. /**
  120237. * Create a new FragmentOutputBlock
  120238. * @param name defines the block name
  120239. */
  120240. constructor(name: string);
  120241. /**
  120242. * Gets the current class name
  120243. * @returns the class name
  120244. */
  120245. getClassName(): string;
  120246. /**
  120247. * Gets the rgba input component
  120248. */
  120249. readonly rgba: NodeMaterialConnectionPoint;
  120250. /**
  120251. * Gets the rgb input component
  120252. */
  120253. readonly rgb: NodeMaterialConnectionPoint;
  120254. /**
  120255. * Gets the a input component
  120256. */
  120257. readonly a: NodeMaterialConnectionPoint;
  120258. protected _buildBlock(state: NodeMaterialBuildState): this;
  120259. }
  120260. }
  120261. declare module BABYLON {
  120262. /**
  120263. * Block used to read a reflection texture from a sampler
  120264. */
  120265. export class ReflectionTextureBlock extends NodeMaterialBlock {
  120266. private _define3DName;
  120267. private _defineCubicName;
  120268. private _defineExplicitName;
  120269. private _defineProjectionName;
  120270. private _defineLocalCubicName;
  120271. private _defineSphericalName;
  120272. private _definePlanarName;
  120273. private _defineEquirectangularName;
  120274. private _defineMirroredEquirectangularFixedName;
  120275. private _defineEquirectangularFixedName;
  120276. private _defineSkyboxName;
  120277. private _cubeSamplerName;
  120278. private _2DSamplerName;
  120279. private _positionUVWName;
  120280. private _directionWName;
  120281. private _reflectionCoordsName;
  120282. private _reflection2DCoordsName;
  120283. private _reflectionColorName;
  120284. private _reflectionMatrixName;
  120285. /**
  120286. * Gets or sets the texture associated with the node
  120287. */
  120288. texture: Nullable<BaseTexture>;
  120289. /**
  120290. * Create a new TextureBlock
  120291. * @param name defines the block name
  120292. */
  120293. constructor(name: string);
  120294. /**
  120295. * Gets the current class name
  120296. * @returns the class name
  120297. */
  120298. getClassName(): string;
  120299. /**
  120300. * Gets the world position input component
  120301. */
  120302. readonly position: NodeMaterialConnectionPoint;
  120303. /**
  120304. * Gets the world position input component
  120305. */
  120306. readonly worldPosition: NodeMaterialConnectionPoint;
  120307. /**
  120308. * Gets the world normal input component
  120309. */
  120310. readonly worldNormal: NodeMaterialConnectionPoint;
  120311. /**
  120312. * Gets the world input component
  120313. */
  120314. readonly world: NodeMaterialConnectionPoint;
  120315. /**
  120316. * Gets the camera (or eye) position component
  120317. */
  120318. readonly cameraPosition: NodeMaterialConnectionPoint;
  120319. /**
  120320. * Gets the view input component
  120321. */
  120322. readonly view: NodeMaterialConnectionPoint;
  120323. /**
  120324. * Gets the rgb output component
  120325. */
  120326. readonly rgb: NodeMaterialConnectionPoint;
  120327. /**
  120328. * Gets the r output component
  120329. */
  120330. readonly r: NodeMaterialConnectionPoint;
  120331. /**
  120332. * Gets the g output component
  120333. */
  120334. readonly g: NodeMaterialConnectionPoint;
  120335. /**
  120336. * Gets the b output component
  120337. */
  120338. readonly b: NodeMaterialConnectionPoint;
  120339. autoConfigure(material: NodeMaterial): void;
  120340. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120341. isReady(): boolean;
  120342. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120343. private _injectVertexCode;
  120344. private _writeOutput;
  120345. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120346. serialize(): any;
  120347. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120348. }
  120349. }
  120350. declare module BABYLON {
  120351. /**
  120352. * Interface used to configure the node material editor
  120353. */
  120354. export interface INodeMaterialEditorOptions {
  120355. /** Define the URl to load node editor script */
  120356. editorURL?: string;
  120357. }
  120358. /** @hidden */
  120359. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  120360. /** BONES */
  120361. NUM_BONE_INFLUENCERS: number;
  120362. BonesPerMesh: number;
  120363. BONETEXTURE: boolean;
  120364. /** MORPH TARGETS */
  120365. MORPHTARGETS: boolean;
  120366. MORPHTARGETS_NORMAL: boolean;
  120367. MORPHTARGETS_TANGENT: boolean;
  120368. MORPHTARGETS_UV: boolean;
  120369. NUM_MORPH_INFLUENCERS: number;
  120370. /** IMAGE PROCESSING */
  120371. IMAGEPROCESSING: boolean;
  120372. VIGNETTE: boolean;
  120373. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120374. VIGNETTEBLENDMODEOPAQUE: boolean;
  120375. TONEMAPPING: boolean;
  120376. TONEMAPPING_ACES: boolean;
  120377. CONTRAST: boolean;
  120378. EXPOSURE: boolean;
  120379. COLORCURVES: boolean;
  120380. COLORGRADING: boolean;
  120381. COLORGRADING3D: boolean;
  120382. SAMPLER3DGREENDEPTH: boolean;
  120383. SAMPLER3DBGRMAP: boolean;
  120384. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120385. /** MISC. */
  120386. BUMPDIRECTUV: number;
  120387. constructor();
  120388. setValue(name: string, value: boolean): void;
  120389. }
  120390. /**
  120391. * Class used to configure NodeMaterial
  120392. */
  120393. export interface INodeMaterialOptions {
  120394. /**
  120395. * Defines if blocks should emit comments
  120396. */
  120397. emitComments: boolean;
  120398. }
  120399. /**
  120400. * Class used to create a node based material built by assembling shader blocks
  120401. */
  120402. export class NodeMaterial extends PushMaterial {
  120403. private static _BuildIdGenerator;
  120404. private _options;
  120405. private _vertexCompilationState;
  120406. private _fragmentCompilationState;
  120407. private _sharedData;
  120408. private _buildId;
  120409. private _buildWasSuccessful;
  120410. private _cachedWorldViewMatrix;
  120411. private _cachedWorldViewProjectionMatrix;
  120412. private _optimizers;
  120413. private _animationFrame;
  120414. /** Define the URl to load node editor script */
  120415. static EditorURL: string;
  120416. private BJSNODEMATERIALEDITOR;
  120417. /** Get the inspector from bundle or global */
  120418. private _getGlobalNodeMaterialEditor;
  120419. /**
  120420. * 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)
  120421. */
  120422. ignoreAlpha: boolean;
  120423. /**
  120424. * Defines the maximum number of lights that can be used in the material
  120425. */
  120426. maxSimultaneousLights: number;
  120427. /**
  120428. * Observable raised when the material is built
  120429. */
  120430. onBuildObservable: Observable<NodeMaterial>;
  120431. /**
  120432. * Gets or sets the root nodes of the material vertex shader
  120433. */
  120434. _vertexOutputNodes: NodeMaterialBlock[];
  120435. /**
  120436. * Gets or sets the root nodes of the material fragment (pixel) shader
  120437. */
  120438. _fragmentOutputNodes: NodeMaterialBlock[];
  120439. /** Gets or sets options to control the node material overall behavior */
  120440. options: INodeMaterialOptions;
  120441. /**
  120442. * Default configuration related to image processing available in the standard Material.
  120443. */
  120444. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120445. /**
  120446. * Gets the image processing configuration used either in this material.
  120447. */
  120448. /**
  120449. * Sets the Default image processing configuration used either in the this material.
  120450. *
  120451. * If sets to null, the scene one is in use.
  120452. */
  120453. imageProcessingConfiguration: ImageProcessingConfiguration;
  120454. /**
  120455. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  120456. */
  120457. attachedBlocks: NodeMaterialBlock[];
  120458. /**
  120459. * Create a new node based material
  120460. * @param name defines the material name
  120461. * @param scene defines the hosting scene
  120462. * @param options defines creation option
  120463. */
  120464. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  120465. /**
  120466. * Gets the current class name of the material e.g. "NodeMaterial"
  120467. * @returns the class name
  120468. */
  120469. getClassName(): string;
  120470. /**
  120471. * Keep track of the image processing observer to allow dispose and replace.
  120472. */
  120473. private _imageProcessingObserver;
  120474. /**
  120475. * Attaches a new image processing configuration to the Standard Material.
  120476. * @param configuration
  120477. */
  120478. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120479. /**
  120480. * Get a block by its name
  120481. * @param name defines the name of the block to retrieve
  120482. * @returns the required block or null if not found
  120483. */
  120484. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  120485. /**
  120486. * Get a block by its name
  120487. * @param predicate defines the predicate used to find the good candidate
  120488. * @returns the required block or null if not found
  120489. */
  120490. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  120491. /**
  120492. * Get an input block by its name
  120493. * @param predicate defines the predicate used to find the good candidate
  120494. * @returns the required input block or null if not found
  120495. */
  120496. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  120497. /**
  120498. * Gets the list of input blocks attached to this material
  120499. * @returns an array of InputBlocks
  120500. */
  120501. getInputBlocks(): InputBlock[];
  120502. /**
  120503. * Adds a new optimizer to the list of optimizers
  120504. * @param optimizer defines the optimizers to add
  120505. * @returns the current material
  120506. */
  120507. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120508. /**
  120509. * Remove an optimizer from the list of optimizers
  120510. * @param optimizer defines the optimizers to remove
  120511. * @returns the current material
  120512. */
  120513. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120514. /**
  120515. * Add a new block to the list of output nodes
  120516. * @param node defines the node to add
  120517. * @returns the current material
  120518. */
  120519. addOutputNode(node: NodeMaterialBlock): this;
  120520. /**
  120521. * Remove a block from the list of root nodes
  120522. * @param node defines the node to remove
  120523. * @returns the current material
  120524. */
  120525. removeOutputNode(node: NodeMaterialBlock): this;
  120526. private _addVertexOutputNode;
  120527. private _removeVertexOutputNode;
  120528. private _addFragmentOutputNode;
  120529. private _removeFragmentOutputNode;
  120530. /**
  120531. * Specifies if the material will require alpha blending
  120532. * @returns a boolean specifying if alpha blending is needed
  120533. */
  120534. needAlphaBlending(): boolean;
  120535. /**
  120536. * Specifies if this material should be rendered in alpha test mode
  120537. * @returns a boolean specifying if an alpha test is needed.
  120538. */
  120539. needAlphaTesting(): boolean;
  120540. private _initializeBlock;
  120541. private _resetDualBlocks;
  120542. /**
  120543. * Build the material and generates the inner effect
  120544. * @param verbose defines if the build should log activity
  120545. */
  120546. build(verbose?: boolean): void;
  120547. /**
  120548. * Runs an otpimization phase to try to improve the shader code
  120549. */
  120550. optimize(): void;
  120551. private _prepareDefinesForAttributes;
  120552. /**
  120553. * Get if the submesh is ready to be used and all its information available.
  120554. * Child classes can use it to update shaders
  120555. * @param mesh defines the mesh to check
  120556. * @param subMesh defines which submesh to check
  120557. * @param useInstances specifies that instances should be used
  120558. * @returns a boolean indicating that the submesh is ready or not
  120559. */
  120560. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120561. /**
  120562. * Get a string representing the shaders built by the current node graph
  120563. */
  120564. readonly compiledShaders: string;
  120565. /**
  120566. * Binds the world matrix to the material
  120567. * @param world defines the world transformation matrix
  120568. */
  120569. bindOnlyWorldMatrix(world: Matrix): void;
  120570. /**
  120571. * Binds the submesh to this material by preparing the effect and shader to draw
  120572. * @param world defines the world transformation matrix
  120573. * @param mesh defines the mesh containing the submesh
  120574. * @param subMesh defines the submesh to bind the material to
  120575. */
  120576. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120577. /**
  120578. * Gets the active textures from the material
  120579. * @returns an array of textures
  120580. */
  120581. getActiveTextures(): BaseTexture[];
  120582. /**
  120583. * Gets the list of texture blocks
  120584. * @returns an array of texture blocks
  120585. */
  120586. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  120587. /**
  120588. * Specifies if the material uses a texture
  120589. * @param texture defines the texture to check against the material
  120590. * @returns a boolean specifying if the material uses the texture
  120591. */
  120592. hasTexture(texture: BaseTexture): boolean;
  120593. /**
  120594. * Disposes the material
  120595. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  120596. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  120597. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  120598. */
  120599. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  120600. /** Creates the node editor window. */
  120601. private _createNodeEditor;
  120602. /**
  120603. * Launch the node material editor
  120604. * @param config Define the configuration of the editor
  120605. * @return a promise fulfilled when the node editor is visible
  120606. */
  120607. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  120608. /**
  120609. * Clear the current material
  120610. */
  120611. clear(): void;
  120612. /**
  120613. * Clear the current material and set it to a default state
  120614. */
  120615. setToDefault(): void;
  120616. /**
  120617. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  120618. * @param url defines the url to load from
  120619. * @returns a promise that will fullfil when the material is fully loaded
  120620. */
  120621. loadAsync(url: string): Promise<void>;
  120622. private _gatherBlocks;
  120623. /**
  120624. * Generate a string containing the code declaration required to create an equivalent of this material
  120625. * @returns a string
  120626. */
  120627. generateCode(): string;
  120628. /**
  120629. * Serializes this material in a JSON representation
  120630. * @returns the serialized material object
  120631. */
  120632. serialize(): any;
  120633. private _restoreConnections;
  120634. /**
  120635. * Clear the current graph and load a new one from a serialization object
  120636. * @param source defines the JSON representation of the material
  120637. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120638. */
  120639. loadFromSerialization(source: any, rootUrl?: string): void;
  120640. /**
  120641. * Creates a node material from parsed material data
  120642. * @param source defines the JSON representation of the material
  120643. * @param scene defines the hosting scene
  120644. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120645. * @returns a new node material
  120646. */
  120647. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  120648. /**
  120649. * Creates a new node material set to default basic configuration
  120650. * @param name defines the name of the material
  120651. * @param scene defines the hosting scene
  120652. * @returns a new NodeMaterial
  120653. */
  120654. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  120655. }
  120656. }
  120657. declare module BABYLON {
  120658. /**
  120659. * Block used to read a texture from a sampler
  120660. */
  120661. export class TextureBlock extends NodeMaterialBlock {
  120662. private _defineName;
  120663. private _linearDefineName;
  120664. private _samplerName;
  120665. private _transformedUVName;
  120666. private _textureTransformName;
  120667. private _textureInfoName;
  120668. private _mainUVName;
  120669. private _mainUVDefineName;
  120670. /**
  120671. * Gets or sets the texture associated with the node
  120672. */
  120673. texture: Nullable<Texture>;
  120674. /**
  120675. * Create a new TextureBlock
  120676. * @param name defines the block name
  120677. */
  120678. constructor(name: string);
  120679. /**
  120680. * Gets the current class name
  120681. * @returns the class name
  120682. */
  120683. getClassName(): string;
  120684. /**
  120685. * Gets the uv input component
  120686. */
  120687. readonly uv: NodeMaterialConnectionPoint;
  120688. /**
  120689. * Gets the rgba output component
  120690. */
  120691. readonly rgba: NodeMaterialConnectionPoint;
  120692. /**
  120693. * Gets the rgb output component
  120694. */
  120695. readonly rgb: NodeMaterialConnectionPoint;
  120696. /**
  120697. * Gets the r output component
  120698. */
  120699. readonly r: NodeMaterialConnectionPoint;
  120700. /**
  120701. * Gets the g output component
  120702. */
  120703. readonly g: NodeMaterialConnectionPoint;
  120704. /**
  120705. * Gets the b output component
  120706. */
  120707. readonly b: NodeMaterialConnectionPoint;
  120708. /**
  120709. * Gets the a output component
  120710. */
  120711. readonly a: NodeMaterialConnectionPoint;
  120712. readonly target: NodeMaterialBlockTargets;
  120713. autoConfigure(material: NodeMaterial): void;
  120714. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120715. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120716. isReady(): boolean;
  120717. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120718. private readonly _isMixed;
  120719. private _injectVertexCode;
  120720. private _writeOutput;
  120721. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120722. protected _dumpPropertiesCode(): string;
  120723. serialize(): any;
  120724. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120725. }
  120726. }
  120727. declare module BABYLON {
  120728. /**
  120729. * Class used to store shared data between 2 NodeMaterialBuildState
  120730. */
  120731. export class NodeMaterialBuildStateSharedData {
  120732. /**
  120733. * Gets the list of emitted varyings
  120734. */
  120735. temps: string[];
  120736. /**
  120737. * Gets the list of emitted varyings
  120738. */
  120739. varyings: string[];
  120740. /**
  120741. * Gets the varying declaration string
  120742. */
  120743. varyingDeclaration: string;
  120744. /**
  120745. * Input blocks
  120746. */
  120747. inputBlocks: InputBlock[];
  120748. /**
  120749. * Input blocks
  120750. */
  120751. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120752. /**
  120753. * Bindable blocks (Blocks that need to set data to the effect)
  120754. */
  120755. bindableBlocks: NodeMaterialBlock[];
  120756. /**
  120757. * List of blocks that can provide a compilation fallback
  120758. */
  120759. blocksWithFallbacks: NodeMaterialBlock[];
  120760. /**
  120761. * List of blocks that can provide a define update
  120762. */
  120763. blocksWithDefines: NodeMaterialBlock[];
  120764. /**
  120765. * List of blocks that can provide a repeatable content
  120766. */
  120767. repeatableContentBlocks: NodeMaterialBlock[];
  120768. /**
  120769. * List of blocks that can provide a dynamic list of uniforms
  120770. */
  120771. dynamicUniformBlocks: NodeMaterialBlock[];
  120772. /**
  120773. * List of blocks that can block the isReady function for the material
  120774. */
  120775. blockingBlocks: NodeMaterialBlock[];
  120776. /**
  120777. * Gets the list of animated inputs
  120778. */
  120779. animatedInputs: InputBlock[];
  120780. /**
  120781. * Build Id used to avoid multiple recompilations
  120782. */
  120783. buildId: number;
  120784. /** List of emitted variables */
  120785. variableNames: {
  120786. [key: string]: number;
  120787. };
  120788. /** List of emitted defines */
  120789. defineNames: {
  120790. [key: string]: number;
  120791. };
  120792. /** Should emit comments? */
  120793. emitComments: boolean;
  120794. /** Emit build activity */
  120795. verbose: boolean;
  120796. /** Gets or sets the hosting scene */
  120797. scene: Scene;
  120798. /**
  120799. * Gets the compilation hints emitted at compilation time
  120800. */
  120801. hints: {
  120802. needWorldViewMatrix: boolean;
  120803. needWorldViewProjectionMatrix: boolean;
  120804. needAlphaBlending: boolean;
  120805. needAlphaTesting: boolean;
  120806. };
  120807. /**
  120808. * List of compilation checks
  120809. */
  120810. checks: {
  120811. emitVertex: boolean;
  120812. emitFragment: boolean;
  120813. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120814. };
  120815. /** Creates a new shared data */
  120816. constructor();
  120817. /**
  120818. * Emits console errors and exceptions if there is a failing check
  120819. */
  120820. emitErrors(): void;
  120821. }
  120822. }
  120823. declare module BABYLON {
  120824. /**
  120825. * Class used to store node based material build state
  120826. */
  120827. export class NodeMaterialBuildState {
  120828. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120829. supportUniformBuffers: boolean;
  120830. /**
  120831. * Gets the list of emitted attributes
  120832. */
  120833. attributes: string[];
  120834. /**
  120835. * Gets the list of emitted uniforms
  120836. */
  120837. uniforms: string[];
  120838. /**
  120839. * Gets the list of emitted constants
  120840. */
  120841. constants: string[];
  120842. /**
  120843. * Gets the list of emitted samplers
  120844. */
  120845. samplers: string[];
  120846. /**
  120847. * Gets the list of emitted functions
  120848. */
  120849. functions: {
  120850. [key: string]: string;
  120851. };
  120852. /**
  120853. * Gets the list of emitted extensions
  120854. */
  120855. extensions: {
  120856. [key: string]: string;
  120857. };
  120858. /**
  120859. * Gets the target of the compilation state
  120860. */
  120861. target: NodeMaterialBlockTargets;
  120862. /**
  120863. * Gets the list of emitted counters
  120864. */
  120865. counters: {
  120866. [key: string]: number;
  120867. };
  120868. /**
  120869. * Shared data between multiple NodeMaterialBuildState instances
  120870. */
  120871. sharedData: NodeMaterialBuildStateSharedData;
  120872. /** @hidden */
  120873. _vertexState: NodeMaterialBuildState;
  120874. /** @hidden */
  120875. _attributeDeclaration: string;
  120876. /** @hidden */
  120877. _uniformDeclaration: string;
  120878. /** @hidden */
  120879. _constantDeclaration: string;
  120880. /** @hidden */
  120881. _samplerDeclaration: string;
  120882. /** @hidden */
  120883. _varyingTransfer: string;
  120884. private _repeatableContentAnchorIndex;
  120885. /** @hidden */
  120886. _builtCompilationString: string;
  120887. /**
  120888. * Gets the emitted compilation strings
  120889. */
  120890. compilationString: string;
  120891. /**
  120892. * Finalize the compilation strings
  120893. * @param state defines the current compilation state
  120894. */
  120895. finalize(state: NodeMaterialBuildState): void;
  120896. /** @hidden */
  120897. readonly _repeatableContentAnchor: string;
  120898. /** @hidden */
  120899. _getFreeVariableName(prefix: string): string;
  120900. /** @hidden */
  120901. _getFreeDefineName(prefix: string): string;
  120902. /** @hidden */
  120903. _excludeVariableName(name: string): void;
  120904. /** @hidden */
  120905. _emit2DSampler(name: string): void;
  120906. /** @hidden */
  120907. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120908. /** @hidden */
  120909. _emitExtension(name: string, extension: string): void;
  120910. /** @hidden */
  120911. _emitFunction(name: string, code: string, comments: string): void;
  120912. /** @hidden */
  120913. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120914. replaceStrings?: {
  120915. search: RegExp;
  120916. replace: string;
  120917. }[];
  120918. repeatKey?: string;
  120919. }): string;
  120920. /** @hidden */
  120921. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120922. repeatKey?: string;
  120923. removeAttributes?: boolean;
  120924. removeUniforms?: boolean;
  120925. removeVaryings?: boolean;
  120926. removeIfDef?: boolean;
  120927. replaceStrings?: {
  120928. search: RegExp;
  120929. replace: string;
  120930. }[];
  120931. }, storeKey?: string): void;
  120932. /** @hidden */
  120933. _registerTempVariable(name: string): boolean;
  120934. /** @hidden */
  120935. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120936. /** @hidden */
  120937. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120938. /** @hidden */
  120939. _emitFloat(value: number): string;
  120940. }
  120941. }
  120942. declare module BABYLON {
  120943. /**
  120944. * Defines a block that can be used inside a node based material
  120945. */
  120946. export class NodeMaterialBlock {
  120947. private _buildId;
  120948. private _buildTarget;
  120949. private _target;
  120950. private _isFinalMerger;
  120951. private _isInput;
  120952. /** @hidden */
  120953. _codeVariableName: string;
  120954. /** @hidden */
  120955. _inputs: NodeMaterialConnectionPoint[];
  120956. /** @hidden */
  120957. _outputs: NodeMaterialConnectionPoint[];
  120958. /** @hidden */
  120959. _preparationId: number;
  120960. /**
  120961. * Gets or sets the name of the block
  120962. */
  120963. name: string;
  120964. /**
  120965. * Gets or sets the unique id of the node
  120966. */
  120967. uniqueId: number;
  120968. /**
  120969. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120970. */
  120971. readonly isFinalMerger: boolean;
  120972. /**
  120973. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120974. */
  120975. readonly isInput: boolean;
  120976. /**
  120977. * Gets or sets the build Id
  120978. */
  120979. buildId: number;
  120980. /**
  120981. * Gets or sets the target of the block
  120982. */
  120983. target: NodeMaterialBlockTargets;
  120984. /**
  120985. * Gets the list of input points
  120986. */
  120987. readonly inputs: NodeMaterialConnectionPoint[];
  120988. /** Gets the list of output points */
  120989. readonly outputs: NodeMaterialConnectionPoint[];
  120990. /**
  120991. * Find an input by its name
  120992. * @param name defines the name of the input to look for
  120993. * @returns the input or null if not found
  120994. */
  120995. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120996. /**
  120997. * Find an output by its name
  120998. * @param name defines the name of the outputto look for
  120999. * @returns the output or null if not found
  121000. */
  121001. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121002. /**
  121003. * Creates a new NodeMaterialBlock
  121004. * @param name defines the block name
  121005. * @param target defines the target of that block (Vertex by default)
  121006. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  121007. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  121008. */
  121009. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  121010. /**
  121011. * Initialize the block and prepare the context for build
  121012. * @param state defines the state that will be used for the build
  121013. */
  121014. initialize(state: NodeMaterialBuildState): void;
  121015. /**
  121016. * Bind data to effect. Will only be called for blocks with isBindable === true
  121017. * @param effect defines the effect to bind data to
  121018. * @param nodeMaterial defines the hosting NodeMaterial
  121019. * @param mesh defines the mesh that will be rendered
  121020. */
  121021. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121022. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  121023. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  121024. protected _writeFloat(value: number): string;
  121025. /**
  121026. * Gets the current class name e.g. "NodeMaterialBlock"
  121027. * @returns the class name
  121028. */
  121029. getClassName(): string;
  121030. /**
  121031. * Register a new input. Must be called inside a block constructor
  121032. * @param name defines the connection point name
  121033. * @param type defines the connection point type
  121034. * @param isOptional defines a boolean indicating that this input can be omitted
  121035. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121036. * @returns the current block
  121037. */
  121038. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  121039. /**
  121040. * Register a new output. Must be called inside a block constructor
  121041. * @param name defines the connection point name
  121042. * @param type defines the connection point type
  121043. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121044. * @returns the current block
  121045. */
  121046. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  121047. /**
  121048. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  121049. * @param forOutput defines an optional connection point to check compatibility with
  121050. * @returns the first available input or null
  121051. */
  121052. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  121053. /**
  121054. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  121055. * @param forBlock defines an optional block to check compatibility with
  121056. * @returns the first available input or null
  121057. */
  121058. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  121059. /**
  121060. * Gets the sibling of the given output
  121061. * @param current defines the current output
  121062. * @returns the next output in the list or null
  121063. */
  121064. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  121065. /**
  121066. * Connect current block with another block
  121067. * @param other defines the block to connect with
  121068. * @param options define the various options to help pick the right connections
  121069. * @returns the current block
  121070. */
  121071. connectTo(other: NodeMaterialBlock, options?: {
  121072. input?: string;
  121073. output?: string;
  121074. outputSwizzle?: string;
  121075. }): this | undefined;
  121076. protected _buildBlock(state: NodeMaterialBuildState): void;
  121077. /**
  121078. * Add uniforms, samplers and uniform buffers at compilation time
  121079. * @param state defines the state to update
  121080. * @param nodeMaterial defines the node material requesting the update
  121081. * @param defines defines the material defines to update
  121082. * @param uniformBuffers defines the list of uniform buffer names
  121083. */
  121084. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121085. /**
  121086. * Add potential fallbacks if shader compilation fails
  121087. * @param mesh defines the mesh to be rendered
  121088. * @param fallbacks defines the current prioritized list of fallbacks
  121089. */
  121090. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121091. /**
  121092. * Initialize defines for shader compilation
  121093. * @param mesh defines the mesh to be rendered
  121094. * @param nodeMaterial defines the node material requesting the update
  121095. * @param defines defines the material defines to update
  121096. * @param useInstances specifies that instances should be used
  121097. */
  121098. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121099. /**
  121100. * Update defines for shader compilation
  121101. * @param mesh defines the mesh to be rendered
  121102. * @param nodeMaterial defines the node material requesting the update
  121103. * @param defines defines the material defines to update
  121104. * @param useInstances specifies that instances should be used
  121105. */
  121106. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121107. /**
  121108. * Lets the block try to connect some inputs automatically
  121109. * @param material defines the hosting NodeMaterial
  121110. */
  121111. autoConfigure(material: NodeMaterial): void;
  121112. /**
  121113. * Function called when a block is declared as repeatable content generator
  121114. * @param vertexShaderState defines the current compilation state for the vertex shader
  121115. * @param fragmentShaderState defines the current compilation state for the fragment shader
  121116. * @param mesh defines the mesh to be rendered
  121117. * @param defines defines the material defines to update
  121118. */
  121119. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121120. /**
  121121. * Checks if the block is ready
  121122. * @param mesh defines the mesh to be rendered
  121123. * @param nodeMaterial defines the node material requesting the update
  121124. * @param defines defines the material defines to update
  121125. * @param useInstances specifies that instances should be used
  121126. * @returns true if the block is ready
  121127. */
  121128. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  121129. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  121130. private _processBuild;
  121131. /**
  121132. * Compile the current node and generate the shader code
  121133. * @param state defines the current compilation state (uniforms, samplers, current string)
  121134. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  121135. * @returns true if already built
  121136. */
  121137. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  121138. protected _inputRename(name: string): string;
  121139. protected _outputRename(name: string): string;
  121140. protected _dumpPropertiesCode(): string;
  121141. /** @hidden */
  121142. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  121143. /**
  121144. * Clone the current block to a new identical block
  121145. * @param scene defines the hosting scene
  121146. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121147. * @returns a copy of the current block
  121148. */
  121149. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  121150. /**
  121151. * Serializes this block in a JSON representation
  121152. * @returns the serialized block object
  121153. */
  121154. serialize(): any;
  121155. /** @hidden */
  121156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121157. }
  121158. }
  121159. declare module BABYLON {
  121160. /**
  121161. * Enum defining the type of animations supported by InputBlock
  121162. */
  121163. export enum AnimatedInputBlockTypes {
  121164. /** No animation */
  121165. None = 0,
  121166. /** Time based animation. Will only work for floats */
  121167. Time = 1
  121168. }
  121169. }
  121170. declare module BABYLON {
  121171. /**
  121172. * Block used to expose an input value
  121173. */
  121174. export class InputBlock extends NodeMaterialBlock {
  121175. private _mode;
  121176. private _associatedVariableName;
  121177. private _storedValue;
  121178. private _valueCallback;
  121179. private _type;
  121180. private _animationType;
  121181. /** Gets or set a value used to limit the range of float values */
  121182. min: number;
  121183. /** Gets or set a value used to limit the range of float values */
  121184. max: number;
  121185. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  121186. matrixMode: number;
  121187. /** @hidden */
  121188. _systemValue: Nullable<NodeMaterialSystemValues>;
  121189. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  121190. visibleInInspector: boolean;
  121191. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  121192. isConstant: boolean;
  121193. /**
  121194. * Gets or sets the connection point type (default is float)
  121195. */
  121196. readonly type: NodeMaterialBlockConnectionPointTypes;
  121197. /**
  121198. * Creates a new InputBlock
  121199. * @param name defines the block name
  121200. * @param target defines the target of that block (Vertex by default)
  121201. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  121202. */
  121203. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  121204. /**
  121205. * Gets the output component
  121206. */
  121207. readonly output: NodeMaterialConnectionPoint;
  121208. /**
  121209. * Set the source of this connection point to a vertex attribute
  121210. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  121211. * @returns the current connection point
  121212. */
  121213. setAsAttribute(attributeName?: string): InputBlock;
  121214. /**
  121215. * Set the source of this connection point to a system value
  121216. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  121217. * @returns the current connection point
  121218. */
  121219. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  121220. /**
  121221. * Gets or sets the value of that point.
  121222. * Please note that this value will be ignored if valueCallback is defined
  121223. */
  121224. value: any;
  121225. /**
  121226. * Gets or sets a callback used to get the value of that point.
  121227. * Please note that setting this value will force the connection point to ignore the value property
  121228. */
  121229. valueCallback: () => any;
  121230. /**
  121231. * Gets or sets the associated variable name in the shader
  121232. */
  121233. associatedVariableName: string;
  121234. /** Gets or sets the type of animation applied to the input */
  121235. animationType: AnimatedInputBlockTypes;
  121236. /**
  121237. * Gets a boolean indicating that this connection point not defined yet
  121238. */
  121239. readonly isUndefined: boolean;
  121240. /**
  121241. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  121242. * In this case the connection point name must be the name of the uniform to use.
  121243. * Can only be set on inputs
  121244. */
  121245. isUniform: boolean;
  121246. /**
  121247. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  121248. * In this case the connection point name must be the name of the attribute to use
  121249. * Can only be set on inputs
  121250. */
  121251. isAttribute: boolean;
  121252. /**
  121253. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  121254. * Can only be set on exit points
  121255. */
  121256. isVarying: boolean;
  121257. /**
  121258. * Gets a boolean indicating that the current connection point is a system value
  121259. */
  121260. readonly isSystemValue: boolean;
  121261. /**
  121262. * Gets or sets the current well known value or null if not defined as a system value
  121263. */
  121264. systemValue: Nullable<NodeMaterialSystemValues>;
  121265. /**
  121266. * Gets the current class name
  121267. * @returns the class name
  121268. */
  121269. getClassName(): string;
  121270. /**
  121271. * Animate the input if animationType !== None
  121272. * @param scene defines the rendering scene
  121273. */
  121274. animate(scene: Scene): void;
  121275. private _emitDefine;
  121276. initialize(state: NodeMaterialBuildState): void;
  121277. /**
  121278. * Set the input block to its default value (based on its type)
  121279. */
  121280. setDefaultValue(): void;
  121281. private _emitConstant;
  121282. private _emit;
  121283. /** @hidden */
  121284. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  121285. /** @hidden */
  121286. _transmit(effect: Effect, scene: Scene): void;
  121287. protected _buildBlock(state: NodeMaterialBuildState): void;
  121288. protected _dumpPropertiesCode(): string;
  121289. serialize(): any;
  121290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121291. }
  121292. }
  121293. declare module BABYLON {
  121294. /**
  121295. * Defines a connection point for a block
  121296. */
  121297. export class NodeMaterialConnectionPoint {
  121298. /** @hidden */
  121299. _ownerBlock: NodeMaterialBlock;
  121300. /** @hidden */
  121301. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121302. private _endpoints;
  121303. private _associatedVariableName;
  121304. /** @hidden */
  121305. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121306. /** @hidden */
  121307. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121308. private _type;
  121309. /** @hidden */
  121310. _enforceAssociatedVariableName: boolean;
  121311. /**
  121312. * Gets or sets the additional types supported by this connection point
  121313. */
  121314. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121315. /**
  121316. * Gets or sets the additional types excluded by this connection point
  121317. */
  121318. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121319. /**
  121320. * Gets or sets the associated variable name in the shader
  121321. */
  121322. associatedVariableName: string;
  121323. /**
  121324. * Gets or sets the connection point type (default is float)
  121325. */
  121326. type: NodeMaterialBlockConnectionPointTypes;
  121327. /**
  121328. * Gets or sets the connection point name
  121329. */
  121330. name: string;
  121331. /**
  121332. * Gets or sets a boolean indicating that this connection point can be omitted
  121333. */
  121334. isOptional: boolean;
  121335. /**
  121336. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  121337. */
  121338. define: string;
  121339. /** @hidden */
  121340. _prioritizeVertex: boolean;
  121341. private _target;
  121342. /** Gets or sets the target of that connection point */
  121343. target: NodeMaterialBlockTargets;
  121344. /**
  121345. * Gets a boolean indicating that the current point is connected
  121346. */
  121347. readonly isConnected: boolean;
  121348. /**
  121349. * Gets a boolean indicating that the current point is connected to an input block
  121350. */
  121351. readonly isConnectedToInputBlock: boolean;
  121352. /**
  121353. * Gets a the connected input block (if any)
  121354. */
  121355. readonly connectInputBlock: Nullable<InputBlock>;
  121356. /** Get the other side of the connection (if any) */
  121357. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121358. /** Get the block that owns this connection point */
  121359. readonly ownerBlock: NodeMaterialBlock;
  121360. /** Get the block connected on the other side of this connection (if any) */
  121361. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  121362. /** Get the block connected on the endpoints of this connection (if any) */
  121363. readonly connectedBlocks: Array<NodeMaterialBlock>;
  121364. /** Gets the list of connected endpoints */
  121365. readonly endpoints: NodeMaterialConnectionPoint[];
  121366. /** Gets a boolean indicating if that output point is connected to at least one input */
  121367. readonly hasEndpoints: boolean;
  121368. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  121369. readonly isConnectedInVertexShader: boolean;
  121370. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  121371. readonly isConnectedInFragmentShader: boolean;
  121372. /**
  121373. * Creates a new connection point
  121374. * @param name defines the connection point name
  121375. * @param ownerBlock defines the block hosting this connection point
  121376. */
  121377. constructor(name: string, ownerBlock: NodeMaterialBlock);
  121378. /**
  121379. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  121380. * @returns the class name
  121381. */
  121382. getClassName(): string;
  121383. /**
  121384. * Gets an boolean indicating if the current point can be connected to another point
  121385. * @param connectionPoint defines the other connection point
  121386. * @returns true if the connection is possible
  121387. */
  121388. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  121389. /**
  121390. * Connect this point to another connection point
  121391. * @param connectionPoint defines the other connection point
  121392. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  121393. * @returns the current connection point
  121394. */
  121395. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  121396. /**
  121397. * Disconnect this point from one of his endpoint
  121398. * @param endpoint defines the other connection point
  121399. * @returns the current connection point
  121400. */
  121401. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  121402. /**
  121403. * Serializes this point in a JSON representation
  121404. * @returns the serialized point object
  121405. */
  121406. serialize(): any;
  121407. }
  121408. }
  121409. declare module BABYLON {
  121410. /**
  121411. * Block used to add support for vertex skinning (bones)
  121412. */
  121413. export class BonesBlock extends NodeMaterialBlock {
  121414. /**
  121415. * Creates a new BonesBlock
  121416. * @param name defines the block name
  121417. */
  121418. constructor(name: string);
  121419. /**
  121420. * Initialize the block and prepare the context for build
  121421. * @param state defines the state that will be used for the build
  121422. */
  121423. initialize(state: NodeMaterialBuildState): void;
  121424. /**
  121425. * Gets the current class name
  121426. * @returns the class name
  121427. */
  121428. getClassName(): string;
  121429. /**
  121430. * Gets the matrix indices input component
  121431. */
  121432. readonly matricesIndices: NodeMaterialConnectionPoint;
  121433. /**
  121434. * Gets the matrix weights input component
  121435. */
  121436. readonly matricesWeights: NodeMaterialConnectionPoint;
  121437. /**
  121438. * Gets the extra matrix indices input component
  121439. */
  121440. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  121441. /**
  121442. * Gets the extra matrix weights input component
  121443. */
  121444. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  121445. /**
  121446. * Gets the world input component
  121447. */
  121448. readonly world: NodeMaterialConnectionPoint;
  121449. /**
  121450. * Gets the output component
  121451. */
  121452. readonly output: NodeMaterialConnectionPoint;
  121453. autoConfigure(material: NodeMaterial): void;
  121454. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121455. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121456. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121457. protected _buildBlock(state: NodeMaterialBuildState): this;
  121458. }
  121459. }
  121460. declare module BABYLON {
  121461. /**
  121462. * Block used to add support for instances
  121463. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  121464. */
  121465. export class InstancesBlock extends NodeMaterialBlock {
  121466. /**
  121467. * Creates a new InstancesBlock
  121468. * @param name defines the block name
  121469. */
  121470. constructor(name: string);
  121471. /**
  121472. * Gets the current class name
  121473. * @returns the class name
  121474. */
  121475. getClassName(): string;
  121476. /**
  121477. * Gets the first world row input component
  121478. */
  121479. readonly world0: NodeMaterialConnectionPoint;
  121480. /**
  121481. * Gets the second world row input component
  121482. */
  121483. readonly world1: NodeMaterialConnectionPoint;
  121484. /**
  121485. * Gets the third world row input component
  121486. */
  121487. readonly world2: NodeMaterialConnectionPoint;
  121488. /**
  121489. * Gets the forth world row input component
  121490. */
  121491. readonly world3: NodeMaterialConnectionPoint;
  121492. /**
  121493. * Gets the world input component
  121494. */
  121495. readonly world: NodeMaterialConnectionPoint;
  121496. /**
  121497. * Gets the output component
  121498. */
  121499. readonly output: NodeMaterialConnectionPoint;
  121500. autoConfigure(material: NodeMaterial): void;
  121501. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121502. protected _buildBlock(state: NodeMaterialBuildState): this;
  121503. }
  121504. }
  121505. declare module BABYLON {
  121506. /**
  121507. * Block used to add morph targets support to vertex shader
  121508. */
  121509. export class MorphTargetsBlock extends NodeMaterialBlock {
  121510. private _repeatableContentAnchor;
  121511. private _repeatebleContentGenerated;
  121512. /**
  121513. * Create a new MorphTargetsBlock
  121514. * @param name defines the block name
  121515. */
  121516. constructor(name: string);
  121517. /**
  121518. * Gets the current class name
  121519. * @returns the class name
  121520. */
  121521. getClassName(): string;
  121522. /**
  121523. * Gets the position input component
  121524. */
  121525. readonly position: NodeMaterialConnectionPoint;
  121526. /**
  121527. * Gets the normal input component
  121528. */
  121529. readonly normal: NodeMaterialConnectionPoint;
  121530. /**
  121531. * Gets the tangent input component
  121532. */
  121533. readonly tangent: NodeMaterialConnectionPoint;
  121534. /**
  121535. * Gets the tangent input component
  121536. */
  121537. readonly uv: NodeMaterialConnectionPoint;
  121538. /**
  121539. * Gets the position output component
  121540. */
  121541. readonly positionOutput: NodeMaterialConnectionPoint;
  121542. /**
  121543. * Gets the normal output component
  121544. */
  121545. readonly normalOutput: NodeMaterialConnectionPoint;
  121546. /**
  121547. * Gets the tangent output component
  121548. */
  121549. readonly tangentOutput: NodeMaterialConnectionPoint;
  121550. /**
  121551. * Gets the tangent output component
  121552. */
  121553. readonly uvOutput: NodeMaterialConnectionPoint;
  121554. initialize(state: NodeMaterialBuildState): void;
  121555. autoConfigure(material: NodeMaterial): void;
  121556. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121557. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121558. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121559. protected _buildBlock(state: NodeMaterialBuildState): this;
  121560. }
  121561. }
  121562. declare module BABYLON {
  121563. /**
  121564. * Block used to get data information from a light
  121565. */
  121566. export class LightInformationBlock extends NodeMaterialBlock {
  121567. private _lightDataUniformName;
  121568. private _lightColorUniformName;
  121569. private _lightTypeDefineName;
  121570. /**
  121571. * Gets or sets the light associated with this block
  121572. */
  121573. light: Nullable<Light>;
  121574. /**
  121575. * Creates a new LightInformationBlock
  121576. * @param name defines the block name
  121577. */
  121578. constructor(name: string);
  121579. /**
  121580. * Gets the current class name
  121581. * @returns the class name
  121582. */
  121583. getClassName(): string;
  121584. /**
  121585. * Gets the world position input component
  121586. */
  121587. readonly worldPosition: NodeMaterialConnectionPoint;
  121588. /**
  121589. * Gets the direction output component
  121590. */
  121591. readonly direction: NodeMaterialConnectionPoint;
  121592. /**
  121593. * Gets the direction output component
  121594. */
  121595. readonly color: NodeMaterialConnectionPoint;
  121596. /**
  121597. * Gets the direction output component
  121598. */
  121599. readonly intensity: NodeMaterialConnectionPoint;
  121600. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121601. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121602. protected _buildBlock(state: NodeMaterialBuildState): this;
  121603. serialize(): any;
  121604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121605. }
  121606. }
  121607. declare module BABYLON {
  121608. /**
  121609. * Block used to add image processing support to fragment shader
  121610. */
  121611. export class ImageProcessingBlock extends NodeMaterialBlock {
  121612. /**
  121613. * Create a new ImageProcessingBlock
  121614. * @param name defines the block name
  121615. */
  121616. constructor(name: string);
  121617. /**
  121618. * Gets the current class name
  121619. * @returns the class name
  121620. */
  121621. getClassName(): string;
  121622. /**
  121623. * Gets the color input component
  121624. */
  121625. readonly color: NodeMaterialConnectionPoint;
  121626. /**
  121627. * Gets the output component
  121628. */
  121629. readonly output: NodeMaterialConnectionPoint;
  121630. /**
  121631. * Initialize the block and prepare the context for build
  121632. * @param state defines the state that will be used for the build
  121633. */
  121634. initialize(state: NodeMaterialBuildState): void;
  121635. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  121636. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121637. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121638. protected _buildBlock(state: NodeMaterialBuildState): this;
  121639. }
  121640. }
  121641. declare module BABYLON {
  121642. /**
  121643. * Block used to pertub normals based on a normal map
  121644. */
  121645. export class PerturbNormalBlock extends NodeMaterialBlock {
  121646. private _tangentSpaceParameterName;
  121647. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  121648. invertX: boolean;
  121649. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  121650. invertY: boolean;
  121651. /**
  121652. * Create a new PerturbNormalBlock
  121653. * @param name defines the block name
  121654. */
  121655. constructor(name: string);
  121656. /**
  121657. * Gets the current class name
  121658. * @returns the class name
  121659. */
  121660. getClassName(): string;
  121661. /**
  121662. * Gets the world position input component
  121663. */
  121664. readonly worldPosition: NodeMaterialConnectionPoint;
  121665. /**
  121666. * Gets the world normal input component
  121667. */
  121668. readonly worldNormal: NodeMaterialConnectionPoint;
  121669. /**
  121670. * Gets the uv input component
  121671. */
  121672. readonly uv: NodeMaterialConnectionPoint;
  121673. /**
  121674. * Gets the normal map color input component
  121675. */
  121676. readonly normalMapColor: NodeMaterialConnectionPoint;
  121677. /**
  121678. * Gets the strength input component
  121679. */
  121680. readonly strength: NodeMaterialConnectionPoint;
  121681. /**
  121682. * Gets the output component
  121683. */
  121684. readonly output: NodeMaterialConnectionPoint;
  121685. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121686. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121687. autoConfigure(material: NodeMaterial): void;
  121688. protected _buildBlock(state: NodeMaterialBuildState): this;
  121689. protected _dumpPropertiesCode(): string;
  121690. serialize(): any;
  121691. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121692. }
  121693. }
  121694. declare module BABYLON {
  121695. /**
  121696. * Block used to discard a pixel if a value is smaller than a cutoff
  121697. */
  121698. export class DiscardBlock extends NodeMaterialBlock {
  121699. /**
  121700. * Create a new DiscardBlock
  121701. * @param name defines the block name
  121702. */
  121703. constructor(name: string);
  121704. /**
  121705. * Gets the current class name
  121706. * @returns the class name
  121707. */
  121708. getClassName(): string;
  121709. /**
  121710. * Gets the color input component
  121711. */
  121712. readonly value: NodeMaterialConnectionPoint;
  121713. /**
  121714. * Gets the cutoff input component
  121715. */
  121716. readonly cutoff: NodeMaterialConnectionPoint;
  121717. protected _buildBlock(state: NodeMaterialBuildState): this;
  121718. }
  121719. }
  121720. declare module BABYLON {
  121721. /**
  121722. * Block used to add support for scene fog
  121723. */
  121724. export class FogBlock extends NodeMaterialBlock {
  121725. private _fogDistanceName;
  121726. private _fogParameters;
  121727. /**
  121728. * Create a new FogBlock
  121729. * @param name defines the block name
  121730. */
  121731. constructor(name: string);
  121732. /**
  121733. * Gets the current class name
  121734. * @returns the class name
  121735. */
  121736. getClassName(): string;
  121737. /**
  121738. * Gets the world position input component
  121739. */
  121740. readonly worldPosition: NodeMaterialConnectionPoint;
  121741. /**
  121742. * Gets the view input component
  121743. */
  121744. readonly view: NodeMaterialConnectionPoint;
  121745. /**
  121746. * Gets the color input component
  121747. */
  121748. readonly input: NodeMaterialConnectionPoint;
  121749. /**
  121750. * Gets the fog color input component
  121751. */
  121752. readonly fogColor: NodeMaterialConnectionPoint;
  121753. /**
  121754. * Gets the output component
  121755. */
  121756. readonly output: NodeMaterialConnectionPoint;
  121757. autoConfigure(material: NodeMaterial): void;
  121758. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121759. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121760. protected _buildBlock(state: NodeMaterialBuildState): this;
  121761. }
  121762. }
  121763. declare module BABYLON {
  121764. /**
  121765. * Block used to add light in the fragment shader
  121766. */
  121767. export class LightBlock extends NodeMaterialBlock {
  121768. private _lightId;
  121769. /**
  121770. * Gets or sets the light associated with this block
  121771. */
  121772. light: Nullable<Light>;
  121773. /**
  121774. * Create a new LightBlock
  121775. * @param name defines the block name
  121776. */
  121777. constructor(name: string);
  121778. /**
  121779. * Gets the current class name
  121780. * @returns the class name
  121781. */
  121782. getClassName(): string;
  121783. /**
  121784. * Gets the world position input component
  121785. */
  121786. readonly worldPosition: NodeMaterialConnectionPoint;
  121787. /**
  121788. * Gets the world normal input component
  121789. */
  121790. readonly worldNormal: NodeMaterialConnectionPoint;
  121791. /**
  121792. * Gets the camera (or eye) position component
  121793. */
  121794. readonly cameraPosition: NodeMaterialConnectionPoint;
  121795. /**
  121796. * Gets the glossiness component
  121797. */
  121798. readonly glossiness: NodeMaterialConnectionPoint;
  121799. /**
  121800. * Gets the glossinness power component
  121801. */
  121802. readonly glossPower: NodeMaterialConnectionPoint;
  121803. /**
  121804. * Gets the diffuse color component
  121805. */
  121806. readonly diffuseColor: NodeMaterialConnectionPoint;
  121807. /**
  121808. * Gets the specular color component
  121809. */
  121810. readonly specularColor: NodeMaterialConnectionPoint;
  121811. /**
  121812. * Gets the diffuse output component
  121813. */
  121814. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121815. /**
  121816. * Gets the specular output component
  121817. */
  121818. readonly specularOutput: NodeMaterialConnectionPoint;
  121819. autoConfigure(material: NodeMaterial): void;
  121820. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121821. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121822. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121823. private _injectVertexCode;
  121824. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121825. serialize(): any;
  121826. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121827. }
  121828. }
  121829. declare module BABYLON {
  121830. /**
  121831. * Block used to multiply 2 values
  121832. */
  121833. export class MultiplyBlock extends NodeMaterialBlock {
  121834. /**
  121835. * Creates a new MultiplyBlock
  121836. * @param name defines the block name
  121837. */
  121838. constructor(name: string);
  121839. /**
  121840. * Gets the current class name
  121841. * @returns the class name
  121842. */
  121843. getClassName(): string;
  121844. /**
  121845. * Gets the left operand input component
  121846. */
  121847. readonly left: NodeMaterialConnectionPoint;
  121848. /**
  121849. * Gets the right operand input component
  121850. */
  121851. readonly right: NodeMaterialConnectionPoint;
  121852. /**
  121853. * Gets the output component
  121854. */
  121855. readonly output: NodeMaterialConnectionPoint;
  121856. protected _buildBlock(state: NodeMaterialBuildState): this;
  121857. }
  121858. }
  121859. declare module BABYLON {
  121860. /**
  121861. * Block used to add 2 vectors
  121862. */
  121863. export class AddBlock extends NodeMaterialBlock {
  121864. /**
  121865. * Creates a new AddBlock
  121866. * @param name defines the block name
  121867. */
  121868. constructor(name: string);
  121869. /**
  121870. * Gets the current class name
  121871. * @returns the class name
  121872. */
  121873. getClassName(): string;
  121874. /**
  121875. * Gets the left operand input component
  121876. */
  121877. readonly left: NodeMaterialConnectionPoint;
  121878. /**
  121879. * Gets the right operand input component
  121880. */
  121881. readonly right: NodeMaterialConnectionPoint;
  121882. /**
  121883. * Gets the output component
  121884. */
  121885. readonly output: NodeMaterialConnectionPoint;
  121886. protected _buildBlock(state: NodeMaterialBuildState): this;
  121887. }
  121888. }
  121889. declare module BABYLON {
  121890. /**
  121891. * Block used to scale a vector by a float
  121892. */
  121893. export class ScaleBlock extends NodeMaterialBlock {
  121894. /**
  121895. * Creates a new ScaleBlock
  121896. * @param name defines the block name
  121897. */
  121898. constructor(name: string);
  121899. /**
  121900. * Gets the current class name
  121901. * @returns the class name
  121902. */
  121903. getClassName(): string;
  121904. /**
  121905. * Gets the input component
  121906. */
  121907. readonly input: NodeMaterialConnectionPoint;
  121908. /**
  121909. * Gets the factor input component
  121910. */
  121911. readonly factor: NodeMaterialConnectionPoint;
  121912. /**
  121913. * Gets the output component
  121914. */
  121915. readonly output: NodeMaterialConnectionPoint;
  121916. protected _buildBlock(state: NodeMaterialBuildState): this;
  121917. }
  121918. }
  121919. declare module BABYLON {
  121920. /**
  121921. * Block used to clamp a float
  121922. */
  121923. export class ClampBlock extends NodeMaterialBlock {
  121924. /** Gets or sets the minimum range */
  121925. minimum: number;
  121926. /** Gets or sets the maximum range */
  121927. maximum: number;
  121928. /**
  121929. * Creates a new ClampBlock
  121930. * @param name defines the block name
  121931. */
  121932. constructor(name: string);
  121933. /**
  121934. * Gets the current class name
  121935. * @returns the class name
  121936. */
  121937. getClassName(): string;
  121938. /**
  121939. * Gets the value input component
  121940. */
  121941. readonly value: NodeMaterialConnectionPoint;
  121942. /**
  121943. * Gets the output component
  121944. */
  121945. readonly output: NodeMaterialConnectionPoint;
  121946. protected _buildBlock(state: NodeMaterialBuildState): this;
  121947. protected _dumpPropertiesCode(): string;
  121948. serialize(): any;
  121949. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121950. }
  121951. }
  121952. declare module BABYLON {
  121953. /**
  121954. * Block used to apply a cross product between 2 vectors
  121955. */
  121956. export class CrossBlock extends NodeMaterialBlock {
  121957. /**
  121958. * Creates a new CrossBlock
  121959. * @param name defines the block name
  121960. */
  121961. constructor(name: string);
  121962. /**
  121963. * Gets the current class name
  121964. * @returns the class name
  121965. */
  121966. getClassName(): string;
  121967. /**
  121968. * Gets the left operand input component
  121969. */
  121970. readonly left: NodeMaterialConnectionPoint;
  121971. /**
  121972. * Gets the right operand input component
  121973. */
  121974. readonly right: NodeMaterialConnectionPoint;
  121975. /**
  121976. * Gets the output component
  121977. */
  121978. readonly output: NodeMaterialConnectionPoint;
  121979. protected _buildBlock(state: NodeMaterialBuildState): this;
  121980. }
  121981. }
  121982. declare module BABYLON {
  121983. /**
  121984. * Block used to apply a dot product between 2 vectors
  121985. */
  121986. export class DotBlock extends NodeMaterialBlock {
  121987. /**
  121988. * Creates a new DotBlock
  121989. * @param name defines the block name
  121990. */
  121991. constructor(name: string);
  121992. /**
  121993. * Gets the current class name
  121994. * @returns the class name
  121995. */
  121996. getClassName(): string;
  121997. /**
  121998. * Gets the left operand input component
  121999. */
  122000. readonly left: NodeMaterialConnectionPoint;
  122001. /**
  122002. * Gets the right operand input component
  122003. */
  122004. readonly right: NodeMaterialConnectionPoint;
  122005. /**
  122006. * Gets the output component
  122007. */
  122008. readonly output: NodeMaterialConnectionPoint;
  122009. protected _buildBlock(state: NodeMaterialBuildState): this;
  122010. }
  122011. }
  122012. declare module BABYLON {
  122013. /**
  122014. * Block used to remap a float from a range to a new one
  122015. */
  122016. export class RemapBlock extends NodeMaterialBlock {
  122017. /**
  122018. * Gets or sets the source range
  122019. */
  122020. sourceRange: Vector2;
  122021. /**
  122022. * Gets or sets the target range
  122023. */
  122024. targetRange: Vector2;
  122025. /**
  122026. * Creates a new RemapBlock
  122027. * @param name defines the block name
  122028. */
  122029. constructor(name: string);
  122030. /**
  122031. * Gets the current class name
  122032. * @returns the class name
  122033. */
  122034. getClassName(): string;
  122035. /**
  122036. * Gets the input component
  122037. */
  122038. readonly input: NodeMaterialConnectionPoint;
  122039. /**
  122040. * Gets the source min input component
  122041. */
  122042. readonly sourceMin: NodeMaterialConnectionPoint;
  122043. /**
  122044. * Gets the source max input component
  122045. */
  122046. readonly sourceMax: NodeMaterialConnectionPoint;
  122047. /**
  122048. * Gets the target min input component
  122049. */
  122050. readonly targetMin: NodeMaterialConnectionPoint;
  122051. /**
  122052. * Gets the target max input component
  122053. */
  122054. readonly targetMax: NodeMaterialConnectionPoint;
  122055. /**
  122056. * Gets the output component
  122057. */
  122058. readonly output: NodeMaterialConnectionPoint;
  122059. protected _buildBlock(state: NodeMaterialBuildState): this;
  122060. protected _dumpPropertiesCode(): string;
  122061. serialize(): any;
  122062. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122063. }
  122064. }
  122065. declare module BABYLON {
  122066. /**
  122067. * Block used to normalize a vector
  122068. */
  122069. export class NormalizeBlock extends NodeMaterialBlock {
  122070. /**
  122071. * Creates a new NormalizeBlock
  122072. * @param name defines the block name
  122073. */
  122074. constructor(name: string);
  122075. /**
  122076. * Gets the current class name
  122077. * @returns the class name
  122078. */
  122079. getClassName(): string;
  122080. /**
  122081. * Gets the input component
  122082. */
  122083. readonly input: NodeMaterialConnectionPoint;
  122084. /**
  122085. * Gets the output component
  122086. */
  122087. readonly output: NodeMaterialConnectionPoint;
  122088. protected _buildBlock(state: NodeMaterialBuildState): this;
  122089. }
  122090. }
  122091. declare module BABYLON {
  122092. /**
  122093. * Operations supported by the Trigonometry block
  122094. */
  122095. export enum TrigonometryBlockOperations {
  122096. /** Cos */
  122097. Cos = 0,
  122098. /** Sin */
  122099. Sin = 1,
  122100. /** Abs */
  122101. Abs = 2,
  122102. /** Exp */
  122103. Exp = 3,
  122104. /** Exp2 */
  122105. Exp2 = 4,
  122106. /** Round */
  122107. Round = 5,
  122108. /** Floor */
  122109. Floor = 6,
  122110. /** Ceiling */
  122111. Ceiling = 7,
  122112. /** Square root */
  122113. Sqrt = 8,
  122114. /** Log */
  122115. Log = 9,
  122116. /** Tangent */
  122117. Tan = 10,
  122118. /** Arc tangent */
  122119. ArcTan = 11,
  122120. /** Arc cosinus */
  122121. ArcCos = 12,
  122122. /** Arc sinus */
  122123. ArcSin = 13,
  122124. /** Fraction */
  122125. Fract = 14,
  122126. /** Sign */
  122127. Sign = 15,
  122128. /** To radians (from degrees) */
  122129. Radians = 16,
  122130. /** To degrees (from radians) */
  122131. Degrees = 17
  122132. }
  122133. /**
  122134. * Block used to apply trigonometry operation to floats
  122135. */
  122136. export class TrigonometryBlock extends NodeMaterialBlock {
  122137. /**
  122138. * Gets or sets the operation applied by the block
  122139. */
  122140. operation: TrigonometryBlockOperations;
  122141. /**
  122142. * Creates a new TrigonometryBlock
  122143. * @param name defines the block name
  122144. */
  122145. constructor(name: string);
  122146. /**
  122147. * Gets the current class name
  122148. * @returns the class name
  122149. */
  122150. getClassName(): string;
  122151. /**
  122152. * Gets the input component
  122153. */
  122154. readonly input: NodeMaterialConnectionPoint;
  122155. /**
  122156. * Gets the output component
  122157. */
  122158. readonly output: NodeMaterialConnectionPoint;
  122159. protected _buildBlock(state: NodeMaterialBuildState): this;
  122160. serialize(): any;
  122161. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122162. }
  122163. }
  122164. declare module BABYLON {
  122165. /**
  122166. * Block used to create a Color3/4 out of individual inputs (one for each component)
  122167. */
  122168. export class ColorMergerBlock extends NodeMaterialBlock {
  122169. /**
  122170. * Create a new ColorMergerBlock
  122171. * @param name defines the block name
  122172. */
  122173. constructor(name: string);
  122174. /**
  122175. * Gets the current class name
  122176. * @returns the class name
  122177. */
  122178. getClassName(): string;
  122179. /**
  122180. * Gets the r component (input)
  122181. */
  122182. readonly r: NodeMaterialConnectionPoint;
  122183. /**
  122184. * Gets the g component (input)
  122185. */
  122186. readonly g: NodeMaterialConnectionPoint;
  122187. /**
  122188. * Gets the b component (input)
  122189. */
  122190. readonly b: NodeMaterialConnectionPoint;
  122191. /**
  122192. * Gets the a component (input)
  122193. */
  122194. readonly a: NodeMaterialConnectionPoint;
  122195. /**
  122196. * Gets the rgba component (output)
  122197. */
  122198. readonly rgba: NodeMaterialConnectionPoint;
  122199. /**
  122200. * Gets the rgb component (output)
  122201. */
  122202. readonly rgb: NodeMaterialConnectionPoint;
  122203. protected _buildBlock(state: NodeMaterialBuildState): this;
  122204. }
  122205. }
  122206. declare module BABYLON {
  122207. /**
  122208. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  122209. */
  122210. export class VectorMergerBlock extends NodeMaterialBlock {
  122211. /**
  122212. * Create a new VectorMergerBlock
  122213. * @param name defines the block name
  122214. */
  122215. constructor(name: string);
  122216. /**
  122217. * Gets the current class name
  122218. * @returns the class name
  122219. */
  122220. getClassName(): string;
  122221. /**
  122222. * Gets the x component (input)
  122223. */
  122224. readonly x: NodeMaterialConnectionPoint;
  122225. /**
  122226. * Gets the y component (input)
  122227. */
  122228. readonly y: NodeMaterialConnectionPoint;
  122229. /**
  122230. * Gets the z component (input)
  122231. */
  122232. readonly z: NodeMaterialConnectionPoint;
  122233. /**
  122234. * Gets the w component (input)
  122235. */
  122236. readonly w: NodeMaterialConnectionPoint;
  122237. /**
  122238. * Gets the xyzw component (output)
  122239. */
  122240. readonly xyzw: NodeMaterialConnectionPoint;
  122241. /**
  122242. * Gets the xyz component (output)
  122243. */
  122244. readonly xyz: NodeMaterialConnectionPoint;
  122245. /**
  122246. * Gets the xy component (output)
  122247. */
  122248. readonly xy: NodeMaterialConnectionPoint;
  122249. protected _buildBlock(state: NodeMaterialBuildState): this;
  122250. }
  122251. }
  122252. declare module BABYLON {
  122253. /**
  122254. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  122255. */
  122256. export class ColorSplitterBlock extends NodeMaterialBlock {
  122257. /**
  122258. * Create a new ColorSplitterBlock
  122259. * @param name defines the block name
  122260. */
  122261. constructor(name: string);
  122262. /**
  122263. * Gets the current class name
  122264. * @returns the class name
  122265. */
  122266. getClassName(): string;
  122267. /**
  122268. * Gets the rgba component (input)
  122269. */
  122270. readonly rgba: NodeMaterialConnectionPoint;
  122271. /**
  122272. * Gets the rgb component (input)
  122273. */
  122274. readonly rgbIn: NodeMaterialConnectionPoint;
  122275. /**
  122276. * Gets the rgb component (output)
  122277. */
  122278. readonly rgbOut: NodeMaterialConnectionPoint;
  122279. /**
  122280. * Gets the r component (output)
  122281. */
  122282. readonly r: NodeMaterialConnectionPoint;
  122283. /**
  122284. * Gets the g component (output)
  122285. */
  122286. readonly g: NodeMaterialConnectionPoint;
  122287. /**
  122288. * Gets the b component (output)
  122289. */
  122290. readonly b: NodeMaterialConnectionPoint;
  122291. /**
  122292. * Gets the a component (output)
  122293. */
  122294. readonly a: NodeMaterialConnectionPoint;
  122295. protected _inputRename(name: string): string;
  122296. protected _outputRename(name: string): string;
  122297. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122298. }
  122299. }
  122300. declare module BABYLON {
  122301. /**
  122302. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  122303. */
  122304. export class VectorSplitterBlock extends NodeMaterialBlock {
  122305. /**
  122306. * Create a new VectorSplitterBlock
  122307. * @param name defines the block name
  122308. */
  122309. constructor(name: string);
  122310. /**
  122311. * Gets the current class name
  122312. * @returns the class name
  122313. */
  122314. getClassName(): string;
  122315. /**
  122316. * Gets the xyzw component (input)
  122317. */
  122318. readonly xyzw: NodeMaterialConnectionPoint;
  122319. /**
  122320. * Gets the xyz component (input)
  122321. */
  122322. readonly xyzIn: NodeMaterialConnectionPoint;
  122323. /**
  122324. * Gets the xy component (input)
  122325. */
  122326. readonly xyIn: NodeMaterialConnectionPoint;
  122327. /**
  122328. * Gets the xyz component (output)
  122329. */
  122330. readonly xyzOut: NodeMaterialConnectionPoint;
  122331. /**
  122332. * Gets the xy component (output)
  122333. */
  122334. readonly xyOut: NodeMaterialConnectionPoint;
  122335. /**
  122336. * Gets the x component (output)
  122337. */
  122338. readonly x: NodeMaterialConnectionPoint;
  122339. /**
  122340. * Gets the y component (output)
  122341. */
  122342. readonly y: NodeMaterialConnectionPoint;
  122343. /**
  122344. * Gets the z component (output)
  122345. */
  122346. readonly z: NodeMaterialConnectionPoint;
  122347. /**
  122348. * Gets the w component (output)
  122349. */
  122350. readonly w: NodeMaterialConnectionPoint;
  122351. protected _inputRename(name: string): string;
  122352. protected _outputRename(name: string): string;
  122353. protected _buildBlock(state: NodeMaterialBuildState): this;
  122354. }
  122355. }
  122356. declare module BABYLON {
  122357. /**
  122358. * Block used to lerp between 2 values
  122359. */
  122360. export class LerpBlock extends NodeMaterialBlock {
  122361. /**
  122362. * Creates a new LerpBlock
  122363. * @param name defines the block name
  122364. */
  122365. constructor(name: string);
  122366. /**
  122367. * Gets the current class name
  122368. * @returns the class name
  122369. */
  122370. getClassName(): string;
  122371. /**
  122372. * Gets the left operand input component
  122373. */
  122374. readonly left: NodeMaterialConnectionPoint;
  122375. /**
  122376. * Gets the right operand input component
  122377. */
  122378. readonly right: NodeMaterialConnectionPoint;
  122379. /**
  122380. * Gets the gradient operand input component
  122381. */
  122382. readonly gradient: NodeMaterialConnectionPoint;
  122383. /**
  122384. * Gets the output component
  122385. */
  122386. readonly output: NodeMaterialConnectionPoint;
  122387. protected _buildBlock(state: NodeMaterialBuildState): this;
  122388. }
  122389. }
  122390. declare module BABYLON {
  122391. /**
  122392. * Block used to divide 2 vectors
  122393. */
  122394. export class DivideBlock extends NodeMaterialBlock {
  122395. /**
  122396. * Creates a new DivideBlock
  122397. * @param name defines the block name
  122398. */
  122399. constructor(name: string);
  122400. /**
  122401. * Gets the current class name
  122402. * @returns the class name
  122403. */
  122404. getClassName(): string;
  122405. /**
  122406. * Gets the left operand input component
  122407. */
  122408. readonly left: NodeMaterialConnectionPoint;
  122409. /**
  122410. * Gets the right operand input component
  122411. */
  122412. readonly right: NodeMaterialConnectionPoint;
  122413. /**
  122414. * Gets the output component
  122415. */
  122416. readonly output: NodeMaterialConnectionPoint;
  122417. protected _buildBlock(state: NodeMaterialBuildState): this;
  122418. }
  122419. }
  122420. declare module BABYLON {
  122421. /**
  122422. * Block used to subtract 2 vectors
  122423. */
  122424. export class SubtractBlock extends NodeMaterialBlock {
  122425. /**
  122426. * Creates a new SubtractBlock
  122427. * @param name defines the block name
  122428. */
  122429. constructor(name: string);
  122430. /**
  122431. * Gets the current class name
  122432. * @returns the class name
  122433. */
  122434. getClassName(): string;
  122435. /**
  122436. * Gets the left operand input component
  122437. */
  122438. readonly left: NodeMaterialConnectionPoint;
  122439. /**
  122440. * Gets the right operand input component
  122441. */
  122442. readonly right: NodeMaterialConnectionPoint;
  122443. /**
  122444. * Gets the output component
  122445. */
  122446. readonly output: NodeMaterialConnectionPoint;
  122447. protected _buildBlock(state: NodeMaterialBuildState): this;
  122448. }
  122449. }
  122450. declare module BABYLON {
  122451. /**
  122452. * Block used to step a value
  122453. */
  122454. export class StepBlock extends NodeMaterialBlock {
  122455. /**
  122456. * Creates a new StepBlock
  122457. * @param name defines the block name
  122458. */
  122459. constructor(name: string);
  122460. /**
  122461. * Gets the current class name
  122462. * @returns the class name
  122463. */
  122464. getClassName(): string;
  122465. /**
  122466. * Gets the value operand input component
  122467. */
  122468. readonly value: NodeMaterialConnectionPoint;
  122469. /**
  122470. * Gets the edge operand input component
  122471. */
  122472. readonly edge: NodeMaterialConnectionPoint;
  122473. /**
  122474. * Gets the output component
  122475. */
  122476. readonly output: NodeMaterialConnectionPoint;
  122477. protected _buildBlock(state: NodeMaterialBuildState): this;
  122478. }
  122479. }
  122480. declare module BABYLON {
  122481. /**
  122482. * Block used to get the opposite (1 - x) of a value
  122483. */
  122484. export class OneMinusBlock extends NodeMaterialBlock {
  122485. /**
  122486. * Creates a new OneMinusBlock
  122487. * @param name defines the block name
  122488. */
  122489. constructor(name: string);
  122490. /**
  122491. * Gets the current class name
  122492. * @returns the class name
  122493. */
  122494. getClassName(): string;
  122495. /**
  122496. * Gets the input component
  122497. */
  122498. readonly input: NodeMaterialConnectionPoint;
  122499. /**
  122500. * Gets the output component
  122501. */
  122502. readonly output: NodeMaterialConnectionPoint;
  122503. protected _buildBlock(state: NodeMaterialBuildState): this;
  122504. }
  122505. }
  122506. declare module BABYLON {
  122507. /**
  122508. * Block used to get the view direction
  122509. */
  122510. export class ViewDirectionBlock extends NodeMaterialBlock {
  122511. /**
  122512. * Creates a new ViewDirectionBlock
  122513. * @param name defines the block name
  122514. */
  122515. constructor(name: string);
  122516. /**
  122517. * Gets the current class name
  122518. * @returns the class name
  122519. */
  122520. getClassName(): string;
  122521. /**
  122522. * Gets the world position component
  122523. */
  122524. readonly worldPosition: NodeMaterialConnectionPoint;
  122525. /**
  122526. * Gets the camera position component
  122527. */
  122528. readonly cameraPosition: NodeMaterialConnectionPoint;
  122529. /**
  122530. * Gets the output component
  122531. */
  122532. readonly output: NodeMaterialConnectionPoint;
  122533. autoConfigure(material: NodeMaterial): void;
  122534. protected _buildBlock(state: NodeMaterialBuildState): this;
  122535. }
  122536. }
  122537. declare module BABYLON {
  122538. /**
  122539. * Block used to compute fresnel value
  122540. */
  122541. export class FresnelBlock extends NodeMaterialBlock {
  122542. /**
  122543. * Create a new FresnelBlock
  122544. * @param name defines the block name
  122545. */
  122546. constructor(name: string);
  122547. /**
  122548. * Gets the current class name
  122549. * @returns the class name
  122550. */
  122551. getClassName(): string;
  122552. /**
  122553. * Gets the world normal input component
  122554. */
  122555. readonly worldNormal: NodeMaterialConnectionPoint;
  122556. /**
  122557. * Gets the view direction input component
  122558. */
  122559. readonly viewDirection: NodeMaterialConnectionPoint;
  122560. /**
  122561. * Gets the bias input component
  122562. */
  122563. readonly bias: NodeMaterialConnectionPoint;
  122564. /**
  122565. * Gets the camera (or eye) position component
  122566. */
  122567. readonly power: NodeMaterialConnectionPoint;
  122568. /**
  122569. * Gets the fresnel output component
  122570. */
  122571. readonly fresnel: NodeMaterialConnectionPoint;
  122572. autoConfigure(material: NodeMaterial): void;
  122573. protected _buildBlock(state: NodeMaterialBuildState): this;
  122574. }
  122575. }
  122576. declare module BABYLON {
  122577. /**
  122578. * Block used to get the max of 2 values
  122579. */
  122580. export class MaxBlock extends NodeMaterialBlock {
  122581. /**
  122582. * Creates a new MaxBlock
  122583. * @param name defines the block name
  122584. */
  122585. constructor(name: string);
  122586. /**
  122587. * Gets the current class name
  122588. * @returns the class name
  122589. */
  122590. getClassName(): string;
  122591. /**
  122592. * Gets the left operand input component
  122593. */
  122594. readonly left: NodeMaterialConnectionPoint;
  122595. /**
  122596. * Gets the right operand input component
  122597. */
  122598. readonly right: NodeMaterialConnectionPoint;
  122599. /**
  122600. * Gets the output component
  122601. */
  122602. readonly output: NodeMaterialConnectionPoint;
  122603. protected _buildBlock(state: NodeMaterialBuildState): this;
  122604. }
  122605. }
  122606. declare module BABYLON {
  122607. /**
  122608. * Block used to get the min of 2 values
  122609. */
  122610. export class MinBlock extends NodeMaterialBlock {
  122611. /**
  122612. * Creates a new MinBlock
  122613. * @param name defines the block name
  122614. */
  122615. constructor(name: string);
  122616. /**
  122617. * Gets the current class name
  122618. * @returns the class name
  122619. */
  122620. getClassName(): string;
  122621. /**
  122622. * Gets the left operand input component
  122623. */
  122624. readonly left: NodeMaterialConnectionPoint;
  122625. /**
  122626. * Gets the right operand input component
  122627. */
  122628. readonly right: NodeMaterialConnectionPoint;
  122629. /**
  122630. * Gets the output component
  122631. */
  122632. readonly output: NodeMaterialConnectionPoint;
  122633. protected _buildBlock(state: NodeMaterialBuildState): this;
  122634. }
  122635. }
  122636. declare module BABYLON {
  122637. /**
  122638. * Block used to get the distance between 2 values
  122639. */
  122640. export class DistanceBlock extends NodeMaterialBlock {
  122641. /**
  122642. * Creates a new DistanceBlock
  122643. * @param name defines the block name
  122644. */
  122645. constructor(name: string);
  122646. /**
  122647. * Gets the current class name
  122648. * @returns the class name
  122649. */
  122650. getClassName(): string;
  122651. /**
  122652. * Gets the left operand input component
  122653. */
  122654. readonly left: NodeMaterialConnectionPoint;
  122655. /**
  122656. * Gets the right operand input component
  122657. */
  122658. readonly right: NodeMaterialConnectionPoint;
  122659. /**
  122660. * Gets the output component
  122661. */
  122662. readonly output: NodeMaterialConnectionPoint;
  122663. protected _buildBlock(state: NodeMaterialBuildState): this;
  122664. }
  122665. }
  122666. declare module BABYLON {
  122667. /**
  122668. * Block used to get the length of a vector
  122669. */
  122670. export class LengthBlock extends NodeMaterialBlock {
  122671. /**
  122672. * Creates a new LengthBlock
  122673. * @param name defines the block name
  122674. */
  122675. constructor(name: string);
  122676. /**
  122677. * Gets the current class name
  122678. * @returns the class name
  122679. */
  122680. getClassName(): string;
  122681. /**
  122682. * Gets the value input component
  122683. */
  122684. readonly value: NodeMaterialConnectionPoint;
  122685. /**
  122686. * Gets the output component
  122687. */
  122688. readonly output: NodeMaterialConnectionPoint;
  122689. protected _buildBlock(state: NodeMaterialBuildState): this;
  122690. }
  122691. }
  122692. declare module BABYLON {
  122693. /**
  122694. * Block used to get negative version of a value (i.e. x * -1)
  122695. */
  122696. export class NegateBlock extends NodeMaterialBlock {
  122697. /**
  122698. * Creates a new NegateBlock
  122699. * @param name defines the block name
  122700. */
  122701. constructor(name: string);
  122702. /**
  122703. * Gets the current class name
  122704. * @returns the class name
  122705. */
  122706. getClassName(): string;
  122707. /**
  122708. * Gets the value input component
  122709. */
  122710. readonly value: NodeMaterialConnectionPoint;
  122711. /**
  122712. * Gets the output component
  122713. */
  122714. readonly output: NodeMaterialConnectionPoint;
  122715. protected _buildBlock(state: NodeMaterialBuildState): this;
  122716. }
  122717. }
  122718. declare module BABYLON {
  122719. /**
  122720. * Block used to get the value of the first parameter raised to the power of the second
  122721. */
  122722. export class PowBlock extends NodeMaterialBlock {
  122723. /**
  122724. * Creates a new PowBlock
  122725. * @param name defines the block name
  122726. */
  122727. constructor(name: string);
  122728. /**
  122729. * Gets the current class name
  122730. * @returns the class name
  122731. */
  122732. getClassName(): string;
  122733. /**
  122734. * Gets the value operand input component
  122735. */
  122736. readonly value: NodeMaterialConnectionPoint;
  122737. /**
  122738. * Gets the power operand input component
  122739. */
  122740. readonly power: NodeMaterialConnectionPoint;
  122741. /**
  122742. * Gets the output component
  122743. */
  122744. readonly output: NodeMaterialConnectionPoint;
  122745. protected _buildBlock(state: NodeMaterialBuildState): this;
  122746. }
  122747. }
  122748. declare module BABYLON {
  122749. /**
  122750. * Block used to get a random number
  122751. */
  122752. export class RandomNumberBlock extends NodeMaterialBlock {
  122753. /**
  122754. * Creates a new RandomNumberBlock
  122755. * @param name defines the block name
  122756. */
  122757. constructor(name: string);
  122758. /**
  122759. * Gets the current class name
  122760. * @returns the class name
  122761. */
  122762. getClassName(): string;
  122763. /**
  122764. * Gets the seed input component
  122765. */
  122766. readonly seed: NodeMaterialConnectionPoint;
  122767. /**
  122768. * Gets the output component
  122769. */
  122770. readonly output: NodeMaterialConnectionPoint;
  122771. protected _buildBlock(state: NodeMaterialBuildState): this;
  122772. }
  122773. }
  122774. declare module BABYLON {
  122775. /**
  122776. * Block used to compute arc tangent of 2 values
  122777. */
  122778. export class ArcTan2Block extends NodeMaterialBlock {
  122779. /**
  122780. * Creates a new ArcTan2Block
  122781. * @param name defines the block name
  122782. */
  122783. constructor(name: string);
  122784. /**
  122785. * Gets the current class name
  122786. * @returns the class name
  122787. */
  122788. getClassName(): string;
  122789. /**
  122790. * Gets the x operand input component
  122791. */
  122792. readonly x: NodeMaterialConnectionPoint;
  122793. /**
  122794. * Gets the y operand input component
  122795. */
  122796. readonly y: NodeMaterialConnectionPoint;
  122797. /**
  122798. * Gets the output component
  122799. */
  122800. readonly output: NodeMaterialConnectionPoint;
  122801. protected _buildBlock(state: NodeMaterialBuildState): this;
  122802. }
  122803. }
  122804. declare module BABYLON {
  122805. /**
  122806. * Block used to smooth step a value
  122807. */
  122808. export class SmoothStepBlock extends NodeMaterialBlock {
  122809. /**
  122810. * Creates a new SmoothStepBlock
  122811. * @param name defines the block name
  122812. */
  122813. constructor(name: string);
  122814. /**
  122815. * Gets the current class name
  122816. * @returns the class name
  122817. */
  122818. getClassName(): string;
  122819. /**
  122820. * Gets the value operand input component
  122821. */
  122822. readonly value: NodeMaterialConnectionPoint;
  122823. /**
  122824. * Gets the first edge operand input component
  122825. */
  122826. readonly edge0: NodeMaterialConnectionPoint;
  122827. /**
  122828. * Gets the second edge operand input component
  122829. */
  122830. readonly edge1: NodeMaterialConnectionPoint;
  122831. /**
  122832. * Gets the output component
  122833. */
  122834. readonly output: NodeMaterialConnectionPoint;
  122835. protected _buildBlock(state: NodeMaterialBuildState): this;
  122836. }
  122837. }
  122838. declare module BABYLON {
  122839. /**
  122840. * Block used to get the reciprocal (1 / x) of a value
  122841. */
  122842. export class ReciprocalBlock extends NodeMaterialBlock {
  122843. /**
  122844. * Creates a new ReciprocalBlock
  122845. * @param name defines the block name
  122846. */
  122847. constructor(name: string);
  122848. /**
  122849. * Gets the current class name
  122850. * @returns the class name
  122851. */
  122852. getClassName(): string;
  122853. /**
  122854. * Gets the input component
  122855. */
  122856. readonly input: NodeMaterialConnectionPoint;
  122857. /**
  122858. * Gets the output component
  122859. */
  122860. readonly output: NodeMaterialConnectionPoint;
  122861. protected _buildBlock(state: NodeMaterialBuildState): this;
  122862. }
  122863. }
  122864. declare module BABYLON {
  122865. /**
  122866. * Block used to replace a color by another one
  122867. */
  122868. export class ReplaceColorBlock extends NodeMaterialBlock {
  122869. /**
  122870. * Creates a new ReplaceColorBlock
  122871. * @param name defines the block name
  122872. */
  122873. constructor(name: string);
  122874. /**
  122875. * Gets the current class name
  122876. * @returns the class name
  122877. */
  122878. getClassName(): string;
  122879. /**
  122880. * Gets the value input component
  122881. */
  122882. readonly value: NodeMaterialConnectionPoint;
  122883. /**
  122884. * Gets the reference input component
  122885. */
  122886. readonly reference: NodeMaterialConnectionPoint;
  122887. /**
  122888. * Gets the distance input component
  122889. */
  122890. readonly distance: NodeMaterialConnectionPoint;
  122891. /**
  122892. * Gets the replacement input component
  122893. */
  122894. readonly replacement: NodeMaterialConnectionPoint;
  122895. /**
  122896. * Gets the output component
  122897. */
  122898. readonly output: NodeMaterialConnectionPoint;
  122899. protected _buildBlock(state: NodeMaterialBuildState): this;
  122900. }
  122901. }
  122902. declare module BABYLON {
  122903. /**
  122904. * Block used to posterize a value
  122905. * @see https://en.wikipedia.org/wiki/Posterization
  122906. */
  122907. export class PosterizeBlock extends NodeMaterialBlock {
  122908. /**
  122909. * Creates a new PosterizeBlock
  122910. * @param name defines the block name
  122911. */
  122912. constructor(name: string);
  122913. /**
  122914. * Gets the current class name
  122915. * @returns the class name
  122916. */
  122917. getClassName(): string;
  122918. /**
  122919. * Gets the value input component
  122920. */
  122921. readonly value: NodeMaterialConnectionPoint;
  122922. /**
  122923. * Gets the steps input component
  122924. */
  122925. readonly steps: NodeMaterialConnectionPoint;
  122926. /**
  122927. * Gets the output component
  122928. */
  122929. readonly output: NodeMaterialConnectionPoint;
  122930. protected _buildBlock(state: NodeMaterialBuildState): this;
  122931. }
  122932. }
  122933. declare module BABYLON {
  122934. /**
  122935. * Operations supported by the Wave block
  122936. */
  122937. export enum WaveBlockKind {
  122938. /** SawTooth */
  122939. SawTooth = 0,
  122940. /** Square */
  122941. Square = 1,
  122942. /** Triangle */
  122943. Triangle = 2
  122944. }
  122945. /**
  122946. * Block used to apply wave operation to floats
  122947. */
  122948. export class WaveBlock extends NodeMaterialBlock {
  122949. /**
  122950. * Gets or sets the kibnd of wave to be applied by the block
  122951. */
  122952. kind: WaveBlockKind;
  122953. /**
  122954. * Creates a new WaveBlock
  122955. * @param name defines the block name
  122956. */
  122957. constructor(name: string);
  122958. /**
  122959. * Gets the current class name
  122960. * @returns the class name
  122961. */
  122962. getClassName(): string;
  122963. /**
  122964. * Gets the input component
  122965. */
  122966. readonly input: NodeMaterialConnectionPoint;
  122967. /**
  122968. * Gets the output component
  122969. */
  122970. readonly output: NodeMaterialConnectionPoint;
  122971. protected _buildBlock(state: NodeMaterialBuildState): this;
  122972. serialize(): any;
  122973. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122974. }
  122975. }
  122976. declare module BABYLON {
  122977. /**
  122978. * Class used to store a color step for the GradientBlock
  122979. */
  122980. export class GradientBlockColorStep {
  122981. /**
  122982. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122983. */
  122984. step: number;
  122985. /**
  122986. * Gets or sets the color associated with this step
  122987. */
  122988. color: Color3;
  122989. /**
  122990. * Creates a new GradientBlockColorStep
  122991. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122992. * @param color defines the color associated with this step
  122993. */
  122994. constructor(
  122995. /**
  122996. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122997. */
  122998. step: number,
  122999. /**
  123000. * Gets or sets the color associated with this step
  123001. */
  123002. color: Color3);
  123003. }
  123004. /**
  123005. * Block used to return a color from a gradient based on an input value between 0 and 1
  123006. */
  123007. export class GradientBlock extends NodeMaterialBlock {
  123008. /**
  123009. * Gets or sets the list of color steps
  123010. */
  123011. colorSteps: GradientBlockColorStep[];
  123012. /**
  123013. * Creates a new GradientBlock
  123014. * @param name defines the block name
  123015. */
  123016. constructor(name: string);
  123017. /**
  123018. * Gets the current class name
  123019. * @returns the class name
  123020. */
  123021. getClassName(): string;
  123022. /**
  123023. * Gets the gradient input component
  123024. */
  123025. readonly gradient: NodeMaterialConnectionPoint;
  123026. /**
  123027. * Gets the output component
  123028. */
  123029. readonly output: NodeMaterialConnectionPoint;
  123030. private _writeColorConstant;
  123031. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123032. serialize(): any;
  123033. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123034. protected _dumpPropertiesCode(): string;
  123035. }
  123036. }
  123037. declare module BABYLON {
  123038. /**
  123039. * Block used to normalize lerp between 2 values
  123040. */
  123041. export class NLerpBlock extends NodeMaterialBlock {
  123042. /**
  123043. * Creates a new NLerpBlock
  123044. * @param name defines the block name
  123045. */
  123046. constructor(name: string);
  123047. /**
  123048. * Gets the current class name
  123049. * @returns the class name
  123050. */
  123051. getClassName(): string;
  123052. /**
  123053. * Gets the left operand input component
  123054. */
  123055. readonly left: NodeMaterialConnectionPoint;
  123056. /**
  123057. * Gets the right operand input component
  123058. */
  123059. readonly right: NodeMaterialConnectionPoint;
  123060. /**
  123061. * Gets the gradient operand input component
  123062. */
  123063. readonly gradient: NodeMaterialConnectionPoint;
  123064. /**
  123065. * Gets the output component
  123066. */
  123067. readonly output: NodeMaterialConnectionPoint;
  123068. protected _buildBlock(state: NodeMaterialBuildState): this;
  123069. }
  123070. }
  123071. declare module BABYLON {
  123072. /**
  123073. * Effect Render Options
  123074. */
  123075. export interface IEffectRendererOptions {
  123076. /**
  123077. * Defines the vertices positions.
  123078. */
  123079. positions?: number[];
  123080. /**
  123081. * Defines the indices.
  123082. */
  123083. indices?: number[];
  123084. }
  123085. /**
  123086. * Helper class to render one or more effects
  123087. */
  123088. export class EffectRenderer {
  123089. private engine;
  123090. private static _DefaultOptions;
  123091. private _vertexBuffers;
  123092. private _indexBuffer;
  123093. private _ringBufferIndex;
  123094. private _ringScreenBuffer;
  123095. private _fullscreenViewport;
  123096. private _getNextFrameBuffer;
  123097. /**
  123098. * Creates an effect renderer
  123099. * @param engine the engine to use for rendering
  123100. * @param options defines the options of the effect renderer
  123101. */
  123102. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  123103. /**
  123104. * Sets the current viewport in normalized coordinates 0-1
  123105. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  123106. */
  123107. setViewport(viewport?: Viewport): void;
  123108. /**
  123109. * Binds the embedded attributes buffer to the effect.
  123110. * @param effect Defines the effect to bind the attributes for
  123111. */
  123112. bindBuffers(effect: Effect): void;
  123113. /**
  123114. * Sets the current effect wrapper to use during draw.
  123115. * The effect needs to be ready before calling this api.
  123116. * This also sets the default full screen position attribute.
  123117. * @param effectWrapper Defines the effect to draw with
  123118. */
  123119. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  123120. /**
  123121. * Draws a full screen quad.
  123122. */
  123123. draw(): void;
  123124. /**
  123125. * renders one or more effects to a specified texture
  123126. * @param effectWrappers list of effects to renderer
  123127. * @param outputTexture texture to draw to, if null it will render to the screen
  123128. */
  123129. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  123130. /**
  123131. * Disposes of the effect renderer
  123132. */
  123133. dispose(): void;
  123134. }
  123135. /**
  123136. * Options to create an EffectWrapper
  123137. */
  123138. interface EffectWrapperCreationOptions {
  123139. /**
  123140. * Engine to use to create the effect
  123141. */
  123142. engine: ThinEngine;
  123143. /**
  123144. * Fragment shader for the effect
  123145. */
  123146. fragmentShader: string;
  123147. /**
  123148. * Vertex shader for the effect
  123149. */
  123150. vertexShader?: string;
  123151. /**
  123152. * Attributes to use in the shader
  123153. */
  123154. attributeNames?: Array<string>;
  123155. /**
  123156. * Uniforms to use in the shader
  123157. */
  123158. uniformNames?: Array<string>;
  123159. /**
  123160. * Texture sampler names to use in the shader
  123161. */
  123162. samplerNames?: Array<string>;
  123163. /**
  123164. * The friendly name of the effect displayed in Spector.
  123165. */
  123166. name?: string;
  123167. }
  123168. /**
  123169. * Wraps an effect to be used for rendering
  123170. */
  123171. export class EffectWrapper {
  123172. /**
  123173. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  123174. */
  123175. onApplyObservable: Observable<{}>;
  123176. /**
  123177. * The underlying effect
  123178. */
  123179. effect: Effect;
  123180. /**
  123181. * Creates an effect to be renderer
  123182. * @param creationOptions options to create the effect
  123183. */
  123184. constructor(creationOptions: EffectWrapperCreationOptions);
  123185. /**
  123186. * Disposes of the effect wrapper
  123187. */
  123188. dispose(): void;
  123189. }
  123190. }
  123191. declare module BABYLON {
  123192. /**
  123193. * Helper class to push actions to a pool of workers.
  123194. */
  123195. export class WorkerPool implements IDisposable {
  123196. private _workerInfos;
  123197. private _pendingActions;
  123198. /**
  123199. * Constructor
  123200. * @param workers Array of workers to use for actions
  123201. */
  123202. constructor(workers: Array<Worker>);
  123203. /**
  123204. * Terminates all workers and clears any pending actions.
  123205. */
  123206. dispose(): void;
  123207. /**
  123208. * Pushes an action to the worker pool. If all the workers are active, the action will be
  123209. * pended until a worker has completed its action.
  123210. * @param action The action to perform. Call onComplete when the action is complete.
  123211. */
  123212. push(action: (worker: Worker, onComplete: () => void) => void): void;
  123213. private _execute;
  123214. }
  123215. }
  123216. declare module BABYLON {
  123217. /**
  123218. * Configuration for Draco compression
  123219. */
  123220. export interface IDracoCompressionConfiguration {
  123221. /**
  123222. * Configuration for the decoder.
  123223. */
  123224. decoder: {
  123225. /**
  123226. * The url to the WebAssembly module.
  123227. */
  123228. wasmUrl?: string;
  123229. /**
  123230. * The url to the WebAssembly binary.
  123231. */
  123232. wasmBinaryUrl?: string;
  123233. /**
  123234. * The url to the fallback JavaScript module.
  123235. */
  123236. fallbackUrl?: string;
  123237. };
  123238. }
  123239. /**
  123240. * Draco compression (https://google.github.io/draco/)
  123241. *
  123242. * This class wraps the Draco module.
  123243. *
  123244. * **Encoder**
  123245. *
  123246. * The encoder is not currently implemented.
  123247. *
  123248. * **Decoder**
  123249. *
  123250. * 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.
  123251. *
  123252. * To update the configuration, use the following code:
  123253. * ```javascript
  123254. * DracoCompression.Configuration = {
  123255. * decoder: {
  123256. * wasmUrl: "<url to the WebAssembly library>",
  123257. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  123258. * fallbackUrl: "<url to the fallback JavaScript library>",
  123259. * }
  123260. * };
  123261. * ```
  123262. *
  123263. * 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.
  123264. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  123265. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  123266. *
  123267. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  123268. * ```javascript
  123269. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  123270. * ```
  123271. *
  123272. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  123273. */
  123274. export class DracoCompression implements IDisposable {
  123275. private _workerPoolPromise?;
  123276. private _decoderModulePromise?;
  123277. /**
  123278. * The configuration. Defaults to the following urls:
  123279. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  123280. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  123281. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  123282. */
  123283. static Configuration: IDracoCompressionConfiguration;
  123284. /**
  123285. * Returns true if the decoder configuration is available.
  123286. */
  123287. static readonly DecoderAvailable: boolean;
  123288. /**
  123289. * Default number of workers to create when creating the draco compression object.
  123290. */
  123291. static DefaultNumWorkers: number;
  123292. private static GetDefaultNumWorkers;
  123293. private static _Default;
  123294. /**
  123295. * Default instance for the draco compression object.
  123296. */
  123297. static readonly Default: DracoCompression;
  123298. /**
  123299. * Constructor
  123300. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  123301. */
  123302. constructor(numWorkers?: number);
  123303. /**
  123304. * Stop all async operations and release resources.
  123305. */
  123306. dispose(): void;
  123307. /**
  123308. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  123309. * @returns a promise that resolves when ready
  123310. */
  123311. whenReadyAsync(): Promise<void>;
  123312. /**
  123313. * Decode Draco compressed mesh data to vertex data.
  123314. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  123315. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  123316. * @returns A promise that resolves with the decoded vertex data
  123317. */
  123318. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  123319. [kind: string]: number;
  123320. }): Promise<VertexData>;
  123321. }
  123322. }
  123323. declare module BABYLON {
  123324. /**
  123325. * Class for building Constructive Solid Geometry
  123326. */
  123327. export class CSG {
  123328. private polygons;
  123329. /**
  123330. * The world matrix
  123331. */
  123332. matrix: Matrix;
  123333. /**
  123334. * Stores the position
  123335. */
  123336. position: Vector3;
  123337. /**
  123338. * Stores the rotation
  123339. */
  123340. rotation: Vector3;
  123341. /**
  123342. * Stores the rotation quaternion
  123343. */
  123344. rotationQuaternion: Nullable<Quaternion>;
  123345. /**
  123346. * Stores the scaling vector
  123347. */
  123348. scaling: Vector3;
  123349. /**
  123350. * Convert the Mesh to CSG
  123351. * @param mesh The Mesh to convert to CSG
  123352. * @returns A new CSG from the Mesh
  123353. */
  123354. static FromMesh(mesh: Mesh): CSG;
  123355. /**
  123356. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  123357. * @param polygons Polygons used to construct a CSG solid
  123358. */
  123359. private static FromPolygons;
  123360. /**
  123361. * Clones, or makes a deep copy, of the CSG
  123362. * @returns A new CSG
  123363. */
  123364. clone(): CSG;
  123365. /**
  123366. * Unions this CSG with another CSG
  123367. * @param csg The CSG to union against this CSG
  123368. * @returns The unioned CSG
  123369. */
  123370. union(csg: CSG): CSG;
  123371. /**
  123372. * Unions this CSG with another CSG in place
  123373. * @param csg The CSG to union against this CSG
  123374. */
  123375. unionInPlace(csg: CSG): void;
  123376. /**
  123377. * Subtracts this CSG with another CSG
  123378. * @param csg The CSG to subtract against this CSG
  123379. * @returns A new CSG
  123380. */
  123381. subtract(csg: CSG): CSG;
  123382. /**
  123383. * Subtracts this CSG with another CSG in place
  123384. * @param csg The CSG to subtact against this CSG
  123385. */
  123386. subtractInPlace(csg: CSG): void;
  123387. /**
  123388. * Intersect this CSG with another CSG
  123389. * @param csg The CSG to intersect against this CSG
  123390. * @returns A new CSG
  123391. */
  123392. intersect(csg: CSG): CSG;
  123393. /**
  123394. * Intersects this CSG with another CSG in place
  123395. * @param csg The CSG to intersect against this CSG
  123396. */
  123397. intersectInPlace(csg: CSG): void;
  123398. /**
  123399. * Return a new CSG solid with solid and empty space switched. This solid is
  123400. * not modified.
  123401. * @returns A new CSG solid with solid and empty space switched
  123402. */
  123403. inverse(): CSG;
  123404. /**
  123405. * Inverses the CSG in place
  123406. */
  123407. inverseInPlace(): void;
  123408. /**
  123409. * This is used to keep meshes transformations so they can be restored
  123410. * when we build back a Babylon Mesh
  123411. * NB : All CSG operations are performed in world coordinates
  123412. * @param csg The CSG to copy the transform attributes from
  123413. * @returns This CSG
  123414. */
  123415. copyTransformAttributes(csg: CSG): CSG;
  123416. /**
  123417. * Build Raw mesh from CSG
  123418. * Coordinates here are in world space
  123419. * @param name The name of the mesh geometry
  123420. * @param scene The Scene
  123421. * @param keepSubMeshes Specifies if the submeshes should be kept
  123422. * @returns A new Mesh
  123423. */
  123424. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123425. /**
  123426. * Build Mesh from CSG taking material and transforms into account
  123427. * @param name The name of the Mesh
  123428. * @param material The material of the Mesh
  123429. * @param scene The Scene
  123430. * @param keepSubMeshes Specifies if submeshes should be kept
  123431. * @returns The new Mesh
  123432. */
  123433. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123434. }
  123435. }
  123436. declare module BABYLON {
  123437. /**
  123438. * Class used to create a trail following a mesh
  123439. */
  123440. export class TrailMesh extends Mesh {
  123441. private _generator;
  123442. private _autoStart;
  123443. private _running;
  123444. private _diameter;
  123445. private _length;
  123446. private _sectionPolygonPointsCount;
  123447. private _sectionVectors;
  123448. private _sectionNormalVectors;
  123449. private _beforeRenderObserver;
  123450. /**
  123451. * @constructor
  123452. * @param name The value used by scene.getMeshByName() to do a lookup.
  123453. * @param generator The mesh to generate a trail.
  123454. * @param scene The scene to add this mesh to.
  123455. * @param diameter Diameter of trailing mesh. Default is 1.
  123456. * @param length Length of trailing mesh. Default is 60.
  123457. * @param autoStart Automatically start trailing mesh. Default true.
  123458. */
  123459. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  123460. /**
  123461. * "TrailMesh"
  123462. * @returns "TrailMesh"
  123463. */
  123464. getClassName(): string;
  123465. private _createMesh;
  123466. /**
  123467. * Start trailing mesh.
  123468. */
  123469. start(): void;
  123470. /**
  123471. * Stop trailing mesh.
  123472. */
  123473. stop(): void;
  123474. /**
  123475. * Update trailing mesh geometry.
  123476. */
  123477. update(): void;
  123478. /**
  123479. * Returns a new TrailMesh object.
  123480. * @param name is a string, the name given to the new mesh
  123481. * @param newGenerator use new generator object for cloned trail mesh
  123482. * @returns a new mesh
  123483. */
  123484. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  123485. /**
  123486. * Serializes this trail mesh
  123487. * @param serializationObject object to write serialization to
  123488. */
  123489. serialize(serializationObject: any): void;
  123490. /**
  123491. * Parses a serialized trail mesh
  123492. * @param parsedMesh the serialized mesh
  123493. * @param scene the scene to create the trail mesh in
  123494. * @returns the created trail mesh
  123495. */
  123496. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  123497. }
  123498. }
  123499. declare module BABYLON {
  123500. /**
  123501. * Class containing static functions to help procedurally build meshes
  123502. */
  123503. export class TiledBoxBuilder {
  123504. /**
  123505. * Creates a box mesh
  123506. * 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)
  123507. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123509. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123511. * @param name defines the name of the mesh
  123512. * @param options defines the options used to create the mesh
  123513. * @param scene defines the hosting scene
  123514. * @returns the box mesh
  123515. */
  123516. static CreateTiledBox(name: string, options: {
  123517. pattern?: number;
  123518. width?: number;
  123519. height?: number;
  123520. depth?: number;
  123521. tileSize?: number;
  123522. tileWidth?: number;
  123523. tileHeight?: number;
  123524. alignHorizontal?: number;
  123525. alignVertical?: number;
  123526. faceUV?: Vector4[];
  123527. faceColors?: Color4[];
  123528. sideOrientation?: number;
  123529. updatable?: boolean;
  123530. }, scene?: Nullable<Scene>): Mesh;
  123531. }
  123532. }
  123533. declare module BABYLON {
  123534. /**
  123535. * Class containing static functions to help procedurally build meshes
  123536. */
  123537. export class TorusKnotBuilder {
  123538. /**
  123539. * Creates a torus knot mesh
  123540. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123541. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123542. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123543. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123547. * @param name defines the name of the mesh
  123548. * @param options defines the options used to create the mesh
  123549. * @param scene defines the hosting scene
  123550. * @returns the torus knot mesh
  123551. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123552. */
  123553. static CreateTorusKnot(name: string, options: {
  123554. radius?: number;
  123555. tube?: number;
  123556. radialSegments?: number;
  123557. tubularSegments?: number;
  123558. p?: number;
  123559. q?: number;
  123560. updatable?: boolean;
  123561. sideOrientation?: number;
  123562. frontUVs?: Vector4;
  123563. backUVs?: Vector4;
  123564. }, scene: any): Mesh;
  123565. }
  123566. }
  123567. declare module BABYLON {
  123568. /**
  123569. * Polygon
  123570. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  123571. */
  123572. export class Polygon {
  123573. /**
  123574. * Creates a rectangle
  123575. * @param xmin bottom X coord
  123576. * @param ymin bottom Y coord
  123577. * @param xmax top X coord
  123578. * @param ymax top Y coord
  123579. * @returns points that make the resulting rectation
  123580. */
  123581. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  123582. /**
  123583. * Creates a circle
  123584. * @param radius radius of circle
  123585. * @param cx scale in x
  123586. * @param cy scale in y
  123587. * @param numberOfSides number of sides that make up the circle
  123588. * @returns points that make the resulting circle
  123589. */
  123590. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  123591. /**
  123592. * Creates a polygon from input string
  123593. * @param input Input polygon data
  123594. * @returns the parsed points
  123595. */
  123596. static Parse(input: string): Vector2[];
  123597. /**
  123598. * Starts building a polygon from x and y coordinates
  123599. * @param x x coordinate
  123600. * @param y y coordinate
  123601. * @returns the started path2
  123602. */
  123603. static StartingAt(x: number, y: number): Path2;
  123604. }
  123605. /**
  123606. * Builds a polygon
  123607. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  123608. */
  123609. export class PolygonMeshBuilder {
  123610. private _points;
  123611. private _outlinepoints;
  123612. private _holes;
  123613. private _name;
  123614. private _scene;
  123615. private _epoints;
  123616. private _eholes;
  123617. private _addToepoint;
  123618. /**
  123619. * Babylon reference to the earcut plugin.
  123620. */
  123621. bjsEarcut: any;
  123622. /**
  123623. * Creates a PolygonMeshBuilder
  123624. * @param name name of the builder
  123625. * @param contours Path of the polygon
  123626. * @param scene scene to add to when creating the mesh
  123627. * @param earcutInjection can be used to inject your own earcut reference
  123628. */
  123629. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  123630. /**
  123631. * Adds a whole within the polygon
  123632. * @param hole Array of points defining the hole
  123633. * @returns this
  123634. */
  123635. addHole(hole: Vector2[]): PolygonMeshBuilder;
  123636. /**
  123637. * Creates the polygon
  123638. * @param updatable If the mesh should be updatable
  123639. * @param depth The depth of the mesh created
  123640. * @returns the created mesh
  123641. */
  123642. build(updatable?: boolean, depth?: number): Mesh;
  123643. /**
  123644. * Creates the polygon
  123645. * @param depth The depth of the mesh created
  123646. * @returns the created VertexData
  123647. */
  123648. buildVertexData(depth?: number): VertexData;
  123649. /**
  123650. * Adds a side to the polygon
  123651. * @param positions points that make the polygon
  123652. * @param normals normals of the polygon
  123653. * @param uvs uvs of the polygon
  123654. * @param indices indices of the polygon
  123655. * @param bounds bounds of the polygon
  123656. * @param points points of the polygon
  123657. * @param depth depth of the polygon
  123658. * @param flip flip of the polygon
  123659. */
  123660. private addSide;
  123661. }
  123662. }
  123663. declare module BABYLON {
  123664. /**
  123665. * Class containing static functions to help procedurally build meshes
  123666. */
  123667. export class PolygonBuilder {
  123668. /**
  123669. * Creates a polygon mesh
  123670. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123671. * * 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
  123672. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123675. * * Remember you can only change the shape positions, not their number when updating a polygon
  123676. * @param name defines the name of the mesh
  123677. * @param options defines the options used to create the mesh
  123678. * @param scene defines the hosting scene
  123679. * @param earcutInjection can be used to inject your own earcut reference
  123680. * @returns the polygon mesh
  123681. */
  123682. static CreatePolygon(name: string, options: {
  123683. shape: Vector3[];
  123684. holes?: Vector3[][];
  123685. depth?: number;
  123686. faceUV?: Vector4[];
  123687. faceColors?: Color4[];
  123688. updatable?: boolean;
  123689. sideOrientation?: number;
  123690. frontUVs?: Vector4;
  123691. backUVs?: Vector4;
  123692. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123693. /**
  123694. * Creates an extruded polygon mesh, with depth in the Y direction.
  123695. * * 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)
  123696. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123697. * @param name defines the name of the mesh
  123698. * @param options defines the options used to create the mesh
  123699. * @param scene defines the hosting scene
  123700. * @param earcutInjection can be used to inject your own earcut reference
  123701. * @returns the polygon mesh
  123702. */
  123703. static ExtrudePolygon(name: string, options: {
  123704. shape: Vector3[];
  123705. holes?: Vector3[][];
  123706. depth?: number;
  123707. faceUV?: Vector4[];
  123708. faceColors?: Color4[];
  123709. updatable?: boolean;
  123710. sideOrientation?: number;
  123711. frontUVs?: Vector4;
  123712. backUVs?: Vector4;
  123713. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123714. }
  123715. }
  123716. declare module BABYLON {
  123717. /**
  123718. * Class containing static functions to help procedurally build meshes
  123719. */
  123720. export class LatheBuilder {
  123721. /**
  123722. * Creates lathe mesh.
  123723. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123724. * * 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
  123725. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123726. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123727. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123728. * * 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
  123729. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123730. * * 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
  123731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123733. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123735. * @param name defines the name of the mesh
  123736. * @param options defines the options used to create the mesh
  123737. * @param scene defines the hosting scene
  123738. * @returns the lathe mesh
  123739. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123740. */
  123741. static CreateLathe(name: string, options: {
  123742. shape: Vector3[];
  123743. radius?: number;
  123744. tessellation?: number;
  123745. clip?: number;
  123746. arc?: number;
  123747. closed?: boolean;
  123748. updatable?: boolean;
  123749. sideOrientation?: number;
  123750. frontUVs?: Vector4;
  123751. backUVs?: Vector4;
  123752. cap?: number;
  123753. invertUV?: boolean;
  123754. }, scene?: Nullable<Scene>): Mesh;
  123755. }
  123756. }
  123757. declare module BABYLON {
  123758. /**
  123759. * Class containing static functions to help procedurally build meshes
  123760. */
  123761. export class TiledPlaneBuilder {
  123762. /**
  123763. * Creates a tiled plane mesh
  123764. * * The parameter `pattern` will, depending on value, do nothing or
  123765. * * * flip (reflect about central vertical) alternate tiles across and up
  123766. * * * flip every tile on alternate rows
  123767. * * * rotate (180 degs) alternate tiles across and up
  123768. * * * rotate every tile on alternate rows
  123769. * * * flip and rotate alternate tiles across and up
  123770. * * * flip and rotate every tile on alternate rows
  123771. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123772. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123773. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123774. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123775. * * 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)
  123776. * * 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)
  123777. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123778. * @param name defines the name of the mesh
  123779. * @param options defines the options used to create the mesh
  123780. * @param scene defines the hosting scene
  123781. * @returns the box mesh
  123782. */
  123783. static CreateTiledPlane(name: string, options: {
  123784. pattern?: number;
  123785. tileSize?: number;
  123786. tileWidth?: number;
  123787. tileHeight?: number;
  123788. size?: number;
  123789. width?: number;
  123790. height?: number;
  123791. alignHorizontal?: number;
  123792. alignVertical?: number;
  123793. sideOrientation?: number;
  123794. frontUVs?: Vector4;
  123795. backUVs?: Vector4;
  123796. updatable?: boolean;
  123797. }, scene?: Nullable<Scene>): Mesh;
  123798. }
  123799. }
  123800. declare module BABYLON {
  123801. /**
  123802. * Class containing static functions to help procedurally build meshes
  123803. */
  123804. export class TubeBuilder {
  123805. /**
  123806. * Creates a tube mesh.
  123807. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123808. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123809. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123810. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123811. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123812. * * 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)
  123813. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123814. * * 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
  123815. * * 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
  123816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123818. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123820. * @param name defines the name of the mesh
  123821. * @param options defines the options used to create the mesh
  123822. * @param scene defines the hosting scene
  123823. * @returns the tube mesh
  123824. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123825. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123826. */
  123827. static CreateTube(name: string, options: {
  123828. path: Vector3[];
  123829. radius?: number;
  123830. tessellation?: number;
  123831. radiusFunction?: {
  123832. (i: number, distance: number): number;
  123833. };
  123834. cap?: number;
  123835. arc?: number;
  123836. updatable?: boolean;
  123837. sideOrientation?: number;
  123838. frontUVs?: Vector4;
  123839. backUVs?: Vector4;
  123840. instance?: Mesh;
  123841. invertUV?: boolean;
  123842. }, scene?: Nullable<Scene>): Mesh;
  123843. }
  123844. }
  123845. declare module BABYLON {
  123846. /**
  123847. * Class containing static functions to help procedurally build meshes
  123848. */
  123849. export class IcoSphereBuilder {
  123850. /**
  123851. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123852. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123853. * * 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`)
  123854. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123855. * * 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
  123856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123859. * @param name defines the name of the mesh
  123860. * @param options defines the options used to create the mesh
  123861. * @param scene defines the hosting scene
  123862. * @returns the icosahedron mesh
  123863. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123864. */
  123865. static CreateIcoSphere(name: string, options: {
  123866. radius?: number;
  123867. radiusX?: number;
  123868. radiusY?: number;
  123869. radiusZ?: number;
  123870. flat?: boolean;
  123871. subdivisions?: number;
  123872. sideOrientation?: number;
  123873. frontUVs?: Vector4;
  123874. backUVs?: Vector4;
  123875. updatable?: boolean;
  123876. }, scene?: Nullable<Scene>): Mesh;
  123877. }
  123878. }
  123879. declare module BABYLON {
  123880. /**
  123881. * Class containing static functions to help procedurally build meshes
  123882. */
  123883. export class DecalBuilder {
  123884. /**
  123885. * Creates a decal mesh.
  123886. * 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
  123887. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123888. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123889. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123890. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123891. * @param name defines the name of the mesh
  123892. * @param sourceMesh defines the mesh where the decal must be applied
  123893. * @param options defines the options used to create the mesh
  123894. * @param scene defines the hosting scene
  123895. * @returns the decal mesh
  123896. * @see https://doc.babylonjs.com/how_to/decals
  123897. */
  123898. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123899. position?: Vector3;
  123900. normal?: Vector3;
  123901. size?: Vector3;
  123902. angle?: number;
  123903. }): Mesh;
  123904. }
  123905. }
  123906. declare module BABYLON {
  123907. /**
  123908. * Class containing static functions to help procedurally build meshes
  123909. */
  123910. export class MeshBuilder {
  123911. /**
  123912. * Creates a box mesh
  123913. * * The parameter `size` sets the size (float) of each box side (default 1)
  123914. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123915. * * 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)
  123916. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123920. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123921. * @param name defines the name of the mesh
  123922. * @param options defines the options used to create the mesh
  123923. * @param scene defines the hosting scene
  123924. * @returns the box mesh
  123925. */
  123926. static CreateBox(name: string, options: {
  123927. size?: number;
  123928. width?: number;
  123929. height?: number;
  123930. depth?: number;
  123931. faceUV?: Vector4[];
  123932. faceColors?: Color4[];
  123933. sideOrientation?: number;
  123934. frontUVs?: Vector4;
  123935. backUVs?: Vector4;
  123936. updatable?: boolean;
  123937. }, scene?: Nullable<Scene>): Mesh;
  123938. /**
  123939. * Creates a tiled box mesh
  123940. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123942. * @param name defines the name of the mesh
  123943. * @param options defines the options used to create the mesh
  123944. * @param scene defines the hosting scene
  123945. * @returns the tiled box mesh
  123946. */
  123947. static CreateTiledBox(name: string, options: {
  123948. pattern?: number;
  123949. size?: number;
  123950. width?: number;
  123951. height?: number;
  123952. depth: number;
  123953. tileSize?: number;
  123954. tileWidth?: number;
  123955. tileHeight?: number;
  123956. faceUV?: Vector4[];
  123957. faceColors?: Color4[];
  123958. alignHorizontal?: number;
  123959. alignVertical?: number;
  123960. sideOrientation?: number;
  123961. updatable?: boolean;
  123962. }, scene?: Nullable<Scene>): Mesh;
  123963. /**
  123964. * Creates a sphere mesh
  123965. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123966. * * 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`)
  123967. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123968. * * 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
  123969. * * 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)
  123970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123973. * @param name defines the name of the mesh
  123974. * @param options defines the options used to create the mesh
  123975. * @param scene defines the hosting scene
  123976. * @returns the sphere mesh
  123977. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123978. */
  123979. static CreateSphere(name: string, options: {
  123980. segments?: number;
  123981. diameter?: number;
  123982. diameterX?: number;
  123983. diameterY?: number;
  123984. diameterZ?: number;
  123985. arc?: number;
  123986. slice?: number;
  123987. sideOrientation?: number;
  123988. frontUVs?: Vector4;
  123989. backUVs?: Vector4;
  123990. updatable?: boolean;
  123991. }, scene?: Nullable<Scene>): Mesh;
  123992. /**
  123993. * Creates a plane polygonal mesh. By default, this is a disc
  123994. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123995. * * 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
  123996. * * 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
  123997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124000. * @param name defines the name of the mesh
  124001. * @param options defines the options used to create the mesh
  124002. * @param scene defines the hosting scene
  124003. * @returns the plane polygonal mesh
  124004. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  124005. */
  124006. static CreateDisc(name: string, options: {
  124007. radius?: number;
  124008. tessellation?: number;
  124009. arc?: number;
  124010. updatable?: boolean;
  124011. sideOrientation?: number;
  124012. frontUVs?: Vector4;
  124013. backUVs?: Vector4;
  124014. }, scene?: Nullable<Scene>): Mesh;
  124015. /**
  124016. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  124017. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  124018. * * 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`)
  124019. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  124020. * * 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
  124021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124024. * @param name defines the name of the mesh
  124025. * @param options defines the options used to create the mesh
  124026. * @param scene defines the hosting scene
  124027. * @returns the icosahedron mesh
  124028. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  124029. */
  124030. static CreateIcoSphere(name: string, options: {
  124031. radius?: number;
  124032. radiusX?: number;
  124033. radiusY?: number;
  124034. radiusZ?: number;
  124035. flat?: boolean;
  124036. subdivisions?: number;
  124037. sideOrientation?: number;
  124038. frontUVs?: Vector4;
  124039. backUVs?: Vector4;
  124040. updatable?: boolean;
  124041. }, scene?: Nullable<Scene>): Mesh;
  124042. /**
  124043. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124044. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124045. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124046. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124047. * * 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
  124048. * * 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
  124049. * * 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
  124050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124053. * * 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
  124054. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124055. * * 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
  124056. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124058. * @param name defines the name of the mesh
  124059. * @param options defines the options used to create the mesh
  124060. * @param scene defines the hosting scene
  124061. * @returns the ribbon mesh
  124062. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124063. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124064. */
  124065. static CreateRibbon(name: string, options: {
  124066. pathArray: Vector3[][];
  124067. closeArray?: boolean;
  124068. closePath?: boolean;
  124069. offset?: number;
  124070. updatable?: boolean;
  124071. sideOrientation?: number;
  124072. frontUVs?: Vector4;
  124073. backUVs?: Vector4;
  124074. instance?: Mesh;
  124075. invertUV?: boolean;
  124076. uvs?: Vector2[];
  124077. colors?: Color4[];
  124078. }, scene?: Nullable<Scene>): Mesh;
  124079. /**
  124080. * Creates a cylinder or a cone mesh
  124081. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124082. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124083. * * 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.
  124084. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124085. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124086. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124087. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124088. * * 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).
  124089. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124090. * * 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).
  124091. * * 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
  124092. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124093. * * 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
  124094. * * 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.
  124095. * * If `enclose` is false, a ring surface is one element.
  124096. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124097. * * 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
  124098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124101. * @param name defines the name of the mesh
  124102. * @param options defines the options used to create the mesh
  124103. * @param scene defines the hosting scene
  124104. * @returns the cylinder mesh
  124105. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124106. */
  124107. static CreateCylinder(name: string, options: {
  124108. height?: number;
  124109. diameterTop?: number;
  124110. diameterBottom?: number;
  124111. diameter?: number;
  124112. tessellation?: number;
  124113. subdivisions?: number;
  124114. arc?: number;
  124115. faceColors?: Color4[];
  124116. faceUV?: Vector4[];
  124117. updatable?: boolean;
  124118. hasRings?: boolean;
  124119. enclose?: boolean;
  124120. cap?: number;
  124121. sideOrientation?: number;
  124122. frontUVs?: Vector4;
  124123. backUVs?: Vector4;
  124124. }, scene?: Nullable<Scene>): Mesh;
  124125. /**
  124126. * Creates a torus mesh
  124127. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124128. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124129. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124133. * @param name defines the name of the mesh
  124134. * @param options defines the options used to create the mesh
  124135. * @param scene defines the hosting scene
  124136. * @returns the torus mesh
  124137. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124138. */
  124139. static CreateTorus(name: string, options: {
  124140. diameter?: number;
  124141. thickness?: number;
  124142. tessellation?: number;
  124143. updatable?: boolean;
  124144. sideOrientation?: number;
  124145. frontUVs?: Vector4;
  124146. backUVs?: Vector4;
  124147. }, scene?: Nullable<Scene>): Mesh;
  124148. /**
  124149. * Creates a torus knot mesh
  124150. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124151. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124152. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124153. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124157. * @param name defines the name of the mesh
  124158. * @param options defines the options used to create the mesh
  124159. * @param scene defines the hosting scene
  124160. * @returns the torus knot mesh
  124161. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124162. */
  124163. static CreateTorusKnot(name: string, options: {
  124164. radius?: number;
  124165. tube?: number;
  124166. radialSegments?: number;
  124167. tubularSegments?: number;
  124168. p?: number;
  124169. q?: number;
  124170. updatable?: boolean;
  124171. sideOrientation?: number;
  124172. frontUVs?: Vector4;
  124173. backUVs?: Vector4;
  124174. }, scene?: Nullable<Scene>): Mesh;
  124175. /**
  124176. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  124177. * * 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
  124178. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  124179. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  124180. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  124181. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  124182. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124183. * * 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
  124184. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  124185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124186. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  124187. * @param name defines the name of the new line system
  124188. * @param options defines the options used to create the line system
  124189. * @param scene defines the hosting scene
  124190. * @returns a new line system mesh
  124191. */
  124192. static CreateLineSystem(name: string, options: {
  124193. lines: Vector3[][];
  124194. updatable?: boolean;
  124195. instance?: Nullable<LinesMesh>;
  124196. colors?: Nullable<Color4[][]>;
  124197. useVertexAlpha?: boolean;
  124198. }, scene: Nullable<Scene>): LinesMesh;
  124199. /**
  124200. * Creates a line mesh
  124201. * 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
  124202. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124203. * * The parameter `points` is an array successive Vector3
  124204. * * 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
  124205. * * The optional parameter `colors` is an array of successive Color4, one per line point
  124206. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  124207. * * When updating an instance, remember that only point positions can change, not the number of points
  124208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124209. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  124210. * @param name defines the name of the new line system
  124211. * @param options defines the options used to create the line system
  124212. * @param scene defines the hosting scene
  124213. * @returns a new line mesh
  124214. */
  124215. static CreateLines(name: string, options: {
  124216. points: Vector3[];
  124217. updatable?: boolean;
  124218. instance?: Nullable<LinesMesh>;
  124219. colors?: Color4[];
  124220. useVertexAlpha?: boolean;
  124221. }, scene?: Nullable<Scene>): LinesMesh;
  124222. /**
  124223. * Creates a dashed line mesh
  124224. * * 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
  124225. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124226. * * The parameter `points` is an array successive Vector3
  124227. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  124228. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  124229. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  124230. * * 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
  124231. * * When updating an instance, remember that only point positions can change, not the number of points
  124232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124233. * @param name defines the name of the mesh
  124234. * @param options defines the options used to create the mesh
  124235. * @param scene defines the hosting scene
  124236. * @returns the dashed line mesh
  124237. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  124238. */
  124239. static CreateDashedLines(name: string, options: {
  124240. points: Vector3[];
  124241. dashSize?: number;
  124242. gapSize?: number;
  124243. dashNb?: number;
  124244. updatable?: boolean;
  124245. instance?: LinesMesh;
  124246. }, scene?: Nullable<Scene>): LinesMesh;
  124247. /**
  124248. * 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.
  124249. * * 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.
  124250. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124251. * * 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.
  124252. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124253. * * 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
  124254. * * 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
  124255. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124258. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124260. * @param name defines the name of the mesh
  124261. * @param options defines the options used to create the mesh
  124262. * @param scene defines the hosting scene
  124263. * @returns the extruded shape mesh
  124264. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124266. */
  124267. static ExtrudeShape(name: string, options: {
  124268. shape: Vector3[];
  124269. path: Vector3[];
  124270. scale?: number;
  124271. rotation?: number;
  124272. cap?: number;
  124273. updatable?: boolean;
  124274. sideOrientation?: number;
  124275. frontUVs?: Vector4;
  124276. backUVs?: Vector4;
  124277. instance?: Mesh;
  124278. invertUV?: boolean;
  124279. }, scene?: Nullable<Scene>): Mesh;
  124280. /**
  124281. * Creates an custom extruded shape mesh.
  124282. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124283. * * 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.
  124284. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124285. * * 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
  124286. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124287. * * 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
  124288. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124289. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124290. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124291. * * 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
  124292. * * 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
  124293. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124296. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124298. * @param name defines the name of the mesh
  124299. * @param options defines the options used to create the mesh
  124300. * @param scene defines the hosting scene
  124301. * @returns the custom extruded shape mesh
  124302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124303. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124305. */
  124306. static ExtrudeShapeCustom(name: string, options: {
  124307. shape: Vector3[];
  124308. path: Vector3[];
  124309. scaleFunction?: any;
  124310. rotationFunction?: any;
  124311. ribbonCloseArray?: boolean;
  124312. ribbonClosePath?: boolean;
  124313. cap?: number;
  124314. updatable?: boolean;
  124315. sideOrientation?: number;
  124316. frontUVs?: Vector4;
  124317. backUVs?: Vector4;
  124318. instance?: Mesh;
  124319. invertUV?: boolean;
  124320. }, scene?: Nullable<Scene>): Mesh;
  124321. /**
  124322. * Creates lathe mesh.
  124323. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124324. * * 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
  124325. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124326. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124327. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124328. * * 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
  124329. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124330. * * 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
  124331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124333. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124335. * @param name defines the name of the mesh
  124336. * @param options defines the options used to create the mesh
  124337. * @param scene defines the hosting scene
  124338. * @returns the lathe mesh
  124339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124340. */
  124341. static CreateLathe(name: string, options: {
  124342. shape: Vector3[];
  124343. radius?: number;
  124344. tessellation?: number;
  124345. clip?: number;
  124346. arc?: number;
  124347. closed?: boolean;
  124348. updatable?: boolean;
  124349. sideOrientation?: number;
  124350. frontUVs?: Vector4;
  124351. backUVs?: Vector4;
  124352. cap?: number;
  124353. invertUV?: boolean;
  124354. }, scene?: Nullable<Scene>): Mesh;
  124355. /**
  124356. * Creates a tiled plane mesh
  124357. * * You can set a limited pattern arrangement with the tiles
  124358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124361. * @param name defines the name of the mesh
  124362. * @param options defines the options used to create the mesh
  124363. * @param scene defines the hosting scene
  124364. * @returns the plane mesh
  124365. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124366. */
  124367. static CreateTiledPlane(name: string, options: {
  124368. pattern?: number;
  124369. tileSize?: number;
  124370. tileWidth?: number;
  124371. tileHeight?: number;
  124372. size?: number;
  124373. width?: number;
  124374. height?: number;
  124375. alignHorizontal?: number;
  124376. alignVertical?: number;
  124377. sideOrientation?: number;
  124378. frontUVs?: Vector4;
  124379. backUVs?: Vector4;
  124380. updatable?: boolean;
  124381. }, scene?: Nullable<Scene>): Mesh;
  124382. /**
  124383. * Creates a plane mesh
  124384. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  124385. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  124386. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  124387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124390. * @param name defines the name of the mesh
  124391. * @param options defines the options used to create the mesh
  124392. * @param scene defines the hosting scene
  124393. * @returns the plane mesh
  124394. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124395. */
  124396. static CreatePlane(name: string, options: {
  124397. size?: number;
  124398. width?: number;
  124399. height?: number;
  124400. sideOrientation?: number;
  124401. frontUVs?: Vector4;
  124402. backUVs?: Vector4;
  124403. updatable?: boolean;
  124404. sourcePlane?: Plane;
  124405. }, scene?: Nullable<Scene>): Mesh;
  124406. /**
  124407. * Creates a ground mesh
  124408. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124409. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124411. * @param name defines the name of the mesh
  124412. * @param options defines the options used to create the mesh
  124413. * @param scene defines the hosting scene
  124414. * @returns the ground mesh
  124415. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124416. */
  124417. static CreateGround(name: string, options: {
  124418. width?: number;
  124419. height?: number;
  124420. subdivisions?: number;
  124421. subdivisionsX?: number;
  124422. subdivisionsY?: number;
  124423. updatable?: boolean;
  124424. }, scene?: Nullable<Scene>): Mesh;
  124425. /**
  124426. * Creates a tiled ground mesh
  124427. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124428. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124429. * * 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
  124430. * * 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
  124431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124432. * @param name defines the name of the mesh
  124433. * @param options defines the options used to create the mesh
  124434. * @param scene defines the hosting scene
  124435. * @returns the tiled ground mesh
  124436. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124437. */
  124438. static CreateTiledGround(name: string, options: {
  124439. xmin: number;
  124440. zmin: number;
  124441. xmax: number;
  124442. zmax: number;
  124443. subdivisions?: {
  124444. w: number;
  124445. h: number;
  124446. };
  124447. precision?: {
  124448. w: number;
  124449. h: number;
  124450. };
  124451. updatable?: boolean;
  124452. }, scene?: Nullable<Scene>): Mesh;
  124453. /**
  124454. * Creates a ground mesh from a height map
  124455. * * The parameter `url` sets the URL of the height map image resource.
  124456. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124457. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124458. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124459. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124460. * * 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.
  124461. * * 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).
  124462. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124464. * @param name defines the name of the mesh
  124465. * @param url defines the url to the height map
  124466. * @param options defines the options used to create the mesh
  124467. * @param scene defines the hosting scene
  124468. * @returns the ground mesh
  124469. * @see https://doc.babylonjs.com/babylon101/height_map
  124470. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124471. */
  124472. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124473. width?: number;
  124474. height?: number;
  124475. subdivisions?: number;
  124476. minHeight?: number;
  124477. maxHeight?: number;
  124478. colorFilter?: Color3;
  124479. alphaFilter?: number;
  124480. updatable?: boolean;
  124481. onReady?: (mesh: GroundMesh) => void;
  124482. }, scene?: Nullable<Scene>): GroundMesh;
  124483. /**
  124484. * Creates a polygon mesh
  124485. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124486. * * 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
  124487. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124490. * * Remember you can only change the shape positions, not their number when updating a polygon
  124491. * @param name defines the name of the mesh
  124492. * @param options defines the options used to create the mesh
  124493. * @param scene defines the hosting scene
  124494. * @param earcutInjection can be used to inject your own earcut reference
  124495. * @returns the polygon mesh
  124496. */
  124497. static CreatePolygon(name: string, options: {
  124498. shape: Vector3[];
  124499. holes?: Vector3[][];
  124500. depth?: number;
  124501. faceUV?: Vector4[];
  124502. faceColors?: Color4[];
  124503. updatable?: boolean;
  124504. sideOrientation?: number;
  124505. frontUVs?: Vector4;
  124506. backUVs?: Vector4;
  124507. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124508. /**
  124509. * Creates an extruded polygon mesh, with depth in the Y direction.
  124510. * * 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)
  124511. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124512. * @param name defines the name of the mesh
  124513. * @param options defines the options used to create the mesh
  124514. * @param scene defines the hosting scene
  124515. * @param earcutInjection can be used to inject your own earcut reference
  124516. * @returns the polygon mesh
  124517. */
  124518. static ExtrudePolygon(name: string, options: {
  124519. shape: Vector3[];
  124520. holes?: Vector3[][];
  124521. depth?: number;
  124522. faceUV?: Vector4[];
  124523. faceColors?: Color4[];
  124524. updatable?: boolean;
  124525. sideOrientation?: number;
  124526. frontUVs?: Vector4;
  124527. backUVs?: Vector4;
  124528. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124529. /**
  124530. * Creates a tube mesh.
  124531. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124532. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124533. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124534. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124535. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124536. * * 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)
  124537. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124538. * * 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
  124539. * * 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
  124540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124542. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124544. * @param name defines the name of the mesh
  124545. * @param options defines the options used to create the mesh
  124546. * @param scene defines the hosting scene
  124547. * @returns the tube mesh
  124548. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124549. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  124550. */
  124551. static CreateTube(name: string, options: {
  124552. path: Vector3[];
  124553. radius?: number;
  124554. tessellation?: number;
  124555. radiusFunction?: {
  124556. (i: number, distance: number): number;
  124557. };
  124558. cap?: number;
  124559. arc?: number;
  124560. updatable?: boolean;
  124561. sideOrientation?: number;
  124562. frontUVs?: Vector4;
  124563. backUVs?: Vector4;
  124564. instance?: Mesh;
  124565. invertUV?: boolean;
  124566. }, scene?: Nullable<Scene>): Mesh;
  124567. /**
  124568. * Creates a polyhedron mesh
  124569. * * 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
  124570. * * The parameter `size` (positive float, default 1) sets the polygon size
  124571. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  124572. * * 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`
  124573. * * 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
  124574. * * 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)`)
  124575. * * 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
  124576. * * 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
  124577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124580. * @param name defines the name of the mesh
  124581. * @param options defines the options used to create the mesh
  124582. * @param scene defines the hosting scene
  124583. * @returns the polyhedron mesh
  124584. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  124585. */
  124586. static CreatePolyhedron(name: string, options: {
  124587. type?: number;
  124588. size?: number;
  124589. sizeX?: number;
  124590. sizeY?: number;
  124591. sizeZ?: number;
  124592. custom?: any;
  124593. faceUV?: Vector4[];
  124594. faceColors?: Color4[];
  124595. flat?: boolean;
  124596. updatable?: boolean;
  124597. sideOrientation?: number;
  124598. frontUVs?: Vector4;
  124599. backUVs?: Vector4;
  124600. }, scene?: Nullable<Scene>): Mesh;
  124601. /**
  124602. * Creates a decal mesh.
  124603. * 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
  124604. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  124605. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  124606. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  124607. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  124608. * @param name defines the name of the mesh
  124609. * @param sourceMesh defines the mesh where the decal must be applied
  124610. * @param options defines the options used to create the mesh
  124611. * @param scene defines the hosting scene
  124612. * @returns the decal mesh
  124613. * @see https://doc.babylonjs.com/how_to/decals
  124614. */
  124615. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  124616. position?: Vector3;
  124617. normal?: Vector3;
  124618. size?: Vector3;
  124619. angle?: number;
  124620. }): Mesh;
  124621. }
  124622. }
  124623. declare module BABYLON {
  124624. /**
  124625. * A simplifier interface for future simplification implementations
  124626. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124627. */
  124628. export interface ISimplifier {
  124629. /**
  124630. * Simplification of a given mesh according to the given settings.
  124631. * Since this requires computation, it is assumed that the function runs async.
  124632. * @param settings The settings of the simplification, including quality and distance
  124633. * @param successCallback A callback that will be called after the mesh was simplified.
  124634. * @param errorCallback in case of an error, this callback will be called. optional.
  124635. */
  124636. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  124637. }
  124638. /**
  124639. * Expected simplification settings.
  124640. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  124641. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124642. */
  124643. export interface ISimplificationSettings {
  124644. /**
  124645. * Gets or sets the expected quality
  124646. */
  124647. quality: number;
  124648. /**
  124649. * Gets or sets the distance when this optimized version should be used
  124650. */
  124651. distance: number;
  124652. /**
  124653. * Gets an already optimized mesh
  124654. */
  124655. optimizeMesh?: boolean;
  124656. }
  124657. /**
  124658. * Class used to specify simplification options
  124659. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124660. */
  124661. export class SimplificationSettings implements ISimplificationSettings {
  124662. /** expected quality */
  124663. quality: number;
  124664. /** distance when this optimized version should be used */
  124665. distance: number;
  124666. /** already optimized mesh */
  124667. optimizeMesh?: boolean | undefined;
  124668. /**
  124669. * Creates a SimplificationSettings
  124670. * @param quality expected quality
  124671. * @param distance distance when this optimized version should be used
  124672. * @param optimizeMesh already optimized mesh
  124673. */
  124674. constructor(
  124675. /** expected quality */
  124676. quality: number,
  124677. /** distance when this optimized version should be used */
  124678. distance: number,
  124679. /** already optimized mesh */
  124680. optimizeMesh?: boolean | undefined);
  124681. }
  124682. /**
  124683. * Interface used to define a simplification task
  124684. */
  124685. export interface ISimplificationTask {
  124686. /**
  124687. * Array of settings
  124688. */
  124689. settings: Array<ISimplificationSettings>;
  124690. /**
  124691. * Simplification type
  124692. */
  124693. simplificationType: SimplificationType;
  124694. /**
  124695. * Mesh to simplify
  124696. */
  124697. mesh: Mesh;
  124698. /**
  124699. * Callback called on success
  124700. */
  124701. successCallback?: () => void;
  124702. /**
  124703. * Defines if parallel processing can be used
  124704. */
  124705. parallelProcessing: boolean;
  124706. }
  124707. /**
  124708. * Queue used to order the simplification tasks
  124709. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124710. */
  124711. export class SimplificationQueue {
  124712. private _simplificationArray;
  124713. /**
  124714. * Gets a boolean indicating that the process is still running
  124715. */
  124716. running: boolean;
  124717. /**
  124718. * Creates a new queue
  124719. */
  124720. constructor();
  124721. /**
  124722. * Adds a new simplification task
  124723. * @param task defines a task to add
  124724. */
  124725. addTask(task: ISimplificationTask): void;
  124726. /**
  124727. * Execute next task
  124728. */
  124729. executeNext(): void;
  124730. /**
  124731. * Execute a simplification task
  124732. * @param task defines the task to run
  124733. */
  124734. runSimplification(task: ISimplificationTask): void;
  124735. private getSimplifier;
  124736. }
  124737. /**
  124738. * The implemented types of simplification
  124739. * At the moment only Quadratic Error Decimation is implemented
  124740. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124741. */
  124742. export enum SimplificationType {
  124743. /** Quadratic error decimation */
  124744. QUADRATIC = 0
  124745. }
  124746. }
  124747. declare module BABYLON {
  124748. interface Scene {
  124749. /** @hidden (Backing field) */
  124750. _simplificationQueue: SimplificationQueue;
  124751. /**
  124752. * Gets or sets the simplification queue attached to the scene
  124753. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124754. */
  124755. simplificationQueue: SimplificationQueue;
  124756. }
  124757. interface Mesh {
  124758. /**
  124759. * Simplify the mesh according to the given array of settings.
  124760. * Function will return immediately and will simplify async
  124761. * @param settings a collection of simplification settings
  124762. * @param parallelProcessing should all levels calculate parallel or one after the other
  124763. * @param simplificationType the type of simplification to run
  124764. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124765. * @returns the current mesh
  124766. */
  124767. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124768. }
  124769. /**
  124770. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124771. * created in a scene
  124772. */
  124773. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124774. /**
  124775. * The component name helpfull to identify the component in the list of scene components.
  124776. */
  124777. readonly name: string;
  124778. /**
  124779. * The scene the component belongs to.
  124780. */
  124781. scene: Scene;
  124782. /**
  124783. * Creates a new instance of the component for the given scene
  124784. * @param scene Defines the scene to register the component in
  124785. */
  124786. constructor(scene: Scene);
  124787. /**
  124788. * Registers the component in a given scene
  124789. */
  124790. register(): void;
  124791. /**
  124792. * Rebuilds the elements related to this component in case of
  124793. * context lost for instance.
  124794. */
  124795. rebuild(): void;
  124796. /**
  124797. * Disposes the component and the associated ressources
  124798. */
  124799. dispose(): void;
  124800. private _beforeCameraUpdate;
  124801. }
  124802. }
  124803. declare module BABYLON {
  124804. /**
  124805. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124806. */
  124807. export interface INavigationEnginePlugin {
  124808. /**
  124809. * plugin name
  124810. */
  124811. name: string;
  124812. /**
  124813. * Creates a navigation mesh
  124814. * @param meshes array of all the geometry used to compute the navigatio mesh
  124815. * @param parameters bunch of parameters used to filter geometry
  124816. */
  124817. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124818. /**
  124819. * Create a navigation mesh debug mesh
  124820. * @param scene is where the mesh will be added
  124821. * @returns debug display mesh
  124822. */
  124823. createDebugNavMesh(scene: Scene): Mesh;
  124824. /**
  124825. * Get a navigation mesh constrained position, closest to the parameter position
  124826. * @param position world position
  124827. * @returns the closest point to position constrained by the navigation mesh
  124828. */
  124829. getClosestPoint(position: Vector3): Vector3;
  124830. /**
  124831. * Get a navigation mesh constrained position, within a particular radius
  124832. * @param position world position
  124833. * @param maxRadius the maximum distance to the constrained world position
  124834. * @returns the closest point to position constrained by the navigation mesh
  124835. */
  124836. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124837. /**
  124838. * Compute the final position from a segment made of destination-position
  124839. * @param position world position
  124840. * @param destination world position
  124841. * @returns the resulting point along the navmesh
  124842. */
  124843. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124844. /**
  124845. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124846. * @param start world position
  124847. * @param end world position
  124848. * @returns array containing world position composing the path
  124849. */
  124850. computePath(start: Vector3, end: Vector3): Vector3[];
  124851. /**
  124852. * If this plugin is supported
  124853. * @returns true if plugin is supported
  124854. */
  124855. isSupported(): boolean;
  124856. /**
  124857. * Create a new Crowd so you can add agents
  124858. * @param maxAgents the maximum agent count in the crowd
  124859. * @param maxAgentRadius the maximum radius an agent can have
  124860. * @param scene to attach the crowd to
  124861. * @returns the crowd you can add agents to
  124862. */
  124863. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124864. /**
  124865. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124866. * The queries will try to find a solution within those bounds
  124867. * default is (1,1,1)
  124868. * @param extent x,y,z value that define the extent around the queries point of reference
  124869. */
  124870. setDefaultQueryExtent(extent: Vector3): void;
  124871. /**
  124872. * Get the Bounding box extent specified by setDefaultQueryExtent
  124873. * @returns the box extent values
  124874. */
  124875. getDefaultQueryExtent(): Vector3;
  124876. /**
  124877. * Release all resources
  124878. */
  124879. dispose(): void;
  124880. }
  124881. /**
  124882. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124883. */
  124884. export interface ICrowd {
  124885. /**
  124886. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124887. * You can attach anything to that node. The node position is updated in the scene update tick.
  124888. * @param pos world position that will be constrained by the navigation mesh
  124889. * @param parameters agent parameters
  124890. * @param transform hooked to the agent that will be update by the scene
  124891. * @returns agent index
  124892. */
  124893. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124894. /**
  124895. * Returns the agent position in world space
  124896. * @param index agent index returned by addAgent
  124897. * @returns world space position
  124898. */
  124899. getAgentPosition(index: number): Vector3;
  124900. /**
  124901. * Gets the agent velocity in world space
  124902. * @param index agent index returned by addAgent
  124903. * @returns world space velocity
  124904. */
  124905. getAgentVelocity(index: number): Vector3;
  124906. /**
  124907. * remove a particular agent previously created
  124908. * @param index agent index returned by addAgent
  124909. */
  124910. removeAgent(index: number): void;
  124911. /**
  124912. * get the list of all agents attached to this crowd
  124913. * @returns list of agent indices
  124914. */
  124915. getAgents(): number[];
  124916. /**
  124917. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124918. * @param deltaTime in seconds
  124919. */
  124920. update(deltaTime: number): void;
  124921. /**
  124922. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124923. * @param index agent index returned by addAgent
  124924. * @param destination targeted world position
  124925. */
  124926. agentGoto(index: number, destination: Vector3): void;
  124927. /**
  124928. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124929. * The queries will try to find a solution within those bounds
  124930. * default is (1,1,1)
  124931. * @param extent x,y,z value that define the extent around the queries point of reference
  124932. */
  124933. setDefaultQueryExtent(extent: Vector3): void;
  124934. /**
  124935. * Get the Bounding box extent specified by setDefaultQueryExtent
  124936. * @returns the box extent values
  124937. */
  124938. getDefaultQueryExtent(): Vector3;
  124939. /**
  124940. * Release all resources
  124941. */
  124942. dispose(): void;
  124943. }
  124944. /**
  124945. * Configures an agent
  124946. */
  124947. export interface IAgentParameters {
  124948. /**
  124949. * Agent radius. [Limit: >= 0]
  124950. */
  124951. radius: number;
  124952. /**
  124953. * Agent height. [Limit: > 0]
  124954. */
  124955. height: number;
  124956. /**
  124957. * Maximum allowed acceleration. [Limit: >= 0]
  124958. */
  124959. maxAcceleration: number;
  124960. /**
  124961. * Maximum allowed speed. [Limit: >= 0]
  124962. */
  124963. maxSpeed: number;
  124964. /**
  124965. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124966. */
  124967. collisionQueryRange: number;
  124968. /**
  124969. * The path visibility optimization range. [Limit: > 0]
  124970. */
  124971. pathOptimizationRange: number;
  124972. /**
  124973. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124974. */
  124975. separationWeight: number;
  124976. }
  124977. /**
  124978. * Configures the navigation mesh creation
  124979. */
  124980. export interface INavMeshParameters {
  124981. /**
  124982. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124983. */
  124984. cs: number;
  124985. /**
  124986. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124987. */
  124988. ch: number;
  124989. /**
  124990. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124991. */
  124992. walkableSlopeAngle: number;
  124993. /**
  124994. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124995. * be considered walkable. [Limit: >= 3] [Units: vx]
  124996. */
  124997. walkableHeight: number;
  124998. /**
  124999. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  125000. */
  125001. walkableClimb: number;
  125002. /**
  125003. * The distance to erode/shrink the walkable area of the heightfield away from
  125004. * obstructions. [Limit: >=0] [Units: vx]
  125005. */
  125006. walkableRadius: number;
  125007. /**
  125008. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  125009. */
  125010. maxEdgeLen: number;
  125011. /**
  125012. * The maximum distance a simplfied contour's border edges should deviate
  125013. * the original raw contour. [Limit: >=0] [Units: vx]
  125014. */
  125015. maxSimplificationError: number;
  125016. /**
  125017. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  125018. */
  125019. minRegionArea: number;
  125020. /**
  125021. * Any regions with a span count smaller than this value will, if possible,
  125022. * be merged with larger regions. [Limit: >=0] [Units: vx]
  125023. */
  125024. mergeRegionArea: number;
  125025. /**
  125026. * The maximum number of vertices allowed for polygons generated during the
  125027. * contour to polygon conversion process. [Limit: >= 3]
  125028. */
  125029. maxVertsPerPoly: number;
  125030. /**
  125031. * Sets the sampling distance to use when generating the detail mesh.
  125032. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  125033. */
  125034. detailSampleDist: number;
  125035. /**
  125036. * The maximum distance the detail mesh surface should deviate from heightfield
  125037. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  125038. */
  125039. detailSampleMaxError: number;
  125040. }
  125041. }
  125042. declare module BABYLON {
  125043. /**
  125044. * RecastJS navigation plugin
  125045. */
  125046. export class RecastJSPlugin implements INavigationEnginePlugin {
  125047. /**
  125048. * Reference to the Recast library
  125049. */
  125050. bjsRECAST: any;
  125051. /**
  125052. * plugin name
  125053. */
  125054. name: string;
  125055. /**
  125056. * the first navmesh created. We might extend this to support multiple navmeshes
  125057. */
  125058. navMesh: any;
  125059. /**
  125060. * Initializes the recastJS plugin
  125061. * @param recastInjection can be used to inject your own recast reference
  125062. */
  125063. constructor(recastInjection?: any);
  125064. /**
  125065. * Creates a navigation mesh
  125066. * @param meshes array of all the geometry used to compute the navigatio mesh
  125067. * @param parameters bunch of parameters used to filter geometry
  125068. */
  125069. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  125070. /**
  125071. * Create a navigation mesh debug mesh
  125072. * @param scene is where the mesh will be added
  125073. * @returns debug display mesh
  125074. */
  125075. createDebugNavMesh(scene: Scene): Mesh;
  125076. /**
  125077. * Get a navigation mesh constrained position, closest to the parameter position
  125078. * @param position world position
  125079. * @returns the closest point to position constrained by the navigation mesh
  125080. */
  125081. getClosestPoint(position: Vector3): Vector3;
  125082. /**
  125083. * Get a navigation mesh constrained position, within a particular radius
  125084. * @param position world position
  125085. * @param maxRadius the maximum distance to the constrained world position
  125086. * @returns the closest point to position constrained by the navigation mesh
  125087. */
  125088. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  125089. /**
  125090. * Compute the final position from a segment made of destination-position
  125091. * @param position world position
  125092. * @param destination world position
  125093. * @returns the resulting point along the navmesh
  125094. */
  125095. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125096. /**
  125097. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125098. * @param start world position
  125099. * @param end world position
  125100. * @returns array containing world position composing the path
  125101. */
  125102. computePath(start: Vector3, end: Vector3): Vector3[];
  125103. /**
  125104. * Create a new Crowd so you can add agents
  125105. * @param maxAgents the maximum agent count in the crowd
  125106. * @param maxAgentRadius the maximum radius an agent can have
  125107. * @param scene to attach the crowd to
  125108. * @returns the crowd you can add agents to
  125109. */
  125110. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  125111. /**
  125112. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125113. * The queries will try to find a solution within those bounds
  125114. * default is (1,1,1)
  125115. * @param extent x,y,z value that define the extent around the queries point of reference
  125116. */
  125117. setDefaultQueryExtent(extent: Vector3): void;
  125118. /**
  125119. * Get the Bounding box extent specified by setDefaultQueryExtent
  125120. * @returns the box extent values
  125121. */
  125122. getDefaultQueryExtent(): Vector3;
  125123. /**
  125124. * Disposes
  125125. */
  125126. dispose(): void;
  125127. /**
  125128. * If this plugin is supported
  125129. * @returns true if plugin is supported
  125130. */
  125131. isSupported(): boolean;
  125132. }
  125133. /**
  125134. * Recast detour crowd implementation
  125135. */
  125136. export class RecastJSCrowd implements ICrowd {
  125137. /**
  125138. * Recast/detour plugin
  125139. */
  125140. bjsRECASTPlugin: RecastJSPlugin;
  125141. /**
  125142. * Link to the detour crowd
  125143. */
  125144. recastCrowd: any;
  125145. /**
  125146. * One transform per agent
  125147. */
  125148. transforms: TransformNode[];
  125149. /**
  125150. * All agents created
  125151. */
  125152. agents: number[];
  125153. /**
  125154. * Link to the scene is kept to unregister the crowd from the scene
  125155. */
  125156. private _scene;
  125157. /**
  125158. * Observer for crowd updates
  125159. */
  125160. private _onBeforeAnimationsObserver;
  125161. /**
  125162. * Constructor
  125163. * @param plugin recastJS plugin
  125164. * @param maxAgents the maximum agent count in the crowd
  125165. * @param maxAgentRadius the maximum radius an agent can have
  125166. * @param scene to attach the crowd to
  125167. * @returns the crowd you can add agents to
  125168. */
  125169. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  125170. /**
  125171. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  125172. * You can attach anything to that node. The node position is updated in the scene update tick.
  125173. * @param pos world position that will be constrained by the navigation mesh
  125174. * @param parameters agent parameters
  125175. * @param transform hooked to the agent that will be update by the scene
  125176. * @returns agent index
  125177. */
  125178. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  125179. /**
  125180. * Returns the agent position in world space
  125181. * @param index agent index returned by addAgent
  125182. * @returns world space position
  125183. */
  125184. getAgentPosition(index: number): Vector3;
  125185. /**
  125186. * Returns the agent velocity in world space
  125187. * @param index agent index returned by addAgent
  125188. * @returns world space velocity
  125189. */
  125190. getAgentVelocity(index: number): Vector3;
  125191. /**
  125192. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  125193. * @param index agent index returned by addAgent
  125194. * @param destination targeted world position
  125195. */
  125196. agentGoto(index: number, destination: Vector3): void;
  125197. /**
  125198. * remove a particular agent previously created
  125199. * @param index agent index returned by addAgent
  125200. */
  125201. removeAgent(index: number): void;
  125202. /**
  125203. * get the list of all agents attached to this crowd
  125204. * @returns list of agent indices
  125205. */
  125206. getAgents(): number[];
  125207. /**
  125208. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  125209. * @param deltaTime in seconds
  125210. */
  125211. update(deltaTime: number): void;
  125212. /**
  125213. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125214. * The queries will try to find a solution within those bounds
  125215. * default is (1,1,1)
  125216. * @param extent x,y,z value that define the extent around the queries point of reference
  125217. */
  125218. setDefaultQueryExtent(extent: Vector3): void;
  125219. /**
  125220. * Get the Bounding box extent specified by setDefaultQueryExtent
  125221. * @returns the box extent values
  125222. */
  125223. getDefaultQueryExtent(): Vector3;
  125224. /**
  125225. * Release all resources
  125226. */
  125227. dispose(): void;
  125228. }
  125229. }
  125230. declare module BABYLON {
  125231. /**
  125232. * Class used to enable access to IndexedDB
  125233. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  125234. */
  125235. export class Database implements IOfflineProvider {
  125236. private _callbackManifestChecked;
  125237. private _currentSceneUrl;
  125238. private _db;
  125239. private _enableSceneOffline;
  125240. private _enableTexturesOffline;
  125241. private _manifestVersionFound;
  125242. private _mustUpdateRessources;
  125243. private _hasReachedQuota;
  125244. private _isSupported;
  125245. private _idbFactory;
  125246. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  125247. private static IsUASupportingBlobStorage;
  125248. /**
  125249. * Gets a boolean indicating if Database storate is enabled (off by default)
  125250. */
  125251. static IDBStorageEnabled: boolean;
  125252. /**
  125253. * Gets a boolean indicating if scene must be saved in the database
  125254. */
  125255. readonly enableSceneOffline: boolean;
  125256. /**
  125257. * Gets a boolean indicating if textures must be saved in the database
  125258. */
  125259. readonly enableTexturesOffline: boolean;
  125260. /**
  125261. * Creates a new Database
  125262. * @param urlToScene defines the url to load the scene
  125263. * @param callbackManifestChecked defines the callback to use when manifest is checked
  125264. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  125265. */
  125266. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  125267. private static _ParseURL;
  125268. private static _ReturnFullUrlLocation;
  125269. private _checkManifestFile;
  125270. /**
  125271. * Open the database and make it available
  125272. * @param successCallback defines the callback to call on success
  125273. * @param errorCallback defines the callback to call on error
  125274. */
  125275. open(successCallback: () => void, errorCallback: () => void): void;
  125276. /**
  125277. * Loads an image from the database
  125278. * @param url defines the url to load from
  125279. * @param image defines the target DOM image
  125280. */
  125281. loadImage(url: string, image: HTMLImageElement): void;
  125282. private _loadImageFromDBAsync;
  125283. private _saveImageIntoDBAsync;
  125284. private _checkVersionFromDB;
  125285. private _loadVersionFromDBAsync;
  125286. private _saveVersionIntoDBAsync;
  125287. /**
  125288. * Loads a file from database
  125289. * @param url defines the URL to load from
  125290. * @param sceneLoaded defines a callback to call on success
  125291. * @param progressCallBack defines a callback to call when progress changed
  125292. * @param errorCallback defines a callback to call on error
  125293. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  125294. */
  125295. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  125296. private _loadFileAsync;
  125297. private _saveFileAsync;
  125298. /**
  125299. * Validates if xhr data is correct
  125300. * @param xhr defines the request to validate
  125301. * @param dataType defines the expected data type
  125302. * @returns true if data is correct
  125303. */
  125304. private static _ValidateXHRData;
  125305. }
  125306. }
  125307. declare module BABYLON {
  125308. /** @hidden */
  125309. export var gpuUpdateParticlesPixelShader: {
  125310. name: string;
  125311. shader: string;
  125312. };
  125313. }
  125314. declare module BABYLON {
  125315. /** @hidden */
  125316. export var gpuUpdateParticlesVertexShader: {
  125317. name: string;
  125318. shader: string;
  125319. };
  125320. }
  125321. declare module BABYLON {
  125322. /** @hidden */
  125323. export var clipPlaneFragmentDeclaration2: {
  125324. name: string;
  125325. shader: string;
  125326. };
  125327. }
  125328. declare module BABYLON {
  125329. /** @hidden */
  125330. export var gpuRenderParticlesPixelShader: {
  125331. name: string;
  125332. shader: string;
  125333. };
  125334. }
  125335. declare module BABYLON {
  125336. /** @hidden */
  125337. export var clipPlaneVertexDeclaration2: {
  125338. name: string;
  125339. shader: string;
  125340. };
  125341. }
  125342. declare module BABYLON {
  125343. /** @hidden */
  125344. export var gpuRenderParticlesVertexShader: {
  125345. name: string;
  125346. shader: string;
  125347. };
  125348. }
  125349. declare module BABYLON {
  125350. /**
  125351. * This represents a GPU particle system in Babylon
  125352. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  125353. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  125354. */
  125355. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  125356. /**
  125357. * The layer mask we are rendering the particles through.
  125358. */
  125359. layerMask: number;
  125360. private _capacity;
  125361. private _activeCount;
  125362. private _currentActiveCount;
  125363. private _accumulatedCount;
  125364. private _renderEffect;
  125365. private _updateEffect;
  125366. private _buffer0;
  125367. private _buffer1;
  125368. private _spriteBuffer;
  125369. private _updateVAO;
  125370. private _renderVAO;
  125371. private _targetIndex;
  125372. private _sourceBuffer;
  125373. private _targetBuffer;
  125374. private _engine;
  125375. private _currentRenderId;
  125376. private _started;
  125377. private _stopped;
  125378. private _timeDelta;
  125379. private _randomTexture;
  125380. private _randomTexture2;
  125381. private _attributesStrideSize;
  125382. private _updateEffectOptions;
  125383. private _randomTextureSize;
  125384. private _actualFrame;
  125385. private readonly _rawTextureWidth;
  125386. /**
  125387. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  125388. */
  125389. static readonly IsSupported: boolean;
  125390. /**
  125391. * An event triggered when the system is disposed.
  125392. */
  125393. onDisposeObservable: Observable<GPUParticleSystem>;
  125394. /**
  125395. * Gets the maximum number of particles active at the same time.
  125396. * @returns The max number of active particles.
  125397. */
  125398. getCapacity(): number;
  125399. /**
  125400. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  125401. * to override the particles.
  125402. */
  125403. forceDepthWrite: boolean;
  125404. /**
  125405. * Gets or set the number of active particles
  125406. */
  125407. activeParticleCount: number;
  125408. private _preWarmDone;
  125409. /**
  125410. * Is this system ready to be used/rendered
  125411. * @return true if the system is ready
  125412. */
  125413. isReady(): boolean;
  125414. /**
  125415. * Gets if the system has been started. (Note: this will still be true after stop is called)
  125416. * @returns True if it has been started, otherwise false.
  125417. */
  125418. isStarted(): boolean;
  125419. /**
  125420. * Starts the particle system and begins to emit
  125421. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  125422. */
  125423. start(delay?: number): void;
  125424. /**
  125425. * Stops the particle system.
  125426. */
  125427. stop(): void;
  125428. /**
  125429. * Remove all active particles
  125430. */
  125431. reset(): void;
  125432. /**
  125433. * Returns the string "GPUParticleSystem"
  125434. * @returns a string containing the class name
  125435. */
  125436. getClassName(): string;
  125437. private _colorGradientsTexture;
  125438. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  125439. /**
  125440. * Adds a new color gradient
  125441. * @param gradient defines the gradient to use (between 0 and 1)
  125442. * @param color1 defines the color to affect to the specified gradient
  125443. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  125444. * @returns the current particle system
  125445. */
  125446. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  125447. /**
  125448. * Remove a specific color gradient
  125449. * @param gradient defines the gradient to remove
  125450. * @returns the current particle system
  125451. */
  125452. removeColorGradient(gradient: number): GPUParticleSystem;
  125453. private _angularSpeedGradientsTexture;
  125454. private _sizeGradientsTexture;
  125455. private _velocityGradientsTexture;
  125456. private _limitVelocityGradientsTexture;
  125457. private _dragGradientsTexture;
  125458. private _addFactorGradient;
  125459. /**
  125460. * Adds a new size gradient
  125461. * @param gradient defines the gradient to use (between 0 and 1)
  125462. * @param factor defines the size factor to affect to the specified gradient
  125463. * @returns the current particle system
  125464. */
  125465. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  125466. /**
  125467. * Remove a specific size gradient
  125468. * @param gradient defines the gradient to remove
  125469. * @returns the current particle system
  125470. */
  125471. removeSizeGradient(gradient: number): GPUParticleSystem;
  125472. /**
  125473. * Adds a new angular speed gradient
  125474. * @param gradient defines the gradient to use (between 0 and 1)
  125475. * @param factor defines the angular speed to affect to the specified gradient
  125476. * @returns the current particle system
  125477. */
  125478. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  125479. /**
  125480. * Remove a specific angular speed gradient
  125481. * @param gradient defines the gradient to remove
  125482. * @returns the current particle system
  125483. */
  125484. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  125485. /**
  125486. * Adds a new velocity gradient
  125487. * @param gradient defines the gradient to use (between 0 and 1)
  125488. * @param factor defines the velocity to affect to the specified gradient
  125489. * @returns the current particle system
  125490. */
  125491. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125492. /**
  125493. * Remove a specific velocity gradient
  125494. * @param gradient defines the gradient to remove
  125495. * @returns the current particle system
  125496. */
  125497. removeVelocityGradient(gradient: number): GPUParticleSystem;
  125498. /**
  125499. * Adds a new limit velocity gradient
  125500. * @param gradient defines the gradient to use (between 0 and 1)
  125501. * @param factor defines the limit velocity value to affect to the specified gradient
  125502. * @returns the current particle system
  125503. */
  125504. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125505. /**
  125506. * Remove a specific limit velocity gradient
  125507. * @param gradient defines the gradient to remove
  125508. * @returns the current particle system
  125509. */
  125510. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  125511. /**
  125512. * Adds a new drag gradient
  125513. * @param gradient defines the gradient to use (between 0 and 1)
  125514. * @param factor defines the drag value to affect to the specified gradient
  125515. * @returns the current particle system
  125516. */
  125517. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  125518. /**
  125519. * Remove a specific drag gradient
  125520. * @param gradient defines the gradient to remove
  125521. * @returns the current particle system
  125522. */
  125523. removeDragGradient(gradient: number): GPUParticleSystem;
  125524. /**
  125525. * Not supported by GPUParticleSystem
  125526. * @param gradient defines the gradient to use (between 0 and 1)
  125527. * @param factor defines the emit rate value to affect to the specified gradient
  125528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125529. * @returns the current particle system
  125530. */
  125531. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125532. /**
  125533. * Not supported by GPUParticleSystem
  125534. * @param gradient defines the gradient to remove
  125535. * @returns the current particle system
  125536. */
  125537. removeEmitRateGradient(gradient: number): IParticleSystem;
  125538. /**
  125539. * Not supported by GPUParticleSystem
  125540. * @param gradient defines the gradient to use (between 0 and 1)
  125541. * @param factor defines the start size value to affect to the specified gradient
  125542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125543. * @returns the current particle system
  125544. */
  125545. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125546. /**
  125547. * Not supported by GPUParticleSystem
  125548. * @param gradient defines the gradient to remove
  125549. * @returns the current particle system
  125550. */
  125551. removeStartSizeGradient(gradient: number): IParticleSystem;
  125552. /**
  125553. * Not supported by GPUParticleSystem
  125554. * @param gradient defines the gradient to use (between 0 and 1)
  125555. * @param min defines the color remap minimal range
  125556. * @param max defines the color remap maximal range
  125557. * @returns the current particle system
  125558. */
  125559. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125560. /**
  125561. * Not supported by GPUParticleSystem
  125562. * @param gradient defines the gradient to remove
  125563. * @returns the current particle system
  125564. */
  125565. removeColorRemapGradient(): IParticleSystem;
  125566. /**
  125567. * Not supported by GPUParticleSystem
  125568. * @param gradient defines the gradient to use (between 0 and 1)
  125569. * @param min defines the alpha remap minimal range
  125570. * @param max defines the alpha remap maximal range
  125571. * @returns the current particle system
  125572. */
  125573. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125574. /**
  125575. * Not supported by GPUParticleSystem
  125576. * @param gradient defines the gradient to remove
  125577. * @returns the current particle system
  125578. */
  125579. removeAlphaRemapGradient(): IParticleSystem;
  125580. /**
  125581. * Not supported by GPUParticleSystem
  125582. * @param gradient defines the gradient to use (between 0 and 1)
  125583. * @param color defines the color to affect to the specified gradient
  125584. * @returns the current particle system
  125585. */
  125586. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  125587. /**
  125588. * Not supported by GPUParticleSystem
  125589. * @param gradient defines the gradient to remove
  125590. * @returns the current particle system
  125591. */
  125592. removeRampGradient(): IParticleSystem;
  125593. /**
  125594. * Not supported by GPUParticleSystem
  125595. * @returns the list of ramp gradients
  125596. */
  125597. getRampGradients(): Nullable<Array<Color3Gradient>>;
  125598. /**
  125599. * Not supported by GPUParticleSystem
  125600. * Gets or sets a boolean indicating that ramp gradients must be used
  125601. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  125602. */
  125603. useRampGradients: boolean;
  125604. /**
  125605. * Not supported by GPUParticleSystem
  125606. * @param gradient defines the gradient to use (between 0 and 1)
  125607. * @param factor defines the life time factor to affect to the specified gradient
  125608. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125609. * @returns the current particle system
  125610. */
  125611. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125612. /**
  125613. * Not supported by GPUParticleSystem
  125614. * @param gradient defines the gradient to remove
  125615. * @returns the current particle system
  125616. */
  125617. removeLifeTimeGradient(gradient: number): IParticleSystem;
  125618. /**
  125619. * Instantiates a GPU particle system.
  125620. * 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.
  125621. * @param name The name of the particle system
  125622. * @param options The options used to create the system
  125623. * @param scene The scene the particle system belongs to
  125624. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  125625. */
  125626. constructor(name: string, options: Partial<{
  125627. capacity: number;
  125628. randomTextureSize: number;
  125629. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  125630. protected _reset(): void;
  125631. private _createUpdateVAO;
  125632. private _createRenderVAO;
  125633. private _initialize;
  125634. /** @hidden */
  125635. _recreateUpdateEffect(): void;
  125636. /** @hidden */
  125637. _recreateRenderEffect(): void;
  125638. /**
  125639. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  125640. * @param preWarm defines if we are in the pre-warmimg phase
  125641. */
  125642. animate(preWarm?: boolean): void;
  125643. private _createFactorGradientTexture;
  125644. private _createSizeGradientTexture;
  125645. private _createAngularSpeedGradientTexture;
  125646. private _createVelocityGradientTexture;
  125647. private _createLimitVelocityGradientTexture;
  125648. private _createDragGradientTexture;
  125649. private _createColorGradientTexture;
  125650. /**
  125651. * Renders the particle system in its current state
  125652. * @param preWarm defines if the system should only update the particles but not render them
  125653. * @returns the current number of particles
  125654. */
  125655. render(preWarm?: boolean): number;
  125656. /**
  125657. * Rebuilds the particle system
  125658. */
  125659. rebuild(): void;
  125660. private _releaseBuffers;
  125661. private _releaseVAOs;
  125662. /**
  125663. * Disposes the particle system and free the associated resources
  125664. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  125665. */
  125666. dispose(disposeTexture?: boolean): void;
  125667. /**
  125668. * Clones the particle system.
  125669. * @param name The name of the cloned object
  125670. * @param newEmitter The new emitter to use
  125671. * @returns the cloned particle system
  125672. */
  125673. clone(name: string, newEmitter: any): GPUParticleSystem;
  125674. /**
  125675. * Serializes the particle system to a JSON object.
  125676. * @returns the JSON object
  125677. */
  125678. serialize(): any;
  125679. /**
  125680. * Parses a JSON object to create a GPU particle system.
  125681. * @param parsedParticleSystem The JSON object to parse
  125682. * @param scene The scene to create the particle system in
  125683. * @param rootUrl The root url to use to load external dependencies like texture
  125684. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  125685. * @returns the parsed GPU particle system
  125686. */
  125687. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  125688. }
  125689. }
  125690. declare module BABYLON {
  125691. /**
  125692. * Represents a set of particle systems working together to create a specific effect
  125693. */
  125694. export class ParticleSystemSet implements IDisposable {
  125695. /**
  125696. * Gets or sets base Assets URL
  125697. */
  125698. static BaseAssetsUrl: string;
  125699. private _emitterCreationOptions;
  125700. private _emitterNode;
  125701. /**
  125702. * Gets the particle system list
  125703. */
  125704. systems: IParticleSystem[];
  125705. /**
  125706. * Gets the emitter node used with this set
  125707. */
  125708. readonly emitterNode: Nullable<TransformNode>;
  125709. /**
  125710. * Creates a new emitter mesh as a sphere
  125711. * @param options defines the options used to create the sphere
  125712. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  125713. * @param scene defines the hosting scene
  125714. */
  125715. setEmitterAsSphere(options: {
  125716. diameter: number;
  125717. segments: number;
  125718. color: Color3;
  125719. }, renderingGroupId: number, scene: Scene): void;
  125720. /**
  125721. * Starts all particle systems of the set
  125722. * @param emitter defines an optional mesh to use as emitter for the particle systems
  125723. */
  125724. start(emitter?: AbstractMesh): void;
  125725. /**
  125726. * Release all associated resources
  125727. */
  125728. dispose(): void;
  125729. /**
  125730. * Serialize the set into a JSON compatible object
  125731. * @returns a JSON compatible representation of the set
  125732. */
  125733. serialize(): any;
  125734. /**
  125735. * Parse a new ParticleSystemSet from a serialized source
  125736. * @param data defines a JSON compatible representation of the set
  125737. * @param scene defines the hosting scene
  125738. * @param gpu defines if we want GPU particles or CPU particles
  125739. * @returns a new ParticleSystemSet
  125740. */
  125741. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  125742. }
  125743. }
  125744. declare module BABYLON {
  125745. /**
  125746. * This class is made for on one-liner static method to help creating particle system set.
  125747. */
  125748. export class ParticleHelper {
  125749. /**
  125750. * Gets or sets base Assets URL
  125751. */
  125752. static BaseAssetsUrl: string;
  125753. /**
  125754. * Create a default particle system that you can tweak
  125755. * @param emitter defines the emitter to use
  125756. * @param capacity defines the system capacity (default is 500 particles)
  125757. * @param scene defines the hosting scene
  125758. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125759. * @returns the new Particle system
  125760. */
  125761. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125762. /**
  125763. * This is the main static method (one-liner) of this helper to create different particle systems
  125764. * @param type This string represents the type to the particle system to create
  125765. * @param scene The scene where the particle system should live
  125766. * @param gpu If the system will use gpu
  125767. * @returns the ParticleSystemSet created
  125768. */
  125769. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125770. /**
  125771. * Static function used to export a particle system to a ParticleSystemSet variable.
  125772. * Please note that the emitter shape is not exported
  125773. * @param systems defines the particle systems to export
  125774. * @returns the created particle system set
  125775. */
  125776. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125777. }
  125778. }
  125779. declare module BABYLON {
  125780. interface Engine {
  125781. /**
  125782. * Create an effect to use with particle systems.
  125783. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125784. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125785. * @param uniformsNames defines a list of attribute names
  125786. * @param samplers defines an array of string used to represent textures
  125787. * @param defines defines the string containing the defines to use to compile the shaders
  125788. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125789. * @param onCompiled defines a function to call when the effect creation is successful
  125790. * @param onError defines a function to call when the effect creation has failed
  125791. * @returns the new Effect
  125792. */
  125793. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125794. }
  125795. interface Mesh {
  125796. /**
  125797. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125798. * @returns an array of IParticleSystem
  125799. */
  125800. getEmittedParticleSystems(): IParticleSystem[];
  125801. /**
  125802. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125803. * @returns an array of IParticleSystem
  125804. */
  125805. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125806. }
  125807. /**
  125808. * @hidden
  125809. */
  125810. export var _IDoNeedToBeInTheBuild: number;
  125811. }
  125812. declare module BABYLON {
  125813. /** Defines the 4 color options */
  125814. export enum PointColor {
  125815. /** color value */
  125816. Color = 2,
  125817. /** uv value */
  125818. UV = 1,
  125819. /** random value */
  125820. Random = 0,
  125821. /** stated value */
  125822. Stated = 3
  125823. }
  125824. /**
  125825. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  125826. * 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.
  125827. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  125828. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  125829. *
  125830. * Full documentation here : TO BE ENTERED
  125831. */
  125832. export class PointsCloudSystem implements IDisposable {
  125833. /**
  125834. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  125835. * Example : var p = SPS.particles[i];
  125836. */
  125837. particles: CloudPoint[];
  125838. /**
  125839. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  125840. */
  125841. nbParticles: number;
  125842. /**
  125843. * This a counter for your own usage. It's not set by any SPS functions.
  125844. */
  125845. counter: number;
  125846. /**
  125847. * The PCS name. This name is also given to the underlying mesh.
  125848. */
  125849. name: string;
  125850. /**
  125851. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  125852. */
  125853. mesh: Mesh;
  125854. /**
  125855. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  125856. * Please read :
  125857. */
  125858. vars: any;
  125859. /**
  125860. * @hidden
  125861. */
  125862. _size: number;
  125863. private _scene;
  125864. private _promises;
  125865. private _positions;
  125866. private _indices;
  125867. private _normals;
  125868. private _colors;
  125869. private _uvs;
  125870. private _indices32;
  125871. private _positions32;
  125872. private _colors32;
  125873. private _uvs32;
  125874. private _updatable;
  125875. private _isVisibilityBoxLocked;
  125876. private _alwaysVisible;
  125877. private _groups;
  125878. private _groupCounter;
  125879. private _computeParticleColor;
  125880. private _computeParticleTexture;
  125881. private _computeParticleRotation;
  125882. private _computeBoundingBox;
  125883. private _isReady;
  125884. /**
  125885. * Creates a PCS (Points Cloud System) object
  125886. * @param name (String) is the PCS name, this will be the underlying mesh name
  125887. * @param pointSize (number) is the size for each point
  125888. * @param scene (Scene) is the scene in which the PCS is added
  125889. * @param options defines the options of the PCS e.g.
  125890. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  125891. */
  125892. constructor(name: string, pointSize: number, scene: Scene, options?: {
  125893. updatable?: boolean;
  125894. });
  125895. /**
  125896. * Builds the PCS underlying mesh. Returns a standard Mesh.
  125897. * If no points were added to the PCS, the returned mesh is just a single point.
  125898. * @returns a promise for the created mesh
  125899. */
  125900. buildMeshAsync(): Promise<Mesh>;
  125901. /**
  125902. * @hidden
  125903. */
  125904. private _buildMesh;
  125905. private _addParticle;
  125906. private _randomUnitVector;
  125907. private _getColorIndicesForCoord;
  125908. private _setPointsColorOrUV;
  125909. private _colorFromTexture;
  125910. private _calculateDensity;
  125911. /**
  125912. * Adds points to the PCS in random positions within a unit sphere
  125913. * @param nb (positive integer) the number of particles to be created from this model
  125914. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  125915. * @returns the number of groups in the system
  125916. */
  125917. addPoints(nb: number, pointFunction?: any): number;
  125918. /**
  125919. * Adds points to the PCS from the surface of the model shape
  125920. * @param mesh is any Mesh object that will be used as a surface model for the points
  125921. * @param nb (positive integer) the number of particles to be created from this model
  125922. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  125923. * @param color (color3) to be used when colorWith is stated
  125924. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  125925. * @returns the number of groups in the system
  125926. */
  125927. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  125928. /**
  125929. * Adds points to the PCS inside the model shape
  125930. * @param mesh is any Mesh object that will be used as a surface model for the points
  125931. * @param nb (positive integer) the number of particles to be created from this model
  125932. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  125933. * @param color (color4) to be used when colorWith is stated
  125934. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  125935. * @returns the number of groups in the system
  125936. */
  125937. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  125938. /**
  125939. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  125940. * This method calls `updateParticle()` for each particle of the SPS.
  125941. * For an animated SPS, it is usually called within the render loop.
  125942. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  125943. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  125944. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  125945. * @returns the PCS.
  125946. */
  125947. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  125948. /**
  125949. * Disposes the PCS.
  125950. */
  125951. dispose(): void;
  125952. /**
  125953. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  125954. * doc :
  125955. * @returns the PCS.
  125956. */
  125957. refreshVisibleSize(): PointsCloudSystem;
  125958. /**
  125959. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  125960. * @param size the size (float) of the visibility box
  125961. * note : this doesn't lock the PCS mesh bounding box.
  125962. * doc :
  125963. */
  125964. setVisibilityBox(size: number): void;
  125965. /**
  125966. * Gets whether the PCS is always visible or not
  125967. * doc :
  125968. */
  125969. /**
  125970. * Sets the PCS as always visible or not
  125971. * doc :
  125972. */
  125973. isAlwaysVisible: boolean;
  125974. /**
  125975. * Tells to `setParticles()` to compute the particle rotations or not
  125976. * Default value : false. The PCS is faster when it's set to false
  125977. * Note : particle rotations are only applied to parent particles
  125978. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  125979. */
  125980. computeParticleRotation: boolean;
  125981. /**
  125982. * Tells to `setParticles()` to compute the particle colors or not.
  125983. * Default value : true. The PCS is faster when it's set to false.
  125984. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  125985. */
  125986. /**
  125987. * Gets if `setParticles()` computes the particle colors or not.
  125988. * Default value : false. The PCS is faster when it's set to false.
  125989. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  125990. */
  125991. computeParticleColor: boolean;
  125992. /**
  125993. * Gets if `setParticles()` computes the particle textures or not.
  125994. * Default value : false. The PCS is faster when it's set to false.
  125995. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  125996. */
  125997. computeParticleTexture: boolean;
  125998. /**
  125999. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  126000. */
  126001. /**
  126002. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  126003. */
  126004. computeBoundingBox: boolean;
  126005. /**
  126006. * This function does nothing. It may be overwritten to set all the particle first values.
  126007. * The PCS doesn't call this function, you may have to call it by your own.
  126008. * doc :
  126009. */
  126010. initParticles(): void;
  126011. /**
  126012. * This function does nothing. It may be overwritten to recycle a particle
  126013. * The PCS doesn't call this function, you can to call it
  126014. * doc :
  126015. * @param particle The particle to recycle
  126016. * @returns the recycled particle
  126017. */
  126018. recycleParticle(particle: CloudPoint): CloudPoint;
  126019. /**
  126020. * Updates a particle : this function should be overwritten by the user.
  126021. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  126022. * doc :
  126023. * @example : just set a particle position or velocity and recycle conditions
  126024. * @param particle The particle to update
  126025. * @returns the updated particle
  126026. */
  126027. updateParticle(particle: CloudPoint): CloudPoint;
  126028. /**
  126029. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  126030. * This does nothing and may be overwritten by the user.
  126031. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126032. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126033. * @param update the boolean update value actually passed to setParticles()
  126034. */
  126035. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126036. /**
  126037. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  126038. * This will be passed three parameters.
  126039. * This does nothing and may be overwritten by the user.
  126040. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126041. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126042. * @param update the boolean update value actually passed to setParticles()
  126043. */
  126044. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126045. }
  126046. }
  126047. declare module BABYLON {
  126048. /**
  126049. * Represents one particle of a points cloud system.
  126050. */
  126051. export class CloudPoint {
  126052. /**
  126053. * particle global index
  126054. */
  126055. idx: number;
  126056. /**
  126057. * The color of the particle
  126058. */
  126059. color: Nullable<Color4>;
  126060. /**
  126061. * The world space position of the particle.
  126062. */
  126063. position: Vector3;
  126064. /**
  126065. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  126066. */
  126067. rotation: Vector3;
  126068. /**
  126069. * The world space rotation quaternion of the particle.
  126070. */
  126071. rotationQuaternion: Nullable<Quaternion>;
  126072. /**
  126073. * The uv of the particle.
  126074. */
  126075. uv: Nullable<Vector2>;
  126076. /**
  126077. * The current speed of the particle.
  126078. */
  126079. velocity: Vector3;
  126080. /**
  126081. * The pivot point in the particle local space.
  126082. */
  126083. pivot: Vector3;
  126084. /**
  126085. * Must the particle be translated from its pivot point in its local space ?
  126086. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  126087. * Default : false
  126088. */
  126089. translateFromPivot: boolean;
  126090. /**
  126091. * Index of this particle in the global "positions" array (Internal use)
  126092. * @hidden
  126093. */
  126094. _pos: number;
  126095. /**
  126096. * @hidden Index of this particle in the global "indices" array (Internal use)
  126097. */
  126098. _ind: number;
  126099. /**
  126100. * Group this particle belongs to
  126101. */
  126102. _group: PointsGroup;
  126103. /**
  126104. * Group id of this particle
  126105. */
  126106. groupId: number;
  126107. /**
  126108. * Index of the particle in its group id (Internal use)
  126109. */
  126110. idxInGroup: number;
  126111. /**
  126112. * @hidden Particle BoundingInfo object (Internal use)
  126113. */
  126114. _boundingInfo: BoundingInfo;
  126115. /**
  126116. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  126117. */
  126118. _pcs: PointsCloudSystem;
  126119. /**
  126120. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  126121. */
  126122. _stillInvisible: boolean;
  126123. /**
  126124. * @hidden Last computed particle rotation matrix
  126125. */
  126126. _rotationMatrix: number[];
  126127. /**
  126128. * Parent particle Id, if any.
  126129. * Default null.
  126130. */
  126131. parentId: Nullable<number>;
  126132. /**
  126133. * @hidden Internal global position in the PCS.
  126134. */
  126135. _globalPosition: Vector3;
  126136. /**
  126137. * Creates a Point Cloud object.
  126138. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  126139. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  126140. * @param group (PointsGroup) is the group the particle belongs to
  126141. * @param groupId (integer) is the group identifier in the PCS.
  126142. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  126143. * @param pcs defines the PCS it is associated to
  126144. */
  126145. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  126146. /**
  126147. * get point size
  126148. */
  126149. /**
  126150. * Set point size
  126151. */
  126152. size: Vector3;
  126153. /**
  126154. * Legacy support, changed quaternion to rotationQuaternion
  126155. */
  126156. /**
  126157. * Legacy support, changed quaternion to rotationQuaternion
  126158. */
  126159. quaternion: Nullable<Quaternion>;
  126160. /**
  126161. * Returns a boolean. True if the particle intersects a mesh, else false
  126162. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  126163. * @param target is the object (point or mesh) what the intersection is computed against
  126164. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  126165. * @returns true if it intersects
  126166. */
  126167. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  126168. /**
  126169. * get the rotation matrix of the particle
  126170. * @hidden
  126171. */
  126172. getRotationMatrix(m: Matrix): void;
  126173. }
  126174. /**
  126175. * Represents a group of points in a points cloud system
  126176. * * PCS internal tool, don't use it manually.
  126177. */
  126178. export class PointsGroup {
  126179. /**
  126180. * The group id
  126181. * @hidden
  126182. */
  126183. groupID: number;
  126184. /**
  126185. * image data for group (internal use)
  126186. * @hidden
  126187. */
  126188. _groupImageData: Nullable<ArrayBufferView>;
  126189. /**
  126190. * Image Width (internal use)
  126191. * @hidden
  126192. */
  126193. _groupImgWidth: number;
  126194. /**
  126195. * Image Height (internal use)
  126196. * @hidden
  126197. */
  126198. _groupImgHeight: number;
  126199. /**
  126200. * Custom position function (internal use)
  126201. * @hidden
  126202. */
  126203. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  126204. /**
  126205. * density per facet for surface points
  126206. * @hidden
  126207. */
  126208. _groupDensity: number[];
  126209. /**
  126210. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  126211. * PCS internal tool, don't use it manually.
  126212. * @hidden
  126213. */
  126214. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  126215. }
  126216. }
  126217. declare module BABYLON {
  126218. interface Scene {
  126219. /** @hidden (Backing field) */
  126220. _physicsEngine: Nullable<IPhysicsEngine>;
  126221. /**
  126222. * Gets the current physics engine
  126223. * @returns a IPhysicsEngine or null if none attached
  126224. */
  126225. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  126226. /**
  126227. * Enables physics to the current scene
  126228. * @param gravity defines the scene's gravity for the physics engine
  126229. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  126230. * @return a boolean indicating if the physics engine was initialized
  126231. */
  126232. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  126233. /**
  126234. * Disables and disposes the physics engine associated with the scene
  126235. */
  126236. disablePhysicsEngine(): void;
  126237. /**
  126238. * Gets a boolean indicating if there is an active physics engine
  126239. * @returns a boolean indicating if there is an active physics engine
  126240. */
  126241. isPhysicsEnabled(): boolean;
  126242. /**
  126243. * Deletes a physics compound impostor
  126244. * @param compound defines the compound to delete
  126245. */
  126246. deleteCompoundImpostor(compound: any): void;
  126247. /**
  126248. * An event triggered when physic simulation is about to be run
  126249. */
  126250. onBeforePhysicsObservable: Observable<Scene>;
  126251. /**
  126252. * An event triggered when physic simulation has been done
  126253. */
  126254. onAfterPhysicsObservable: Observable<Scene>;
  126255. }
  126256. interface AbstractMesh {
  126257. /** @hidden */
  126258. _physicsImpostor: Nullable<PhysicsImpostor>;
  126259. /**
  126260. * Gets or sets impostor used for physic simulation
  126261. * @see http://doc.babylonjs.com/features/physics_engine
  126262. */
  126263. physicsImpostor: Nullable<PhysicsImpostor>;
  126264. /**
  126265. * Gets the current physics impostor
  126266. * @see http://doc.babylonjs.com/features/physics_engine
  126267. * @returns a physics impostor or null
  126268. */
  126269. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  126270. /** Apply a physic impulse to the mesh
  126271. * @param force defines the force to apply
  126272. * @param contactPoint defines where to apply the force
  126273. * @returns the current mesh
  126274. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  126275. */
  126276. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  126277. /**
  126278. * Creates a physic joint between two meshes
  126279. * @param otherMesh defines the other mesh to use
  126280. * @param pivot1 defines the pivot to use on this mesh
  126281. * @param pivot2 defines the pivot to use on the other mesh
  126282. * @param options defines additional options (can be plugin dependent)
  126283. * @returns the current mesh
  126284. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  126285. */
  126286. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  126287. /** @hidden */
  126288. _disposePhysicsObserver: Nullable<Observer<Node>>;
  126289. }
  126290. /**
  126291. * Defines the physics engine scene component responsible to manage a physics engine
  126292. */
  126293. export class PhysicsEngineSceneComponent implements ISceneComponent {
  126294. /**
  126295. * The component name helpful to identify the component in the list of scene components.
  126296. */
  126297. readonly name: string;
  126298. /**
  126299. * The scene the component belongs to.
  126300. */
  126301. scene: Scene;
  126302. /**
  126303. * Creates a new instance of the component for the given scene
  126304. * @param scene Defines the scene to register the component in
  126305. */
  126306. constructor(scene: Scene);
  126307. /**
  126308. * Registers the component in a given scene
  126309. */
  126310. register(): void;
  126311. /**
  126312. * Rebuilds the elements related to this component in case of
  126313. * context lost for instance.
  126314. */
  126315. rebuild(): void;
  126316. /**
  126317. * Disposes the component and the associated ressources
  126318. */
  126319. dispose(): void;
  126320. }
  126321. }
  126322. declare module BABYLON {
  126323. /**
  126324. * A helper for physics simulations
  126325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126326. */
  126327. export class PhysicsHelper {
  126328. private _scene;
  126329. private _physicsEngine;
  126330. /**
  126331. * Initializes the Physics helper
  126332. * @param scene Babylon.js scene
  126333. */
  126334. constructor(scene: Scene);
  126335. /**
  126336. * Applies a radial explosion impulse
  126337. * @param origin the origin of the explosion
  126338. * @param radiusOrEventOptions the radius or the options of radial explosion
  126339. * @param strength the explosion strength
  126340. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126341. * @returns A physics radial explosion event, or null
  126342. */
  126343. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126344. /**
  126345. * Applies a radial explosion force
  126346. * @param origin the origin of the explosion
  126347. * @param radiusOrEventOptions the radius or the options of radial explosion
  126348. * @param strength the explosion strength
  126349. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126350. * @returns A physics radial explosion event, or null
  126351. */
  126352. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126353. /**
  126354. * Creates a gravitational field
  126355. * @param origin the origin of the explosion
  126356. * @param radiusOrEventOptions the radius or the options of radial explosion
  126357. * @param strength the explosion strength
  126358. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126359. * @returns A physics gravitational field event, or null
  126360. */
  126361. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  126362. /**
  126363. * Creates a physics updraft event
  126364. * @param origin the origin of the updraft
  126365. * @param radiusOrEventOptions the radius or the options of the updraft
  126366. * @param strength the strength of the updraft
  126367. * @param height the height of the updraft
  126368. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  126369. * @returns A physics updraft event, or null
  126370. */
  126371. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  126372. /**
  126373. * Creates a physics vortex event
  126374. * @param origin the of the vortex
  126375. * @param radiusOrEventOptions the radius or the options of the vortex
  126376. * @param strength the strength of the vortex
  126377. * @param height the height of the vortex
  126378. * @returns a Physics vortex event, or null
  126379. * A physics vortex event or null
  126380. */
  126381. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  126382. }
  126383. /**
  126384. * Represents a physics radial explosion event
  126385. */
  126386. class PhysicsRadialExplosionEvent {
  126387. private _scene;
  126388. private _options;
  126389. private _sphere;
  126390. private _dataFetched;
  126391. /**
  126392. * Initializes a radial explosioin event
  126393. * @param _scene BabylonJS scene
  126394. * @param _options The options for the vortex event
  126395. */
  126396. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  126397. /**
  126398. * Returns the data related to the radial explosion event (sphere).
  126399. * @returns The radial explosion event data
  126400. */
  126401. getData(): PhysicsRadialExplosionEventData;
  126402. /**
  126403. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  126404. * @param impostor A physics imposter
  126405. * @param origin the origin of the explosion
  126406. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  126407. */
  126408. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  126409. /**
  126410. * Triggers affecterd impostors callbacks
  126411. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  126412. */
  126413. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  126414. /**
  126415. * Disposes the sphere.
  126416. * @param force Specifies if the sphere should be disposed by force
  126417. */
  126418. dispose(force?: boolean): void;
  126419. /*** Helpers ***/
  126420. private _prepareSphere;
  126421. private _intersectsWithSphere;
  126422. }
  126423. /**
  126424. * Represents a gravitational field event
  126425. */
  126426. class PhysicsGravitationalFieldEvent {
  126427. private _physicsHelper;
  126428. private _scene;
  126429. private _origin;
  126430. private _options;
  126431. private _tickCallback;
  126432. private _sphere;
  126433. private _dataFetched;
  126434. /**
  126435. * Initializes the physics gravitational field event
  126436. * @param _physicsHelper A physics helper
  126437. * @param _scene BabylonJS scene
  126438. * @param _origin The origin position of the gravitational field event
  126439. * @param _options The options for the vortex event
  126440. */
  126441. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  126442. /**
  126443. * Returns the data related to the gravitational field event (sphere).
  126444. * @returns A gravitational field event
  126445. */
  126446. getData(): PhysicsGravitationalFieldEventData;
  126447. /**
  126448. * Enables the gravitational field.
  126449. */
  126450. enable(): void;
  126451. /**
  126452. * Disables the gravitational field.
  126453. */
  126454. disable(): void;
  126455. /**
  126456. * Disposes the sphere.
  126457. * @param force The force to dispose from the gravitational field event
  126458. */
  126459. dispose(force?: boolean): void;
  126460. private _tick;
  126461. }
  126462. /**
  126463. * Represents a physics updraft event
  126464. */
  126465. class PhysicsUpdraftEvent {
  126466. private _scene;
  126467. private _origin;
  126468. private _options;
  126469. private _physicsEngine;
  126470. private _originTop;
  126471. private _originDirection;
  126472. private _tickCallback;
  126473. private _cylinder;
  126474. private _cylinderPosition;
  126475. private _dataFetched;
  126476. /**
  126477. * Initializes the physics updraft event
  126478. * @param _scene BabylonJS scene
  126479. * @param _origin The origin position of the updraft
  126480. * @param _options The options for the updraft event
  126481. */
  126482. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  126483. /**
  126484. * Returns the data related to the updraft event (cylinder).
  126485. * @returns A physics updraft event
  126486. */
  126487. getData(): PhysicsUpdraftEventData;
  126488. /**
  126489. * Enables the updraft.
  126490. */
  126491. enable(): void;
  126492. /**
  126493. * Disables the updraft.
  126494. */
  126495. disable(): void;
  126496. /**
  126497. * Disposes the cylinder.
  126498. * @param force Specifies if the updraft should be disposed by force
  126499. */
  126500. dispose(force?: boolean): void;
  126501. private getImpostorHitData;
  126502. private _tick;
  126503. /*** Helpers ***/
  126504. private _prepareCylinder;
  126505. private _intersectsWithCylinder;
  126506. }
  126507. /**
  126508. * Represents a physics vortex event
  126509. */
  126510. class PhysicsVortexEvent {
  126511. private _scene;
  126512. private _origin;
  126513. private _options;
  126514. private _physicsEngine;
  126515. private _originTop;
  126516. private _tickCallback;
  126517. private _cylinder;
  126518. private _cylinderPosition;
  126519. private _dataFetched;
  126520. /**
  126521. * Initializes the physics vortex event
  126522. * @param _scene The BabylonJS scene
  126523. * @param _origin The origin position of the vortex
  126524. * @param _options The options for the vortex event
  126525. */
  126526. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  126527. /**
  126528. * Returns the data related to the vortex event (cylinder).
  126529. * @returns The physics vortex event data
  126530. */
  126531. getData(): PhysicsVortexEventData;
  126532. /**
  126533. * Enables the vortex.
  126534. */
  126535. enable(): void;
  126536. /**
  126537. * Disables the cortex.
  126538. */
  126539. disable(): void;
  126540. /**
  126541. * Disposes the sphere.
  126542. * @param force
  126543. */
  126544. dispose(force?: boolean): void;
  126545. private getImpostorHitData;
  126546. private _tick;
  126547. /*** Helpers ***/
  126548. private _prepareCylinder;
  126549. private _intersectsWithCylinder;
  126550. }
  126551. /**
  126552. * Options fot the radial explosion event
  126553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126554. */
  126555. export class PhysicsRadialExplosionEventOptions {
  126556. /**
  126557. * The radius of the sphere for the radial explosion.
  126558. */
  126559. radius: number;
  126560. /**
  126561. * The strenth of the explosion.
  126562. */
  126563. strength: number;
  126564. /**
  126565. * The strenght of the force in correspondence to the distance of the affected object
  126566. */
  126567. falloff: PhysicsRadialImpulseFalloff;
  126568. /**
  126569. * Sphere options for the radial explosion.
  126570. */
  126571. sphere: {
  126572. segments: number;
  126573. diameter: number;
  126574. };
  126575. /**
  126576. * Sphere options for the radial explosion.
  126577. */
  126578. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  126579. }
  126580. /**
  126581. * Options fot the updraft event
  126582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126583. */
  126584. export class PhysicsUpdraftEventOptions {
  126585. /**
  126586. * The radius of the cylinder for the vortex
  126587. */
  126588. radius: number;
  126589. /**
  126590. * The strenth of the updraft.
  126591. */
  126592. strength: number;
  126593. /**
  126594. * The height of the cylinder for the updraft.
  126595. */
  126596. height: number;
  126597. /**
  126598. * The mode for the the updraft.
  126599. */
  126600. updraftMode: PhysicsUpdraftMode;
  126601. }
  126602. /**
  126603. * Options fot the vortex event
  126604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126605. */
  126606. export class PhysicsVortexEventOptions {
  126607. /**
  126608. * The radius of the cylinder for the vortex
  126609. */
  126610. radius: number;
  126611. /**
  126612. * The strenth of the vortex.
  126613. */
  126614. strength: number;
  126615. /**
  126616. * The height of the cylinder for the vortex.
  126617. */
  126618. height: number;
  126619. /**
  126620. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  126621. */
  126622. centripetalForceThreshold: number;
  126623. /**
  126624. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  126625. */
  126626. centripetalForceMultiplier: number;
  126627. /**
  126628. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  126629. */
  126630. centrifugalForceMultiplier: number;
  126631. /**
  126632. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  126633. */
  126634. updraftForceMultiplier: number;
  126635. }
  126636. /**
  126637. * The strenght of the force in correspondence to the distance of the affected object
  126638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126639. */
  126640. export enum PhysicsRadialImpulseFalloff {
  126641. /** Defines that impulse is constant in strength across it's whole radius */
  126642. Constant = 0,
  126643. /** Defines that impulse gets weaker if it's further from the origin */
  126644. Linear = 1
  126645. }
  126646. /**
  126647. * The strength of the force in correspondence to the distance of the affected object
  126648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126649. */
  126650. export enum PhysicsUpdraftMode {
  126651. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  126652. Center = 0,
  126653. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  126654. Perpendicular = 1
  126655. }
  126656. /**
  126657. * Interface for a physics hit data
  126658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126659. */
  126660. export interface PhysicsHitData {
  126661. /**
  126662. * The force applied at the contact point
  126663. */
  126664. force: Vector3;
  126665. /**
  126666. * The contact point
  126667. */
  126668. contactPoint: Vector3;
  126669. /**
  126670. * The distance from the origin to the contact point
  126671. */
  126672. distanceFromOrigin: number;
  126673. }
  126674. /**
  126675. * Interface for radial explosion event data
  126676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126677. */
  126678. export interface PhysicsRadialExplosionEventData {
  126679. /**
  126680. * A sphere used for the radial explosion event
  126681. */
  126682. sphere: Mesh;
  126683. }
  126684. /**
  126685. * Interface for gravitational field event data
  126686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126687. */
  126688. export interface PhysicsGravitationalFieldEventData {
  126689. /**
  126690. * A sphere mesh used for the gravitational field event
  126691. */
  126692. sphere: Mesh;
  126693. }
  126694. /**
  126695. * Interface for updraft event data
  126696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126697. */
  126698. export interface PhysicsUpdraftEventData {
  126699. /**
  126700. * A cylinder used for the updraft event
  126701. */
  126702. cylinder: Mesh;
  126703. }
  126704. /**
  126705. * Interface for vortex event data
  126706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126707. */
  126708. export interface PhysicsVortexEventData {
  126709. /**
  126710. * A cylinder used for the vortex event
  126711. */
  126712. cylinder: Mesh;
  126713. }
  126714. /**
  126715. * Interface for an affected physics impostor
  126716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126717. */
  126718. export interface PhysicsAffectedImpostorWithData {
  126719. /**
  126720. * The impostor affected by the effect
  126721. */
  126722. impostor: PhysicsImpostor;
  126723. /**
  126724. * The data about the hit/horce from the explosion
  126725. */
  126726. hitData: PhysicsHitData;
  126727. }
  126728. }
  126729. declare module BABYLON {
  126730. /** @hidden */
  126731. export var blackAndWhitePixelShader: {
  126732. name: string;
  126733. shader: string;
  126734. };
  126735. }
  126736. declare module BABYLON {
  126737. /**
  126738. * Post process used to render in black and white
  126739. */
  126740. export class BlackAndWhitePostProcess extends PostProcess {
  126741. /**
  126742. * Linear about to convert he result to black and white (default: 1)
  126743. */
  126744. degree: number;
  126745. /**
  126746. * Creates a black and white post process
  126747. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  126748. * @param name The name of the effect.
  126749. * @param options The required width/height ratio to downsize to before computing the render pass.
  126750. * @param camera The camera to apply the render pass to.
  126751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126752. * @param engine The engine which the post process will be applied. (default: current engine)
  126753. * @param reusable If the post process can be reused on the same frame. (default: false)
  126754. */
  126755. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126756. }
  126757. }
  126758. declare module BABYLON {
  126759. /**
  126760. * This represents a set of one or more post processes in Babylon.
  126761. * A post process can be used to apply a shader to a texture after it is rendered.
  126762. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126763. */
  126764. export class PostProcessRenderEffect {
  126765. private _postProcesses;
  126766. private _getPostProcesses;
  126767. private _singleInstance;
  126768. private _cameras;
  126769. private _indicesForCamera;
  126770. /**
  126771. * Name of the effect
  126772. * @hidden
  126773. */
  126774. _name: string;
  126775. /**
  126776. * Instantiates a post process render effect.
  126777. * A post process can be used to apply a shader to a texture after it is rendered.
  126778. * @param engine The engine the effect is tied to
  126779. * @param name The name of the effect
  126780. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  126781. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  126782. */
  126783. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  126784. /**
  126785. * Checks if all the post processes in the effect are supported.
  126786. */
  126787. readonly isSupported: boolean;
  126788. /**
  126789. * Updates the current state of the effect
  126790. * @hidden
  126791. */
  126792. _update(): void;
  126793. /**
  126794. * Attaches the effect on cameras
  126795. * @param cameras The camera to attach to.
  126796. * @hidden
  126797. */
  126798. _attachCameras(cameras: Camera): void;
  126799. /**
  126800. * Attaches the effect on cameras
  126801. * @param cameras The camera to attach to.
  126802. * @hidden
  126803. */
  126804. _attachCameras(cameras: Camera[]): void;
  126805. /**
  126806. * Detaches the effect on cameras
  126807. * @param cameras The camera to detatch from.
  126808. * @hidden
  126809. */
  126810. _detachCameras(cameras: Camera): void;
  126811. /**
  126812. * Detatches the effect on cameras
  126813. * @param cameras The camera to detatch from.
  126814. * @hidden
  126815. */
  126816. _detachCameras(cameras: Camera[]): void;
  126817. /**
  126818. * Enables the effect on given cameras
  126819. * @param cameras The camera to enable.
  126820. * @hidden
  126821. */
  126822. _enable(cameras: Camera): void;
  126823. /**
  126824. * Enables the effect on given cameras
  126825. * @param cameras The camera to enable.
  126826. * @hidden
  126827. */
  126828. _enable(cameras: Nullable<Camera[]>): void;
  126829. /**
  126830. * Disables the effect on the given cameras
  126831. * @param cameras The camera to disable.
  126832. * @hidden
  126833. */
  126834. _disable(cameras: Camera): void;
  126835. /**
  126836. * Disables the effect on the given cameras
  126837. * @param cameras The camera to disable.
  126838. * @hidden
  126839. */
  126840. _disable(cameras: Nullable<Camera[]>): void;
  126841. /**
  126842. * Gets a list of the post processes contained in the effect.
  126843. * @param camera The camera to get the post processes on.
  126844. * @returns The list of the post processes in the effect.
  126845. */
  126846. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  126847. }
  126848. }
  126849. declare module BABYLON {
  126850. /** @hidden */
  126851. export var extractHighlightsPixelShader: {
  126852. name: string;
  126853. shader: string;
  126854. };
  126855. }
  126856. declare module BABYLON {
  126857. /**
  126858. * 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.
  126859. */
  126860. export class ExtractHighlightsPostProcess extends PostProcess {
  126861. /**
  126862. * The luminance threshold, pixels below this value will be set to black.
  126863. */
  126864. threshold: number;
  126865. /** @hidden */
  126866. _exposure: number;
  126867. /**
  126868. * Post process which has the input texture to be used when performing highlight extraction
  126869. * @hidden
  126870. */
  126871. _inputPostProcess: Nullable<PostProcess>;
  126872. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126873. }
  126874. }
  126875. declare module BABYLON {
  126876. /** @hidden */
  126877. export var bloomMergePixelShader: {
  126878. name: string;
  126879. shader: string;
  126880. };
  126881. }
  126882. declare module BABYLON {
  126883. /**
  126884. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126885. */
  126886. export class BloomMergePostProcess extends PostProcess {
  126887. /** Weight of the bloom to be added to the original input. */
  126888. weight: number;
  126889. /**
  126890. * Creates a new instance of @see BloomMergePostProcess
  126891. * @param name The name of the effect.
  126892. * @param originalFromInput Post process which's input will be used for the merge.
  126893. * @param blurred Blurred highlights post process which's output will be used.
  126894. * @param weight Weight of the bloom to be added to the original input.
  126895. * @param options The required width/height ratio to downsize to before computing the render pass.
  126896. * @param camera The camera to apply the render pass to.
  126897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126898. * @param engine The engine which the post process will be applied. (default: current engine)
  126899. * @param reusable If the post process can be reused on the same frame. (default: false)
  126900. * @param textureType Type of textures used when performing the post process. (default: 0)
  126901. * @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)
  126902. */
  126903. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  126904. /** Weight of the bloom to be added to the original input. */
  126905. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126906. }
  126907. }
  126908. declare module BABYLON {
  126909. /**
  126910. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  126911. */
  126912. export class BloomEffect extends PostProcessRenderEffect {
  126913. private bloomScale;
  126914. /**
  126915. * @hidden Internal
  126916. */
  126917. _effects: Array<PostProcess>;
  126918. /**
  126919. * @hidden Internal
  126920. */
  126921. _downscale: ExtractHighlightsPostProcess;
  126922. private _blurX;
  126923. private _blurY;
  126924. private _merge;
  126925. /**
  126926. * The luminance threshold to find bright areas of the image to bloom.
  126927. */
  126928. threshold: number;
  126929. /**
  126930. * The strength of the bloom.
  126931. */
  126932. weight: number;
  126933. /**
  126934. * Specifies the size of the bloom blur kernel, relative to the final output size
  126935. */
  126936. kernel: number;
  126937. /**
  126938. * Creates a new instance of @see BloomEffect
  126939. * @param scene The scene the effect belongs to.
  126940. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  126941. * @param bloomKernel The size of the kernel to be used when applying the blur.
  126942. * @param bloomWeight The the strength of bloom.
  126943. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126944. * @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)
  126945. */
  126946. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  126947. /**
  126948. * Disposes each of the internal effects for a given camera.
  126949. * @param camera The camera to dispose the effect on.
  126950. */
  126951. disposeEffects(camera: Camera): void;
  126952. /**
  126953. * @hidden Internal
  126954. */
  126955. _updateEffects(): void;
  126956. /**
  126957. * Internal
  126958. * @returns if all the contained post processes are ready.
  126959. * @hidden
  126960. */
  126961. _isReady(): boolean;
  126962. }
  126963. }
  126964. declare module BABYLON {
  126965. /** @hidden */
  126966. export var chromaticAberrationPixelShader: {
  126967. name: string;
  126968. shader: string;
  126969. };
  126970. }
  126971. declare module BABYLON {
  126972. /**
  126973. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  126974. */
  126975. export class ChromaticAberrationPostProcess extends PostProcess {
  126976. /**
  126977. * The amount of seperation of rgb channels (default: 30)
  126978. */
  126979. aberrationAmount: number;
  126980. /**
  126981. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  126982. */
  126983. radialIntensity: number;
  126984. /**
  126985. * 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))
  126986. */
  126987. direction: Vector2;
  126988. /**
  126989. * 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))
  126990. */
  126991. centerPosition: Vector2;
  126992. /**
  126993. * Creates a new instance ChromaticAberrationPostProcess
  126994. * @param name The name of the effect.
  126995. * @param screenWidth The width of the screen to apply the effect on.
  126996. * @param screenHeight The height of the screen to apply the effect on.
  126997. * @param options The required width/height ratio to downsize to before computing the render pass.
  126998. * @param camera The camera to apply the render pass to.
  126999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127000. * @param engine The engine which the post process will be applied. (default: current engine)
  127001. * @param reusable If the post process can be reused on the same frame. (default: false)
  127002. * @param textureType Type of textures used when performing the post process. (default: 0)
  127003. * @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)
  127004. */
  127005. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127006. }
  127007. }
  127008. declare module BABYLON {
  127009. /** @hidden */
  127010. export var circleOfConfusionPixelShader: {
  127011. name: string;
  127012. shader: string;
  127013. };
  127014. }
  127015. declare module BABYLON {
  127016. /**
  127017. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  127018. */
  127019. export class CircleOfConfusionPostProcess extends PostProcess {
  127020. /**
  127021. * 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.
  127022. */
  127023. lensSize: number;
  127024. /**
  127025. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127026. */
  127027. fStop: number;
  127028. /**
  127029. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127030. */
  127031. focusDistance: number;
  127032. /**
  127033. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  127034. */
  127035. focalLength: number;
  127036. private _depthTexture;
  127037. /**
  127038. * Creates a new instance CircleOfConfusionPostProcess
  127039. * @param name The name of the effect.
  127040. * @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.
  127041. * @param options The required width/height ratio to downsize to before computing the render pass.
  127042. * @param camera The camera to apply the render pass to.
  127043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127044. * @param engine The engine which the post process will be applied. (default: current engine)
  127045. * @param reusable If the post process can be reused on the same frame. (default: false)
  127046. * @param textureType Type of textures used when performing the post process. (default: 0)
  127047. * @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)
  127048. */
  127049. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127050. /**
  127051. * 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.
  127052. */
  127053. depthTexture: RenderTargetTexture;
  127054. }
  127055. }
  127056. declare module BABYLON {
  127057. /** @hidden */
  127058. export var colorCorrectionPixelShader: {
  127059. name: string;
  127060. shader: string;
  127061. };
  127062. }
  127063. declare module BABYLON {
  127064. /**
  127065. *
  127066. * This post-process allows the modification of rendered colors by using
  127067. * a 'look-up table' (LUT). This effect is also called Color Grading.
  127068. *
  127069. * The object needs to be provided an url to a texture containing the color
  127070. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  127071. * Use an image editing software to tweak the LUT to match your needs.
  127072. *
  127073. * For an example of a color LUT, see here:
  127074. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  127075. * For explanations on color grading, see here:
  127076. * @see http://udn.epicgames.com/Three/ColorGrading.html
  127077. *
  127078. */
  127079. export class ColorCorrectionPostProcess extends PostProcess {
  127080. private _colorTableTexture;
  127081. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127082. }
  127083. }
  127084. declare module BABYLON {
  127085. /** @hidden */
  127086. export var convolutionPixelShader: {
  127087. name: string;
  127088. shader: string;
  127089. };
  127090. }
  127091. declare module BABYLON {
  127092. /**
  127093. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  127094. * input texture to perform effects such as edge detection or sharpening
  127095. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127096. */
  127097. export class ConvolutionPostProcess extends PostProcess {
  127098. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127099. kernel: number[];
  127100. /**
  127101. * Creates a new instance ConvolutionPostProcess
  127102. * @param name The name of the effect.
  127103. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  127104. * @param options The required width/height ratio to downsize to before computing the render pass.
  127105. * @param camera The camera to apply the render pass to.
  127106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127107. * @param engine The engine which the post process will be applied. (default: current engine)
  127108. * @param reusable If the post process can be reused on the same frame. (default: false)
  127109. * @param textureType Type of textures used when performing the post process. (default: 0)
  127110. */
  127111. constructor(name: string,
  127112. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127113. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127114. /**
  127115. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127116. */
  127117. static EdgeDetect0Kernel: number[];
  127118. /**
  127119. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127120. */
  127121. static EdgeDetect1Kernel: number[];
  127122. /**
  127123. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127124. */
  127125. static EdgeDetect2Kernel: number[];
  127126. /**
  127127. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127128. */
  127129. static SharpenKernel: number[];
  127130. /**
  127131. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127132. */
  127133. static EmbossKernel: number[];
  127134. /**
  127135. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127136. */
  127137. static GaussianKernel: number[];
  127138. }
  127139. }
  127140. declare module BABYLON {
  127141. /**
  127142. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  127143. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  127144. * based on samples that have a large difference in distance than the center pixel.
  127145. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  127146. */
  127147. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  127148. direction: Vector2;
  127149. /**
  127150. * Creates a new instance CircleOfConfusionPostProcess
  127151. * @param name The name of the effect.
  127152. * @param scene The scene the effect belongs to.
  127153. * @param direction The direction the blur should be applied.
  127154. * @param kernel The size of the kernel used to blur.
  127155. * @param options The required width/height ratio to downsize to before computing the render pass.
  127156. * @param camera The camera to apply the render pass to.
  127157. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  127158. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  127159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127160. * @param engine The engine which the post process will be applied. (default: current engine)
  127161. * @param reusable If the post process can be reused on the same frame. (default: false)
  127162. * @param textureType Type of textures used when performing the post process. (default: 0)
  127163. * @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)
  127164. */
  127165. 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);
  127166. }
  127167. }
  127168. declare module BABYLON {
  127169. /** @hidden */
  127170. export var depthOfFieldMergePixelShader: {
  127171. name: string;
  127172. shader: string;
  127173. };
  127174. }
  127175. declare module BABYLON {
  127176. /**
  127177. * Options to be set when merging outputs from the default pipeline.
  127178. */
  127179. export class DepthOfFieldMergePostProcessOptions {
  127180. /**
  127181. * The original image to merge on top of
  127182. */
  127183. originalFromInput: PostProcess;
  127184. /**
  127185. * Parameters to perform the merge of the depth of field effect
  127186. */
  127187. depthOfField?: {
  127188. circleOfConfusion: PostProcess;
  127189. blurSteps: Array<PostProcess>;
  127190. };
  127191. /**
  127192. * Parameters to perform the merge of bloom effect
  127193. */
  127194. bloom?: {
  127195. blurred: PostProcess;
  127196. weight: number;
  127197. };
  127198. }
  127199. /**
  127200. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  127201. */
  127202. export class DepthOfFieldMergePostProcess extends PostProcess {
  127203. private blurSteps;
  127204. /**
  127205. * Creates a new instance of DepthOfFieldMergePostProcess
  127206. * @param name The name of the effect.
  127207. * @param originalFromInput Post process which's input will be used for the merge.
  127208. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  127209. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  127210. * @param options The required width/height ratio to downsize to before computing the render pass.
  127211. * @param camera The camera to apply the render pass to.
  127212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127213. * @param engine The engine which the post process will be applied. (default: current engine)
  127214. * @param reusable If the post process can be reused on the same frame. (default: false)
  127215. * @param textureType Type of textures used when performing the post process. (default: 0)
  127216. * @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)
  127217. */
  127218. 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);
  127219. /**
  127220. * Updates the effect with the current post process compile time values and recompiles the shader.
  127221. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  127222. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  127223. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  127224. * @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
  127225. * @param onCompiled Called when the shader has been compiled.
  127226. * @param onError Called if there is an error when compiling a shader.
  127227. */
  127228. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  127229. }
  127230. }
  127231. declare module BABYLON {
  127232. /**
  127233. * Specifies the level of max blur that should be applied when using the depth of field effect
  127234. */
  127235. export enum DepthOfFieldEffectBlurLevel {
  127236. /**
  127237. * Subtle blur
  127238. */
  127239. Low = 0,
  127240. /**
  127241. * Medium blur
  127242. */
  127243. Medium = 1,
  127244. /**
  127245. * Large blur
  127246. */
  127247. High = 2
  127248. }
  127249. /**
  127250. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  127251. */
  127252. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  127253. private _circleOfConfusion;
  127254. /**
  127255. * @hidden Internal, blurs from high to low
  127256. */
  127257. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  127258. private _depthOfFieldBlurY;
  127259. private _dofMerge;
  127260. /**
  127261. * @hidden Internal post processes in depth of field effect
  127262. */
  127263. _effects: Array<PostProcess>;
  127264. /**
  127265. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  127266. */
  127267. focalLength: number;
  127268. /**
  127269. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127270. */
  127271. fStop: number;
  127272. /**
  127273. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127274. */
  127275. focusDistance: number;
  127276. /**
  127277. * 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.
  127278. */
  127279. lensSize: number;
  127280. /**
  127281. * Creates a new instance DepthOfFieldEffect
  127282. * @param scene The scene the effect belongs to.
  127283. * @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.
  127284. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127285. * @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)
  127286. */
  127287. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  127288. /**
  127289. * Get the current class name of the current effet
  127290. * @returns "DepthOfFieldEffect"
  127291. */
  127292. getClassName(): string;
  127293. /**
  127294. * 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.
  127295. */
  127296. depthTexture: RenderTargetTexture;
  127297. /**
  127298. * Disposes each of the internal effects for a given camera.
  127299. * @param camera The camera to dispose the effect on.
  127300. */
  127301. disposeEffects(camera: Camera): void;
  127302. /**
  127303. * @hidden Internal
  127304. */
  127305. _updateEffects(): void;
  127306. /**
  127307. * Internal
  127308. * @returns if all the contained post processes are ready.
  127309. * @hidden
  127310. */
  127311. _isReady(): boolean;
  127312. }
  127313. }
  127314. declare module BABYLON {
  127315. /** @hidden */
  127316. export var displayPassPixelShader: {
  127317. name: string;
  127318. shader: string;
  127319. };
  127320. }
  127321. declare module BABYLON {
  127322. /**
  127323. * DisplayPassPostProcess which produces an output the same as it's input
  127324. */
  127325. export class DisplayPassPostProcess extends PostProcess {
  127326. /**
  127327. * Creates the DisplayPassPostProcess
  127328. * @param name The name of the effect.
  127329. * @param options The required width/height ratio to downsize to before computing the render pass.
  127330. * @param camera The camera to apply the render pass to.
  127331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127332. * @param engine The engine which the post process will be applied. (default: current engine)
  127333. * @param reusable If the post process can be reused on the same frame. (default: false)
  127334. */
  127335. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127336. }
  127337. }
  127338. declare module BABYLON {
  127339. /** @hidden */
  127340. export var filterPixelShader: {
  127341. name: string;
  127342. shader: string;
  127343. };
  127344. }
  127345. declare module BABYLON {
  127346. /**
  127347. * Applies a kernel filter to the image
  127348. */
  127349. export class FilterPostProcess extends PostProcess {
  127350. /** The matrix to be applied to the image */
  127351. kernelMatrix: Matrix;
  127352. /**
  127353. *
  127354. * @param name The name of the effect.
  127355. * @param kernelMatrix The matrix to be applied to the image
  127356. * @param options The required width/height ratio to downsize to before computing the render pass.
  127357. * @param camera The camera to apply the render pass to.
  127358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127359. * @param engine The engine which the post process will be applied. (default: current engine)
  127360. * @param reusable If the post process can be reused on the same frame. (default: false)
  127361. */
  127362. constructor(name: string,
  127363. /** The matrix to be applied to the image */
  127364. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127365. }
  127366. }
  127367. declare module BABYLON {
  127368. /** @hidden */
  127369. export var fxaaPixelShader: {
  127370. name: string;
  127371. shader: string;
  127372. };
  127373. }
  127374. declare module BABYLON {
  127375. /** @hidden */
  127376. export var fxaaVertexShader: {
  127377. name: string;
  127378. shader: string;
  127379. };
  127380. }
  127381. declare module BABYLON {
  127382. /**
  127383. * Fxaa post process
  127384. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  127385. */
  127386. export class FxaaPostProcess extends PostProcess {
  127387. /** @hidden */
  127388. texelWidth: number;
  127389. /** @hidden */
  127390. texelHeight: number;
  127391. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127392. private _getDefines;
  127393. }
  127394. }
  127395. declare module BABYLON {
  127396. /** @hidden */
  127397. export var grainPixelShader: {
  127398. name: string;
  127399. shader: string;
  127400. };
  127401. }
  127402. declare module BABYLON {
  127403. /**
  127404. * The GrainPostProcess adds noise to the image at mid luminance levels
  127405. */
  127406. export class GrainPostProcess extends PostProcess {
  127407. /**
  127408. * The intensity of the grain added (default: 30)
  127409. */
  127410. intensity: number;
  127411. /**
  127412. * If the grain should be randomized on every frame
  127413. */
  127414. animated: boolean;
  127415. /**
  127416. * Creates a new instance of @see GrainPostProcess
  127417. * @param name The name of the effect.
  127418. * @param options The required width/height ratio to downsize to before computing the render pass.
  127419. * @param camera The camera to apply the render pass to.
  127420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127421. * @param engine The engine which the post process will be applied. (default: current engine)
  127422. * @param reusable If the post process can be reused on the same frame. (default: false)
  127423. * @param textureType Type of textures used when performing the post process. (default: 0)
  127424. * @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)
  127425. */
  127426. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127427. }
  127428. }
  127429. declare module BABYLON {
  127430. /** @hidden */
  127431. export var highlightsPixelShader: {
  127432. name: string;
  127433. shader: string;
  127434. };
  127435. }
  127436. declare module BABYLON {
  127437. /**
  127438. * Extracts highlights from the image
  127439. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127440. */
  127441. export class HighlightsPostProcess extends PostProcess {
  127442. /**
  127443. * Extracts highlights from the image
  127444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127445. * @param name The name of the effect.
  127446. * @param options The required width/height ratio to downsize to before computing the render pass.
  127447. * @param camera The camera to apply the render pass to.
  127448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127449. * @param engine The engine which the post process will be applied. (default: current engine)
  127450. * @param reusable If the post process can be reused on the same frame. (default: false)
  127451. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  127452. */
  127453. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127454. }
  127455. }
  127456. declare module BABYLON {
  127457. /** @hidden */
  127458. export var mrtFragmentDeclaration: {
  127459. name: string;
  127460. shader: string;
  127461. };
  127462. }
  127463. declare module BABYLON {
  127464. /** @hidden */
  127465. export var geometryPixelShader: {
  127466. name: string;
  127467. shader: string;
  127468. };
  127469. }
  127470. declare module BABYLON {
  127471. /** @hidden */
  127472. export var geometryVertexShader: {
  127473. name: string;
  127474. shader: string;
  127475. };
  127476. }
  127477. declare module BABYLON {
  127478. /** @hidden */
  127479. interface ISavedTransformationMatrix {
  127480. world: Matrix;
  127481. viewProjection: Matrix;
  127482. }
  127483. /**
  127484. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  127485. */
  127486. export class GeometryBufferRenderer {
  127487. /**
  127488. * Constant used to retrieve the position texture index in the G-Buffer textures array
  127489. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  127490. */
  127491. static readonly POSITION_TEXTURE_TYPE: number;
  127492. /**
  127493. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  127494. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  127495. */
  127496. static readonly VELOCITY_TEXTURE_TYPE: number;
  127497. /**
  127498. * Dictionary used to store the previous transformation matrices of each rendered mesh
  127499. * in order to compute objects velocities when enableVelocity is set to "true"
  127500. * @hidden
  127501. */
  127502. _previousTransformationMatrices: {
  127503. [index: number]: ISavedTransformationMatrix;
  127504. };
  127505. /**
  127506. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  127507. * in order to compute objects velocities when enableVelocity is set to "true"
  127508. * @hidden
  127509. */
  127510. _previousBonesTransformationMatrices: {
  127511. [index: number]: Float32Array;
  127512. };
  127513. /**
  127514. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  127515. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  127516. */
  127517. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  127518. private _scene;
  127519. private _multiRenderTarget;
  127520. private _ratio;
  127521. private _enablePosition;
  127522. private _enableVelocity;
  127523. private _positionIndex;
  127524. private _velocityIndex;
  127525. protected _effect: Effect;
  127526. protected _cachedDefines: string;
  127527. /**
  127528. * Set the render list (meshes to be rendered) used in the G buffer.
  127529. */
  127530. renderList: Mesh[];
  127531. /**
  127532. * Gets wether or not G buffer are supported by the running hardware.
  127533. * This requires draw buffer supports
  127534. */
  127535. readonly isSupported: boolean;
  127536. /**
  127537. * Returns the index of the given texture type in the G-Buffer textures array
  127538. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  127539. * @returns the index of the given texture type in the G-Buffer textures array
  127540. */
  127541. getTextureIndex(textureType: number): number;
  127542. /**
  127543. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  127544. */
  127545. /**
  127546. * Sets whether or not objects positions are enabled for the G buffer.
  127547. */
  127548. enablePosition: boolean;
  127549. /**
  127550. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  127551. */
  127552. /**
  127553. * Sets wether or not objects velocities are enabled for the G buffer.
  127554. */
  127555. enableVelocity: boolean;
  127556. /**
  127557. * Gets the scene associated with the buffer.
  127558. */
  127559. readonly scene: Scene;
  127560. /**
  127561. * Gets the ratio used by the buffer during its creation.
  127562. * How big is the buffer related to the main canvas.
  127563. */
  127564. readonly ratio: number;
  127565. /** @hidden */
  127566. static _SceneComponentInitialization: (scene: Scene) => void;
  127567. /**
  127568. * Creates a new G Buffer for the scene
  127569. * @param scene The scene the buffer belongs to
  127570. * @param ratio How big is the buffer related to the main canvas.
  127571. */
  127572. constructor(scene: Scene, ratio?: number);
  127573. /**
  127574. * Checks wether everything is ready to render a submesh to the G buffer.
  127575. * @param subMesh the submesh to check readiness for
  127576. * @param useInstances is the mesh drawn using instance or not
  127577. * @returns true if ready otherwise false
  127578. */
  127579. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127580. /**
  127581. * Gets the current underlying G Buffer.
  127582. * @returns the buffer
  127583. */
  127584. getGBuffer(): MultiRenderTarget;
  127585. /**
  127586. * Gets the number of samples used to render the buffer (anti aliasing).
  127587. */
  127588. /**
  127589. * Sets the number of samples used to render the buffer (anti aliasing).
  127590. */
  127591. samples: number;
  127592. /**
  127593. * Disposes the renderer and frees up associated resources.
  127594. */
  127595. dispose(): void;
  127596. protected _createRenderTargets(): void;
  127597. private _copyBonesTransformationMatrices;
  127598. }
  127599. }
  127600. declare module BABYLON {
  127601. interface Scene {
  127602. /** @hidden (Backing field) */
  127603. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127604. /**
  127605. * Gets or Sets the current geometry buffer associated to the scene.
  127606. */
  127607. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127608. /**
  127609. * Enables a GeometryBufferRender and associates it with the scene
  127610. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  127611. * @returns the GeometryBufferRenderer
  127612. */
  127613. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  127614. /**
  127615. * Disables the GeometryBufferRender associated with the scene
  127616. */
  127617. disableGeometryBufferRenderer(): void;
  127618. }
  127619. /**
  127620. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  127621. * in several rendering techniques.
  127622. */
  127623. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  127624. /**
  127625. * The component name helpful to identify the component in the list of scene components.
  127626. */
  127627. readonly name: string;
  127628. /**
  127629. * The scene the component belongs to.
  127630. */
  127631. scene: Scene;
  127632. /**
  127633. * Creates a new instance of the component for the given scene
  127634. * @param scene Defines the scene to register the component in
  127635. */
  127636. constructor(scene: Scene);
  127637. /**
  127638. * Registers the component in a given scene
  127639. */
  127640. register(): void;
  127641. /**
  127642. * Rebuilds the elements related to this component in case of
  127643. * context lost for instance.
  127644. */
  127645. rebuild(): void;
  127646. /**
  127647. * Disposes the component and the associated ressources
  127648. */
  127649. dispose(): void;
  127650. private _gatherRenderTargets;
  127651. }
  127652. }
  127653. declare module BABYLON {
  127654. /** @hidden */
  127655. export var motionBlurPixelShader: {
  127656. name: string;
  127657. shader: string;
  127658. };
  127659. }
  127660. declare module BABYLON {
  127661. /**
  127662. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  127663. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  127664. * As an example, all you have to do is to create the post-process:
  127665. * var mb = new BABYLON.MotionBlurPostProcess(
  127666. * 'mb', // The name of the effect.
  127667. * scene, // The scene containing the objects to blur according to their velocity.
  127668. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  127669. * camera // The camera to apply the render pass to.
  127670. * );
  127671. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  127672. */
  127673. export class MotionBlurPostProcess extends PostProcess {
  127674. /**
  127675. * Defines how much the image is blurred by the movement. Default value is equal to 1
  127676. */
  127677. motionStrength: number;
  127678. /**
  127679. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  127680. */
  127681. /**
  127682. * Sets the number of iterations to be used for motion blur quality
  127683. */
  127684. motionBlurSamples: number;
  127685. private _motionBlurSamples;
  127686. private _geometryBufferRenderer;
  127687. /**
  127688. * Creates a new instance MotionBlurPostProcess
  127689. * @param name The name of the effect.
  127690. * @param scene The scene containing the objects to blur according to their velocity.
  127691. * @param options The required width/height ratio to downsize to before computing the render pass.
  127692. * @param camera The camera to apply the render pass to.
  127693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127694. * @param engine The engine which the post process will be applied. (default: current engine)
  127695. * @param reusable If the post process can be reused on the same frame. (default: false)
  127696. * @param textureType Type of textures used when performing the post process. (default: 0)
  127697. * @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)
  127698. */
  127699. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127700. /**
  127701. * Excludes the given skinned mesh from computing bones velocities.
  127702. * 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.
  127703. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  127704. */
  127705. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127706. /**
  127707. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  127708. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  127709. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  127710. */
  127711. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127712. /**
  127713. * Disposes the post process.
  127714. * @param camera The camera to dispose the post process on.
  127715. */
  127716. dispose(camera?: Camera): void;
  127717. }
  127718. }
  127719. declare module BABYLON {
  127720. /** @hidden */
  127721. export var refractionPixelShader: {
  127722. name: string;
  127723. shader: string;
  127724. };
  127725. }
  127726. declare module BABYLON {
  127727. /**
  127728. * Post process which applies a refractin texture
  127729. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127730. */
  127731. export class RefractionPostProcess extends PostProcess {
  127732. /** the base color of the refraction (used to taint the rendering) */
  127733. color: Color3;
  127734. /** simulated refraction depth */
  127735. depth: number;
  127736. /** the coefficient of the base color (0 to remove base color tainting) */
  127737. colorLevel: number;
  127738. private _refTexture;
  127739. private _ownRefractionTexture;
  127740. /**
  127741. * Gets or sets the refraction texture
  127742. * Please note that you are responsible for disposing the texture if you set it manually
  127743. */
  127744. refractionTexture: Texture;
  127745. /**
  127746. * Initializes the RefractionPostProcess
  127747. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127748. * @param name The name of the effect.
  127749. * @param refractionTextureUrl Url of the refraction texture to use
  127750. * @param color the base color of the refraction (used to taint the rendering)
  127751. * @param depth simulated refraction depth
  127752. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  127753. * @param camera The camera to apply the render pass to.
  127754. * @param options The required width/height ratio to downsize to before computing the render pass.
  127755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127756. * @param engine The engine which the post process will be applied. (default: current engine)
  127757. * @param reusable If the post process can be reused on the same frame. (default: false)
  127758. */
  127759. constructor(name: string, refractionTextureUrl: string,
  127760. /** the base color of the refraction (used to taint the rendering) */
  127761. color: Color3,
  127762. /** simulated refraction depth */
  127763. depth: number,
  127764. /** the coefficient of the base color (0 to remove base color tainting) */
  127765. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127766. /**
  127767. * Disposes of the post process
  127768. * @param camera Camera to dispose post process on
  127769. */
  127770. dispose(camera: Camera): void;
  127771. }
  127772. }
  127773. declare module BABYLON {
  127774. /** @hidden */
  127775. export var sharpenPixelShader: {
  127776. name: string;
  127777. shader: string;
  127778. };
  127779. }
  127780. declare module BABYLON {
  127781. /**
  127782. * The SharpenPostProcess applies a sharpen kernel to every pixel
  127783. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127784. */
  127785. export class SharpenPostProcess extends PostProcess {
  127786. /**
  127787. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  127788. */
  127789. colorAmount: number;
  127790. /**
  127791. * How much sharpness should be applied (default: 0.3)
  127792. */
  127793. edgeAmount: number;
  127794. /**
  127795. * Creates a new instance ConvolutionPostProcess
  127796. * @param name The name of the effect.
  127797. * @param options The required width/height ratio to downsize to before computing the render pass.
  127798. * @param camera The camera to apply the render pass to.
  127799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127800. * @param engine The engine which the post process will be applied. (default: current engine)
  127801. * @param reusable If the post process can be reused on the same frame. (default: false)
  127802. * @param textureType Type of textures used when performing the post process. (default: 0)
  127803. * @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)
  127804. */
  127805. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127806. }
  127807. }
  127808. declare module BABYLON {
  127809. /**
  127810. * PostProcessRenderPipeline
  127811. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127812. */
  127813. export class PostProcessRenderPipeline {
  127814. private engine;
  127815. private _renderEffects;
  127816. private _renderEffectsForIsolatedPass;
  127817. /**
  127818. * List of inspectable custom properties (used by the Inspector)
  127819. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  127820. */
  127821. inspectableCustomProperties: IInspectable[];
  127822. /**
  127823. * @hidden
  127824. */
  127825. protected _cameras: Camera[];
  127826. /** @hidden */
  127827. _name: string;
  127828. /**
  127829. * Gets pipeline name
  127830. */
  127831. readonly name: string;
  127832. /**
  127833. * Initializes a PostProcessRenderPipeline
  127834. * @param engine engine to add the pipeline to
  127835. * @param name name of the pipeline
  127836. */
  127837. constructor(engine: Engine, name: string);
  127838. /**
  127839. * Gets the class name
  127840. * @returns "PostProcessRenderPipeline"
  127841. */
  127842. getClassName(): string;
  127843. /**
  127844. * If all the render effects in the pipeline are supported
  127845. */
  127846. readonly isSupported: boolean;
  127847. /**
  127848. * Adds an effect to the pipeline
  127849. * @param renderEffect the effect to add
  127850. */
  127851. addEffect(renderEffect: PostProcessRenderEffect): void;
  127852. /** @hidden */
  127853. _rebuild(): void;
  127854. /** @hidden */
  127855. _enableEffect(renderEffectName: string, cameras: Camera): void;
  127856. /** @hidden */
  127857. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  127858. /** @hidden */
  127859. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127860. /** @hidden */
  127861. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127862. /** @hidden */
  127863. _attachCameras(cameras: Camera, unique: boolean): void;
  127864. /** @hidden */
  127865. _attachCameras(cameras: Camera[], unique: boolean): void;
  127866. /** @hidden */
  127867. _detachCameras(cameras: Camera): void;
  127868. /** @hidden */
  127869. _detachCameras(cameras: Nullable<Camera[]>): void;
  127870. /** @hidden */
  127871. _update(): void;
  127872. /** @hidden */
  127873. _reset(): void;
  127874. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  127875. /**
  127876. * Disposes of the pipeline
  127877. */
  127878. dispose(): void;
  127879. }
  127880. }
  127881. declare module BABYLON {
  127882. /**
  127883. * PostProcessRenderPipelineManager class
  127884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127885. */
  127886. export class PostProcessRenderPipelineManager {
  127887. private _renderPipelines;
  127888. /**
  127889. * Initializes a PostProcessRenderPipelineManager
  127890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127891. */
  127892. constructor();
  127893. /**
  127894. * Gets the list of supported render pipelines
  127895. */
  127896. readonly supportedPipelines: PostProcessRenderPipeline[];
  127897. /**
  127898. * Adds a pipeline to the manager
  127899. * @param renderPipeline The pipeline to add
  127900. */
  127901. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  127902. /**
  127903. * Attaches a camera to the pipeline
  127904. * @param renderPipelineName The name of the pipeline to attach to
  127905. * @param cameras the camera to attach
  127906. * @param unique if the camera can be attached multiple times to the pipeline
  127907. */
  127908. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  127909. /**
  127910. * Detaches a camera from the pipeline
  127911. * @param renderPipelineName The name of the pipeline to detach from
  127912. * @param cameras the camera to detach
  127913. */
  127914. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  127915. /**
  127916. * Enables an effect by name on a pipeline
  127917. * @param renderPipelineName the name of the pipeline to enable the effect in
  127918. * @param renderEffectName the name of the effect to enable
  127919. * @param cameras the cameras that the effect should be enabled on
  127920. */
  127921. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  127922. /**
  127923. * Disables an effect by name on a pipeline
  127924. * @param renderPipelineName the name of the pipeline to disable the effect in
  127925. * @param renderEffectName the name of the effect to disable
  127926. * @param cameras the cameras that the effect should be disabled on
  127927. */
  127928. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  127929. /**
  127930. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  127931. */
  127932. update(): void;
  127933. /** @hidden */
  127934. _rebuild(): void;
  127935. /**
  127936. * Disposes of the manager and pipelines
  127937. */
  127938. dispose(): void;
  127939. }
  127940. }
  127941. declare module BABYLON {
  127942. interface Scene {
  127943. /** @hidden (Backing field) */
  127944. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  127945. /**
  127946. * Gets the postprocess render pipeline manager
  127947. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127948. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  127949. */
  127950. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  127951. }
  127952. /**
  127953. * Defines the Render Pipeline scene component responsible to rendering pipelines
  127954. */
  127955. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  127956. /**
  127957. * The component name helpfull to identify the component in the list of scene components.
  127958. */
  127959. readonly name: string;
  127960. /**
  127961. * The scene the component belongs to.
  127962. */
  127963. scene: Scene;
  127964. /**
  127965. * Creates a new instance of the component for the given scene
  127966. * @param scene Defines the scene to register the component in
  127967. */
  127968. constructor(scene: Scene);
  127969. /**
  127970. * Registers the component in a given scene
  127971. */
  127972. register(): void;
  127973. /**
  127974. * Rebuilds the elements related to this component in case of
  127975. * context lost for instance.
  127976. */
  127977. rebuild(): void;
  127978. /**
  127979. * Disposes the component and the associated ressources
  127980. */
  127981. dispose(): void;
  127982. private _gatherRenderTargets;
  127983. }
  127984. }
  127985. declare module BABYLON {
  127986. /**
  127987. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  127988. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  127989. */
  127990. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127991. private _scene;
  127992. private _camerasToBeAttached;
  127993. /**
  127994. * ID of the sharpen post process,
  127995. */
  127996. private readonly SharpenPostProcessId;
  127997. /**
  127998. * @ignore
  127999. * ID of the image processing post process;
  128000. */
  128001. readonly ImageProcessingPostProcessId: string;
  128002. /**
  128003. * @ignore
  128004. * ID of the Fast Approximate Anti-Aliasing post process;
  128005. */
  128006. readonly FxaaPostProcessId: string;
  128007. /**
  128008. * ID of the chromatic aberration post process,
  128009. */
  128010. private readonly ChromaticAberrationPostProcessId;
  128011. /**
  128012. * ID of the grain post process
  128013. */
  128014. private readonly GrainPostProcessId;
  128015. /**
  128016. * Sharpen post process which will apply a sharpen convolution to enhance edges
  128017. */
  128018. sharpen: SharpenPostProcess;
  128019. private _sharpenEffect;
  128020. private bloom;
  128021. /**
  128022. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  128023. */
  128024. depthOfField: DepthOfFieldEffect;
  128025. /**
  128026. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128027. */
  128028. fxaa: FxaaPostProcess;
  128029. /**
  128030. * Image post processing pass used to perform operations such as tone mapping or color grading.
  128031. */
  128032. imageProcessing: ImageProcessingPostProcess;
  128033. /**
  128034. * Chromatic aberration post process which will shift rgb colors in the image
  128035. */
  128036. chromaticAberration: ChromaticAberrationPostProcess;
  128037. private _chromaticAberrationEffect;
  128038. /**
  128039. * Grain post process which add noise to the image
  128040. */
  128041. grain: GrainPostProcess;
  128042. private _grainEffect;
  128043. /**
  128044. * Glow post process which adds a glow to emissive areas of the image
  128045. */
  128046. private _glowLayer;
  128047. /**
  128048. * Animations which can be used to tweak settings over a period of time
  128049. */
  128050. animations: Animation[];
  128051. private _imageProcessingConfigurationObserver;
  128052. private _sharpenEnabled;
  128053. private _bloomEnabled;
  128054. private _depthOfFieldEnabled;
  128055. private _depthOfFieldBlurLevel;
  128056. private _fxaaEnabled;
  128057. private _imageProcessingEnabled;
  128058. private _defaultPipelineTextureType;
  128059. private _bloomScale;
  128060. private _chromaticAberrationEnabled;
  128061. private _grainEnabled;
  128062. private _buildAllowed;
  128063. /**
  128064. * Gets active scene
  128065. */
  128066. readonly scene: Scene;
  128067. /**
  128068. * Enable or disable the sharpen process from the pipeline
  128069. */
  128070. sharpenEnabled: boolean;
  128071. private _resizeObserver;
  128072. private _hardwareScaleLevel;
  128073. private _bloomKernel;
  128074. /**
  128075. * Specifies the size of the bloom blur kernel, relative to the final output size
  128076. */
  128077. bloomKernel: number;
  128078. /**
  128079. * Specifies the weight of the bloom in the final rendering
  128080. */
  128081. private _bloomWeight;
  128082. /**
  128083. * Specifies the luma threshold for the area that will be blurred by the bloom
  128084. */
  128085. private _bloomThreshold;
  128086. private _hdr;
  128087. /**
  128088. * The strength of the bloom.
  128089. */
  128090. bloomWeight: number;
  128091. /**
  128092. * The strength of the bloom.
  128093. */
  128094. bloomThreshold: number;
  128095. /**
  128096. * The scale of the bloom, lower value will provide better performance.
  128097. */
  128098. bloomScale: number;
  128099. /**
  128100. * Enable or disable the bloom from the pipeline
  128101. */
  128102. bloomEnabled: boolean;
  128103. private _rebuildBloom;
  128104. /**
  128105. * If the depth of field is enabled.
  128106. */
  128107. depthOfFieldEnabled: boolean;
  128108. /**
  128109. * Blur level of the depth of field effect. (Higher blur will effect performance)
  128110. */
  128111. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  128112. /**
  128113. * If the anti aliasing is enabled.
  128114. */
  128115. fxaaEnabled: boolean;
  128116. private _samples;
  128117. /**
  128118. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  128119. */
  128120. samples: number;
  128121. /**
  128122. * If image processing is enabled.
  128123. */
  128124. imageProcessingEnabled: boolean;
  128125. /**
  128126. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  128127. */
  128128. glowLayerEnabled: boolean;
  128129. /**
  128130. * Gets the glow layer (or null if not defined)
  128131. */
  128132. readonly glowLayer: Nullable<GlowLayer>;
  128133. /**
  128134. * Enable or disable the chromaticAberration process from the pipeline
  128135. */
  128136. chromaticAberrationEnabled: boolean;
  128137. /**
  128138. * Enable or disable the grain process from the pipeline
  128139. */
  128140. grainEnabled: boolean;
  128141. /**
  128142. * @constructor
  128143. * @param name - The rendering pipeline name (default: "")
  128144. * @param hdr - If high dynamic range textures should be used (default: true)
  128145. * @param scene - The scene linked to this pipeline (default: the last created scene)
  128146. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  128147. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  128148. */
  128149. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  128150. /**
  128151. * Get the class name
  128152. * @returns "DefaultRenderingPipeline"
  128153. */
  128154. getClassName(): string;
  128155. /**
  128156. * Force the compilation of the entire pipeline.
  128157. */
  128158. prepare(): void;
  128159. private _hasCleared;
  128160. private _prevPostProcess;
  128161. private _prevPrevPostProcess;
  128162. private _setAutoClearAndTextureSharing;
  128163. private _depthOfFieldSceneObserver;
  128164. private _buildPipeline;
  128165. private _disposePostProcesses;
  128166. /**
  128167. * Adds a camera to the pipeline
  128168. * @param camera the camera to be added
  128169. */
  128170. addCamera(camera: Camera): void;
  128171. /**
  128172. * Removes a camera from the pipeline
  128173. * @param camera the camera to remove
  128174. */
  128175. removeCamera(camera: Camera): void;
  128176. /**
  128177. * Dispose of the pipeline and stop all post processes
  128178. */
  128179. dispose(): void;
  128180. /**
  128181. * Serialize the rendering pipeline (Used when exporting)
  128182. * @returns the serialized object
  128183. */
  128184. serialize(): any;
  128185. /**
  128186. * Parse the serialized pipeline
  128187. * @param source Source pipeline.
  128188. * @param scene The scene to load the pipeline to.
  128189. * @param rootUrl The URL of the serialized pipeline.
  128190. * @returns An instantiated pipeline from the serialized object.
  128191. */
  128192. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  128193. }
  128194. }
  128195. declare module BABYLON {
  128196. /** @hidden */
  128197. export var lensHighlightsPixelShader: {
  128198. name: string;
  128199. shader: string;
  128200. };
  128201. }
  128202. declare module BABYLON {
  128203. /** @hidden */
  128204. export var depthOfFieldPixelShader: {
  128205. name: string;
  128206. shader: string;
  128207. };
  128208. }
  128209. declare module BABYLON {
  128210. /**
  128211. * BABYLON.JS Chromatic Aberration GLSL Shader
  128212. * Author: Olivier Guyot
  128213. * Separates very slightly R, G and B colors on the edges of the screen
  128214. * Inspired by Francois Tarlier & Martins Upitis
  128215. */
  128216. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  128217. /**
  128218. * @ignore
  128219. * The chromatic aberration PostProcess id in the pipeline
  128220. */
  128221. LensChromaticAberrationEffect: string;
  128222. /**
  128223. * @ignore
  128224. * The highlights enhancing PostProcess id in the pipeline
  128225. */
  128226. HighlightsEnhancingEffect: string;
  128227. /**
  128228. * @ignore
  128229. * The depth-of-field PostProcess id in the pipeline
  128230. */
  128231. LensDepthOfFieldEffect: string;
  128232. private _scene;
  128233. private _depthTexture;
  128234. private _grainTexture;
  128235. private _chromaticAberrationPostProcess;
  128236. private _highlightsPostProcess;
  128237. private _depthOfFieldPostProcess;
  128238. private _edgeBlur;
  128239. private _grainAmount;
  128240. private _chromaticAberration;
  128241. private _distortion;
  128242. private _highlightsGain;
  128243. private _highlightsThreshold;
  128244. private _dofDistance;
  128245. private _dofAperture;
  128246. private _dofDarken;
  128247. private _dofPentagon;
  128248. private _blurNoise;
  128249. /**
  128250. * @constructor
  128251. *
  128252. * Effect parameters are as follow:
  128253. * {
  128254. * chromatic_aberration: number; // from 0 to x (1 for realism)
  128255. * edge_blur: number; // from 0 to x (1 for realism)
  128256. * distortion: number; // from 0 to x (1 for realism)
  128257. * grain_amount: number; // from 0 to 1
  128258. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  128259. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  128260. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  128261. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  128262. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  128263. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  128264. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  128265. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  128266. * }
  128267. * Note: if an effect parameter is unset, effect is disabled
  128268. *
  128269. * @param name The rendering pipeline name
  128270. * @param parameters - An object containing all parameters (see above)
  128271. * @param scene The scene linked to this pipeline
  128272. * @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)
  128273. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128274. */
  128275. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  128276. /**
  128277. * Get the class name
  128278. * @returns "LensRenderingPipeline"
  128279. */
  128280. getClassName(): string;
  128281. /**
  128282. * Gets associated scene
  128283. */
  128284. readonly scene: Scene;
  128285. /**
  128286. * Gets or sets the edge blur
  128287. */
  128288. edgeBlur: number;
  128289. /**
  128290. * Gets or sets the grain amount
  128291. */
  128292. grainAmount: number;
  128293. /**
  128294. * Gets or sets the chromatic aberration amount
  128295. */
  128296. chromaticAberration: number;
  128297. /**
  128298. * Gets or sets the depth of field aperture
  128299. */
  128300. dofAperture: number;
  128301. /**
  128302. * Gets or sets the edge distortion
  128303. */
  128304. edgeDistortion: number;
  128305. /**
  128306. * Gets or sets the depth of field distortion
  128307. */
  128308. dofDistortion: number;
  128309. /**
  128310. * Gets or sets the darken out of focus amount
  128311. */
  128312. darkenOutOfFocus: number;
  128313. /**
  128314. * Gets or sets a boolean indicating if blur noise is enabled
  128315. */
  128316. blurNoise: boolean;
  128317. /**
  128318. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  128319. */
  128320. pentagonBokeh: boolean;
  128321. /**
  128322. * Gets or sets the highlight grain amount
  128323. */
  128324. highlightsGain: number;
  128325. /**
  128326. * Gets or sets the highlight threshold
  128327. */
  128328. highlightsThreshold: number;
  128329. /**
  128330. * Sets the amount of blur at the edges
  128331. * @param amount blur amount
  128332. */
  128333. setEdgeBlur(amount: number): void;
  128334. /**
  128335. * Sets edge blur to 0
  128336. */
  128337. disableEdgeBlur(): void;
  128338. /**
  128339. * Sets the amout of grain
  128340. * @param amount Amount of grain
  128341. */
  128342. setGrainAmount(amount: number): void;
  128343. /**
  128344. * Set grain amount to 0
  128345. */
  128346. disableGrain(): void;
  128347. /**
  128348. * Sets the chromatic aberration amount
  128349. * @param amount amount of chromatic aberration
  128350. */
  128351. setChromaticAberration(amount: number): void;
  128352. /**
  128353. * Sets chromatic aberration amount to 0
  128354. */
  128355. disableChromaticAberration(): void;
  128356. /**
  128357. * Sets the EdgeDistortion amount
  128358. * @param amount amount of EdgeDistortion
  128359. */
  128360. setEdgeDistortion(amount: number): void;
  128361. /**
  128362. * Sets edge distortion to 0
  128363. */
  128364. disableEdgeDistortion(): void;
  128365. /**
  128366. * Sets the FocusDistance amount
  128367. * @param amount amount of FocusDistance
  128368. */
  128369. setFocusDistance(amount: number): void;
  128370. /**
  128371. * Disables depth of field
  128372. */
  128373. disableDepthOfField(): void;
  128374. /**
  128375. * Sets the Aperture amount
  128376. * @param amount amount of Aperture
  128377. */
  128378. setAperture(amount: number): void;
  128379. /**
  128380. * Sets the DarkenOutOfFocus amount
  128381. * @param amount amount of DarkenOutOfFocus
  128382. */
  128383. setDarkenOutOfFocus(amount: number): void;
  128384. private _pentagonBokehIsEnabled;
  128385. /**
  128386. * Creates a pentagon bokeh effect
  128387. */
  128388. enablePentagonBokeh(): void;
  128389. /**
  128390. * Disables the pentagon bokeh effect
  128391. */
  128392. disablePentagonBokeh(): void;
  128393. /**
  128394. * Enables noise blur
  128395. */
  128396. enableNoiseBlur(): void;
  128397. /**
  128398. * Disables noise blur
  128399. */
  128400. disableNoiseBlur(): void;
  128401. /**
  128402. * Sets the HighlightsGain amount
  128403. * @param amount amount of HighlightsGain
  128404. */
  128405. setHighlightsGain(amount: number): void;
  128406. /**
  128407. * Sets the HighlightsThreshold amount
  128408. * @param amount amount of HighlightsThreshold
  128409. */
  128410. setHighlightsThreshold(amount: number): void;
  128411. /**
  128412. * Disables highlights
  128413. */
  128414. disableHighlights(): void;
  128415. /**
  128416. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  128417. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  128418. */
  128419. dispose(disableDepthRender?: boolean): void;
  128420. private _createChromaticAberrationPostProcess;
  128421. private _createHighlightsPostProcess;
  128422. private _createDepthOfFieldPostProcess;
  128423. private _createGrainTexture;
  128424. }
  128425. }
  128426. declare module BABYLON {
  128427. /** @hidden */
  128428. export var ssao2PixelShader: {
  128429. name: string;
  128430. shader: string;
  128431. };
  128432. }
  128433. declare module BABYLON {
  128434. /** @hidden */
  128435. export var ssaoCombinePixelShader: {
  128436. name: string;
  128437. shader: string;
  128438. };
  128439. }
  128440. declare module BABYLON {
  128441. /**
  128442. * Render pipeline to produce ssao effect
  128443. */
  128444. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  128445. /**
  128446. * @ignore
  128447. * The PassPostProcess id in the pipeline that contains the original scene color
  128448. */
  128449. SSAOOriginalSceneColorEffect: string;
  128450. /**
  128451. * @ignore
  128452. * The SSAO PostProcess id in the pipeline
  128453. */
  128454. SSAORenderEffect: string;
  128455. /**
  128456. * @ignore
  128457. * The horizontal blur PostProcess id in the pipeline
  128458. */
  128459. SSAOBlurHRenderEffect: string;
  128460. /**
  128461. * @ignore
  128462. * The vertical blur PostProcess id in the pipeline
  128463. */
  128464. SSAOBlurVRenderEffect: string;
  128465. /**
  128466. * @ignore
  128467. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128468. */
  128469. SSAOCombineRenderEffect: string;
  128470. /**
  128471. * The output strength of the SSAO post-process. Default value is 1.0.
  128472. */
  128473. totalStrength: number;
  128474. /**
  128475. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  128476. */
  128477. maxZ: number;
  128478. /**
  128479. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  128480. */
  128481. minZAspect: number;
  128482. private _samples;
  128483. /**
  128484. * Number of samples used for the SSAO calculations. Default value is 8
  128485. */
  128486. samples: number;
  128487. private _textureSamples;
  128488. /**
  128489. * Number of samples to use for antialiasing
  128490. */
  128491. textureSamples: number;
  128492. /**
  128493. * Ratio object used for SSAO ratio and blur ratio
  128494. */
  128495. private _ratio;
  128496. /**
  128497. * Dynamically generated sphere sampler.
  128498. */
  128499. private _sampleSphere;
  128500. /**
  128501. * Blur filter offsets
  128502. */
  128503. private _samplerOffsets;
  128504. private _expensiveBlur;
  128505. /**
  128506. * If bilateral blur should be used
  128507. */
  128508. expensiveBlur: boolean;
  128509. /**
  128510. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  128511. */
  128512. radius: number;
  128513. /**
  128514. * The base color of the SSAO post-process
  128515. * The final result is "base + ssao" between [0, 1]
  128516. */
  128517. base: number;
  128518. /**
  128519. * Support test.
  128520. */
  128521. static readonly IsSupported: boolean;
  128522. private _scene;
  128523. private _depthTexture;
  128524. private _normalTexture;
  128525. private _randomTexture;
  128526. private _originalColorPostProcess;
  128527. private _ssaoPostProcess;
  128528. private _blurHPostProcess;
  128529. private _blurVPostProcess;
  128530. private _ssaoCombinePostProcess;
  128531. private _firstUpdate;
  128532. /**
  128533. * Gets active scene
  128534. */
  128535. readonly scene: Scene;
  128536. /**
  128537. * @constructor
  128538. * @param name The rendering pipeline name
  128539. * @param scene The scene linked to this pipeline
  128540. * @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 }
  128541. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128542. */
  128543. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128544. /**
  128545. * Get the class name
  128546. * @returns "SSAO2RenderingPipeline"
  128547. */
  128548. getClassName(): string;
  128549. /**
  128550. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128551. */
  128552. dispose(disableGeometryBufferRenderer?: boolean): void;
  128553. private _createBlurPostProcess;
  128554. /** @hidden */
  128555. _rebuild(): void;
  128556. private _bits;
  128557. private _radicalInverse_VdC;
  128558. private _hammersley;
  128559. private _hemisphereSample_uniform;
  128560. private _generateHemisphere;
  128561. private _createSSAOPostProcess;
  128562. private _createSSAOCombinePostProcess;
  128563. private _createRandomTexture;
  128564. /**
  128565. * Serialize the rendering pipeline (Used when exporting)
  128566. * @returns the serialized object
  128567. */
  128568. serialize(): any;
  128569. /**
  128570. * Parse the serialized pipeline
  128571. * @param source Source pipeline.
  128572. * @param scene The scene to load the pipeline to.
  128573. * @param rootUrl The URL of the serialized pipeline.
  128574. * @returns An instantiated pipeline from the serialized object.
  128575. */
  128576. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  128577. }
  128578. }
  128579. declare module BABYLON {
  128580. /** @hidden */
  128581. export var ssaoPixelShader: {
  128582. name: string;
  128583. shader: string;
  128584. };
  128585. }
  128586. declare module BABYLON {
  128587. /**
  128588. * Render pipeline to produce ssao effect
  128589. */
  128590. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  128591. /**
  128592. * @ignore
  128593. * The PassPostProcess id in the pipeline that contains the original scene color
  128594. */
  128595. SSAOOriginalSceneColorEffect: string;
  128596. /**
  128597. * @ignore
  128598. * The SSAO PostProcess id in the pipeline
  128599. */
  128600. SSAORenderEffect: string;
  128601. /**
  128602. * @ignore
  128603. * The horizontal blur PostProcess id in the pipeline
  128604. */
  128605. SSAOBlurHRenderEffect: string;
  128606. /**
  128607. * @ignore
  128608. * The vertical blur PostProcess id in the pipeline
  128609. */
  128610. SSAOBlurVRenderEffect: string;
  128611. /**
  128612. * @ignore
  128613. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128614. */
  128615. SSAOCombineRenderEffect: string;
  128616. /**
  128617. * The output strength of the SSAO post-process. Default value is 1.0.
  128618. */
  128619. totalStrength: number;
  128620. /**
  128621. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  128622. */
  128623. radius: number;
  128624. /**
  128625. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  128626. * Must not be equal to fallOff and superior to fallOff.
  128627. * Default value is 0.0075
  128628. */
  128629. area: number;
  128630. /**
  128631. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  128632. * Must not be equal to area and inferior to area.
  128633. * Default value is 0.000001
  128634. */
  128635. fallOff: number;
  128636. /**
  128637. * The base color of the SSAO post-process
  128638. * The final result is "base + ssao" between [0, 1]
  128639. */
  128640. base: number;
  128641. private _scene;
  128642. private _depthTexture;
  128643. private _randomTexture;
  128644. private _originalColorPostProcess;
  128645. private _ssaoPostProcess;
  128646. private _blurHPostProcess;
  128647. private _blurVPostProcess;
  128648. private _ssaoCombinePostProcess;
  128649. private _firstUpdate;
  128650. /**
  128651. * Gets active scene
  128652. */
  128653. readonly scene: Scene;
  128654. /**
  128655. * @constructor
  128656. * @param name - The rendering pipeline name
  128657. * @param scene - The scene linked to this pipeline
  128658. * @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 }
  128659. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  128660. */
  128661. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128662. /**
  128663. * Get the class name
  128664. * @returns "SSAORenderingPipeline"
  128665. */
  128666. getClassName(): string;
  128667. /**
  128668. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128669. */
  128670. dispose(disableDepthRender?: boolean): void;
  128671. private _createBlurPostProcess;
  128672. /** @hidden */
  128673. _rebuild(): void;
  128674. private _createSSAOPostProcess;
  128675. private _createSSAOCombinePostProcess;
  128676. private _createRandomTexture;
  128677. }
  128678. }
  128679. declare module BABYLON {
  128680. /** @hidden */
  128681. export var standardPixelShader: {
  128682. name: string;
  128683. shader: string;
  128684. };
  128685. }
  128686. declare module BABYLON {
  128687. /**
  128688. * Standard rendering pipeline
  128689. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  128690. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  128691. */
  128692. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128693. /**
  128694. * Public members
  128695. */
  128696. /**
  128697. * Post-process which contains the original scene color before the pipeline applies all the effects
  128698. */
  128699. originalPostProcess: Nullable<PostProcess>;
  128700. /**
  128701. * Post-process used to down scale an image x4
  128702. */
  128703. downSampleX4PostProcess: Nullable<PostProcess>;
  128704. /**
  128705. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  128706. */
  128707. brightPassPostProcess: Nullable<PostProcess>;
  128708. /**
  128709. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  128710. */
  128711. blurHPostProcesses: PostProcess[];
  128712. /**
  128713. * Post-process array storing all the vertical blur post-processes used by the pipeline
  128714. */
  128715. blurVPostProcesses: PostProcess[];
  128716. /**
  128717. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  128718. */
  128719. textureAdderPostProcess: Nullable<PostProcess>;
  128720. /**
  128721. * Post-process used to create volumetric lighting effect
  128722. */
  128723. volumetricLightPostProcess: Nullable<PostProcess>;
  128724. /**
  128725. * Post-process used to smooth the previous volumetric light post-process on the X axis
  128726. */
  128727. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  128728. /**
  128729. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  128730. */
  128731. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  128732. /**
  128733. * Post-process used to merge the volumetric light effect and the real scene color
  128734. */
  128735. volumetricLightMergePostProces: Nullable<PostProcess>;
  128736. /**
  128737. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  128738. */
  128739. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  128740. /**
  128741. * Base post-process used to calculate the average luminance of the final image for HDR
  128742. */
  128743. luminancePostProcess: Nullable<PostProcess>;
  128744. /**
  128745. * Post-processes used to create down sample post-processes in order to get
  128746. * the average luminance of the final image for HDR
  128747. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  128748. */
  128749. luminanceDownSamplePostProcesses: PostProcess[];
  128750. /**
  128751. * Post-process used to create a HDR effect (light adaptation)
  128752. */
  128753. hdrPostProcess: Nullable<PostProcess>;
  128754. /**
  128755. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  128756. */
  128757. textureAdderFinalPostProcess: Nullable<PostProcess>;
  128758. /**
  128759. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  128760. */
  128761. lensFlareFinalPostProcess: Nullable<PostProcess>;
  128762. /**
  128763. * Post-process used to merge the final HDR post-process and the real scene color
  128764. */
  128765. hdrFinalPostProcess: Nullable<PostProcess>;
  128766. /**
  128767. * Post-process used to create a lens flare effect
  128768. */
  128769. lensFlarePostProcess: Nullable<PostProcess>;
  128770. /**
  128771. * Post-process that merges the result of the lens flare post-process and the real scene color
  128772. */
  128773. lensFlareComposePostProcess: Nullable<PostProcess>;
  128774. /**
  128775. * Post-process used to create a motion blur effect
  128776. */
  128777. motionBlurPostProcess: Nullable<PostProcess>;
  128778. /**
  128779. * Post-process used to create a depth of field effect
  128780. */
  128781. depthOfFieldPostProcess: Nullable<PostProcess>;
  128782. /**
  128783. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128784. */
  128785. fxaaPostProcess: Nullable<FxaaPostProcess>;
  128786. /**
  128787. * Represents the brightness threshold in order to configure the illuminated surfaces
  128788. */
  128789. brightThreshold: number;
  128790. /**
  128791. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  128792. */
  128793. blurWidth: number;
  128794. /**
  128795. * Sets if the blur for highlighted surfaces must be only horizontal
  128796. */
  128797. horizontalBlur: boolean;
  128798. /**
  128799. * Gets the overall exposure used by the pipeline
  128800. */
  128801. /**
  128802. * Sets the overall exposure used by the pipeline
  128803. */
  128804. exposure: number;
  128805. /**
  128806. * Texture used typically to simulate "dirty" on camera lens
  128807. */
  128808. lensTexture: Nullable<Texture>;
  128809. /**
  128810. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  128811. */
  128812. volumetricLightCoefficient: number;
  128813. /**
  128814. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  128815. */
  128816. volumetricLightPower: number;
  128817. /**
  128818. * Used the set the blur intensity to smooth the volumetric lights
  128819. */
  128820. volumetricLightBlurScale: number;
  128821. /**
  128822. * Light (spot or directional) used to generate the volumetric lights rays
  128823. * The source light must have a shadow generate so the pipeline can get its
  128824. * depth map
  128825. */
  128826. sourceLight: Nullable<SpotLight | DirectionalLight>;
  128827. /**
  128828. * For eye adaptation, represents the minimum luminance the eye can see
  128829. */
  128830. hdrMinimumLuminance: number;
  128831. /**
  128832. * For eye adaptation, represents the decrease luminance speed
  128833. */
  128834. hdrDecreaseRate: number;
  128835. /**
  128836. * For eye adaptation, represents the increase luminance speed
  128837. */
  128838. hdrIncreaseRate: number;
  128839. /**
  128840. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128841. */
  128842. /**
  128843. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128844. */
  128845. hdrAutoExposure: boolean;
  128846. /**
  128847. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  128848. */
  128849. lensColorTexture: Nullable<Texture>;
  128850. /**
  128851. * The overall strengh for the lens flare effect
  128852. */
  128853. lensFlareStrength: number;
  128854. /**
  128855. * Dispersion coefficient for lens flare ghosts
  128856. */
  128857. lensFlareGhostDispersal: number;
  128858. /**
  128859. * Main lens flare halo width
  128860. */
  128861. lensFlareHaloWidth: number;
  128862. /**
  128863. * Based on the lens distortion effect, defines how much the lens flare result
  128864. * is distorted
  128865. */
  128866. lensFlareDistortionStrength: number;
  128867. /**
  128868. * Configures the blur intensity used for for lens flare (halo)
  128869. */
  128870. lensFlareBlurWidth: number;
  128871. /**
  128872. * Lens star texture must be used to simulate rays on the flares and is available
  128873. * in the documentation
  128874. */
  128875. lensStarTexture: Nullable<Texture>;
  128876. /**
  128877. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  128878. * flare effect by taking account of the dirt texture
  128879. */
  128880. lensFlareDirtTexture: Nullable<Texture>;
  128881. /**
  128882. * Represents the focal length for the depth of field effect
  128883. */
  128884. depthOfFieldDistance: number;
  128885. /**
  128886. * Represents the blur intensity for the blurred part of the depth of field effect
  128887. */
  128888. depthOfFieldBlurWidth: number;
  128889. /**
  128890. * Gets how much the image is blurred by the movement while using the motion blur post-process
  128891. */
  128892. /**
  128893. * Sets how much the image is blurred by the movement while using the motion blur post-process
  128894. */
  128895. motionStrength: number;
  128896. /**
  128897. * Gets wether or not the motion blur post-process is object based or screen based.
  128898. */
  128899. /**
  128900. * Sets wether or not the motion blur post-process should be object based or screen based
  128901. */
  128902. objectBasedMotionBlur: boolean;
  128903. /**
  128904. * List of animations for the pipeline (IAnimatable implementation)
  128905. */
  128906. animations: Animation[];
  128907. /**
  128908. * Private members
  128909. */
  128910. private _scene;
  128911. private _currentDepthOfFieldSource;
  128912. private _basePostProcess;
  128913. private _fixedExposure;
  128914. private _currentExposure;
  128915. private _hdrAutoExposure;
  128916. private _hdrCurrentLuminance;
  128917. private _motionStrength;
  128918. private _isObjectBasedMotionBlur;
  128919. private _floatTextureType;
  128920. private _camerasToBeAttached;
  128921. private _ratio;
  128922. private _bloomEnabled;
  128923. private _depthOfFieldEnabled;
  128924. private _vlsEnabled;
  128925. private _lensFlareEnabled;
  128926. private _hdrEnabled;
  128927. private _motionBlurEnabled;
  128928. private _fxaaEnabled;
  128929. private _motionBlurSamples;
  128930. private _volumetricLightStepsCount;
  128931. private _samples;
  128932. /**
  128933. * @ignore
  128934. * Specifies if the bloom pipeline is enabled
  128935. */
  128936. BloomEnabled: boolean;
  128937. /**
  128938. * @ignore
  128939. * Specifies if the depth of field pipeline is enabed
  128940. */
  128941. DepthOfFieldEnabled: boolean;
  128942. /**
  128943. * @ignore
  128944. * Specifies if the lens flare pipeline is enabed
  128945. */
  128946. LensFlareEnabled: boolean;
  128947. /**
  128948. * @ignore
  128949. * Specifies if the HDR pipeline is enabled
  128950. */
  128951. HDREnabled: boolean;
  128952. /**
  128953. * @ignore
  128954. * Specifies if the volumetric lights scattering effect is enabled
  128955. */
  128956. VLSEnabled: boolean;
  128957. /**
  128958. * @ignore
  128959. * Specifies if the motion blur effect is enabled
  128960. */
  128961. MotionBlurEnabled: boolean;
  128962. /**
  128963. * Specifies if anti-aliasing is enabled
  128964. */
  128965. fxaaEnabled: boolean;
  128966. /**
  128967. * Specifies the number of steps used to calculate the volumetric lights
  128968. * Typically in interval [50, 200]
  128969. */
  128970. volumetricLightStepsCount: number;
  128971. /**
  128972. * Specifies the number of samples used for the motion blur effect
  128973. * Typically in interval [16, 64]
  128974. */
  128975. motionBlurSamples: number;
  128976. /**
  128977. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  128978. */
  128979. samples: number;
  128980. /**
  128981. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  128982. * @constructor
  128983. * @param name The rendering pipeline name
  128984. * @param scene The scene linked to this pipeline
  128985. * @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)
  128986. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  128987. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128988. */
  128989. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  128990. private _buildPipeline;
  128991. private _createDownSampleX4PostProcess;
  128992. private _createBrightPassPostProcess;
  128993. private _createBlurPostProcesses;
  128994. private _createTextureAdderPostProcess;
  128995. private _createVolumetricLightPostProcess;
  128996. private _createLuminancePostProcesses;
  128997. private _createHdrPostProcess;
  128998. private _createLensFlarePostProcess;
  128999. private _createDepthOfFieldPostProcess;
  129000. private _createMotionBlurPostProcess;
  129001. private _getDepthTexture;
  129002. private _disposePostProcesses;
  129003. /**
  129004. * Dispose of the pipeline and stop all post processes
  129005. */
  129006. dispose(): void;
  129007. /**
  129008. * Serialize the rendering pipeline (Used when exporting)
  129009. * @returns the serialized object
  129010. */
  129011. serialize(): any;
  129012. /**
  129013. * Parse the serialized pipeline
  129014. * @param source Source pipeline.
  129015. * @param scene The scene to load the pipeline to.
  129016. * @param rootUrl The URL of the serialized pipeline.
  129017. * @returns An instantiated pipeline from the serialized object.
  129018. */
  129019. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  129020. /**
  129021. * Luminance steps
  129022. */
  129023. static LuminanceSteps: number;
  129024. }
  129025. }
  129026. declare module BABYLON {
  129027. /** @hidden */
  129028. export var tonemapPixelShader: {
  129029. name: string;
  129030. shader: string;
  129031. };
  129032. }
  129033. declare module BABYLON {
  129034. /** Defines operator used for tonemapping */
  129035. export enum TonemappingOperator {
  129036. /** Hable */
  129037. Hable = 0,
  129038. /** Reinhard */
  129039. Reinhard = 1,
  129040. /** HejiDawson */
  129041. HejiDawson = 2,
  129042. /** Photographic */
  129043. Photographic = 3
  129044. }
  129045. /**
  129046. * Defines a post process to apply tone mapping
  129047. */
  129048. export class TonemapPostProcess extends PostProcess {
  129049. private _operator;
  129050. /** Defines the required exposure adjustement */
  129051. exposureAdjustment: number;
  129052. /**
  129053. * Creates a new TonemapPostProcess
  129054. * @param name defines the name of the postprocess
  129055. * @param _operator defines the operator to use
  129056. * @param exposureAdjustment defines the required exposure adjustement
  129057. * @param camera defines the camera to use (can be null)
  129058. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  129059. * @param engine defines the hosting engine (can be ignore if camera is set)
  129060. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129061. */
  129062. constructor(name: string, _operator: TonemappingOperator,
  129063. /** Defines the required exposure adjustement */
  129064. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  129065. }
  129066. }
  129067. declare module BABYLON {
  129068. /** @hidden */
  129069. export var depthVertexShader: {
  129070. name: string;
  129071. shader: string;
  129072. };
  129073. }
  129074. declare module BABYLON {
  129075. /** @hidden */
  129076. export var volumetricLightScatteringPixelShader: {
  129077. name: string;
  129078. shader: string;
  129079. };
  129080. }
  129081. declare module BABYLON {
  129082. /** @hidden */
  129083. export var volumetricLightScatteringPassVertexShader: {
  129084. name: string;
  129085. shader: string;
  129086. };
  129087. }
  129088. declare module BABYLON {
  129089. /** @hidden */
  129090. export var volumetricLightScatteringPassPixelShader: {
  129091. name: string;
  129092. shader: string;
  129093. };
  129094. }
  129095. declare module BABYLON {
  129096. /**
  129097. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  129098. */
  129099. export class VolumetricLightScatteringPostProcess extends PostProcess {
  129100. private _volumetricLightScatteringPass;
  129101. private _volumetricLightScatteringRTT;
  129102. private _viewPort;
  129103. private _screenCoordinates;
  129104. private _cachedDefines;
  129105. /**
  129106. * If not undefined, the mesh position is computed from the attached node position
  129107. */
  129108. attachedNode: {
  129109. position: Vector3;
  129110. };
  129111. /**
  129112. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  129113. */
  129114. customMeshPosition: Vector3;
  129115. /**
  129116. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  129117. */
  129118. useCustomMeshPosition: boolean;
  129119. /**
  129120. * If the post-process should inverse the light scattering direction
  129121. */
  129122. invert: boolean;
  129123. /**
  129124. * The internal mesh used by the post-process
  129125. */
  129126. mesh: Mesh;
  129127. /**
  129128. * @hidden
  129129. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  129130. */
  129131. useDiffuseColor: boolean;
  129132. /**
  129133. * Array containing the excluded meshes not rendered in the internal pass
  129134. */
  129135. excludedMeshes: AbstractMesh[];
  129136. /**
  129137. * Controls the overall intensity of the post-process
  129138. */
  129139. exposure: number;
  129140. /**
  129141. * Dissipates each sample's contribution in range [0, 1]
  129142. */
  129143. decay: number;
  129144. /**
  129145. * Controls the overall intensity of each sample
  129146. */
  129147. weight: number;
  129148. /**
  129149. * Controls the density of each sample
  129150. */
  129151. density: number;
  129152. /**
  129153. * @constructor
  129154. * @param name The post-process name
  129155. * @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)
  129156. * @param camera The camera that the post-process will be attached to
  129157. * @param mesh The mesh used to create the light scattering
  129158. * @param samples The post-process quality, default 100
  129159. * @param samplingModeThe post-process filtering mode
  129160. * @param engine The babylon engine
  129161. * @param reusable If the post-process is reusable
  129162. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  129163. */
  129164. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  129165. /**
  129166. * Returns the string "VolumetricLightScatteringPostProcess"
  129167. * @returns "VolumetricLightScatteringPostProcess"
  129168. */
  129169. getClassName(): string;
  129170. private _isReady;
  129171. /**
  129172. * Sets the new light position for light scattering effect
  129173. * @param position The new custom light position
  129174. */
  129175. setCustomMeshPosition(position: Vector3): void;
  129176. /**
  129177. * Returns the light position for light scattering effect
  129178. * @return Vector3 The custom light position
  129179. */
  129180. getCustomMeshPosition(): Vector3;
  129181. /**
  129182. * Disposes the internal assets and detaches the post-process from the camera
  129183. */
  129184. dispose(camera: Camera): void;
  129185. /**
  129186. * Returns the render target texture used by the post-process
  129187. * @return the render target texture used by the post-process
  129188. */
  129189. getPass(): RenderTargetTexture;
  129190. private _meshExcluded;
  129191. private _createPass;
  129192. private _updateMeshScreenCoordinates;
  129193. /**
  129194. * Creates a default mesh for the Volumeric Light Scattering post-process
  129195. * @param name The mesh name
  129196. * @param scene The scene where to create the mesh
  129197. * @return the default mesh
  129198. */
  129199. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  129200. }
  129201. }
  129202. declare module BABYLON {
  129203. interface Scene {
  129204. /** @hidden (Backing field) */
  129205. _boundingBoxRenderer: BoundingBoxRenderer;
  129206. /** @hidden (Backing field) */
  129207. _forceShowBoundingBoxes: boolean;
  129208. /**
  129209. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  129210. */
  129211. forceShowBoundingBoxes: boolean;
  129212. /**
  129213. * Gets the bounding box renderer associated with the scene
  129214. * @returns a BoundingBoxRenderer
  129215. */
  129216. getBoundingBoxRenderer(): BoundingBoxRenderer;
  129217. }
  129218. interface AbstractMesh {
  129219. /** @hidden (Backing field) */
  129220. _showBoundingBox: boolean;
  129221. /**
  129222. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  129223. */
  129224. showBoundingBox: boolean;
  129225. }
  129226. /**
  129227. * Component responsible of rendering the bounding box of the meshes in a scene.
  129228. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  129229. */
  129230. export class BoundingBoxRenderer implements ISceneComponent {
  129231. /**
  129232. * The component name helpfull to identify the component in the list of scene components.
  129233. */
  129234. readonly name: string;
  129235. /**
  129236. * The scene the component belongs to.
  129237. */
  129238. scene: Scene;
  129239. /**
  129240. * Color of the bounding box lines placed in front of an object
  129241. */
  129242. frontColor: Color3;
  129243. /**
  129244. * Color of the bounding box lines placed behind an object
  129245. */
  129246. backColor: Color3;
  129247. /**
  129248. * Defines if the renderer should show the back lines or not
  129249. */
  129250. showBackLines: boolean;
  129251. /**
  129252. * @hidden
  129253. */
  129254. renderList: SmartArray<BoundingBox>;
  129255. private _colorShader;
  129256. private _vertexBuffers;
  129257. private _indexBuffer;
  129258. private _fillIndexBuffer;
  129259. private _fillIndexData;
  129260. /**
  129261. * Instantiates a new bounding box renderer in a scene.
  129262. * @param scene the scene the renderer renders in
  129263. */
  129264. constructor(scene: Scene);
  129265. /**
  129266. * Registers the component in a given scene
  129267. */
  129268. register(): void;
  129269. private _evaluateSubMesh;
  129270. private _activeMesh;
  129271. private _prepareRessources;
  129272. private _createIndexBuffer;
  129273. /**
  129274. * Rebuilds the elements related to this component in case of
  129275. * context lost for instance.
  129276. */
  129277. rebuild(): void;
  129278. /**
  129279. * @hidden
  129280. */
  129281. reset(): void;
  129282. /**
  129283. * Render the bounding boxes of a specific rendering group
  129284. * @param renderingGroupId defines the rendering group to render
  129285. */
  129286. render(renderingGroupId: number): void;
  129287. /**
  129288. * In case of occlusion queries, we can render the occlusion bounding box through this method
  129289. * @param mesh Define the mesh to render the occlusion bounding box for
  129290. */
  129291. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  129292. /**
  129293. * Dispose and release the resources attached to this renderer.
  129294. */
  129295. dispose(): void;
  129296. }
  129297. }
  129298. declare module BABYLON {
  129299. /** @hidden */
  129300. export var depthPixelShader: {
  129301. name: string;
  129302. shader: string;
  129303. };
  129304. }
  129305. declare module BABYLON {
  129306. /**
  129307. * This represents a depth renderer in Babylon.
  129308. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  129309. */
  129310. export class DepthRenderer {
  129311. private _scene;
  129312. private _depthMap;
  129313. private _effect;
  129314. private readonly _storeNonLinearDepth;
  129315. private readonly _clearColor;
  129316. /** Get if the depth renderer is using packed depth or not */
  129317. readonly isPacked: boolean;
  129318. private _cachedDefines;
  129319. private _camera;
  129320. /**
  129321. * Specifiess that the depth renderer will only be used within
  129322. * the camera it is created for.
  129323. * This can help forcing its rendering during the camera processing.
  129324. */
  129325. useOnlyInActiveCamera: boolean;
  129326. /** @hidden */
  129327. static _SceneComponentInitialization: (scene: Scene) => void;
  129328. /**
  129329. * Instantiates a depth renderer
  129330. * @param scene The scene the renderer belongs to
  129331. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  129332. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  129333. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129334. */
  129335. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  129336. /**
  129337. * Creates the depth rendering effect and checks if the effect is ready.
  129338. * @param subMesh The submesh to be used to render the depth map of
  129339. * @param useInstances If multiple world instances should be used
  129340. * @returns if the depth renderer is ready to render the depth map
  129341. */
  129342. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129343. /**
  129344. * Gets the texture which the depth map will be written to.
  129345. * @returns The depth map texture
  129346. */
  129347. getDepthMap(): RenderTargetTexture;
  129348. /**
  129349. * Disposes of the depth renderer.
  129350. */
  129351. dispose(): void;
  129352. }
  129353. }
  129354. declare module BABYLON {
  129355. interface Scene {
  129356. /** @hidden (Backing field) */
  129357. _depthRenderer: {
  129358. [id: string]: DepthRenderer;
  129359. };
  129360. /**
  129361. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  129362. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  129363. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129364. * @returns the created depth renderer
  129365. */
  129366. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  129367. /**
  129368. * Disables a depth renderer for a given camera
  129369. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  129370. */
  129371. disableDepthRenderer(camera?: Nullable<Camera>): void;
  129372. }
  129373. /**
  129374. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  129375. * in several rendering techniques.
  129376. */
  129377. export class DepthRendererSceneComponent implements ISceneComponent {
  129378. /**
  129379. * The component name helpfull to identify the component in the list of scene components.
  129380. */
  129381. readonly name: string;
  129382. /**
  129383. * The scene the component belongs to.
  129384. */
  129385. scene: Scene;
  129386. /**
  129387. * Creates a new instance of the component for the given scene
  129388. * @param scene Defines the scene to register the component in
  129389. */
  129390. constructor(scene: Scene);
  129391. /**
  129392. * Registers the component in a given scene
  129393. */
  129394. register(): void;
  129395. /**
  129396. * Rebuilds the elements related to this component in case of
  129397. * context lost for instance.
  129398. */
  129399. rebuild(): void;
  129400. /**
  129401. * Disposes the component and the associated ressources
  129402. */
  129403. dispose(): void;
  129404. private _gatherRenderTargets;
  129405. private _gatherActiveCameraRenderTargets;
  129406. }
  129407. }
  129408. declare module BABYLON {
  129409. /** @hidden */
  129410. export var outlinePixelShader: {
  129411. name: string;
  129412. shader: string;
  129413. };
  129414. }
  129415. declare module BABYLON {
  129416. /** @hidden */
  129417. export var outlineVertexShader: {
  129418. name: string;
  129419. shader: string;
  129420. };
  129421. }
  129422. declare module BABYLON {
  129423. interface Scene {
  129424. /** @hidden */
  129425. _outlineRenderer: OutlineRenderer;
  129426. /**
  129427. * Gets the outline renderer associated with the scene
  129428. * @returns a OutlineRenderer
  129429. */
  129430. getOutlineRenderer(): OutlineRenderer;
  129431. }
  129432. interface AbstractMesh {
  129433. /** @hidden (Backing field) */
  129434. _renderOutline: boolean;
  129435. /**
  129436. * Gets or sets a boolean indicating if the outline must be rendered as well
  129437. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  129438. */
  129439. renderOutline: boolean;
  129440. /** @hidden (Backing field) */
  129441. _renderOverlay: boolean;
  129442. /**
  129443. * Gets or sets a boolean indicating if the overlay must be rendered as well
  129444. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  129445. */
  129446. renderOverlay: boolean;
  129447. }
  129448. /**
  129449. * This class is responsible to draw bothe outline/overlay of meshes.
  129450. * It should not be used directly but through the available method on mesh.
  129451. */
  129452. export class OutlineRenderer implements ISceneComponent {
  129453. /**
  129454. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  129455. */
  129456. private static _StencilReference;
  129457. /**
  129458. * The name of the component. Each component must have a unique name.
  129459. */
  129460. name: string;
  129461. /**
  129462. * The scene the component belongs to.
  129463. */
  129464. scene: Scene;
  129465. /**
  129466. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  129467. */
  129468. zOffset: number;
  129469. private _engine;
  129470. private _effect;
  129471. private _cachedDefines;
  129472. private _savedDepthWrite;
  129473. /**
  129474. * Instantiates a new outline renderer. (There could be only one per scene).
  129475. * @param scene Defines the scene it belongs to
  129476. */
  129477. constructor(scene: Scene);
  129478. /**
  129479. * Register the component to one instance of a scene.
  129480. */
  129481. register(): void;
  129482. /**
  129483. * Rebuilds the elements related to this component in case of
  129484. * context lost for instance.
  129485. */
  129486. rebuild(): void;
  129487. /**
  129488. * Disposes the component and the associated ressources.
  129489. */
  129490. dispose(): void;
  129491. /**
  129492. * Renders the outline in the canvas.
  129493. * @param subMesh Defines the sumesh to render
  129494. * @param batch Defines the batch of meshes in case of instances
  129495. * @param useOverlay Defines if the rendering is for the overlay or the outline
  129496. */
  129497. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  129498. /**
  129499. * Returns whether or not the outline renderer is ready for a given submesh.
  129500. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  129501. * @param subMesh Defines the submesh to check readyness for
  129502. * @param useInstances Defines wheter wee are trying to render instances or not
  129503. * @returns true if ready otherwise false
  129504. */
  129505. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129506. private _beforeRenderingMesh;
  129507. private _afterRenderingMesh;
  129508. }
  129509. }
  129510. declare module BABYLON {
  129511. /**
  129512. * Class used to manage multiple sprites of different sizes on the same spritesheet
  129513. * @see http://doc.babylonjs.com/babylon101/sprites
  129514. */
  129515. export class SpritePackedManager extends SpriteManager {
  129516. /** defines the packed manager's name */
  129517. name: string;
  129518. /**
  129519. * Creates a new sprite manager from a packed sprite sheet
  129520. * @param name defines the manager's name
  129521. * @param imgUrl defines the sprite sheet url
  129522. * @param capacity defines the maximum allowed number of sprites
  129523. * @param scene defines the hosting scene
  129524. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  129525. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  129526. * @param samplingMode defines the smapling mode to use with spritesheet
  129527. * @param fromPacked set to true; do not alter
  129528. */
  129529. constructor(
  129530. /** defines the packed manager's name */
  129531. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  129532. }
  129533. }
  129534. declare module BABYLON {
  129535. /**
  129536. * Defines the list of states available for a task inside a AssetsManager
  129537. */
  129538. export enum AssetTaskState {
  129539. /**
  129540. * Initialization
  129541. */
  129542. INIT = 0,
  129543. /**
  129544. * Running
  129545. */
  129546. RUNNING = 1,
  129547. /**
  129548. * Done
  129549. */
  129550. DONE = 2,
  129551. /**
  129552. * Error
  129553. */
  129554. ERROR = 3
  129555. }
  129556. /**
  129557. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  129558. */
  129559. export abstract class AbstractAssetTask {
  129560. /**
  129561. * Task name
  129562. */ name: string;
  129563. /**
  129564. * Callback called when the task is successful
  129565. */
  129566. onSuccess: (task: any) => void;
  129567. /**
  129568. * Callback called when the task is not successful
  129569. */
  129570. onError: (task: any, message?: string, exception?: any) => void;
  129571. /**
  129572. * Creates a new AssetsManager
  129573. * @param name defines the name of the task
  129574. */
  129575. constructor(
  129576. /**
  129577. * Task name
  129578. */ name: string);
  129579. private _isCompleted;
  129580. private _taskState;
  129581. private _errorObject;
  129582. /**
  129583. * Get if the task is completed
  129584. */
  129585. readonly isCompleted: boolean;
  129586. /**
  129587. * Gets the current state of the task
  129588. */
  129589. readonly taskState: AssetTaskState;
  129590. /**
  129591. * Gets the current error object (if task is in error)
  129592. */
  129593. readonly errorObject: {
  129594. message?: string;
  129595. exception?: any;
  129596. };
  129597. /**
  129598. * Internal only
  129599. * @hidden
  129600. */
  129601. _setErrorObject(message?: string, exception?: any): void;
  129602. /**
  129603. * Execute the current task
  129604. * @param scene defines the scene where you want your assets to be loaded
  129605. * @param onSuccess is a callback called when the task is successfully executed
  129606. * @param onError is a callback called if an error occurs
  129607. */
  129608. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129609. /**
  129610. * Execute the current task
  129611. * @param scene defines the scene where you want your assets to be loaded
  129612. * @param onSuccess is a callback called when the task is successfully executed
  129613. * @param onError is a callback called if an error occurs
  129614. */
  129615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129616. /**
  129617. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  129618. * This can be used with failed tasks that have the reason for failure fixed.
  129619. */
  129620. reset(): void;
  129621. private onErrorCallback;
  129622. private onDoneCallback;
  129623. }
  129624. /**
  129625. * Define the interface used by progress events raised during assets loading
  129626. */
  129627. export interface IAssetsProgressEvent {
  129628. /**
  129629. * Defines the number of remaining tasks to process
  129630. */
  129631. remainingCount: number;
  129632. /**
  129633. * Defines the total number of tasks
  129634. */
  129635. totalCount: number;
  129636. /**
  129637. * Defines the task that was just processed
  129638. */
  129639. task: AbstractAssetTask;
  129640. }
  129641. /**
  129642. * Class used to share progress information about assets loading
  129643. */
  129644. export class AssetsProgressEvent implements IAssetsProgressEvent {
  129645. /**
  129646. * Defines the number of remaining tasks to process
  129647. */
  129648. remainingCount: number;
  129649. /**
  129650. * Defines the total number of tasks
  129651. */
  129652. totalCount: number;
  129653. /**
  129654. * Defines the task that was just processed
  129655. */
  129656. task: AbstractAssetTask;
  129657. /**
  129658. * Creates a AssetsProgressEvent
  129659. * @param remainingCount defines the number of remaining tasks to process
  129660. * @param totalCount defines the total number of tasks
  129661. * @param task defines the task that was just processed
  129662. */
  129663. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  129664. }
  129665. /**
  129666. * Define a task used by AssetsManager to load meshes
  129667. */
  129668. export class MeshAssetTask extends AbstractAssetTask {
  129669. /**
  129670. * Defines the name of the task
  129671. */
  129672. name: string;
  129673. /**
  129674. * Defines the list of mesh's names you want to load
  129675. */
  129676. meshesNames: any;
  129677. /**
  129678. * Defines the root url to use as a base to load your meshes and associated resources
  129679. */
  129680. rootUrl: string;
  129681. /**
  129682. * Defines the filename of the scene to load from
  129683. */
  129684. sceneFilename: string;
  129685. /**
  129686. * Gets the list of loaded meshes
  129687. */
  129688. loadedMeshes: Array<AbstractMesh>;
  129689. /**
  129690. * Gets the list of loaded particle systems
  129691. */
  129692. loadedParticleSystems: Array<IParticleSystem>;
  129693. /**
  129694. * Gets the list of loaded skeletons
  129695. */
  129696. loadedSkeletons: Array<Skeleton>;
  129697. /**
  129698. * Gets the list of loaded animation groups
  129699. */
  129700. loadedAnimationGroups: Array<AnimationGroup>;
  129701. /**
  129702. * Callback called when the task is successful
  129703. */
  129704. onSuccess: (task: MeshAssetTask) => void;
  129705. /**
  129706. * Callback called when the task is successful
  129707. */
  129708. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  129709. /**
  129710. * Creates a new MeshAssetTask
  129711. * @param name defines the name of the task
  129712. * @param meshesNames defines the list of mesh's names you want to load
  129713. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  129714. * @param sceneFilename defines the filename of the scene to load from
  129715. */
  129716. constructor(
  129717. /**
  129718. * Defines the name of the task
  129719. */
  129720. name: string,
  129721. /**
  129722. * Defines the list of mesh's names you want to load
  129723. */
  129724. meshesNames: any,
  129725. /**
  129726. * Defines the root url to use as a base to load your meshes and associated resources
  129727. */
  129728. rootUrl: string,
  129729. /**
  129730. * Defines the filename of the scene to load from
  129731. */
  129732. sceneFilename: string);
  129733. /**
  129734. * Execute the current task
  129735. * @param scene defines the scene where you want your assets to be loaded
  129736. * @param onSuccess is a callback called when the task is successfully executed
  129737. * @param onError is a callback called if an error occurs
  129738. */
  129739. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129740. }
  129741. /**
  129742. * Define a task used by AssetsManager to load text content
  129743. */
  129744. export class TextFileAssetTask extends AbstractAssetTask {
  129745. /**
  129746. * Defines the name of the task
  129747. */
  129748. name: string;
  129749. /**
  129750. * Defines the location of the file to load
  129751. */
  129752. url: string;
  129753. /**
  129754. * Gets the loaded text string
  129755. */
  129756. text: string;
  129757. /**
  129758. * Callback called when the task is successful
  129759. */
  129760. onSuccess: (task: TextFileAssetTask) => void;
  129761. /**
  129762. * Callback called when the task is successful
  129763. */
  129764. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  129765. /**
  129766. * Creates a new TextFileAssetTask object
  129767. * @param name defines the name of the task
  129768. * @param url defines the location of the file to load
  129769. */
  129770. constructor(
  129771. /**
  129772. * Defines the name of the task
  129773. */
  129774. name: string,
  129775. /**
  129776. * Defines the location of the file to load
  129777. */
  129778. url: string);
  129779. /**
  129780. * Execute the current task
  129781. * @param scene defines the scene where you want your assets to be loaded
  129782. * @param onSuccess is a callback called when the task is successfully executed
  129783. * @param onError is a callback called if an error occurs
  129784. */
  129785. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129786. }
  129787. /**
  129788. * Define a task used by AssetsManager to load binary data
  129789. */
  129790. export class BinaryFileAssetTask extends AbstractAssetTask {
  129791. /**
  129792. * Defines the name of the task
  129793. */
  129794. name: string;
  129795. /**
  129796. * Defines the location of the file to load
  129797. */
  129798. url: string;
  129799. /**
  129800. * Gets the lodaded data (as an array buffer)
  129801. */
  129802. data: ArrayBuffer;
  129803. /**
  129804. * Callback called when the task is successful
  129805. */
  129806. onSuccess: (task: BinaryFileAssetTask) => void;
  129807. /**
  129808. * Callback called when the task is successful
  129809. */
  129810. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  129811. /**
  129812. * Creates a new BinaryFileAssetTask object
  129813. * @param name defines the name of the new task
  129814. * @param url defines the location of the file to load
  129815. */
  129816. constructor(
  129817. /**
  129818. * Defines the name of the task
  129819. */
  129820. name: string,
  129821. /**
  129822. * Defines the location of the file to load
  129823. */
  129824. url: string);
  129825. /**
  129826. * Execute the current task
  129827. * @param scene defines the scene where you want your assets to be loaded
  129828. * @param onSuccess is a callback called when the task is successfully executed
  129829. * @param onError is a callback called if an error occurs
  129830. */
  129831. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129832. }
  129833. /**
  129834. * Define a task used by AssetsManager to load images
  129835. */
  129836. export class ImageAssetTask extends AbstractAssetTask {
  129837. /**
  129838. * Defines the name of the task
  129839. */
  129840. name: string;
  129841. /**
  129842. * Defines the location of the image to load
  129843. */
  129844. url: string;
  129845. /**
  129846. * Gets the loaded images
  129847. */
  129848. image: HTMLImageElement;
  129849. /**
  129850. * Callback called when the task is successful
  129851. */
  129852. onSuccess: (task: ImageAssetTask) => void;
  129853. /**
  129854. * Callback called when the task is successful
  129855. */
  129856. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  129857. /**
  129858. * Creates a new ImageAssetTask
  129859. * @param name defines the name of the task
  129860. * @param url defines the location of the image to load
  129861. */
  129862. constructor(
  129863. /**
  129864. * Defines the name of the task
  129865. */
  129866. name: string,
  129867. /**
  129868. * Defines the location of the image to load
  129869. */
  129870. url: string);
  129871. /**
  129872. * Execute the current task
  129873. * @param scene defines the scene where you want your assets to be loaded
  129874. * @param onSuccess is a callback called when the task is successfully executed
  129875. * @param onError is a callback called if an error occurs
  129876. */
  129877. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129878. }
  129879. /**
  129880. * Defines the interface used by texture loading tasks
  129881. */
  129882. export interface ITextureAssetTask<TEX extends BaseTexture> {
  129883. /**
  129884. * Gets the loaded texture
  129885. */
  129886. texture: TEX;
  129887. }
  129888. /**
  129889. * Define a task used by AssetsManager to load 2D textures
  129890. */
  129891. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  129892. /**
  129893. * Defines the name of the task
  129894. */
  129895. name: string;
  129896. /**
  129897. * Defines the location of the file to load
  129898. */
  129899. url: string;
  129900. /**
  129901. * Defines if mipmap should not be generated (default is false)
  129902. */
  129903. noMipmap?: boolean | undefined;
  129904. /**
  129905. * Defines if texture must be inverted on Y axis (default is false)
  129906. */
  129907. invertY?: boolean | undefined;
  129908. /**
  129909. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129910. */
  129911. samplingMode: number;
  129912. /**
  129913. * Gets the loaded texture
  129914. */
  129915. texture: Texture;
  129916. /**
  129917. * Callback called when the task is successful
  129918. */
  129919. onSuccess: (task: TextureAssetTask) => void;
  129920. /**
  129921. * Callback called when the task is successful
  129922. */
  129923. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  129924. /**
  129925. * Creates a new TextureAssetTask object
  129926. * @param name defines the name of the task
  129927. * @param url defines the location of the file to load
  129928. * @param noMipmap defines if mipmap should not be generated (default is false)
  129929. * @param invertY defines if texture must be inverted on Y axis (default is false)
  129930. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129931. */
  129932. constructor(
  129933. /**
  129934. * Defines the name of the task
  129935. */
  129936. name: string,
  129937. /**
  129938. * Defines the location of the file to load
  129939. */
  129940. url: string,
  129941. /**
  129942. * Defines if mipmap should not be generated (default is false)
  129943. */
  129944. noMipmap?: boolean | undefined,
  129945. /**
  129946. * Defines if texture must be inverted on Y axis (default is false)
  129947. */
  129948. invertY?: boolean | undefined,
  129949. /**
  129950. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129951. */
  129952. samplingMode?: number);
  129953. /**
  129954. * Execute the current task
  129955. * @param scene defines the scene where you want your assets to be loaded
  129956. * @param onSuccess is a callback called when the task is successfully executed
  129957. * @param onError is a callback called if an error occurs
  129958. */
  129959. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129960. }
  129961. /**
  129962. * Define a task used by AssetsManager to load cube textures
  129963. */
  129964. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  129965. /**
  129966. * Defines the name of the task
  129967. */
  129968. name: string;
  129969. /**
  129970. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  129971. */
  129972. url: string;
  129973. /**
  129974. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  129975. */
  129976. extensions?: string[] | undefined;
  129977. /**
  129978. * Defines if mipmaps should not be generated (default is false)
  129979. */
  129980. noMipmap?: boolean | undefined;
  129981. /**
  129982. * Defines the explicit list of files (undefined by default)
  129983. */
  129984. files?: string[] | undefined;
  129985. /**
  129986. * Gets the loaded texture
  129987. */
  129988. texture: CubeTexture;
  129989. /**
  129990. * Callback called when the task is successful
  129991. */
  129992. onSuccess: (task: CubeTextureAssetTask) => void;
  129993. /**
  129994. * Callback called when the task is successful
  129995. */
  129996. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  129997. /**
  129998. * Creates a new CubeTextureAssetTask
  129999. * @param name defines the name of the task
  130000. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130001. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130002. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130003. * @param files defines the explicit list of files (undefined by default)
  130004. */
  130005. constructor(
  130006. /**
  130007. * Defines the name of the task
  130008. */
  130009. name: string,
  130010. /**
  130011. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130012. */
  130013. url: string,
  130014. /**
  130015. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130016. */
  130017. extensions?: string[] | undefined,
  130018. /**
  130019. * Defines if mipmaps should not be generated (default is false)
  130020. */
  130021. noMipmap?: boolean | undefined,
  130022. /**
  130023. * Defines the explicit list of files (undefined by default)
  130024. */
  130025. files?: string[] | undefined);
  130026. /**
  130027. * Execute the current task
  130028. * @param scene defines the scene where you want your assets to be loaded
  130029. * @param onSuccess is a callback called when the task is successfully executed
  130030. * @param onError is a callback called if an error occurs
  130031. */
  130032. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130033. }
  130034. /**
  130035. * Define a task used by AssetsManager to load HDR cube textures
  130036. */
  130037. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  130038. /**
  130039. * Defines the name of the task
  130040. */
  130041. name: string;
  130042. /**
  130043. * Defines the location of the file to load
  130044. */
  130045. url: string;
  130046. /**
  130047. * Defines the desired size (the more it increases the longer the generation will be)
  130048. */
  130049. size: number;
  130050. /**
  130051. * Defines if mipmaps should not be generated (default is false)
  130052. */
  130053. noMipmap: boolean;
  130054. /**
  130055. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130056. */
  130057. generateHarmonics: boolean;
  130058. /**
  130059. * 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)
  130060. */
  130061. gammaSpace: boolean;
  130062. /**
  130063. * Internal Use Only
  130064. */
  130065. reserved: boolean;
  130066. /**
  130067. * Gets the loaded texture
  130068. */
  130069. texture: HDRCubeTexture;
  130070. /**
  130071. * Callback called when the task is successful
  130072. */
  130073. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  130074. /**
  130075. * Callback called when the task is successful
  130076. */
  130077. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  130078. /**
  130079. * Creates a new HDRCubeTextureAssetTask object
  130080. * @param name defines the name of the task
  130081. * @param url defines the location of the file to load
  130082. * @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.
  130083. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130084. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130085. * @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)
  130086. * @param reserved Internal use only
  130087. */
  130088. constructor(
  130089. /**
  130090. * Defines the name of the task
  130091. */
  130092. name: string,
  130093. /**
  130094. * Defines the location of the file to load
  130095. */
  130096. url: string,
  130097. /**
  130098. * Defines the desired size (the more it increases the longer the generation will be)
  130099. */
  130100. size: number,
  130101. /**
  130102. * Defines if mipmaps should not be generated (default is false)
  130103. */
  130104. noMipmap?: boolean,
  130105. /**
  130106. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130107. */
  130108. generateHarmonics?: boolean,
  130109. /**
  130110. * 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)
  130111. */
  130112. gammaSpace?: boolean,
  130113. /**
  130114. * Internal Use Only
  130115. */
  130116. reserved?: boolean);
  130117. /**
  130118. * Execute the current task
  130119. * @param scene defines the scene where you want your assets to be loaded
  130120. * @param onSuccess is a callback called when the task is successfully executed
  130121. * @param onError is a callback called if an error occurs
  130122. */
  130123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130124. }
  130125. /**
  130126. * Define a task used by AssetsManager to load Equirectangular cube textures
  130127. */
  130128. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  130129. /**
  130130. * Defines the name of the task
  130131. */
  130132. name: string;
  130133. /**
  130134. * Defines the location of the file to load
  130135. */
  130136. url: string;
  130137. /**
  130138. * Defines the desired size (the more it increases the longer the generation will be)
  130139. */
  130140. size: number;
  130141. /**
  130142. * Defines if mipmaps should not be generated (default is false)
  130143. */
  130144. noMipmap: boolean;
  130145. /**
  130146. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130147. * but the standard material would require them in Gamma space) (default is true)
  130148. */
  130149. gammaSpace: boolean;
  130150. /**
  130151. * Gets the loaded texture
  130152. */
  130153. texture: EquiRectangularCubeTexture;
  130154. /**
  130155. * Callback called when the task is successful
  130156. */
  130157. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  130158. /**
  130159. * Callback called when the task is successful
  130160. */
  130161. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  130162. /**
  130163. * Creates a new EquiRectangularCubeTextureAssetTask object
  130164. * @param name defines the name of the task
  130165. * @param url defines the location of the file to load
  130166. * @param size defines the desired size (the more it increases the longer the generation will be)
  130167. * If the size is omitted this implies you are using a preprocessed cubemap.
  130168. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130169. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  130170. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  130171. * (default is true)
  130172. */
  130173. constructor(
  130174. /**
  130175. * Defines the name of the task
  130176. */
  130177. name: string,
  130178. /**
  130179. * Defines the location of the file to load
  130180. */
  130181. url: string,
  130182. /**
  130183. * Defines the desired size (the more it increases the longer the generation will be)
  130184. */
  130185. size: number,
  130186. /**
  130187. * Defines if mipmaps should not be generated (default is false)
  130188. */
  130189. noMipmap?: boolean,
  130190. /**
  130191. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130192. * but the standard material would require them in Gamma space) (default is true)
  130193. */
  130194. gammaSpace?: boolean);
  130195. /**
  130196. * Execute the current task
  130197. * @param scene defines the scene where you want your assets to be loaded
  130198. * @param onSuccess is a callback called when the task is successfully executed
  130199. * @param onError is a callback called if an error occurs
  130200. */
  130201. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130202. }
  130203. /**
  130204. * This class can be used to easily import assets into a scene
  130205. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  130206. */
  130207. export class AssetsManager {
  130208. private _scene;
  130209. private _isLoading;
  130210. protected _tasks: AbstractAssetTask[];
  130211. protected _waitingTasksCount: number;
  130212. protected _totalTasksCount: number;
  130213. /**
  130214. * Callback called when all tasks are processed
  130215. */
  130216. onFinish: (tasks: AbstractAssetTask[]) => void;
  130217. /**
  130218. * Callback called when a task is successful
  130219. */
  130220. onTaskSuccess: (task: AbstractAssetTask) => void;
  130221. /**
  130222. * Callback called when a task had an error
  130223. */
  130224. onTaskError: (task: AbstractAssetTask) => void;
  130225. /**
  130226. * Callback called when a task is done (whatever the result is)
  130227. */
  130228. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  130229. /**
  130230. * Observable called when all tasks are processed
  130231. */
  130232. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  130233. /**
  130234. * Observable called when a task had an error
  130235. */
  130236. onTaskErrorObservable: Observable<AbstractAssetTask>;
  130237. /**
  130238. * Observable called when all tasks were executed
  130239. */
  130240. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  130241. /**
  130242. * Observable called when a task is done (whatever the result is)
  130243. */
  130244. onProgressObservable: Observable<IAssetsProgressEvent>;
  130245. /**
  130246. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  130247. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  130248. */
  130249. useDefaultLoadingScreen: boolean;
  130250. /**
  130251. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  130252. * when all assets have been downloaded.
  130253. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  130254. */
  130255. autoHideLoadingUI: boolean;
  130256. /**
  130257. * Creates a new AssetsManager
  130258. * @param scene defines the scene to work on
  130259. */
  130260. constructor(scene: Scene);
  130261. /**
  130262. * Add a MeshAssetTask to the list of active tasks
  130263. * @param taskName defines the name of the new task
  130264. * @param meshesNames defines the name of meshes to load
  130265. * @param rootUrl defines the root url to use to locate files
  130266. * @param sceneFilename defines the filename of the scene file
  130267. * @returns a new MeshAssetTask object
  130268. */
  130269. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  130270. /**
  130271. * Add a TextFileAssetTask to the list of active tasks
  130272. * @param taskName defines the name of the new task
  130273. * @param url defines the url of the file to load
  130274. * @returns a new TextFileAssetTask object
  130275. */
  130276. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  130277. /**
  130278. * Add a BinaryFileAssetTask to the list of active tasks
  130279. * @param taskName defines the name of the new task
  130280. * @param url defines the url of the file to load
  130281. * @returns a new BinaryFileAssetTask object
  130282. */
  130283. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  130284. /**
  130285. * Add a ImageAssetTask to the list of active tasks
  130286. * @param taskName defines the name of the new task
  130287. * @param url defines the url of the file to load
  130288. * @returns a new ImageAssetTask object
  130289. */
  130290. addImageTask(taskName: string, url: string): ImageAssetTask;
  130291. /**
  130292. * Add a TextureAssetTask to the list of active tasks
  130293. * @param taskName defines the name of the new task
  130294. * @param url defines the url of the file to load
  130295. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130296. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  130297. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130298. * @returns a new TextureAssetTask object
  130299. */
  130300. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  130301. /**
  130302. * Add a CubeTextureAssetTask to the list of active tasks
  130303. * @param taskName defines the name of the new task
  130304. * @param url defines the url of the file to load
  130305. * @param extensions defines the extension to use to load the cube map (can be null)
  130306. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130307. * @param files defines the list of files to load (can be null)
  130308. * @returns a new CubeTextureAssetTask object
  130309. */
  130310. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  130311. /**
  130312. *
  130313. * Add a HDRCubeTextureAssetTask to the list of active tasks
  130314. * @param taskName defines the name of the new task
  130315. * @param url defines the url of the file to load
  130316. * @param size defines the size you want for the cubemap (can be null)
  130317. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130318. * @param generateHarmonics defines if you want to automatically generate (true by default)
  130319. * @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)
  130320. * @param reserved Internal use only
  130321. * @returns a new HDRCubeTextureAssetTask object
  130322. */
  130323. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  130324. /**
  130325. *
  130326. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  130327. * @param taskName defines the name of the new task
  130328. * @param url defines the url of the file to load
  130329. * @param size defines the size you want for the cubemap (can be null)
  130330. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130331. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130332. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130333. * @returns a new EquiRectangularCubeTextureAssetTask object
  130334. */
  130335. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  130336. /**
  130337. * Remove a task from the assets manager.
  130338. * @param task the task to remove
  130339. */
  130340. removeTask(task: AbstractAssetTask): void;
  130341. private _decreaseWaitingTasksCount;
  130342. private _runTask;
  130343. /**
  130344. * Reset the AssetsManager and remove all tasks
  130345. * @return the current instance of the AssetsManager
  130346. */
  130347. reset(): AssetsManager;
  130348. /**
  130349. * Start the loading process
  130350. * @return the current instance of the AssetsManager
  130351. */
  130352. load(): AssetsManager;
  130353. /**
  130354. * Start the loading process as an async operation
  130355. * @return a promise returning the list of failed tasks
  130356. */
  130357. loadAsync(): Promise<void>;
  130358. }
  130359. }
  130360. declare module BABYLON {
  130361. /**
  130362. * Wrapper class for promise with external resolve and reject.
  130363. */
  130364. export class Deferred<T> {
  130365. /**
  130366. * The promise associated with this deferred object.
  130367. */
  130368. readonly promise: Promise<T>;
  130369. private _resolve;
  130370. private _reject;
  130371. /**
  130372. * The resolve method of the promise associated with this deferred object.
  130373. */
  130374. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  130375. /**
  130376. * The reject method of the promise associated with this deferred object.
  130377. */
  130378. readonly reject: (reason?: any) => void;
  130379. /**
  130380. * Constructor for this deferred object.
  130381. */
  130382. constructor();
  130383. }
  130384. }
  130385. declare module BABYLON {
  130386. /**
  130387. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  130388. */
  130389. export class MeshExploder {
  130390. private _centerMesh;
  130391. private _meshes;
  130392. private _meshesOrigins;
  130393. private _toCenterVectors;
  130394. private _scaledDirection;
  130395. private _newPosition;
  130396. private _centerPosition;
  130397. /**
  130398. * Explodes meshes from a center mesh.
  130399. * @param meshes The meshes to explode.
  130400. * @param centerMesh The mesh to be center of explosion.
  130401. */
  130402. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  130403. private _setCenterMesh;
  130404. /**
  130405. * Get class name
  130406. * @returns "MeshExploder"
  130407. */
  130408. getClassName(): string;
  130409. /**
  130410. * "Exploded meshes"
  130411. * @returns Array of meshes with the centerMesh at index 0.
  130412. */
  130413. getMeshes(): Array<Mesh>;
  130414. /**
  130415. * Explodes meshes giving a specific direction
  130416. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  130417. */
  130418. explode(direction?: number): void;
  130419. }
  130420. }
  130421. declare module BABYLON {
  130422. /**
  130423. * Class used to help managing file picking and drag'n'drop
  130424. */
  130425. export class FilesInput {
  130426. /**
  130427. * List of files ready to be loaded
  130428. */
  130429. static readonly FilesToLoad: {
  130430. [key: string]: File;
  130431. };
  130432. /**
  130433. * Callback called when a file is processed
  130434. */
  130435. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  130436. private _engine;
  130437. private _currentScene;
  130438. private _sceneLoadedCallback;
  130439. private _progressCallback;
  130440. private _additionalRenderLoopLogicCallback;
  130441. private _textureLoadingCallback;
  130442. private _startingProcessingFilesCallback;
  130443. private _onReloadCallback;
  130444. private _errorCallback;
  130445. private _elementToMonitor;
  130446. private _sceneFileToLoad;
  130447. private _filesToLoad;
  130448. /**
  130449. * Creates a new FilesInput
  130450. * @param engine defines the rendering engine
  130451. * @param scene defines the hosting scene
  130452. * @param sceneLoadedCallback callback called when scene is loaded
  130453. * @param progressCallback callback called to track progress
  130454. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  130455. * @param textureLoadingCallback callback called when a texture is loading
  130456. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  130457. * @param onReloadCallback callback called when a reload is requested
  130458. * @param errorCallback callback call if an error occurs
  130459. */
  130460. 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);
  130461. private _dragEnterHandler;
  130462. private _dragOverHandler;
  130463. private _dropHandler;
  130464. /**
  130465. * Calls this function to listen to drag'n'drop events on a specific DOM element
  130466. * @param elementToMonitor defines the DOM element to track
  130467. */
  130468. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  130469. /**
  130470. * Release all associated resources
  130471. */
  130472. dispose(): void;
  130473. private renderFunction;
  130474. private drag;
  130475. private drop;
  130476. private _traverseFolder;
  130477. private _processFiles;
  130478. /**
  130479. * Load files from a drop event
  130480. * @param event defines the drop event to use as source
  130481. */
  130482. loadFiles(event: any): void;
  130483. private _processReload;
  130484. /**
  130485. * Reload the current scene from the loaded files
  130486. */
  130487. reload(): void;
  130488. }
  130489. }
  130490. declare module BABYLON {
  130491. /**
  130492. * Defines the root class used to create scene optimization to use with SceneOptimizer
  130493. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130494. */
  130495. export class SceneOptimization {
  130496. /**
  130497. * Defines the priority of this optimization (0 by default which means first in the list)
  130498. */
  130499. priority: number;
  130500. /**
  130501. * Gets a string describing the action executed by the current optimization
  130502. * @returns description string
  130503. */
  130504. getDescription(): string;
  130505. /**
  130506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130507. * @param scene defines the current scene where to apply this optimization
  130508. * @param optimizer defines the current optimizer
  130509. * @returns true if everything that can be done was applied
  130510. */
  130511. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130512. /**
  130513. * Creates the SceneOptimization object
  130514. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130515. * @param desc defines the description associated with the optimization
  130516. */
  130517. constructor(
  130518. /**
  130519. * Defines the priority of this optimization (0 by default which means first in the list)
  130520. */
  130521. priority?: number);
  130522. }
  130523. /**
  130524. * Defines an optimization used to reduce the size of render target textures
  130525. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130526. */
  130527. export class TextureOptimization extends SceneOptimization {
  130528. /**
  130529. * Defines the priority of this optimization (0 by default which means first in the list)
  130530. */
  130531. priority: number;
  130532. /**
  130533. * 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
  130534. */
  130535. maximumSize: number;
  130536. /**
  130537. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130538. */
  130539. step: number;
  130540. /**
  130541. * Gets a string describing the action executed by the current optimization
  130542. * @returns description string
  130543. */
  130544. getDescription(): string;
  130545. /**
  130546. * Creates the TextureOptimization object
  130547. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130548. * @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
  130549. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130550. */
  130551. constructor(
  130552. /**
  130553. * Defines the priority of this optimization (0 by default which means first in the list)
  130554. */
  130555. priority?: number,
  130556. /**
  130557. * 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
  130558. */
  130559. maximumSize?: number,
  130560. /**
  130561. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130562. */
  130563. step?: number);
  130564. /**
  130565. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130566. * @param scene defines the current scene where to apply this optimization
  130567. * @param optimizer defines the current optimizer
  130568. * @returns true if everything that can be done was applied
  130569. */
  130570. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130571. }
  130572. /**
  130573. * Defines an optimization used to increase or decrease the rendering resolution
  130574. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130575. */
  130576. export class HardwareScalingOptimization extends SceneOptimization {
  130577. /**
  130578. * Defines the priority of this optimization (0 by default which means first in the list)
  130579. */
  130580. priority: number;
  130581. /**
  130582. * Defines the maximum scale to use (2 by default)
  130583. */
  130584. maximumScale: number;
  130585. /**
  130586. * Defines the step to use between two passes (0.5 by default)
  130587. */
  130588. step: number;
  130589. private _currentScale;
  130590. private _directionOffset;
  130591. /**
  130592. * Gets a string describing the action executed by the current optimization
  130593. * @return description string
  130594. */
  130595. getDescription(): string;
  130596. /**
  130597. * Creates the HardwareScalingOptimization object
  130598. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130599. * @param maximumScale defines the maximum scale to use (2 by default)
  130600. * @param step defines the step to use between two passes (0.5 by default)
  130601. */
  130602. constructor(
  130603. /**
  130604. * Defines the priority of this optimization (0 by default which means first in the list)
  130605. */
  130606. priority?: number,
  130607. /**
  130608. * Defines the maximum scale to use (2 by default)
  130609. */
  130610. maximumScale?: number,
  130611. /**
  130612. * Defines the step to use between two passes (0.5 by default)
  130613. */
  130614. step?: number);
  130615. /**
  130616. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130617. * @param scene defines the current scene where to apply this optimization
  130618. * @param optimizer defines the current optimizer
  130619. * @returns true if everything that can be done was applied
  130620. */
  130621. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130622. }
  130623. /**
  130624. * Defines an optimization used to remove shadows
  130625. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130626. */
  130627. export class ShadowsOptimization extends SceneOptimization {
  130628. /**
  130629. * Gets a string describing the action executed by the current optimization
  130630. * @return description string
  130631. */
  130632. getDescription(): string;
  130633. /**
  130634. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130635. * @param scene defines the current scene where to apply this optimization
  130636. * @param optimizer defines the current optimizer
  130637. * @returns true if everything that can be done was applied
  130638. */
  130639. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130640. }
  130641. /**
  130642. * Defines an optimization used to turn post-processes off
  130643. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130644. */
  130645. export class PostProcessesOptimization extends SceneOptimization {
  130646. /**
  130647. * Gets a string describing the action executed by the current optimization
  130648. * @return description string
  130649. */
  130650. getDescription(): string;
  130651. /**
  130652. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130653. * @param scene defines the current scene where to apply this optimization
  130654. * @param optimizer defines the current optimizer
  130655. * @returns true if everything that can be done was applied
  130656. */
  130657. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130658. }
  130659. /**
  130660. * Defines an optimization used to turn lens flares off
  130661. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130662. */
  130663. export class LensFlaresOptimization extends SceneOptimization {
  130664. /**
  130665. * Gets a string describing the action executed by the current optimization
  130666. * @return description string
  130667. */
  130668. getDescription(): string;
  130669. /**
  130670. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130671. * @param scene defines the current scene where to apply this optimization
  130672. * @param optimizer defines the current optimizer
  130673. * @returns true if everything that can be done was applied
  130674. */
  130675. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130676. }
  130677. /**
  130678. * Defines an optimization based on user defined callback.
  130679. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130680. */
  130681. export class CustomOptimization extends SceneOptimization {
  130682. /**
  130683. * Callback called to apply the custom optimization.
  130684. */
  130685. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  130686. /**
  130687. * Callback called to get custom description
  130688. */
  130689. onGetDescription: () => string;
  130690. /**
  130691. * Gets a string describing the action executed by the current optimization
  130692. * @returns description string
  130693. */
  130694. getDescription(): string;
  130695. /**
  130696. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130697. * @param scene defines the current scene where to apply this optimization
  130698. * @param optimizer defines the current optimizer
  130699. * @returns true if everything that can be done was applied
  130700. */
  130701. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130702. }
  130703. /**
  130704. * Defines an optimization used to turn particles off
  130705. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130706. */
  130707. export class ParticlesOptimization extends SceneOptimization {
  130708. /**
  130709. * Gets a string describing the action executed by the current optimization
  130710. * @return description string
  130711. */
  130712. getDescription(): string;
  130713. /**
  130714. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130715. * @param scene defines the current scene where to apply this optimization
  130716. * @param optimizer defines the current optimizer
  130717. * @returns true if everything that can be done was applied
  130718. */
  130719. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130720. }
  130721. /**
  130722. * Defines an optimization used to turn render targets off
  130723. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130724. */
  130725. export class RenderTargetsOptimization extends SceneOptimization {
  130726. /**
  130727. * Gets a string describing the action executed by the current optimization
  130728. * @return description string
  130729. */
  130730. getDescription(): string;
  130731. /**
  130732. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130733. * @param scene defines the current scene where to apply this optimization
  130734. * @param optimizer defines the current optimizer
  130735. * @returns true if everything that can be done was applied
  130736. */
  130737. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130738. }
  130739. /**
  130740. * Defines an optimization used to merge meshes with compatible materials
  130741. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130742. */
  130743. export class MergeMeshesOptimization extends SceneOptimization {
  130744. private static _UpdateSelectionTree;
  130745. /**
  130746. * Gets or sets a boolean which defines if optimization octree has to be updated
  130747. */
  130748. /**
  130749. * Gets or sets a boolean which defines if optimization octree has to be updated
  130750. */
  130751. static UpdateSelectionTree: boolean;
  130752. /**
  130753. * Gets a string describing the action executed by the current optimization
  130754. * @return description string
  130755. */
  130756. getDescription(): string;
  130757. private _canBeMerged;
  130758. /**
  130759. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130760. * @param scene defines the current scene where to apply this optimization
  130761. * @param optimizer defines the current optimizer
  130762. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  130763. * @returns true if everything that can be done was applied
  130764. */
  130765. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  130766. }
  130767. /**
  130768. * Defines a list of options used by SceneOptimizer
  130769. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130770. */
  130771. export class SceneOptimizerOptions {
  130772. /**
  130773. * Defines the target frame rate to reach (60 by default)
  130774. */
  130775. targetFrameRate: number;
  130776. /**
  130777. * Defines the interval between two checkes (2000ms by default)
  130778. */
  130779. trackerDuration: number;
  130780. /**
  130781. * Gets the list of optimizations to apply
  130782. */
  130783. optimizations: SceneOptimization[];
  130784. /**
  130785. * Creates a new list of options used by SceneOptimizer
  130786. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  130787. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  130788. */
  130789. constructor(
  130790. /**
  130791. * Defines the target frame rate to reach (60 by default)
  130792. */
  130793. targetFrameRate?: number,
  130794. /**
  130795. * Defines the interval between two checkes (2000ms by default)
  130796. */
  130797. trackerDuration?: number);
  130798. /**
  130799. * Add a new optimization
  130800. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  130801. * @returns the current SceneOptimizerOptions
  130802. */
  130803. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  130804. /**
  130805. * Add a new custom optimization
  130806. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  130807. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  130808. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130809. * @returns the current SceneOptimizerOptions
  130810. */
  130811. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  130812. /**
  130813. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  130814. * @param targetFrameRate defines the target frame rate (60 by default)
  130815. * @returns a SceneOptimizerOptions object
  130816. */
  130817. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130818. /**
  130819. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  130820. * @param targetFrameRate defines the target frame rate (60 by default)
  130821. * @returns a SceneOptimizerOptions object
  130822. */
  130823. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130824. /**
  130825. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  130826. * @param targetFrameRate defines the target frame rate (60 by default)
  130827. * @returns a SceneOptimizerOptions object
  130828. */
  130829. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130830. }
  130831. /**
  130832. * Class used to run optimizations in order to reach a target frame rate
  130833. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130834. */
  130835. export class SceneOptimizer implements IDisposable {
  130836. private _isRunning;
  130837. private _options;
  130838. private _scene;
  130839. private _currentPriorityLevel;
  130840. private _targetFrameRate;
  130841. private _trackerDuration;
  130842. private _currentFrameRate;
  130843. private _sceneDisposeObserver;
  130844. private _improvementMode;
  130845. /**
  130846. * Defines an observable called when the optimizer reaches the target frame rate
  130847. */
  130848. onSuccessObservable: Observable<SceneOptimizer>;
  130849. /**
  130850. * Defines an observable called when the optimizer enables an optimization
  130851. */
  130852. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  130853. /**
  130854. * Defines an observable called when the optimizer is not able to reach the target frame rate
  130855. */
  130856. onFailureObservable: Observable<SceneOptimizer>;
  130857. /**
  130858. * Gets a boolean indicating if the optimizer is in improvement mode
  130859. */
  130860. readonly isInImprovementMode: boolean;
  130861. /**
  130862. * Gets the current priority level (0 at start)
  130863. */
  130864. readonly currentPriorityLevel: number;
  130865. /**
  130866. * Gets the current frame rate checked by the SceneOptimizer
  130867. */
  130868. readonly currentFrameRate: number;
  130869. /**
  130870. * Gets or sets the current target frame rate (60 by default)
  130871. */
  130872. /**
  130873. * Gets or sets the current target frame rate (60 by default)
  130874. */
  130875. targetFrameRate: number;
  130876. /**
  130877. * Gets or sets the current interval between two checks (every 2000ms by default)
  130878. */
  130879. /**
  130880. * Gets or sets the current interval between two checks (every 2000ms by default)
  130881. */
  130882. trackerDuration: number;
  130883. /**
  130884. * Gets the list of active optimizations
  130885. */
  130886. readonly optimizations: SceneOptimization[];
  130887. /**
  130888. * Creates a new SceneOptimizer
  130889. * @param scene defines the scene to work on
  130890. * @param options defines the options to use with the SceneOptimizer
  130891. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  130892. * @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)
  130893. */
  130894. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  130895. /**
  130896. * Stops the current optimizer
  130897. */
  130898. stop(): void;
  130899. /**
  130900. * Reset the optimizer to initial step (current priority level = 0)
  130901. */
  130902. reset(): void;
  130903. /**
  130904. * Start the optimizer. By default it will try to reach a specific framerate
  130905. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  130906. */
  130907. start(): void;
  130908. private _checkCurrentState;
  130909. /**
  130910. * Release all resources
  130911. */
  130912. dispose(): void;
  130913. /**
  130914. * Helper function to create a SceneOptimizer with one single line of code
  130915. * @param scene defines the scene to work on
  130916. * @param options defines the options to use with the SceneOptimizer
  130917. * @param onSuccess defines a callback to call on success
  130918. * @param onFailure defines a callback to call on failure
  130919. * @returns the new SceneOptimizer object
  130920. */
  130921. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  130922. }
  130923. }
  130924. declare module BABYLON {
  130925. /**
  130926. * Class used to serialize a scene into a string
  130927. */
  130928. export class SceneSerializer {
  130929. /**
  130930. * Clear cache used by a previous serialization
  130931. */
  130932. static ClearCache(): void;
  130933. /**
  130934. * Serialize a scene into a JSON compatible object
  130935. * @param scene defines the scene to serialize
  130936. * @returns a JSON compatible object
  130937. */
  130938. static Serialize(scene: Scene): any;
  130939. /**
  130940. * Serialize a mesh into a JSON compatible object
  130941. * @param toSerialize defines the mesh to serialize
  130942. * @param withParents defines if parents must be serialized as well
  130943. * @param withChildren defines if children must be serialized as well
  130944. * @returns a JSON compatible object
  130945. */
  130946. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  130947. }
  130948. }
  130949. declare module BABYLON {
  130950. /**
  130951. * Class used to host texture specific utilities
  130952. */
  130953. export class TextureTools {
  130954. /**
  130955. * Uses the GPU to create a copy texture rescaled at a given size
  130956. * @param texture Texture to copy from
  130957. * @param width defines the desired width
  130958. * @param height defines the desired height
  130959. * @param useBilinearMode defines if bilinear mode has to be used
  130960. * @return the generated texture
  130961. */
  130962. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  130963. }
  130964. }
  130965. declare module BABYLON {
  130966. /**
  130967. * This represents the different options available for the video capture.
  130968. */
  130969. export interface VideoRecorderOptions {
  130970. /** Defines the mime type of the video. */
  130971. mimeType: string;
  130972. /** Defines the FPS the video should be recorded at. */
  130973. fps: number;
  130974. /** Defines the chunk size for the recording data. */
  130975. recordChunckSize: number;
  130976. /** The audio tracks to attach to the recording. */
  130977. audioTracks?: MediaStreamTrack[];
  130978. }
  130979. /**
  130980. * This can help with recording videos from BabylonJS.
  130981. * This is based on the available WebRTC functionalities of the browser.
  130982. *
  130983. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  130984. */
  130985. export class VideoRecorder {
  130986. private static readonly _defaultOptions;
  130987. /**
  130988. * Returns whether or not the VideoRecorder is available in your browser.
  130989. * @param engine Defines the Babylon Engine.
  130990. * @returns true if supported otherwise false.
  130991. */
  130992. static IsSupported(engine: Engine): boolean;
  130993. private readonly _options;
  130994. private _canvas;
  130995. private _mediaRecorder;
  130996. private _recordedChunks;
  130997. private _fileName;
  130998. private _resolve;
  130999. private _reject;
  131000. /**
  131001. * True when a recording is already in progress.
  131002. */
  131003. readonly isRecording: boolean;
  131004. /**
  131005. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  131006. * @param engine Defines the BabylonJS Engine you wish to record.
  131007. * @param options Defines options that can be used to customize the capture.
  131008. */
  131009. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  131010. /**
  131011. * Stops the current recording before the default capture timeout passed in the startRecording function.
  131012. */
  131013. stopRecording(): void;
  131014. /**
  131015. * Starts recording the canvas for a max duration specified in parameters.
  131016. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  131017. * If null no automatic download will start and you can rely on the promise to get the data back.
  131018. * @param maxDuration Defines the maximum recording time in seconds.
  131019. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  131020. * @return A promise callback at the end of the recording with the video data in Blob.
  131021. */
  131022. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  131023. /**
  131024. * Releases internal resources used during the recording.
  131025. */
  131026. dispose(): void;
  131027. private _handleDataAvailable;
  131028. private _handleError;
  131029. private _handleStop;
  131030. }
  131031. }
  131032. declare module BABYLON {
  131033. /**
  131034. * Class containing a set of static utilities functions for screenshots
  131035. */
  131036. export class ScreenshotTools {
  131037. /**
  131038. * Captures a screenshot of the current rendering
  131039. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131040. * @param engine defines the rendering engine
  131041. * @param camera defines the source camera
  131042. * @param size This parameter can be set to a single number or to an object with the
  131043. * following (optional) properties: precision, width, height. If a single number is passed,
  131044. * it will be used for both width and height. If an object is passed, the screenshot size
  131045. * will be derived from the parameters. The precision property is a multiplier allowing
  131046. * rendering at a higher or lower resolution
  131047. * @param successCallback defines the callback receives a single parameter which contains the
  131048. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131049. * src parameter of an <img> to display it
  131050. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131051. * Check your browser for supported MIME types
  131052. */
  131053. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  131054. /**
  131055. * Captures a screenshot of the current rendering
  131056. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131057. * @param engine defines the rendering engine
  131058. * @param camera defines the source camera
  131059. * @param size This parameter can be set to a single number or to an object with the
  131060. * following (optional) properties: precision, width, height. If a single number is passed,
  131061. * it will be used for both width and height. If an object is passed, the screenshot size
  131062. * will be derived from the parameters. The precision property is a multiplier allowing
  131063. * rendering at a higher or lower resolution
  131064. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131065. * Check your browser for supported MIME types
  131066. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131067. * to the src parameter of an <img> to display it
  131068. */
  131069. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  131070. /**
  131071. * Generates an image screenshot from the specified camera.
  131072. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131073. * @param engine The engine to use for rendering
  131074. * @param camera The camera to use for rendering
  131075. * @param size This parameter can be set to a single number or to an object with the
  131076. * following (optional) properties: precision, width, height. If a single number is passed,
  131077. * it will be used for both width and height. If an object is passed, the screenshot size
  131078. * will be derived from the parameters. The precision property is a multiplier allowing
  131079. * rendering at a higher or lower resolution
  131080. * @param successCallback The callback receives a single parameter which contains the
  131081. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131082. * src parameter of an <img> to display it
  131083. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131084. * Check your browser for supported MIME types
  131085. * @param samples Texture samples (default: 1)
  131086. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131087. * @param fileName A name for for the downloaded file.
  131088. */
  131089. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  131090. /**
  131091. * Generates an image screenshot from the specified camera.
  131092. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131093. * @param engine The engine to use for rendering
  131094. * @param camera The camera to use for rendering
  131095. * @param size This parameter can be set to a single number or to an object with the
  131096. * following (optional) properties: precision, width, height. If a single number is passed,
  131097. * it will be used for both width and height. If an object is passed, the screenshot size
  131098. * will be derived from the parameters. The precision property is a multiplier allowing
  131099. * rendering at a higher or lower resolution
  131100. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131101. * Check your browser for supported MIME types
  131102. * @param samples Texture samples (default: 1)
  131103. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131104. * @param fileName A name for for the downloaded file.
  131105. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131106. * to the src parameter of an <img> to display it
  131107. */
  131108. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  131109. /**
  131110. * Gets height and width for screenshot size
  131111. * @private
  131112. */
  131113. private static _getScreenshotSize;
  131114. }
  131115. }
  131116. declare module BABYLON {
  131117. /**
  131118. * A cursor which tracks a point on a path
  131119. */
  131120. export class PathCursor {
  131121. private path;
  131122. /**
  131123. * Stores path cursor callbacks for when an onchange event is triggered
  131124. */
  131125. private _onchange;
  131126. /**
  131127. * The value of the path cursor
  131128. */
  131129. value: number;
  131130. /**
  131131. * The animation array of the path cursor
  131132. */
  131133. animations: Animation[];
  131134. /**
  131135. * Initializes the path cursor
  131136. * @param path The path to track
  131137. */
  131138. constructor(path: Path2);
  131139. /**
  131140. * Gets the cursor point on the path
  131141. * @returns A point on the path cursor at the cursor location
  131142. */
  131143. getPoint(): Vector3;
  131144. /**
  131145. * Moves the cursor ahead by the step amount
  131146. * @param step The amount to move the cursor forward
  131147. * @returns This path cursor
  131148. */
  131149. moveAhead(step?: number): PathCursor;
  131150. /**
  131151. * Moves the cursor behind by the step amount
  131152. * @param step The amount to move the cursor back
  131153. * @returns This path cursor
  131154. */
  131155. moveBack(step?: number): PathCursor;
  131156. /**
  131157. * Moves the cursor by the step amount
  131158. * If the step amount is greater than one, an exception is thrown
  131159. * @param step The amount to move the cursor
  131160. * @returns This path cursor
  131161. */
  131162. move(step: number): PathCursor;
  131163. /**
  131164. * Ensures that the value is limited between zero and one
  131165. * @returns This path cursor
  131166. */
  131167. private ensureLimits;
  131168. /**
  131169. * Runs onchange callbacks on change (used by the animation engine)
  131170. * @returns This path cursor
  131171. */
  131172. private raiseOnChange;
  131173. /**
  131174. * Executes a function on change
  131175. * @param f A path cursor onchange callback
  131176. * @returns This path cursor
  131177. */
  131178. onchange(f: (cursor: PathCursor) => void): PathCursor;
  131179. }
  131180. }
  131181. declare module BABYLON {
  131182. /** @hidden */
  131183. export var blurPixelShader: {
  131184. name: string;
  131185. shader: string;
  131186. };
  131187. }
  131188. declare module BABYLON {
  131189. /** @hidden */
  131190. export var pointCloudVertexDeclaration: {
  131191. name: string;
  131192. shader: string;
  131193. };
  131194. }
  131195. // Mixins
  131196. interface Window {
  131197. mozIndexedDB: IDBFactory;
  131198. webkitIndexedDB: IDBFactory;
  131199. msIndexedDB: IDBFactory;
  131200. webkitURL: typeof URL;
  131201. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  131202. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  131203. WebGLRenderingContext: WebGLRenderingContext;
  131204. MSGesture: MSGesture;
  131205. CANNON: any;
  131206. AudioContext: AudioContext;
  131207. webkitAudioContext: AudioContext;
  131208. PointerEvent: any;
  131209. Math: Math;
  131210. Uint8Array: Uint8ArrayConstructor;
  131211. Float32Array: Float32ArrayConstructor;
  131212. mozURL: typeof URL;
  131213. msURL: typeof URL;
  131214. VRFrameData: any; // WebVR, from specs 1.1
  131215. DracoDecoderModule: any;
  131216. setImmediate(handler: (...args: any[]) => void): number;
  131217. }
  131218. interface HTMLCanvasElement {
  131219. requestPointerLock(): void;
  131220. msRequestPointerLock?(): void;
  131221. mozRequestPointerLock?(): void;
  131222. webkitRequestPointerLock?(): void;
  131223. /** Track wether a record is in progress */
  131224. isRecording: boolean;
  131225. /** Capture Stream method defined by some browsers */
  131226. captureStream(fps?: number): MediaStream;
  131227. }
  131228. interface CanvasRenderingContext2D {
  131229. msImageSmoothingEnabled: boolean;
  131230. }
  131231. interface MouseEvent {
  131232. mozMovementX: number;
  131233. mozMovementY: number;
  131234. webkitMovementX: number;
  131235. webkitMovementY: number;
  131236. msMovementX: number;
  131237. msMovementY: number;
  131238. }
  131239. interface Navigator {
  131240. mozGetVRDevices: (any: any) => any;
  131241. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131242. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131243. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131244. webkitGetGamepads(): Gamepad[];
  131245. msGetGamepads(): Gamepad[];
  131246. webkitGamepads(): Gamepad[];
  131247. }
  131248. interface HTMLVideoElement {
  131249. mozSrcObject: any;
  131250. }
  131251. interface Math {
  131252. fround(x: number): number;
  131253. imul(a: number, b: number): number;
  131254. }
  131255. interface WebGLRenderingContext {
  131256. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  131257. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  131258. vertexAttribDivisor(index: number, divisor: number): void;
  131259. createVertexArray(): any;
  131260. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  131261. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  131262. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  131263. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  131264. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  131265. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  131266. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  131267. // Queries
  131268. createQuery(): WebGLQuery;
  131269. deleteQuery(query: WebGLQuery): void;
  131270. beginQuery(target: number, query: WebGLQuery): void;
  131271. endQuery(target: number): void;
  131272. getQueryParameter(query: WebGLQuery, pname: number): any;
  131273. getQuery(target: number, pname: number): any;
  131274. MAX_SAMPLES: number;
  131275. RGBA8: number;
  131276. READ_FRAMEBUFFER: number;
  131277. DRAW_FRAMEBUFFER: number;
  131278. UNIFORM_BUFFER: number;
  131279. HALF_FLOAT_OES: number;
  131280. RGBA16F: number;
  131281. RGBA32F: number;
  131282. R32F: number;
  131283. RG32F: number;
  131284. RGB32F: number;
  131285. R16F: number;
  131286. RG16F: number;
  131287. RGB16F: number;
  131288. RED: number;
  131289. RG: number;
  131290. R8: number;
  131291. RG8: number;
  131292. UNSIGNED_INT_24_8: number;
  131293. DEPTH24_STENCIL8: number;
  131294. MIN: number;
  131295. MAX: number;
  131296. /* Multiple Render Targets */
  131297. drawBuffers(buffers: number[]): void;
  131298. readBuffer(src: number): void;
  131299. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  131300. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  131301. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  131302. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  131303. // Occlusion Query
  131304. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  131305. ANY_SAMPLES_PASSED: number;
  131306. QUERY_RESULT_AVAILABLE: number;
  131307. QUERY_RESULT: number;
  131308. }
  131309. interface WebGLProgram {
  131310. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  131311. }
  131312. interface EXT_disjoint_timer_query {
  131313. QUERY_COUNTER_BITS_EXT: number;
  131314. TIME_ELAPSED_EXT: number;
  131315. TIMESTAMP_EXT: number;
  131316. GPU_DISJOINT_EXT: number;
  131317. QUERY_RESULT_EXT: number;
  131318. QUERY_RESULT_AVAILABLE_EXT: number;
  131319. queryCounterEXT(query: WebGLQuery, target: number): void;
  131320. createQueryEXT(): WebGLQuery;
  131321. beginQueryEXT(target: number, query: WebGLQuery): void;
  131322. endQueryEXT(target: number): void;
  131323. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  131324. deleteQueryEXT(query: WebGLQuery): void;
  131325. }
  131326. interface WebGLUniformLocation {
  131327. _currentState: any;
  131328. }
  131329. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  131330. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  131331. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  131332. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131333. interface WebGLRenderingContext {
  131334. readonly RASTERIZER_DISCARD: number;
  131335. readonly DEPTH_COMPONENT24: number;
  131336. readonly TEXTURE_3D: number;
  131337. readonly TEXTURE_2D_ARRAY: number;
  131338. readonly TEXTURE_COMPARE_FUNC: number;
  131339. readonly TEXTURE_COMPARE_MODE: number;
  131340. readonly COMPARE_REF_TO_TEXTURE: number;
  131341. readonly TEXTURE_WRAP_R: number;
  131342. readonly HALF_FLOAT: number;
  131343. readonly RGB8: number;
  131344. readonly RED_INTEGER: number;
  131345. readonly RG_INTEGER: number;
  131346. readonly RGB_INTEGER: number;
  131347. readonly RGBA_INTEGER: number;
  131348. readonly R8_SNORM: number;
  131349. readonly RG8_SNORM: number;
  131350. readonly RGB8_SNORM: number;
  131351. readonly RGBA8_SNORM: number;
  131352. readonly R8I: number;
  131353. readonly RG8I: number;
  131354. readonly RGB8I: number;
  131355. readonly RGBA8I: number;
  131356. readonly R8UI: number;
  131357. readonly RG8UI: number;
  131358. readonly RGB8UI: number;
  131359. readonly RGBA8UI: number;
  131360. readonly R16I: number;
  131361. readonly RG16I: number;
  131362. readonly RGB16I: number;
  131363. readonly RGBA16I: number;
  131364. readonly R16UI: number;
  131365. readonly RG16UI: number;
  131366. readonly RGB16UI: number;
  131367. readonly RGBA16UI: number;
  131368. readonly R32I: number;
  131369. readonly RG32I: number;
  131370. readonly RGB32I: number;
  131371. readonly RGBA32I: number;
  131372. readonly R32UI: number;
  131373. readonly RG32UI: number;
  131374. readonly RGB32UI: number;
  131375. readonly RGBA32UI: number;
  131376. readonly RGB10_A2UI: number;
  131377. readonly R11F_G11F_B10F: number;
  131378. readonly RGB9_E5: number;
  131379. readonly RGB10_A2: number;
  131380. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  131381. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  131382. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  131383. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  131384. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  131385. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  131386. 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;
  131387. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  131388. readonly TRANSFORM_FEEDBACK: number;
  131389. readonly INTERLEAVED_ATTRIBS: number;
  131390. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  131391. createTransformFeedback(): WebGLTransformFeedback;
  131392. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  131393. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  131394. beginTransformFeedback(primitiveMode: number): void;
  131395. endTransformFeedback(): void;
  131396. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  131397. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131398. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131399. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131400. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  131401. }
  131402. interface ImageBitmap {
  131403. readonly width: number;
  131404. readonly height: number;
  131405. close(): void;
  131406. }
  131407. interface WebGLQuery extends WebGLObject {
  131408. }
  131409. declare var WebGLQuery: {
  131410. prototype: WebGLQuery;
  131411. new(): WebGLQuery;
  131412. };
  131413. interface WebGLSampler extends WebGLObject {
  131414. }
  131415. declare var WebGLSampler: {
  131416. prototype: WebGLSampler;
  131417. new(): WebGLSampler;
  131418. };
  131419. interface WebGLSync extends WebGLObject {
  131420. }
  131421. declare var WebGLSync: {
  131422. prototype: WebGLSync;
  131423. new(): WebGLSync;
  131424. };
  131425. interface WebGLTransformFeedback extends WebGLObject {
  131426. }
  131427. declare var WebGLTransformFeedback: {
  131428. prototype: WebGLTransformFeedback;
  131429. new(): WebGLTransformFeedback;
  131430. };
  131431. interface WebGLVertexArrayObject extends WebGLObject {
  131432. }
  131433. declare var WebGLVertexArrayObject: {
  131434. prototype: WebGLVertexArrayObject;
  131435. new(): WebGLVertexArrayObject;
  131436. };
  131437. // Type definitions for WebVR API
  131438. // Project: https://w3c.github.io/webvr/
  131439. // Definitions by: six a <https://github.com/lostfictions>
  131440. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131441. interface VRDisplay extends EventTarget {
  131442. /**
  131443. * Dictionary of capabilities describing the VRDisplay.
  131444. */
  131445. readonly capabilities: VRDisplayCapabilities;
  131446. /**
  131447. * z-depth defining the far plane of the eye view frustum
  131448. * enables mapping of values in the render target depth
  131449. * attachment to scene coordinates. Initially set to 10000.0.
  131450. */
  131451. depthFar: number;
  131452. /**
  131453. * z-depth defining the near plane of the eye view frustum
  131454. * enables mapping of values in the render target depth
  131455. * attachment to scene coordinates. Initially set to 0.01.
  131456. */
  131457. depthNear: number;
  131458. /**
  131459. * An identifier for this distinct VRDisplay. Used as an
  131460. * association point in the Gamepad API.
  131461. */
  131462. readonly displayId: number;
  131463. /**
  131464. * A display name, a user-readable name identifying it.
  131465. */
  131466. readonly displayName: string;
  131467. readonly isConnected: boolean;
  131468. readonly isPresenting: boolean;
  131469. /**
  131470. * If this VRDisplay supports room-scale experiences, the optional
  131471. * stage attribute contains details on the room-scale parameters.
  131472. */
  131473. readonly stageParameters: VRStageParameters | null;
  131474. /**
  131475. * Passing the value returned by `requestAnimationFrame` to
  131476. * `cancelAnimationFrame` will unregister the callback.
  131477. * @param handle Define the hanle of the request to cancel
  131478. */
  131479. cancelAnimationFrame(handle: number): void;
  131480. /**
  131481. * Stops presenting to the VRDisplay.
  131482. * @returns a promise to know when it stopped
  131483. */
  131484. exitPresent(): Promise<void>;
  131485. /**
  131486. * Return the current VREyeParameters for the given eye.
  131487. * @param whichEye Define the eye we want the parameter for
  131488. * @returns the eye parameters
  131489. */
  131490. getEyeParameters(whichEye: string): VREyeParameters;
  131491. /**
  131492. * Populates the passed VRFrameData with the information required to render
  131493. * the current frame.
  131494. * @param frameData Define the data structure to populate
  131495. * @returns true if ok otherwise false
  131496. */
  131497. getFrameData(frameData: VRFrameData): boolean;
  131498. /**
  131499. * Get the layers currently being presented.
  131500. * @returns the list of VR layers
  131501. */
  131502. getLayers(): VRLayer[];
  131503. /**
  131504. * Return a VRPose containing the future predicted pose of the VRDisplay
  131505. * when the current frame will be presented. The value returned will not
  131506. * change until JavaScript has returned control to the browser.
  131507. *
  131508. * The VRPose will contain the position, orientation, velocity,
  131509. * and acceleration of each of these properties.
  131510. * @returns the pose object
  131511. */
  131512. getPose(): VRPose;
  131513. /**
  131514. * Return the current instantaneous pose of the VRDisplay, with no
  131515. * prediction applied.
  131516. * @returns the current instantaneous pose
  131517. */
  131518. getImmediatePose(): VRPose;
  131519. /**
  131520. * The callback passed to `requestAnimationFrame` will be called
  131521. * any time a new frame should be rendered. When the VRDisplay is
  131522. * presenting the callback will be called at the native refresh
  131523. * rate of the HMD. When not presenting this function acts
  131524. * identically to how window.requestAnimationFrame acts. Content should
  131525. * make no assumptions of frame rate or vsync behavior as the HMD runs
  131526. * asynchronously from other displays and at differing refresh rates.
  131527. * @param callback Define the eaction to run next frame
  131528. * @returns the request handle it
  131529. */
  131530. requestAnimationFrame(callback: FrameRequestCallback): number;
  131531. /**
  131532. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  131533. * Repeat calls while already presenting will update the VRLayers being displayed.
  131534. * @param layers Define the list of layer to present
  131535. * @returns a promise to know when the request has been fulfilled
  131536. */
  131537. requestPresent(layers: VRLayer[]): Promise<void>;
  131538. /**
  131539. * Reset the pose for this display, treating its current position and
  131540. * orientation as the "origin/zero" values. VRPose.position,
  131541. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  131542. * updated when calling resetPose(). This should be called in only
  131543. * sitting-space experiences.
  131544. */
  131545. resetPose(): void;
  131546. /**
  131547. * The VRLayer provided to the VRDisplay will be captured and presented
  131548. * in the HMD. Calling this function has the same effect on the source
  131549. * canvas as any other operation that uses its source image, and canvases
  131550. * created without preserveDrawingBuffer set to true will be cleared.
  131551. * @param pose Define the pose to submit
  131552. */
  131553. submitFrame(pose?: VRPose): void;
  131554. }
  131555. declare var VRDisplay: {
  131556. prototype: VRDisplay;
  131557. new(): VRDisplay;
  131558. };
  131559. interface VRLayer {
  131560. leftBounds?: number[] | Float32Array | null;
  131561. rightBounds?: number[] | Float32Array | null;
  131562. source?: HTMLCanvasElement | null;
  131563. }
  131564. interface VRDisplayCapabilities {
  131565. readonly canPresent: boolean;
  131566. readonly hasExternalDisplay: boolean;
  131567. readonly hasOrientation: boolean;
  131568. readonly hasPosition: boolean;
  131569. readonly maxLayers: number;
  131570. }
  131571. interface VREyeParameters {
  131572. /** @deprecated */
  131573. readonly fieldOfView: VRFieldOfView;
  131574. readonly offset: Float32Array;
  131575. readonly renderHeight: number;
  131576. readonly renderWidth: number;
  131577. }
  131578. interface VRFieldOfView {
  131579. readonly downDegrees: number;
  131580. readonly leftDegrees: number;
  131581. readonly rightDegrees: number;
  131582. readonly upDegrees: number;
  131583. }
  131584. interface VRFrameData {
  131585. readonly leftProjectionMatrix: Float32Array;
  131586. readonly leftViewMatrix: Float32Array;
  131587. readonly pose: VRPose;
  131588. readonly rightProjectionMatrix: Float32Array;
  131589. readonly rightViewMatrix: Float32Array;
  131590. readonly timestamp: number;
  131591. }
  131592. interface VRPose {
  131593. readonly angularAcceleration: Float32Array | null;
  131594. readonly angularVelocity: Float32Array | null;
  131595. readonly linearAcceleration: Float32Array | null;
  131596. readonly linearVelocity: Float32Array | null;
  131597. readonly orientation: Float32Array | null;
  131598. readonly position: Float32Array | null;
  131599. readonly timestamp: number;
  131600. }
  131601. interface VRStageParameters {
  131602. sittingToStandingTransform?: Float32Array;
  131603. sizeX?: number;
  131604. sizeY?: number;
  131605. }
  131606. interface Navigator {
  131607. getVRDisplays(): Promise<VRDisplay[]>;
  131608. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  131609. }
  131610. interface Window {
  131611. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  131612. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  131613. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  131614. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131615. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131616. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  131617. }
  131618. interface Gamepad {
  131619. readonly displayId: number;
  131620. }
  131621. type XRSessionMode =
  131622. | "inline"
  131623. | "immersive-vr"
  131624. | "immersive-ar";
  131625. type XRReferenceSpaceType =
  131626. | "viewer"
  131627. | "local"
  131628. | "local-floor"
  131629. | "bounded-floor"
  131630. | "unbounded";
  131631. type XREnvironmentBlendMode =
  131632. | "opaque"
  131633. | "additive"
  131634. | "alpha-blend";
  131635. type XRVisibilityState =
  131636. | "visible"
  131637. | "visible-blurred"
  131638. | "hidden";
  131639. type XRHandedness =
  131640. | "none"
  131641. | "left"
  131642. | "right";
  131643. type XRTargetRayMode =
  131644. | "gaze"
  131645. | "tracked-pointer"
  131646. | "screen";
  131647. type XREye =
  131648. | "none"
  131649. | "left"
  131650. | "right";
  131651. interface XRSpace extends EventTarget {
  131652. }
  131653. interface XRRenderState {
  131654. depthNear?: number;
  131655. depthFar?: number;
  131656. inlineVerticalFieldOfView?: number;
  131657. baseLayer?: XRWebGLLayer;
  131658. }
  131659. interface XRInputSource {
  131660. handedness: XRHandedness;
  131661. targetRayMode: XRTargetRayMode;
  131662. targetRaySpace: XRSpace;
  131663. gripSpace: XRSpace | undefined;
  131664. gamepad: Gamepad | undefined;
  131665. profiles: Array<string>;
  131666. }
  131667. interface XRSession {
  131668. addEventListener: Function;
  131669. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  131670. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  131671. requestAnimationFrame: Function;
  131672. end(): Promise<void>;
  131673. renderState: XRRenderState;
  131674. inputSources: Array<XRInputSource>;
  131675. }
  131676. interface XRReferenceSpace extends XRSpace {
  131677. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  131678. onreset: any;
  131679. }
  131680. interface XRFrame {
  131681. session: XRSession;
  131682. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  131683. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  131684. }
  131685. interface XRViewerPose extends XRPose {
  131686. views: Array<XRView>;
  131687. }
  131688. interface XRPose {
  131689. transform: XRRigidTransform;
  131690. emulatedPosition: boolean;
  131691. }
  131692. declare var XRWebGLLayer: {
  131693. prototype: XRWebGLLayer;
  131694. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  131695. };
  131696. interface XRWebGLLayer {
  131697. framebuffer: WebGLFramebuffer;
  131698. framebufferWidth: number;
  131699. framebufferHeight: number;
  131700. getViewport: Function;
  131701. }
  131702. interface XRRigidTransform {
  131703. position: DOMPointReadOnly;
  131704. orientation: DOMPointReadOnly;
  131705. matrix: Float32Array;
  131706. inverse: XRRigidTransform;
  131707. }
  131708. interface XRView {
  131709. eye: XREye;
  131710. projectionMatrix: Float32Array;
  131711. transform: XRRigidTransform;
  131712. }
  131713. interface XRInputSourceChangeEvent {
  131714. session: XRSession;
  131715. removed: Array<XRInputSource>;
  131716. added: Array<XRInputSource>;
  131717. }